Annotation of loncom/homework/grades.pm, revision 1.25

1.17      albertel    1: # The LearningOnline Network with CAPA
1.13      albertel    2: # The LON-CAPA Grading handler
1.17      albertel    3: #
1.25    ! albertel    4: # $Id: grades.pm,v 1.24 2002/05/15 23:47:49 albertel Exp $
1.17      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.13      albertel   28: # 2/9,2/13 Guy Albertelli
1.8       www        29: # 6/8 Gerd Kortemeyer
1.13      albertel   30: # 7/26 H.K. Ng
1.14      www        31: # 8/20 Gerd Kortemeyer
1.1       albertel   32: 
                     33: package Apache::grades;
                     34: use strict;
                     35: use Apache::style;
                     36: use Apache::lonxml;
                     37: use Apache::lonnet;
1.3       albertel   38: use Apache::loncommon;
1.1       albertel   39: use Apache::lonhomework;
                     40: use Apache::Constants qw(:common);
                     41: 
1.2       albertel   42: sub moreinfo {
1.13      albertel   43:   my ($request,$reason) = @_;
                     44:   $request->print("Unable to process request: $reason");
                     45:   if ( $Apache::grades::viewgrades eq 'F' ) {
                     46:     $request->print('<form action="/adm/grades" method="post">'."\n");
1.16      albertel   47:     if ($ENV{'form.url'}) {
                     48:       $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />'."\n");
                     49:     }
                     50:     if ($ENV{'form.symb'}) {
                     51:       $request->print('<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />'."\n");
                     52:     }
                     53:     $request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'" />'."\n");
                     54:     $request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'" />'."<br />\n");
                     55:     $request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'" />'."<br />\n");
                     56:     $request->print('<input type="submit" name="submit" value="ReSubmit" />'."<br />\n");
1.13      albertel   57:     $request->print('</form>');
                     58:   }
                     59:   return '';
1.2       albertel   60: }
                     61: 
1.23      www        62: sub verifyreceipt {
                     63:     my $request=shift;
                     64:     my $courseid=$ENV{'request.course.id'};
                     65:     my $cdom=$ENV{"course.$courseid.domain"};
                     66:     my $cnum=$ENV{"course.$courseid.num"};
                     67:     my $receipt=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'}).'-'.
                     68:                 $ENV{'form.receipt'};
                     69:     $receipt=~s/[^\-\d]//g;
                     70:     my $symb=$ENV{'form.symb'};
                     71:     unless ($symb) {
                     72: 	$symb=&Apache::lonnet::symbread($ENV{'form.url'});
                     73:     }
                     74:     if ((&Apache::lonnet::allowed('mgr',$courseid)) && ($symb)) {
                     75:         $request->print('<h1>Verifying Submission Receipt '.$receipt.'</h1>');
                     76:         my $matches=0;
1.24      albertel   77:         my (%classlist) = &getclasslist($cdom,$cnum,'0');
1.23      www        78:         foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
                     79:             my ($uname,$udom)=split(/\:/,$student);
                     80:             if ($receipt eq 
                     81:              &Apache::lonnet::ireceipt($uname,$udom,$courseid,$symb)) {
                     82:                $request->print('Matching '.$student.'<br>');
                     83:                $matches++;
                     84: 	   }
                     85:         }
                     86:         $request->print('<p>'.$matches.' match(es)</p>');
                     87:     }
                     88:     return '';
                     89: }
1.13      albertel   90: 
1.10      ng         91: sub listStudents {
1.13      albertel   92:   my ($request) = shift;
1.23      www        93:   my $cdom=$ENV{"course.$ENV{'request.course.id'}.domain"};
                     94:   my $cnum=$ENV{"course.$ENV{'request.course.id'}.num"};
                     95:   my $hostver=unpack("%32C*",$Apache::lonnet::perlvar{'lonHostID'});
                     96:   $request->print(<<ENDHEADER);
                     97: <h1>Verify a Submission Receipt Issued by this Server</h1>
                     98: <form action="/adm/grades" method="post">
                     99: <tt>$hostver-<input type="text" name="receipt" size="4"></tt>
                    100: <input type="submit" name="submit" value="Verify">
                    101: <input type="hidden" name="command" value="verify">
                    102: ENDHEADER
                    103: 	  if ($ENV{'form.url'}) {
                    104: 	    $request->print(
                    105:     '<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />');
                    106: 	  }
                    107: 	  if ($ENV{'form.symb'}) {
                    108: 	    $request->print(
                    109:     '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />');
                    110: 	  }
                    111:   $request->print(<<ENDTABLEST);
                    112: </form>
                    113: <h1>Show Student Submissions on Assessment</h1>
                    114: <table border="1">
                    115: <tr><th>Username</th><th>Domain</th><th>Name</th><th>&nbsp;</th></tr>
                    116: ENDTABLEST
1.24      albertel  117:   my (%classlist) = &getclasslist($cdom,$cnum,'0');
1.13      albertel  118:   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
                    119:       my ($sname,$sdom) = split(/:/,$student);
                    120: 
1.25    ! albertel  121:       my %name=&Apache::lonnet::get('environment', ['lastname','generation',
        !           122: 						    'firstname','middlename'],
        !           123: 				    $sdom,$sname);
        !           124:       my $fullname;
        !           125:       my ($tmp) = keys(%name);
        !           126:       if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
        !           127: 	$fullname=$name{'lastname'}.$name{'generation'};
        !           128: 	if ($fullname =~ /[^\s]+/) { $fullname.=','; }
        !           129: 	$fullname.=$name{'firstname'}.' '.$name{'middlename'};
        !           130:       }
1.13      albertel  131:       if ( $Apache::grades::viewgrades eq 'F' ) {
1.25    ! albertel  132: 	  $request->print("\n".'<tr>'."<td>$sname</td><td>$sdom</td><td>$fullname</td><td>".
1.21      albertel  133: 			  '<form action="/adm/grades" method="post">');
1.16      albertel  134: 	  if ($ENV{'form.url'}) {
1.19      www       135: 	    $request->print(
                    136:     '<input type="hidden" name="url" value="'.$ENV{'form.url'}.'" />');
1.16      albertel  137: 	  }
                    138: 	  if ($ENV{'form.symb'}) {
1.19      www       139: 	    $request->print(
                    140:     '<input type="hidden" name="symb" value="'.$ENV{'form.symb'}.'" />');
1.16      albertel  141: 	  }
1.19      www       142: 	  $request->print(
                    143:     '<input type="hidden" name="command" value="'.$ENV{'form.command'}.'" />');
                    144: 	  $request->print(
                    145:              '<input type="hidden" name="student" value="'.$sname.'" />');
                    146: 	  $request->print(
                    147:              '<input type="hidden" name="domain" value="'.$sdom.'" />');
                    148: 	  $request->print(
                    149:                          '<input type="submit" name="submit" value="View" />');
1.21      albertel  150: 	  $request->print('</form></td></tr>');
1.13      albertel  151:       }
                    152:   }
1.19      www       153:   $request->print('</table>');
1.10      ng        154: }
                    155: 
1.13      albertel  156: 
1.7       albertel  157: #FIXME - needs to handle multiple matches
1.2       albertel  158: sub finduser {
1.13      albertel  159:   my ($name) = @_;
                    160:   my $domain = '';
                    161: 
                    162:   if ( $Apache::grades::viewgrades eq 'F' ) {
                    163:     #get classlist
                    164:     my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
1.24      albertel  165:     #print "Found $cdom:$cnum<br />";
                    166:     my (%classlist) = &getclasslist($cdom,$cnum,'0');
1.13      albertel  167:     foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
                    168:       my ($posname,$posdomain) = split(/:/,$student);
                    169:       if ($posname =~ $name) { $name=$posname; $domain=$posdomain; last; }
1.7       albertel  170:     }
1.13      albertel  171:     return ($name,$domain);
                    172:   } else {
                    173:     return ($ENV{'user.name'},$ENV{'user.domain'});
                    174:   }
1.5       albertel  175: }
                    176: 
                    177: sub getclasslist {
1.24      albertel  178:   my ($coursedomain,$coursenum,$hideexpired) = @_;
                    179:   my %classlist=&Apache::lonnet::dump('classlist',$coursedomain,$coursenum);
1.13      albertel  180:   my $now = time;
1.24      albertel  181:   foreach my $student (keys(%classlist)) {
                    182:     my ($end,$start)=split(/:/,$classlist{$student});
1.13      albertel  183:     # still a student?
                    184:     if (($hideexpired) && ($end) && ($end < $now)) {
1.15      albertel  185:       #print "Skipping:$name:$end:$now<br />\n";
1.13      albertel  186:       next;
                    187:     }
1.15      albertel  188:     #print "record=$record<br>";
1.24      albertel  189:     push( @{ $classlist{'allids'} }, $student);
1.13      albertel  190:   }
                    191:   return (%classlist);
1.5       albertel  192: }
                    193: 
                    194: sub getpartlist {
1.13      albertel  195:   my ($url) = @_;
                    196:   my @parts =();
                    197:   my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
                    198:   foreach my $key (@metakeys) {
                    199:     if ( $key =~ m/stores_([0-9]+)_.*/ ) {
                    200:       push(@parts,$key);
1.6       albertel  201:     }
1.13      albertel  202:   }
                    203:   return @parts;
1.5       albertel  204: }
                    205: 
                    206: sub viewstudentgrade {
1.13      albertel  207:   my ($url,$symb,$courseid,$student,@parts) = @_;
                    208:   my $result ='';
                    209:   my $cellclr = '"#ffffdd"';
                    210:   my ($stuname,$domain) = split(/:/,$student);
                    211: 
                    212:   my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
                    213: 
                    214:   $result.="<tr><td bgcolor=$cellclr>$stuname</td><td bgcolor=$cellclr align=\"middle\">$domain</td>\n";
                    215:   foreach my $part (@parts) {
                    216:     my ($temp,$part,$type)=split(/_/,$part);
                    217:     #print "resource.$part.$type = ".$record{"resource.$part.$type"}." <br />\n";
                    218:     if ($type eq 'awarded') {
                    219:       my $score=$record{"resource.$part.$type"};
                    220:       $result.="<td bgcolor=$cellclr align=\"middle\"><input type=\"text\" name=\"GRADE.$student.$part.$type\" value=\"$score\" size=\"4\" /></td>\n";
                    221:     } elsif ($type eq 'tries') {
                    222:       my $score=$record{"resource.$part.$type"};
                    223:       $result.="<td bgcolor=$cellclr align=\"middle\"><input type=\"text\" name=\"GRADE.$student.$part.$type\" value=\"$score\" size=\"4\" /></td>\n"
                    224:     } elsif ($type eq 'solved') {
                    225:       my $score=$record{"resource.$part.$type"};
                    226:       $result.="<td bgcolor=$cellclr align=\"middle\"><select name=\"GRADE.$student.$part.$type\">\n";
                    227:       if ($score =~ /^correct/) {
                    228: 	$result.="<option selected=\"on\">correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";
                    229:       } elsif ($score =~ /^incorrect/) {
                    230: 	$result.="<option>correct</option>\n<option selected=\"on\">incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";
                    231:       } elsif ($score eq '') {
                    232: 	$result.="<option>correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option selected=\"on\">nothing</option>\n";
                    233:       } elsif ($score =~ /^excused/) {
                    234: 	$result.="<option>correct</option>\n<option>incorrect</option>\n<option selected=\"on\">excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";
                    235:       } elsif ($score =~ /^ungraded/) {
                    236: 	$result.="<option>correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option selected=\"on\">ungraded</option>\n<option>nothing</option>\n";
                    237:       }
                    238:       $result.="</select></td>\n";
                    239:     }
                    240:   }
                    241:   $result.='</tr>';
                    242:   return $result;
1.5       albertel  243: }
1.13      albertel  244: #FIXME need to look at the meatdata <stores> spec on what type of data to accept and provide an
1.6       albertel  245: #interface based on that, also do that to above function.
1.5       albertel  246: sub setstudentgrade {
1.13      albertel  247:   my ($url,$symb,$courseid,$student,@parts) = @_;
                    248: 
                    249:   my $result ='';
                    250: 
                    251:   my ($stuname,$domain) = split(/:/,$student);
                    252: 
                    253:   my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
                    254: 
                    255:   my %newrecord;
                    256: 
                    257:   foreach my $part (@parts) {
                    258:     my ($temp,$part,$type)=split(/_/,$part);
                    259:     my $oldscore=$record{"resource.$part.$type"};
                    260:     my $newscore=$ENV{"form.GRADE.$student.$part.$type"};
                    261:     if ($type eq 'solved') {
                    262:       my $update=0;
                    263:       if ($newscore eq 'nothing' ) {
                    264: 	if ($oldscore ne '') {
                    265: 	  $update=1;
                    266: 	  $newscore = '';
1.6       albertel  267: 	}
1.13      albertel  268:       } elsif ($oldscore !~ m/^$newscore/) {
                    269: 	$update=1;
                    270: 	$result.="Updating $stuname to $newscore<br />\n";
                    271: 	if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }
                    272: 	if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }
                    273: 	if ($newscore eq 'excused') { $newscore = 'excused'; }
                    274: 	if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }
                    275:       } else {
                    276: 	#$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";
                    277:       }
                    278:       if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
                    279:     } else {
                    280:       if ($oldscore ne $newscore) {
                    281: 	$newrecord{"resource.$part.$type"}=$newscore;
                    282: 	$result.="Updating $student"."'s status for $part.$type to $newscore<br />\n";
                    283:       } else {
                    284: 	#$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";
                    285:       }
                    286:     }
                    287:   }
                    288:   if ( scalar(keys(%newrecord)) > 0 ) {
                    289:     $newrecord{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";
                    290:     &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
                    291: 
                    292:     $result.="Stored away ".scalar(keys(%newrecord))." elements.<br />\n";
                    293:   }
                    294:   return $result;
1.2       albertel  295: }
                    296: 
                    297: sub submission {
1.13      albertel  298:   my ($request) = @_;
                    299:   my $url=$ENV{'form.url'};
                    300:   $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
                    301:   if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; }
1.10      ng        302: #  if ($ENV{'form.student'} eq '') { &listStudents($request); return ''; }
1.13      albertel  303:   my ($uname,$udom) = &finduser($ENV{'form.student'});
                    304:   if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }
1.16      albertel  305:   my $symb;
                    306:   if ($ENV{'form.symb'}) {
                    307:     $symb=$ENV{'form.symb'};
                    308:   } else {
                    309:     $symb=&Apache::lonnet::symbread($url);
                    310:   }
1.13      albertel  311:   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
                    312:   my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
                    313: 						      $ENV{'request.course.id'});
                    314:   my $result="<h2> Submission Record </h2>  $uname:$udom for $url <br />".$answer;
1.17      albertel  315:   my $rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
                    316: 						   $ENV{'request.course.id'});
1.22      albertel  317:   $result.="Student's view of the problem:<br /> $rendered <br /> Correct answer:<br />";
1.18      albertel  318: 
1.22      albertel  319:   $answer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
1.18      albertel  320: 						  $ENV{'request.course.id'});
                    321:   $result.=$answer;
1.13      albertel  322:   return $result;
1.2       albertel  323: }
                    324: 
1.5       albertel  325: sub viewgrades {
1.13      albertel  326:   my ($request) = @_;
                    327:   my $result='';
1.5       albertel  328: 
1.13      albertel  329:   #get resource reference
                    330:   my $url=$ENV{'form.url'};
                    331:   $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
                    332:   my $symb=$ENV{'form.symb'};
                    333:   if (!$symb) { $symb=&Apache::lonnet::symbread($url); }
                    334:   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }
                    335: 
                    336:   #get classlist
                    337:   my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
1.24      albertel  338:   #print "Found $cdom:$cnum<br />";
                    339:   my (%classlist) = &getclasslist($cdom,$cnum,'0');
1.13      albertel  340:   my $headerclr = '"#ccffff"';
                    341:   my $cellclr = '"#ffffcc"';
                    342: 
                    343:   #get list of parts for this problem
                    344:   my (@parts) = &getpartlist($url);
                    345: 
                    346:   $request->print ("<h2><font color=\"#339966\">Manual Grading</font></h2>");
                    347: 
                    348:   #start the form
                    349:   $result = '<form action="/adm/grades" method="post">'."\n".
1.16      albertel  350:     '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
                    351:       '<input type="hidden" name="url" value="'.$url.'" />'."\n".
1.13      albertel  352: 	'<input type="hidden" name="command" value="editgrades" />'."\n".
                    353: 	  '<input type="submit" name="submit" value="Submit Changes" />'."\n".
                    354: 	    '<table border=0><tr><td bgcolor="#999999">'."\n".
                    355: 	     '<table border=0>'."\n".
                    356: 	      '<tr><td bgcolor='.$headerclr.'>UserId</td><td bgcolor='.$headerclr.'>Domain</td>'."\n";
                    357:   foreach my $part (@parts) {
                    358:      my $display=&Apache::lonnet::metadata($url,$part.'.display');
                    359:      if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }
                    360:      $result.='<td bgcolor='.$headerclr.'>'.$display.'</td>'."\n";
                    361:    }
                    362:   $result.="</tr>";
                    363:   #get info for each student
                    364:   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
                    365:     $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
                    366:   }
                    367:   $result.='</table></td></tr></table><input type="submit" name="submit" value="Submit Changes" /></form>';
1.5       albertel  368: 
1.13      albertel  369:   return $result;
1.5       albertel  370: }
                    371: 
                    372: sub editgrades {
1.13      albertel  373:   my ($request) = @_;
                    374:   my $result='';
1.5       albertel  375: 
1.13      albertel  376:   my $symb=$ENV{'form.symb'};
                    377:   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$symb:$ENV{'form.url'}"); return ''; }
                    378:   my $url=$ENV{'form.url'};
                    379:   #get classlist
                    380:   my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
1.24      albertel  381:   #print "Found $cdom:$cnum<br />";
                    382:   my (%classlist) = &getclasslist($cdom,$cnum,'0');
1.13      albertel  383: 
                    384:   #get list of parts for this problem
                    385:   my (@parts) = &getpartlist($url);
                    386: 
                    387:   $result.='<form action="/adm/grades" method="post">'."\n".
                    388:     '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
                    389:       '<input type="hidden" name="url" value="'.$url.'" />'."\n".
                    390: 	'<input type="hidden" name="command" value="viewgrades" />'."\n".
                    391: 	  '<input type="submit" name="submit" value="See Grades" /> <br />'."\n";
                    392: 
                    393:   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
                    394:     $result.=&setstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);
                    395:   }
1.5       albertel  396: 
1.13      albertel  397:   $result.='<input type="submit" name="submit" value="See Grades" /></table></form>';
                    398:   return $result;
1.5       albertel  399: }
                    400: 
1.2       albertel  401: sub send_header {
1.13      albertel  402:   my ($request)= @_;
                    403:   $request->print(&Apache::lontexconvert::header());
1.6       albertel  404: #  $request->print("
                    405: #<script>
                    406: #remotewindow=open('','homeworkremote');
                    407: #remotewindow.close();
                    408: #</script>"); 
1.13      albertel  409:   $request->print('<body bgcolor="#FFFFFF">');
1.2       albertel  410: }
                    411: 
                    412: sub send_footer {
1.13      albertel  413:   my ($request)= @_;
1.2       albertel  414:   $request->print('</body>');
                    415:   $request->print(&Apache::lontexconvert::footer());
                    416: }
                    417: 
1.1       albertel  418: sub handler {
1.13      albertel  419:   my $request=$_[0];
                    420: 
                    421:   if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} else {$Apache::lonxml::debug=0;}
                    422:   
                    423:   if ($ENV{'browser.mathml'}) {
                    424:     $request->content_type('text/xml');
                    425:   } else {
                    426:     $request->content_type('text/html');
                    427:   }
                    428:   $request->send_http_header;
                    429:   return OK if $request->header_only;
1.16      albertel  430:   &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
1.13      albertel  431:   my $url=$ENV{'form.url'};
                    432:   my $symb=$ENV{'form.symb'};
                    433:   my $command=$ENV{'form.command'};
1.16      albertel  434:   if (!$url) {
                    435:     my ($temp1,$temp2);
                    436:     ($temp1,$temp2,$ENV{'form.url'})=split(/___/,$symb);
                    437:     $url = $ENV{'form.url'};
                    438:   }
1.13      albertel  439:   &send_header($request);
                    440:   if ($url eq '' && $symb eq '') {
1.14      www       441:      if ($ENV{'user.adv'}) {
                    442:          if (($ENV{'form.codeone'}) && ($ENV{'form.codetwo'}) &&
                    443:              ($ENV{'form.codethree'})) {
                    444:              my $token=$ENV{'form.codeone'}.'*'.$ENV{'form.codetwo'}.'*'.
                    445: 		        $ENV{'form.codethree'};
                    446:              my ($tsymb,$tuname,$tudom,$tcrsid)=
                    447: 		 &Apache::lonnet::checkin($token);
                    448:              if ($tsymb) {
                    449:                 my ($map,$id,$url)=split(/\_\_\_/,$tsymb);
                    450:                 if (&Apache::lonnet::allowed('mgr',$tcrsid)) {
                    451:                    $request->print(
                    452:                      &Apache::lonnet::ssi('/res/'.$url,
                    453:                         ('grade_username' => $tuname,
                    454:                          'grade_domain' => $tudom,
                    455:                          'grade_courseid' => $tcrsid,
                    456:                          'grade_symb' => $tsymb)));
                    457:                 } else {
                    458:                    $request->print('<h1>Not authorized: '.$token.'</h1>');
                    459:                 }           
                    460: 	    } else {
                    461:                 $request->print('<h1>Not a valid DocID: '.$token.'</h1>');
                    462:             }
                    463: 	 } else {
                    464:              $request->print(&Apache::lonxml::tokeninputfield());
                    465:          }
                    466:      }
1.13      albertel  467:   } else {
                    468:     $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});
                    469:     if ($command eq 'submission') {
1.20      albertel  470:       &listStudents($request) if ($ENV{'form.student'} eq '');
1.13      albertel  471:       $request->print(&submission($request)) if ($ENV{'form.student'} ne '');
                    472:     } elsif ($command eq 'viewgrades') {
                    473:       $request->print(&viewgrades($request));
                    474:     } elsif ($command eq 'editgrades') {
                    475:       $request->print(&editgrades($request));
1.23      www       476:     } elsif ($command eq 'verify') {
                    477:       $request->print(&verifyreceipt($request));
1.12      harris41  478:     } else {
1.23      www       479:       $request->print("Unknown action: $command:");
1.2       albertel  480:     }
1.13      albertel  481:   }
                    482:   &send_footer($request);
                    483:   return OK;
1.1       albertel  484: }
                    485: 
                    486: 1;
                    487: 
1.13      albertel  488: __END__;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>