[system] / trunk / webwork-modperl / lib / Apache / WeBWorK.pm Repository:
ViewVC logotype

Diff of /trunk/webwork-modperl/lib/Apache/WeBWorK.pm

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

Revision 695 Revision 699
15use warnings; 15use warnings;
16use Apache::Constants qw(:common REDIRECT); 16use Apache::Constants qw(:common REDIRECT);
17use Apache::Request; 17use Apache::Request;
18use WeBWorK::Authen; 18use WeBWorK::Authen;
19use WeBWorK::Authz; 19use WeBWorK::Authz;
20use WeBWorK::Constants qw(WEBWORK_HOME);
20use WeBWorK::ContentGenerator::Feedback; 21use WeBWorK::ContentGenerator::Feedback;
21use WeBWorK::ContentGenerator::Login; 22use WeBWorK::ContentGenerator::Login;
22use WeBWorK::ContentGenerator::Logout; 23use WeBWorK::ContentGenerator::Logout;
23use WeBWorK::ContentGenerator::Hardcopy; 24use WeBWorK::ContentGenerator::Hardcopy;
24use WeBWorK::ContentGenerator::Options; 25use WeBWorK::ContentGenerator::Options;
69 # Create the @components array, which contains the path specified in the URL 70 # Create the @components array, which contains the path specified in the URL
70 my($junk, @components) = split "/", $path_info; 71 my($junk, @components) = split "/", $path_info;
71 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf 72 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf
72 my $course = shift @components; 73 my $course = shift @components;
73 74
74 # If no course was specified, phreak out. 75 # If no course was specified, redirect to the URL specified by the constant WEBWORK_HOME
75 # Eventually, display a list of courses, or something. 76 # (this is typically just "/".)
76 unless (defined $course) { 77 unless (defined $course) {
77 warn "No course specified.\n"; 78 $r->header_out(Location => WEBWORK_HOME);
78 return DECLINED; 79 return REDIRECT;
79 # *** we should either write a "Courses" module, or redirect to a static page.
80 } 80 }
81 81
82 # Try to get the course environment. 82 # Try to get the course environment.
83 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $urlRoot, $course);}; 83 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $urlRoot, $course);};
84 if ($@) { # If there was an error getting the requested course 84 if ($@) { # If there was an error getting the requested course
98 ### Begin dispatching ### 98 ### Begin dispatching ###
99 99
100 # WeBWorK::Authen::verify erases the passwd field and sets the key field 100 # WeBWorK::Authen::verify erases the passwd field and sets the key field
101 # if login is successful. 101 # if login is successful.
102 if (!WeBWorK::Authen->new($r, $course_env)->verify) { 102 if (!WeBWorK::Authen->new($r, $course_env)->verify) {
103 # *** &verify should throw a descriptive exception on weird failures
104 return WeBWorK::ContentGenerator::Login->new($r, $course_env)->go; 103 return WeBWorK::ContentGenerator::Login->new($r, $course_env)->go;
105 } else { 104 } else {
106 # After we are authenticated, there are some things that need to be 105 # After we are authenticated, there are some things that need to be
107 # sorted out, Authorization-wize, before we start dispatching to individual 106 # sorted out, Authorization-wize, before we start dispatching to individual
108 # content generators. 107 # content generators.
116 if (!defined $arg) { # We want the list of problem sets 115 if (!defined $arg) { # We want the list of problem sets
117 return WeBWorK::ContentGenerator::ProblemSets->new($r, $course_env)->go; 116 return WeBWorK::ContentGenerator::ProblemSets->new($r, $course_env)->go;
118 } elsif ($arg eq "hardcopy") { 117 } elsif ($arg eq "hardcopy") {
119 my $hardcopyArgument = shift @components; 118 my $hardcopyArgument = shift @components;
120 $hardcopyArgument = "" unless defined $hardcopyArgument; 119 $hardcopyArgument = "" unless defined $hardcopyArgument;
121 # *** can i say go(shift || "") here?
122 return WeBWorK::ContentGenerator::Hardcopy->new($r, $course_env)->go($hardcopyArgument); 120 return WeBWorK::ContentGenerator::Hardcopy->new($r, $course_env)->go($hardcopyArgument);
123 } elsif ($arg eq "prof") { 121 } elsif ($arg eq "prof") {
124 return WeBWorK::ContentGenerator::Professor->new($r, $course_env)->go; 122 return WeBWorK::ContentGenerator::Professor->new($r, $course_env)->go;
125 } elsif ($arg eq "options") { 123 } elsif ($arg eq "options") {
126 return WeBWorK::ContentGenerator::Options->new($r, $course_env)->go; 124 return WeBWorK::ContentGenerator::Options->new($r, $course_env)->go;
127 } elsif ($arg eq "feedback") { 125 } elsif ($arg eq "feedback") {
128 return WeBWorK::ContentGenerator::Feedback->new($r, $course_env)->go; 126 return WeBWorK::ContentGenerator::Feedback->new($r, $course_env)->go;
129 } elsif ($arg eq "logout") { 127 } elsif ($arg eq "logout") {
130 return WeBWorK::ContentGenerator::Logout->new($r, $course_env)->go; 128 return WeBWorK::ContentGenerator::Logout->new($r, $course_env)->go;
131 } elsif ($arg eq "test") { 129 } elsif ($arg eq "test") {
132 # *** we should change this name, or remove it altogether.
133 return WeBWorK::ContentGenerator::Test->new($r, $course_env)->go; 130 return WeBWorK::ContentGenerator::Test->new($r, $course_env)->go;
134 } else { # We've got the name of a problem set. 131 } else { # We've got the name of a problem set.
135 my $problem_set = $arg; 132 my $problem_set = $arg;
136 my $ps_arg = shift @components; 133 my $ps_arg = shift @components;
137 134
138 if (!defined $ps_arg) { 135 if (!defined $ps_arg) {
139 # list the problems in the problem set 136 # list the problems in the problem set
140 return WeBWorK::ContentGenerator::ProblemSet->new($r, $course_env)->go($problem_set); 137 return WeBWorK::ContentGenerator::ProblemSet->new($r, $course_env)->go($problem_set);
141 } elsif ($ps_arg eq "hardcopy") {
142 # *** do we need this? hardcopy is not being called this way
143 }
144 else { 138 } else {
145 # We've got the name of a problem 139 # We've got the name of a problem
146 my $problem = $ps_arg; 140 my $problem = $ps_arg;
147 return WeBWorK::ContentGenerator::Problem->new($r, $course_env)->go($problem_set, $problem); 141 return WeBWorK::ContentGenerator::Problem->new($r, $course_env)->go($problem_set, $problem);
148 } 142 }
149 } 143 }

Legend:
Removed from v.695  
changed lines
  Added in v.699

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9