[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 699 Revision 746
33# This module should be installed as a Handler for the location selected for 33# This module should be installed as a Handler for the location selected for
34# WeBWorK on your webserver. Here is an example of a stanza that can be added 34# WeBWorK on your webserver. Here is an example of a stanza that can be added
35# to your httpd.conf file to achieve this: 35# to your httpd.conf file to achieve this:
36# 36#
37# <IfModule mod_perl.c> 37# <IfModule mod_perl.c>
38# PerlFreshRestart On 38# PerlFreshRestart On
39# <Location /modperl-sam> 39# <Location /webwork>
40# SetHandler perl-script 40# SetHandler perl-script
41# PerlSetVar webwork_root /opt/webwork
42# <Perl>
43# use lib '/opt/webwork/lib';
44# </Perl>
45# PerlHandler Apache::WeBWorK 41# PerlHandler Apache::WeBWorK
42# PerlSetVar webwork_root /path/to/webwork-modperl
43# <Perl>
44# use lib '/path/to/webwork-modperl/lib';
45# use lib '/path/to/webwork-modperl/pglib';
46# </Perl>
46# </Location> 47# </Location>
47# </IfModule> 48# </IfModule>
48 49
49sub handler() { 50sub handler() {
50 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 51 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
51 52
70 # Create the @components array, which contains the path specified in the URL 71 # Create the @components array, which contains the path specified in the URL
71 my($junk, @components) = split "/", $path_info; 72 my($junk, @components) = split "/", $path_info;
72 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf 73 my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf
73 my $course = shift @components; 74 my $course = shift @components;
74 75
75 # If no course was specified, redirect to the URL specified by the constant WEBWORK_HOME
76 # (this is typically just "/".)
77 unless (defined $course) {
78 $r->header_out(Location => WEBWORK_HOME);
79 return REDIRECT;
80 }
81
82 # Try to get the course environment. 76 # Try to get the course environment.
83 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $urlRoot, $course);}; 77 my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $urlRoot, $course);};
84 if ($@) { # If there was an error getting the requested course 78 if ($@) { # If there was an error getting the requested course
85 # TODO: display an error page. For now, 404 it. 79 # TODO: display an error page. For now, 404 it.
86 warn $@; 80 warn $@;
87 return DECLINED; 81 return DECLINED;
82 }
83
84 # If no course was specified, redirect to the URL specified by the constant WEBWORK_HOME
85 # (this is typically just "/".)
86 unless (defined $course) {
87 $r->header_out(Location => $course_env->{webworkURLs}->{home});
88 return REDIRECT;
88 } 89 }
89 90
90 # Freak out if the requested course doesn't exist. For now, this is just a 91 # Freak out if the requested course doesn't exist. For now, this is just a
91 # check to see if the course directory exists. 92 # check to see if the course directory exists.
92 if (!-e $course_env->{webworkDirs}->{courses} . "/$course") { 93 if (!-e $course_env->{webworkDirs}->{courses} . "/$course") {

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9