Annotation of loncom/homework/lonhomework.pm, revision 1.83
1.63 albertel 1: # The LearningOnline Network with CAPA
1.52 albertel 2: # The LON-CAPA Homework handler
1.63 albertel 3: #
1.83 ! albertel 4: # $Id: lonhomework.pm,v 1.82 2002/07/18 20:52:36 bowersj2 Exp $
1.63 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.52 albertel 28: # Guy Albertelli
1.17 www 29: # 11/30 Gerd Kortemeyer
1.56 www 30: # 6/1,8/17,8/18 Gerd Kortemeyer
1.82 bowersj2 31: # 7/18 Jeremy Bowers
1.1 albertel 32:
33: package Apache::lonhomework;
34: use strict;
1.73 albertel 35: use Apache::style();
36: use Apache::lonxml();
37: use Apache::lonnet();
38: use Apache::lonplot();
39: use Apache::inputtags();
40: use Apache::structuretags();
41: use Apache::randomlabel();
42: use Apache::response();
43: use Apache::hint();
44: use Apache::outputtags();
1.83 ! albertel 45: use Apache::caparesponse();
! 46: use Apache::radiobuttonresponse();
! 47: use Apache::optionresponse();
! 48: use Apache::imageresponse();
! 49: use Apache::essayresponse();
! 50: use Apache::externalresponse();
1.26 www 51: use Apache::Constants qw(:common);
1.73 albertel 52: use HTML::Entities();
1.83 ! albertel 53: use Apache::loncommon();
1.47 albertel 54: #use Time::HiRes qw( gettimeofday tv_interval );
1.43 albertel 55:
1.69 harris41 56: BEGIN {
1.43 albertel 57: &Apache::lonxml::register_insert();
58: }
59:
1.5 albertel 60: sub get_target {
1.52 albertel 61: if ( $ENV{'request.state'} eq "published") {
1.66 albertel 62: if ( defined($ENV{'form.grade_target'})
63: && ($Apache::lonhomework::viewgrades == 'F' )) {
64: return ($ENV{'form.grade_target'});
65: }
1.62 albertel 66: if ( defined($ENV{'form.submitted'})) {
1.52 albertel 67: return ('grade', 'web');
68: } else {
69: return ('web');
70: }
71: } elsif ($ENV{'request.state'} eq "construct") {
1.74 albertel 72: if ( defined($ENV{'form.grade_target'}) ) {
73: return ($ENV{'form.grade_target'});
74: }
1.62 albertel 75: if ( defined($ENV{'form.preview'})) {
76: if ( defined($ENV{'form.submitted'})) {
1.52 albertel 77: return ('grade', 'web');
78: } else {
79: return ('web');
80: }
81: } else {
82: if ( $ENV{'form.problemmode'} eq 'View' ) {
1.62 albertel 83: if ( defined($ENV{'form.submitted'}) &&
84: (!defined($ENV{'form.resetdata'})) ) {
1.60 albertel 85: return ('grade', 'web','answer');
1.42 albertel 86: } else {
1.60 albertel 87: return ('web','answer');
1.42 albertel 88: }
1.52 albertel 89: } elsif ( $ENV{'form.problemmode'} eq 'Edit' ) {
90: if ( $ENV{'form.submitted'} eq 'edit' ) {
1.80 albertel 91: if ( $ENV{'form.submit'} eq 'Submit Changes and View' ) {
1.81 albertel 92: return ('modified','web','answer');
1.80 albertel 93: } else {
94: return ('modified','edit');
95: }
1.42 albertel 96: } else {
1.52 albertel 97: return ('edit');
1.42 albertel 98: }
1.52 albertel 99: } else {
100: return ('web');
101: }
1.15 albertel 102: }
1.52 albertel 103: }
104: return ();
1.5 albertel 105: }
106:
1.3 albertel 107: sub setup_vars {
1.52 albertel 108: my ($target) = @_;
109: return ';'
1.11 albertel 110: # return ';$external::target='.$target.';';
1.2 albertel 111: }
112:
113: sub send_header {
1.52 albertel 114: my ($request)= @_;
115: $request->print(&Apache::lontexconvert::header());
1.16 albertel 116: # $request->print('<form name='.$ENV{'form.request.prefix'}.'lonhomework method="POST" action="'.$request->uri.'">');
1.2 albertel 117: }
118:
1.36 albertel 119: sub createmenu {
1.52 albertel 120: my ($which,$request)=@_;
121: if ($which eq 'grade') {
122: $request->print('<script language="JavaScript">
123: hwkmenu=window.open("/res/adm/pages/homeworkmenu.html","homeworkremote",
124: "height=350,width=150,menubar=no");
125: </script>');
126: }
1.36 albertel 127: }
128:
1.2 albertel 129: sub send_footer {
1.52 albertel 130: my ($request)= @_;
1.16 albertel 131: # $request->print('</form>');
1.52 albertel 132: $request->print(&Apache::lontexconvert::footer());
1.2 albertel 133: }
134:
1.52 albertel 135: $Apache::lonxml::browse='';
1.53 www 136:
137: sub check_access {
1.52 albertel 138: my ($id) = @_;
139: my $date ='';
140: my $status = '';
141: my $datemsg = '';
142: my $lastdate = '';
143: my $temp;
144: my $type;
145: my $passed;
146: &Apache::lonxml::debug("checking for part :$id:");
1.73 albertel 147: &Apache::lonxml::debug("time:".time);
1.52 albertel 148: foreach $temp ("opendate","duedate","answerdate") {
149: $lastdate = $date;
150: $date = &Apache::lonnet::EXT("resource.$id.$temp");
151: &Apache::lonxml::debug("found :$date: for :$temp:");
152: if ($date eq '') {
153: $date = "an unknown date"; $passed = 0;
154: } elsif ($date eq 'con_lost') {
155: $date = "an indeterminate date"; $passed = 0;
156: } else {
157: if (time < $date) { $passed = 0; } else { $passed = 1; }
158: $date = localtime $date;
1.51 harris41 159: }
1.52 albertel 160: if (!$passed) { $type=$temp; last; }
161: }
162: &Apache::lonxml::debug("have :$type:$passed:");
163: if ($passed) {
164: $status='SHOW_ANSWER';
165: $datemsg=$date;
166: } elsif ($type eq 'opendate') {
167: $status='CLOSED';
168: $datemsg = "will open on $date";
169: } elsif ($type eq 'duedate') {
170: $status='CAN_ANSWER';
171: $datemsg = "is due at $date";
172: } elsif ($type eq 'answerdate') {
173: $status='CLOSED';
174: $datemsg = "was due on $lastdate, and answers will be available on $date";
175: }
176: if ($status eq 'CAN_ANSWER') {
177: #check #tries
178: my $tries = $Apache::lonhomework::history{"resource.$id.tries"};
179: my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
180: if ( $tries eq '' ) { $tries = '0'; }
181: if ( $maxtries eq '' ) { $maxtries = '2'; }
182: if ($tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
183: }
1.54 www 184:
1.56 www 185: if (($status ne 'CLOSED') && ($Apache::lonhomework::type eq 'exam') &&
186: (!$Apache::lonhomework::history{"resource.0.outtoken"})) {
1.54 www 187: return ('UNCHECKEDOUT','needs to be checked out');
188: }
189:
190:
1.52 albertel 191: &Apache::lonxml::debug("sending back :$status:$datemsg:");
192: if (($Apache::lonhomework::browse eq 'F') && ($status eq 'CLOSED')) {
193: &Apache::lonxml::debug("should be allowed to browse a resource when closed");
194: $status='CAN_ANSWER';
195: $datemsg='is closed but you are allowed to view it';
196: }
197: if ($ENV{'request.state'} eq "construct") {
198: &Apache::lonxml::debug("in construction ignoring dates");
199: $status='CAN_ANSWER';
200: $datemsg='is in under construction';
201: }
202: return ($status,$datemsg);
1.20 albertel 203: }
204:
1.41 albertel 205: sub showhash {
1.52 albertel 206: my (%hash) = @_;
1.79 albertel 207: &showhashsubset(\%hash,'');
208: return '';
209: }
210:
211: sub showhashsubset {
212: my ($hash,$keyre) = @_;
1.52 albertel 213: my $resultkey;
1.79 albertel 214: foreach $resultkey (sort keys %$hash) {
215: if ($resultkey =~ /$keyre/) {
216: if (ref($$hash{$resultkey})) {
217: if ($$hash{$resultkey} =~ /ARRAY/ ) {
218: my $string="$resultkey ---- (";
219: foreach my $elm (@{ $$hash{$resultkey} }) {
220: $string.="$elm,";
221: }
222: chop($string);
223: &Apache::lonxml::debug("$string)");
224: } else {
225: &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
1.73 albertel 226: }
227: } else {
1.79 albertel 228: &Apache::lonxml::debug("$resultkey ---- $$hash{$resultkey}");
1.73 albertel 229: }
230: }
1.52 albertel 231: }
232: &Apache::lonxml::debug("\n<br />restored values^</br>\n");
233: return '';
1.41 albertel 234: }
235:
236: sub setuppermissions {
1.52 albertel 237: $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
238: $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
239: return ''
1.41 albertel 240: }
241:
242: sub setupheader {
1.52 albertel 243: my $request=$_[0];
244: if ($ENV{'browser.mathml'}) {
245: $request->content_type('text/xml');
246: } else {
247: $request->content_type('text/html');
248: }
1.68 albertel 249: if (!$Apache::lonxml::debug && ($ENV{'REQUEST_METHOD'} eq 'GET')) {
250: &Apache::loncommon::no_cache($request);
251: }
1.52 albertel 252: $request->send_http_header;
253: return OK if $request->header_only;
254: return ''
1.41 albertel 255: }
1.35 albertel 256:
1.47 albertel 257: sub handle_save_or_undo {
1.52 albertel 258: my ($request,$problem,$result) = @_;
1.70 albertel 259: my $file = &Apache::lonnet::filelocation("",$request->uri);
260: my $filebak =$file.".bak";
261: my $filetmp =$file.".tmp";
1.64 albertel 262: my $error=0;
1.52 albertel 263:
264: if ($ENV{'form.Undo'} eq 'undo') {
1.70 albertel 265: my $error=0;
266: if (!copy($file,$filetmp)) { $error=1; }
267: if ((!$error) && (!copy($filebak,$file))) { $error=1; }
268: if ((!$error) && (!move($filetmp,$filebak))) { $error=1; }
269: if (!$error) {
270: $request->print("<p><b>Undid changes, Switched $filebak and $file</b></p>");
1.52 albertel 271: } else {
1.70 albertel 272: $request->print("<p><font color=\"red\" size=\"+1\"><b>Unable to undo, unable to switch $filebak and $file</b></font></p>");
1.64 albertel 273: $error=1;
1.52 albertel 274: }
275: } else {
1.70 albertel 276: my $fs=Apache::File->new(">$filebak");
1.52 albertel 277: if (defined($fs)) {
278: print $fs $$problem;
1.70 albertel 279: $request->print("<b>Making Backup to $filebak</b><br />");
1.52 albertel 280: } else {
1.70 albertel 281: $request->print("<font color=\"red\" size=\"+1\"><b>Unable to make backup $filebak</b></font>");
1.64 albertel 282: $error=2;
1.52 albertel 283: }
1.70 albertel 284: my $fh=Apache::File->new(">$file");
1.52 albertel 285: if (defined($fh)) {
286: print $fh $$result;
1.70 albertel 287: $request->print("<b>Saving Modifications to $file</b><br />");
1.47 albertel 288: } else {
1.70 albertel 289: $request->print("<font color=\"red\" size=\"+1\"><b>Unable to write to $file</b></font>");
1.64 albertel 290: $error|=4;
1.47 albertel 291: }
1.52 albertel 292: }
1.64 albertel 293: return $error;
294: }
295:
1.74 albertel 296: sub analyze {
297: my ($request,$file) = @_;
298: &Apache::lonxml::debug("Analyze");
299: my $result=&Apache::lonnet::ssi($request->uri,('grade_target' => 'analyze'));
300: &Apache::lonxml::debug(":$result:");
301: (my $garbage,$result)=split(/_HASH_REF__/,$result,2);
302: &showhash(&Apache::lonnet::str2hash($result));
303: return $result;
304: }
305:
1.64 albertel 306: sub editxmlmode {
307: my ($request,$file) = @_;
308: my $result;
309: my $problem=&Apache::lonnet::getfile($file);
310: if ($problem == -1) {
311: &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
312: $problem='';
313: }
314: if (defined($ENV{'form.editxmltext'}) || defined($ENV{'form.Undo'})) {
315: my $error=&handle_save_or_undo($request,\$problem,
316: \$ENV{'form.editxmltext'});
317: if (!$error) { $problem=&Apache::lonnet::getfile($file); }
318: }
1.80 albertel 319: &Apache::lonhomework::showhashsubset(\%ENV,'^form');
320: if ( $ENV{'form.submit'} eq 'Submit Changes and View' ) {
321: &Apache::lonhomework::showhashsubset(\%ENV,'^form');
322: $ENV{'form.problemmode'}='View';
323: &renderpage($request,$file);
324: } else {
325: my ($rows,$cols) = &Apache::edit::textarea_sizes(\$problem);
1.82 bowersj2 326: my $xml_help = Apache::loncommon::help_open_topic("Problem_Editor_XML_Index");
1.80 albertel 327: if ($cols > 80) { $cols = 80; }
328: $result.='<html><body bgcolor="#FFFFFF">
1.64 albertel 329: <form name="lonhomework" method="POST" action="'.
330: $ENV{'request.uri'}.'">
331: <input type="hidden" name="problemmode" value="EditXML" />
1.80 albertel 332: <input type="submit" name="problemmode" value="Discard Edits and View" />
1.64 albertel 333: <input type="submit" name="problemmode" value="Edit" />
334: <hr />
335: <input type="submit" name="submit" value="Submit Changes" />
1.80 albertel 336: <input type="submit" name="submit" value="Submit Changes and View" />
1.64 albertel 337: <input type="submit" name="Undo" value="undo" />
338: <hr />
1.82 bowersj2 339: ' . $xml_help . ' Problem Help<br>
1.64 albertel 340: <textarea rows="'.$rows.'" cols="'.$cols.'" name="editxmltext">'.
1.73 albertel 341: &HTML::Entities::encode($problem).'</textarea>
1.64 albertel 342: </form></body></html>';
1.80 albertel 343: $request->print($result);
344: }
1.64 albertel 345: return '';
1.47 albertel 346: }
347:
1.41 albertel 348: sub renderpage {
1.52 albertel 349: my ($request,$file) = @_;
350:
351: my (@targets) = &get_target();
1.70 albertel 352: &Apache::lonxml::debug("Running targets ".join(':',@targets));
1.52 albertel 353: foreach my $target (@targets) {
354: #my $t0 = [&gettimeofday()];
355: my $problem=&Apache::lonnet::getfile($file);
356: if ($problem == -1) {
357: &Apache::lonxml::error("<b> Unable to find <i>$file</i></b>");
358: $problem='';
359: }
360:
361: my %mystyle;
362: my $result = '';
363: &Apache::inputtags::initialize_inputtags;
364: &Apache::edit::initialize_edit;
1.74 albertel 365: if ($target eq 'analyze') { %Apache::lonhomework::anaylze=(); }
1.52 albertel 366: if ($target eq 'web') {
1.76 albertel 367: my ($symb)=&Apache::lonxml::whichuser();
368: if ($symb eq '') {
1.52 albertel 369: if ($ENV{'request.state'} eq "construct") {
1.36 albertel 370: } else {
1.52 albertel 371: $request->print("Browsing or <a href=\"/adm/ambiguous\">ambiguous</a> reference, submissions ignored<br />");
1.51 harris41 372: }
1.52 albertel 373: }
374: #if ($Apache::lonhomework::viewgrades eq 'F') {&createmenu('grade',$request); }
375: }
1.64 albertel 376: #if ($target eq 'grade') { &showhash(%Apache::lonhomework::history); }
1.79 albertel 377: #if ($target eq 'web') { &showhash(%ENV); }
1.52 albertel 378:
379: my $default=&Apache::lonnet::getfile('/home/httpd/html/res/adm/includes/default_homework.lcpm');
380: if ($default == -1) {
381: &Apache::lonxml::error("<b>Unable to find <i>default_homework.lcpm</i></b>");
382: $default='';
383: }
1.70 albertel 384: &Apache::lonxml::debug("Should be parsing now");
1.78 albertel 385: $result = &Apache::lonxml::xmlparse($request, $target, $problem,
1.52 albertel 386: $default.&setup_vars($target),%mystyle);
387:
388: #$request->print("Result follows:");
389: if ($target eq 'modified') {
390: &handle_save_or_undo($request,\$problem,\$result);
391: } else {
1.74 albertel 392: if ($target eq 'analyze') {
393: $result=&Apache::lonnet::hashref2str(\%Apache::lonhomework::analyze);
1.75 albertel 394: undef(%Apache::lonhomework::analyze);
1.74 albertel 395: }
1.52 albertel 396: #my $td=&tv_interval($t0);
397: #if ( $Apache::lonxml::debug) {
398: #$result =~ s:</body>::;
399: #$result.="<br />Spent $td seconds processing target $target\n</body>";
400: #}
401: $request->print($result);
402: }
403: #$request->print(":Result ends");
404: #my $td=&tv_interval($t0);
405: }
1.41 albertel 406: }
407:
1.42 albertel 408: # with no arg it returns a HTML <option> list of the template titles
409: # with one arg it returns the filename associated with the arg passed
410: sub get_template_list {
1.52 albertel 411: my ($namewanted,$extension) = @_;
412: my $result;
413: &Apache::lonxml::debug("Looking for :$extension:");
414: foreach my $file (</home/httpd/html/res/adm/includes/templates/*.$extension>) {
415: my $name=&Apache::lonnet::metadata($file,'title');
416: if ($namewanted && ($name eq $namewanted)) {
417: $result=$file;
418: last;
419: } else {
420: $result.="<option>$name</option>";
1.42 albertel 421: }
1.52 albertel 422: }
423: return $result;
1.42 albertel 424: }
425:
426: sub newproblem {
1.65 matthew 427: my ($request) = @_;
428: my $extension=$request->uri;
429: $extension=~s:^.*\.([\w]+)$:$1:;
430: &Apache::lonxml::debug("Looking for :$extension:");
431: if ($ENV{'form.template'}) {
432: use File::Copy;
433: my $file = &get_template_list($ENV{'form.template'},$extension);
434: my $dest = &Apache::lonnet::filelocation("",$request->uri);
435: copy($file,$dest);
436: &renderpage($request,$dest);
437: } elsif($ENV{'form.newfile'}) {
438: # I don't like hard-coded filenames but for now, this will work.
439: use File::Copy;
440: my $templatefilename =
1.66 albertel 441: $request->dir_config('lonIncludes').'/templates/blank.problem';
442: &Apache::lonxml::debug("$templatefilename");
1.65 matthew 443: my $dest = &Apache::lonnet::filelocation("",$request->uri);
444: copy($templatefilename,$dest);
445: &renderpage($request,$dest);
446: }else {
447: my $templatelist=&get_template_list('',$extension);
448: my $url=$request->uri;
449: my $dest = &Apache::lonnet::filelocation("",$request->uri);
450: if (!defined($templatelist)) {
451: # We didn't find a template, so just create a blank problem.
452: $request->print(<<ENDNEWPROBLEM);
453: <body bgcolor="#FFFFFF">
454: The requested file $url doesn\'t exist. You can create a new $extension <br />
455: <form action="$url" method="POST">
456: <input type="submit" name="newfile" value="New $extension"><br />
457: </form>
458: </body>
459: ENDNEWPROBLEM
460: return '';
461: }
462: $request->print(<<ENDNEWPROBLEM);
1.42 albertel 463: <body bgcolor="#FFFFFF">
1.65 matthew 464: The requested file $url doesn\'t exist. You can create a new $extension <br />
1.42 albertel 465: <form action="$url" method="POST">
1.50 albertel 466: <input type="submit" value="New $extension"><br />
1.42 albertel 467: <select name="template">
468: $templatelist
469: </select>
470: </form>
471: </body>
472: ENDNEWPROBLEM
1.65 matthew 473: }
474: return '';
1.42 albertel 475: }
476:
477: sub view_or_edit_menu {
1.52 albertel 478: my ($request) = @_;
479: my $url=$request->uri;
480: $request->print(<<EDITMENU);
1.42 albertel 481: <body bgcolor="#FFFFFF">
482: <form action="$url" method="POST">
483: Would you like to <input type="submit" name="problemmode" value="View"> or
484: <input type="submit" name="problemmode" value="Edit"> the problem.
485: </form>
486: </body>
487: EDITMENU
488: }
489:
1.41 albertel 490: sub handler {
1.52 albertel 491: #my $t0 = [&gettimeofday()];
492: my $request=$_[0];
1.41 albertel 493:
1.52 albertel 494: if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}
1.41 albertel 495:
496: if (&setupheader($request)) { return OK; }
1.52 albertel 497: $ENV{'request.uri'}=$request->uri;
1.41 albertel 498:
499: #setup permissions
1.52 albertel 500: $Apache::lonhomework::browse= &Apache::lonnet::allowed('bre',$ENV{'request.filename'});
501: $Apache::lonhomework::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
502: &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:");
1.71 albertel 503: # some times multiple problemmodes are submitted, need to select
504: # the last one
1.80 albertel 505: &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
1.72 albertel 506: if ( defined($ENV{'form.problemmode'}) &&
1.77 albertel 507: ref($ENV{'form.problemmode'}) ) {
1.80 albertel 508: &Apache::lonxml::debug("Problem Mode ".join(",",@$ENV{'form.problemmode'}));
1.72 albertel 509: my $mode=$ENV{'form.problemmode'}->[-1];
1.71 albertel 510: undef $ENV{'form.problemmode'};
1.72 albertel 511: $ENV{'form.problemmode'}=$mode;
1.71 albertel 512: }
1.64 albertel 513: &Apache::lonxml::debug("Problem Mode ".$ENV{'form.problemmode'});
1.52 albertel 514: my $file=&Apache::lonnet::filelocation("",$request->uri);
515:
516: #check if we know where we are
517: if ($ENV{'request.course.fn'} && !&Apache::lonnet::symbread()) {
518: # if we are browsing we might not be able to know where we are
519: if ($Apache::lonhomework::browse ne 'F') {
520: #should know where we are, so ask
521: $request->internal_redirect('/adm/ambiguous'); return;
1.41 albertel 522: }
1.52 albertel 523: }
1.41 albertel 524:
1.52 albertel 525: if ($ENV{'request.state'} eq "construct") {
1.62 albertel 526: if ($ENV{'form.resetdata'} eq 'Reset Submissions') {
527: my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
528: &Apache::lonnet::tmpreset($symb,'',$domain,$name);
529: }
1.52 albertel 530: if ( -e $file ) {
531: if (!(defined $ENV{'form.problemmode'})) {
532: #first visit to problem in construction space
1.64 albertel 533: #&view_or_edit_menu($request);
534: $ENV{'form.problemmode'}='View';
535: &renderpage($request,$file);
536: } elsif ($ENV{'form.problemmode'} eq 'EditXML') {
537: &editxmlmode($request,$file);
1.74 albertel 538: } elsif ($ENV{'form.problemmode'} eq 'Answer Distribution') {
539: &analyze($request,$file);
1.52 albertel 540: } else {
541: &renderpage($request,$file);
1.41 albertel 542: }
543: } else {
1.52 albertel 544: # requested file doesn't exist in contruction space
545: &newproblem($request);
1.41 albertel 546: }
1.52 albertel 547: } else {
548: # just render the page normally outside of construction space
1.74 albertel 549: &Apache::lonxml::debug("not construct");
1.52 albertel 550: &renderpage($request,$file);
551: }
552: #my $td=&tv_interval($t0);
553: #&Apache::lonxml::debug("Spent $td seconds processing");
554: # &Apache::lonhomework::send_footer($request);
555: # always turn off debug messages
556: $Apache::lonxml::debug=0;
557: return OK;
558:
1.1 albertel 559: }
560:
561: 1;
562: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>