[system] / trunk / webwork2 / lib / Apache / WeBWorK.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/Apache/WeBWorK.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 289 Revision 290
10 10
11package Apache::WeBWorK; 11package Apache::WeBWorK;
12 12
13use strict; 13use strict;
14use Apache::Constants qw(:common REDIRECT); 14use Apache::Constants qw(:common REDIRECT);
15use Apache::Request;
15use WeBWorK::CourseEnvironment; 16use WeBWorK::CourseEnvironment;
16use Apache::Request; 17use WeBWorK::Test;
18#use WeBWorK::Authen;
17 19
18# registering discontent: wanted to call this dispatch, but mod_perl gave me lip 20# registering discontent: wanted to call this dispatch, but mod_perl gave me lip
19sub handler() { 21sub handler() {
20 my $r = Apache::Request->new(shift); # have to deal with unpredictable GET or POST data ,and sift through it for the key. So use Apache::Request 22 my $r = Apache::Request->new(shift); # have to deal with unpredictable GET or POST data ,and sift through it for the key. So use Apache::Request
21 my $path_info = $r->path_info; 23 my $path_info = $r->path_info;
24 unless ($path_info) { 26 unless ($path_info) {
25 $r->header_out(Location => "$current_uri/"); 27 $r->header_out(Location => "$current_uri/");
26 return REDIRECT; 28 return REDIRECT;
27 } 29 }
28 30
29 $r->content_type('text/html');
30 $r->send_http_header;
31 return OK if $r->header_only; 31 return OK if $r->header_only;
32 my($junk, @components) = split "/", $path_info; 32 my($junk, @components) = split "/", $path_info;
33 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf 33 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf
34 my $course = shift @components; 34 my $course = shift @components;
35 # catch errors in $@ 35 # catch errors in $@
36 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $course);}; 36 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $course);};
37 if ($@) { 37 if ($@) {
38 # TODO: display an error page. For now, print something mildly useful 38 # TODO: display an error page. For now, print something mildly useful
39 $r->print('<p><font color=red>'.$@.'</font></p>'); 39 return DECLINED;
40 } 40 }
41 41
42 # These values are part of the standard webwork form, and at least two 42# if (!WeBWorK::Authen->new($r, $course_env)->authen) {
43 # of them should appear in every form on the system. Depending on when 43# return WeBWorK::Login->new($r, $course_env)->go();
44 # you are reading this, this may or may not be enforced in the code. 44# } else {
45 $user = $r->param('user'); 45 if (1) {
46 $passwd = $r->param('passwd'); 46 return WeBWorK::Test->new($r, $course_env)->go();
47 $key = $r->param('key'); 47 }
48# }
48 49
49 50
50 51
51 $r->print(<<END); 52 $r->print(<<END);
52COURSE = $course<br> 53COURSE = $course<br>

Legend:
Removed from v.289  
changed lines
  Added in v.290

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9