--- trunk/webwork2/lib/Apache/WeBWorK.pm 2002/11/23 00:25:40 646 +++ trunk/webwork2/lib/Apache/WeBWorK.pm 2003/01/06 19:17:28 683 @@ -17,6 +17,7 @@ use Apache::Request; use WeBWorK::Authen; use WeBWorK::Authz; +use WeBWorK::ContentGenerator::Feedback; use WeBWorK::ContentGenerator::Login; use WeBWorK::ContentGenerator::Logout; use WeBWorK::ContentGenerator::Hardcopy; @@ -24,6 +25,7 @@ use WeBWorK::ContentGenerator::Problem; use WeBWorK::ContentGenerator::ProblemSet; use WeBWorK::ContentGenerator::ProblemSets; +use WeBWorK::ContentGenerator::Professor; use WeBWorK::ContentGenerator::Test; use WeBWorK::CourseEnvironment; @@ -49,8 +51,7 @@ # This stuff is pretty much copied out of the O'Reilly mod_perl book. # It's for figuring out the basepath. I may change this up if I # find a better way to do it. - my $path_info = $r->path_info; - my $path_translated = $r->lookup_uri($path_info)->filename; + my $path_info = $r->path_info || ""; my $current_uri = $r->uri; my $args = $r->args; @@ -59,6 +60,7 @@ unless (substr($current_uri,-1) eq '/') { $r->header_out(Location => "$current_uri/" . ($args ? "?$args" : "")); return REDIRECT; + # *** any post data gets lost here -- fix that. } # Create the @components array, which contains the path specified in the URL @@ -69,7 +71,9 @@ # If no course was specified, phreak out. # Eventually, display a list of courses, or something. unless (defined $course) { + warn "No course specified.\n"; return DECLINED; + # *** we should either write a "Courses" module, or redirect to a static page. } # Try to get the course environment. @@ -79,10 +83,12 @@ warn $@; return DECLINED; } - + # Freak out if the requested course doesn't exist. For now, this is just a # check to see if the course directory exists. if (!-e $course_env->{webworkDirs}->{courses} . "/$course") { + warn "Course directory for $course not found at " + . $course_env->{webworkDirs}->{courses} . "/$course" ."\n"; return DECLINED; } @@ -91,19 +97,17 @@ # WeBWorK::Authen::verify erases the passwd field and sets the key field # if login is successful. if (!WeBWorK::Authen->new($r, $course_env)->verify) { + # *** &verify should throw a descriptive exception on weird failures return WeBWorK::ContentGenerator::Login->new($r, $course_env)->go; } else { # After we are authenticated, there are some things that need to be # sorted out, Authorization-wize, before we start dispatching to individual # content generators. - my $effectiveUser = $r->param("effectiveUser") || ""; my $user = $r->param("user"); + my $effectiveUser = $r->param("effectiveUser") || $user; my $su_authorized = WeBWorK::Authz->new($r, $course_env)->hasPermissions($user, "become_student", $effectiveUser); - # This hoary statement has the effect of forcing effectiveUser to equal user unless - # the user is otherwise authorized. - if (!($user ne $effectiveUser && $su_authorized) || !defined $effectiveUser) { - $r->param("effectiveUser",$user); - } + $effectiveUser = $user unless $su_authorized; + $r->param("effectiveUser", $effectiveUser); my $arg = shift @components; if (!defined $arg) { # We want the list of problem sets @@ -111,14 +115,18 @@ } elsif ($arg eq "hardcopy") { my $hardcopyArgument = shift @components; $hardcopyArgument = "" unless defined $hardcopyArgument; + # *** can i say go(shift || "") here? return WeBWorK::ContentGenerator::Hardcopy->new($r, $course_env)->go($hardcopyArgument); } elsif ($arg eq "prof") { - # *** + return WeBWorK::ContentGenerator::Professor->new($r, $course_env)->go; } elsif ($arg eq "options") { return WeBWorK::ContentGenerator::Options->new($r, $course_env)->go; + } elsif ($arg eq "feedback") { + return WeBWorK::ContentGenerator::Feedback->new($r, $course_env)->go; } elsif ($arg eq "logout") { return WeBWorK::ContentGenerator::Logout->new($r, $course_env)->go; } elsif ($arg eq "test") { + # *** we should change this name, or remove it altogether. return WeBWorK::ContentGenerator::Test->new($r, $course_env)->go; } else { # We've got the name of a problem set. my $problem_set = $arg; @@ -128,7 +136,7 @@ # list the problems in the problem set return WeBWorK::ContentGenerator::ProblemSet->new($r, $course_env)->go($problem_set); } elsif ($ps_arg eq "hardcopy") { - ### + # *** do we need this? hardcopy is not being called this way } else { # We've got the name of a problem @@ -138,7 +146,7 @@ } } - + # If the dispatcher doesn't know any modules that want to handle # the current path, it'll claim that the path does not exist by # declining the request.