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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 283 - (download) (as text) (annotate)
Wed May 22 18:44:14 2002 UTC (17 years, 9 months ago) by malsyned
File size: 2273 byte(s)



    1 # Apache::WeBWorK - The WeBWorK dispatcher module
    2 # Place something like the following in your Apache configuration to load the
    3 # WeBWorK module and install it as a handler for the WeBWorK system
    4 
    5 # PerlModule Apache::WeBWorK
    6 # <Location /webwork>
    7 # SetHandler perl-script
    8 # PerlHandler Apache::WeBWorK::dispatch
    9 # </Location>
   10 
   11 package Apache::WeBWorK;
   12 
   13 use strict;
   14 use Apache::Constants qw(:common REDIRECT);
   15 use WeBWorK::CourseEnvironment;
   16 use Apache::Request;
   17 
   18 # registering discontent: wanted to call this dispatch, but mod_perl gave me lip
   19 sub 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
   21   my $path_info = $r->path_info;
   22   my $path_translated = $r->lookup_uri($path_info)->filename;
   23   my $current_uri = $r->uri;
   24   unless ($path_info) {
   25     $r->header_out(Location => "$current_uri/");
   26     return REDIRECT;
   27   }
   28 
   29   $r->content_type('text/html');
   30   $r->send_http_header;
   31   return OK if $r->header_only;
   32   my($junk, @components) = split "/", $path_info;
   33   my $webwork_root = $r->dir_config('webwork_root'); # From a PerlSetVar in httpd.conf
   34   my $course = shift @components;
   35   # catch errors in $@
   36   my $course_env = eval {WeBWorK::CourseEnvironment->new($webwork_root, $course);};
   37   if ($@) {
   38     # TODO: display an error page.  For now, print something mildly useful
   39     $r->print('<p><font color=red>'.$@.'</font></p>');
   40   }
   41 
   42   # These values are part of the standard webwork form, and at least two
   43   # of them should appear in every form on the system.  Depending on when
   44   # you are reading this, this may or may not be enforced in the code.
   45   $user = $r->param('user');
   46   $passwd = $r->param('passwd');
   47   $key = $r->param('key');
   48 
   49 
   50 
   51   $r->print(<<END);
   52 COURSE = $course<br>
   53 WEBWORK_ROOT = $webwork_root<br>
   54 URI = <em>$current_uri</em><br>
   55 Path information = <em>$path_info</em><br>
   56 Translated path = <em>$path_translated</em>
   57 </body>
   58 </html>
   59 END
   60 
   61   return OK;
   62 }
   63 
   64 1;
   65 
   66 __END__
   67 
   68 # if (!auth) {
   69 #   loginpage
   70 # } else {
   71 #   dispatch
   72 # }
   73 
   74 
   75 
   76 load some global settings for the system
   77   - apparently, these are going to live in the package Global
   78   - this sucks, since it's not really the global namespace
   79   - but whatever.
   80 
   81 disassemble the URI to some extent
   82   - we need to know the course

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9