| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork-modperl/lib/WeBWorK.pm,v 1.50 2004/03/04 21:00:51 sh002i Exp $ |
4 | # $CVSHeader: webwork-modperl/lib/WeBWorK.pm,v 1.51 2004/03/15 02:25:11 sh002i Exp $ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 107 | debug(("-" x 80) . "\n"); |
107 | debug(("-" x 80) . "\n"); |
| 108 | |
108 | |
| 109 | debug("Now we need to look at the path a little to figure out where we are\n"); |
109 | debug("Now we need to look at the path a little to figure out where we are\n"); |
| 110 | |
110 | |
| 111 | debug("-------------------- call to WeBWorK::URLPath::newFromPath\n"); |
111 | debug("-------------------- call to WeBWorK::URLPath::newFromPath\n"); |
| 112 | my $urlPath = newFromPath WeBWorK::URLPath $path; |
112 | my $urlPath = WeBWorK::URLPath->newFromPath($path); |
| 113 | debug("-------------------- call to WeBWorK::URLPath::newFromPath\n"); |
113 | debug("-------------------- call to WeBWorK::URLPath::newFromPath\n"); |
| 114 | |
114 | |
| 115 | unless ($urlPath) { |
115 | unless ($urlPath) { |
| 116 | debug("This path is invalid... see you later!\n"); |
116 | debug("This path is invalid... see you later!\n"); |
| 117 | return DECLINED; |
117 | return DECLINED; |
| … | |
… | |
| 138 | debug("Reconstructing the original path gets us: $selfPath\n"); |
138 | debug("Reconstructing the original path gets us: $selfPath\n"); |
| 139 | debug("And we can generate the path to our parent, too: $parentPath\n"); |
139 | debug("And we can generate the path to our parent, too: $parentPath\n"); |
| 140 | debug("(We could also figure out who our children are, but we'd need to supply additional arguments.)\n"); |
140 | debug("(We could also figure out who our children are, but we'd need to supply additional arguments.)\n"); |
| 141 | debug(("-" x 80) . "\n"); |
141 | debug(("-" x 80) . "\n"); |
| 142 | |
142 | |
|
|
143 | debug("The URLPath looks good, we'll add it to the request.\n"); |
|
|
144 | $r->urlpath($urlPath); |
|
|
145 | |
| 143 | debug("Now we want to look at the parameters we got.\n"); |
146 | debug("Now we want to look at the parameters we got.\n"); |
| 144 | |
147 | |
| 145 | debug("The raw params:\n"); |
148 | debug("The raw params:\n"); |
| 146 | foreach my $key ($r->param) { |
149 | foreach my $key ($r->param) { |
| 147 | debug("\t$key\n"); |
150 | debug("\t$key\n"); |
| … | |
… | |
| 159 | debug(("-" x 80) . "\n"); |
162 | debug(("-" x 80) . "\n"); |
| 160 | |
163 | |
| 161 | debug("We need to get a course environment (with or without a courseID!)\n"); |
164 | debug("We need to get a course environment (with or without a courseID!)\n"); |
| 162 | my $ce = new WeBWorK::CourseEnvironment($webwork_root, $location, $pg_root, $displayArgs{courseID}); |
165 | my $ce = new WeBWorK::CourseEnvironment($webwork_root, $location, $pg_root, $displayArgs{courseID}); |
| 163 | debug("Here's the course environment: $ce\n"); |
166 | debug("Here's the course environment: $ce\n"); |
|
|
167 | $r->ce($ce); |
| 164 | |
168 | |
| 165 | my @uploads = $r->upload; |
169 | my @uploads = $r->upload; |
| 166 | foreach my $u (@uploads) { |
170 | foreach my $u (@uploads) { |
| 167 | # make sure it's a "real" upload |
171 | # make sure it's a "real" upload |
| 168 | next unless $u->filename; |
172 | next unless $u->filename; |
| … | |
… | |
| 183 | if ($displayArgs{courseID}) { |
187 | if ($displayArgs{courseID}) { |
| 184 | debug("We got a courseID from the URLPath, now we can do some stuff:\n"); |
188 | debug("We got a courseID from the URLPath, now we can do some stuff:\n"); |
| 185 | debug("...we can create a database object...\n"); |
189 | debug("...we can create a database object...\n"); |
| 186 | $db = new WeBWorK::DB($ce->{dbLayout}); |
190 | $db = new WeBWorK::DB($ce->{dbLayout}); |
| 187 | debug("(here's the DB handle: $db)\n"); |
191 | debug("(here's the DB handle: $db)\n"); |
|
|
192 | $r->db($db); |
| 188 | |
193 | |
| 189 | debug("...and we can authenticate the remote user...\n"); |
194 | debug("...and we can authenticate the remote user...\n"); |
| 190 | my $authen = new WeBWorK::Authen $r, $ce, $db; |
195 | my $authen = new WeBWorK::Authen($r); |
| 191 | my $authenOK = $authen->verify; |
196 | my $authenOK = $authen->verify; |
| 192 | if ($authenOK) { |
197 | if ($authenOK) { |
| 193 | debug("Hi, ", $r->param("user"), ", glad you made it.\n"); |
198 | debug("Hi, ", $r->param("user"), ", glad you made it.\n"); |
| 194 | |
199 | |
| 195 | debug("Authentication succeeded, so it makes sense to create an authz object...\n"); |
200 | debug("Authentication succeeded, so it makes sense to create an authz object...\n"); |
| 196 | $authz = new WeBWorK::Authz $r, $ce, $db; |
201 | $authz = new WeBWorK::Authz($r, $ce, $db); |
| 197 | debug("(here's the authz object: $authz)\n"); |
202 | debug("(here's the authz object: $authz)\n"); |
|
|
203 | $r->authz($authz); |
| 198 | |
204 | |
| 199 | debug("Now we deal with the effective user:\n"); |
205 | debug("Now we deal with the effective user:\n"); |
| 200 | my $userID = $r->param("user"); |
206 | my $userID = $r->param("user"); |
| 201 | my $eUserID = $r->param("effectiveUser") || $userID; |
207 | my $eUserID = $r->param("effectiveUser") || $userID; |
| 202 | debug("userID=$userID eUserID=$eUserID\n"); |
208 | debug("userID=$userID eUserID=$eUserID\n"); |
| … | |
… | |
| 212 | debug("Bad news: authentication failed!\n"); |
218 | debug("Bad news: authentication failed!\n"); |
| 213 | $displayModule = AUTHEN_MODULE; |
219 | $displayModule = AUTHEN_MODULE; |
| 214 | debug("set displayModule to $displayModule\n"); |
220 | debug("set displayModule to $displayModule\n"); |
| 215 | } |
221 | } |
| 216 | } |
222 | } |
| 217 | |
|
|
| 218 | debug("Now we add \$ce, \$db, \$authz, and \$urlPath to the WeBWorK::Request object.\n"); |
|
|
| 219 | $r->ce($ce); |
|
|
| 220 | $r->db($db); |
|
|
| 221 | $r->authz($authz); |
|
|
| 222 | $r->urlpath($urlPath); |
|
|
| 223 | |
223 | |
| 224 | debug(("-" x 80) . "\n"); |
224 | debug(("-" x 80) . "\n"); |
| 225 | debug("Finally, we'll load the display module...\n"); |
225 | debug("Finally, we'll load the display module...\n"); |
| 226 | |
226 | |
| 227 | runtime_use($displayModule); |
227 | runtime_use($displayModule); |