Diff for /loncom/homework/grades.pm between versions 1.6 and 1.12

version 1.6, 2001/04/17 21:07:38 version 1.12, 2001/08/06 16:37:58
Line 1 Line 1
 # The LON-CAPA Grading handler  # The LON-CAPA grading handler.
 # 2/9,2/13 Guy Albertelli  #
   # Handles the viewing of grades.
   #
   # YEAR=2001
   # 2/7,2/9,2/13,4/16,4/17,5/1 Guy Albertelli
   # 6/8 Gerd Kortemeyer
   # 7/26 Guy Albertelli
   # 7/27 H.K. Ng
   # 7/30 Guy Albertelli
   # 8/6 Scott Harrison
   
 package Apache::grades;  package Apache::grades;
 use strict;  use strict;
Line 10  use Apache::loncommon; Line 19  use Apache::loncommon;
 use Apache::lonhomework;  use Apache::lonhomework;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
   
   # ======================================================== Get more information
 sub moreinfo {  sub moreinfo {
   my ($request,$reason) = @_;      my ($request,$reason) = @_;
   $request->print("Unable to process request: $reason");      $request->print("Unable to process request: $reason");
   if ( $Apache::grades::viewgrades eq 'F' ) {      if ( $Apache::grades::viewgrades eq 'F' ) {
     $request->print('<form action="/adm/grades" method="post">'."\n");   $request->print('<form action="/adm/grades" method="post">'."\n");
     $request->print('<input type="hidden" name="url" value="'.$ENV{'form.url'}.'"></input>'."\n");   $request->print('<input type="hidden" name="url" value="'.
     $request->print('<input type="hidden" name="command" value="'.$ENV{'form.command'}.'"></input>'."\n");   $ENV{'form.url'}.'"></input>'."\n");
     $request->print("Student:".'<input type="text" name="student" value="'.$ENV{'form.student'}.'"></input>'."<br />\n");   $request->print('<input type="hidden" name="command" value="'.
     $request->print("Domain:".'<input type="text" name="domain" value="'.$ENV{'user.domain'}.'"></input>'."<br />\n");   $ENV{'form.command'}.'"></input>'."\n");
     $request->print('<input type="submit" name="submit" value="ReSubmit"></input>'."<br />\n");   $request->print("Student:".
     $request->print('</form>');   '<input type="text" name="student" value="'.
   }   $ENV{'form.student'}.'"></input>'."<br />\n");
   return '';   $request->print("Domain:".
    '<input type="text" name="domain" value="'.
    $ENV{'user.domain'}.'"></input>'."<br />\n");
    $request->print('<input type="submit" name="submit" '.
    'value="ReSubmit"></input>'."<br />\n");
    $request->print('</form>');
       }
       return '';
 }  }
   
   # ========================================= Displays the class list of students
   sub listStudents {
       my ($request) = shift;
       my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
       my $chome = $ENV{"course.$ENV{'request.course.id'}.home"};
       $request->print ("Found $cdom:$cnum:$chome<br />");
       my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
       foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
    my ($sname,$sdom) = split(/:/,$student);
    my $reply = &Apache::lonnet::reply('get:'.$sdom.':'.$sname.
       ':environment:lastname&generation&firstname&middle'.
       'name',&Apache::lonnet::homeserver($sname,$sdom));
    print "reply=$reply<br>";
    my (@nameparts) = split /&/,$reply;
   #        my $sfullname = $Apache::lonnet::unescape($nameparts[0]);
    if ( $Apache::grades::viewgrades eq 'F' ) {
       $request->print('<form action="/adm/grades" method="post">'."\n");
       $request->print("$sname @nameparts\n");
       $request->print('<input type="hidden" name="url" value="'.
       $ENV{'form.url'}.'"></input>'."\n");
       $request->print('<input type="hidden" name="command" value="'.
       $ENV{'form.command'}.'"></input>'."\n");
       $request->print('<input type="hidden" name="student" '.
       'value="'.$sname.'"></input>'."\n");
       $request->print('<input type="hidden" name="domain" '.
       'value="'.$sdom.'"></input>'."\n");
       $request->print('<input type="submit" name="submit" '.
       'value="View"></input>'."<br />\n");
       $request->print('</form>');
    }
       }
   }
   
 #FIXME - needs to be much smarter  # ========== Finds a user based on a name substring (returns a 2 element array)
   #FIXME - needs to handle multiple matches
 sub finduser {  sub finduser {
   my ($name) = @_;      my ($name) = @_;
       my $domain = '';
   if ( $Apache::grades::viewgrades eq 'F' ) {      if ( $Apache::grades::viewgrades eq 'F' ) {
     return ($name,$ENV{'user.domain'});   #get classlist
   } else {   my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
     return ($ENV{'user.name'},$ENV{'user.domain'});   my $chome = $ENV{"course.$ENV{'request.course.id'}.home"};
   }   #print "Found $cdom:$cnum:$chome<br />";
    my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
    foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
       my ($posname,$posdomain) = split(/:/,$student);
       if ($posname =~ $name) { 
    $name = $posname;
    $domain = $posdomain;
    last;
       }
    }
    return ($name,$domain);
       } else {
    return ($ENV{'user.name'},$ENV{'user.domain'});
       }
 }  }
   
   # ===================================== Gets a class list (returns a hash list)
 sub getclasslist {  sub getclasslist {
   my ($coursedomain,$coursenum,$coursehome,$hideexpired) = @_;      my ($coursedomain,$coursenum,$coursehome,$hideexpired) = @_;
   my $classlist=&Apache::lonnet::reply("dump:$coursedomain:$coursenum:classlist",$coursehome);      my $classlist = &Apache::lonnet::reply('dump:'.$coursedomain.':'.
   my %classlist=();   $coursenum.':classlist',$coursehome);
   my $now = time;      my %classlist = ();
   foreach my $record (split /&/, $classlist) {      my $now = time;
     my ($name,$value)=split(/=/,&Apache::lonnet::unescape($record));      foreach my $record (split /&/, $classlist) {
     my ($end,$start)=split(/:/,$value);   my ($name,$value)=split(/=/,&Apache::lonnet::unescape($record));
     # still a student?   my ($end,$start)=split(/:/,$value);
     if (($hideexpired) && ($end) && ($end < $now)) {   # still a student?
       print "Skipping:$name:$end:$now<br />\n";   if (($hideexpired) && ($end) && ($end < $now)) {
       next;      print "Skipping:$name:$end:$now<br />\n";
     }      next;
     push( @{ $classlist{'allids'} }, $name);    }
   }   print "record=$record<br>";
   return (%classlist);   push( @{ $classlist{'allids'} }, $name); 
       }
       return (%classlist);
 }  }
   
   # ============================== Get parts of a stored value (returns an array)
 sub getpartlist {  sub getpartlist {
   my ($url) = @_;      my ($url) = @_;
   my @parts =();      my @parts =();
   my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));      my (@metakeys) = split(/,/,&Apache::lonnet::metadata($url,'keys'));
   foreach my $key (@metakeys) {      foreach my $key (@metakeys) {
     if ( $key =~ m/stores_([0-9]+)_.*/ ) {   if ( $key =~ m/stores_([0-9]+)_.*/ ) {
       push(@parts,$key);      push(@parts,$key);
    }
     }      }
   }      return @parts;
   return @parts;  
 }  }
   
   # =================================== Displays student grade (returns a string)
 sub viewstudentgrade {  sub viewstudentgrade {
   my ($url,$symb,$courseid,$student,@parts) = @_;      my ($url,$symb,$courseid,$student,@parts) = @_;
   my $result ='';      my $result = '';
       my $cellclr = '"#ffffdd"';
   my ($stuname,$domain) = split(/:/,$student);      my ($stuname,$domain) = split(/:/,$student);
       my %record = &Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
   my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname,      $result .= "<tr><td bgcolor=$cellclr>$stuname</td><td bgcolor=".
       &Apache::lonnet::homeserver($stuname,$domain));         "\"$cellclr\" align=\"middle\">$domain</td>\n";
       foreach my $part (@parts) {
   $result.="<tr><td>$stuname</td><td>$domain</td>\n";   my ($temp,$part,$type)=split(/_/,$part);
   foreach my $part (@parts) {   #print "resource.$part.$type = ".$record{"resource.$part.$type"}." <br />\n";
     my ($temp,$part,$type)=split(/_/,$part);   if ($type eq 'awarded') {
     #print "resource.$part.$type = ".$record{"resource.$part.$type"}." <br />\n";      my $score = $record{"resource.$part.$type"};
     if ($type eq 'awarded') {      $result .= "<td bgcolor=$cellclr align=\"middle\">".
       my $score=$record{"resource.$part.$type"};         "<input type=\"text\" name=".
       $result.="<td><input type=\"text\" name=\"GRADE.$student.$part.$type\" value=\"$score\" size=\"4\" /></td>\n";         "\"GRADE.$student.$part.$type\" ".
     } elsif ($type eq 'tries') {         "value=\"$score\" size=\"4\" /></td>\n";
       my $score=$record{"resource.$part.$type"};   } elsif ($type eq 'tries') {
       $result.="<td><input type=\"text\" name=\"GRADE.$student.$part.$type\" value=\"$score\" size=\"4\" /></td>\n"      my $score = $record{"resource.$part.$type"};
     } elsif ($type eq 'solved') {      $result .= "<td bgcolor=$cellclr align=\"middle\"><input ".
       my $score=$record{"resource.$part.$type"};         "type=\"text\" name=\"GRADE.$student.$part.".
       $result.="<td><select name=\"GRADE.$student.$part.$type\">\n";          "$type\" value=\"$score\" size=\"4\" /></td>\n";
       if ($score =~ /^correct/) {   } elsif ($type eq 'solved') {
  $result.="<option selected=\"on\">correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";      my $score = $record{"resource.$part.$type"};
       } elsif ($score =~ /^incorrect/) {      $result .= "<td bgcolor=\"$cellclr\" align=\"middle\">".
  $result.="<option>correct</option>\n<option selected=\"on\">incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";         "<select name=\"GRADE.$student.$part.$type\">\n";
       } elsif ($score eq '') {      if ($score =~ /^correct/) {
  $result.="<option>correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option>ungraded</option>\n<option selected=\"on\">nothing</option>\n";   $result .= "<option selected=\"on\">correct</option>".
       } elsif ($score =~ /^excused/) {             "\n<option>incorrect</option>\n<option>".
  $result.="<option>correct</option>\n<option>incorrect</option>\n<option selected=\"on\">excused</option>\n<option>ungraded</option>\n<option>nothing</option>\n";     "excused</option>\n<option>ungraded".
       } elsif ($score =~ /^ungraded/) {     "</option>\n<option>nothing</option>\n";
  $result.="<option>correct</option>\n<option>incorrect</option>\n<option>excused</option>\n<option selected=\"on\">ungraded</option>\n<option>nothing</option>\n";      } elsif ($score =~ /^incorrect/) {
       }   $result .= "<option>correct</option>\n<option ".
       $result.="</select></td>\n";             "selected=\"on\">incorrect</option>\n".
     }     "<option>excused</option>\n<option>".
   }     "ungraded</option>\n<option>nothing</option>\n";
   $result.='</tr>';      } elsif ($score eq '') {
   return $result;   $result .= "<option>correct</option>\n<option> ".
              "incorrect</option>\n<option>excused".
                              "</option>\n<option>ungraded</option>\n".
      "<option selected=\"on\">nothing</option>\n";
       } elsif ($score =~ /^excused/) {
    $result .= "<option>correct</option>\n<option>".
                              "incorrect</option>\n<option selected=".
                              "\"on\">excused</option>\n<option>".
      "ungraded</option>\n<option>nothing</option>\n";
       } elsif ($score =~ /^ungraded/) {
    $result .= "<option>correct</option>\n<option>".
              "incorrect</option>\n<option>excused".
                              "</option>\n<option selected=\"on\">".
      "ungraded</option>\n<option>nothing</option>\n";
       }
       $result .= "</select></td>\n";
    }
       }
       $result .= '</tr>';
       return $result;
 }  }
 #FIXME need to look at the meatdata <stores> spec on what type of data to accept and provide an  
   # ========================================================== Sets student grade
   #FIXME need to look at the meatdata <stores> spec
   # on what type of data to accept and provide an
 #interface based on that, also do that to above function.  #interface based on that, also do that to above function.
 sub setstudentgrade {  sub setstudentgrade {
   my ($url,$symb,$courseid,$student,@parts) = @_;      my ($url,$symb,$courseid,$student,@parts) = @_;
       my $result ='';
   my $result ='';      my ($stuname,$domain) = split(/:/,$student);
       my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname);
   my ($stuname,$domain) = split(/:/,$student);      my %newrecord;
       foreach my $part (@parts) {
   my %record=&Apache::lonnet::restore($symb,$courseid,$domain,$stuname,   my ($temp,$part,$type) = split(/_/,$part);
       &Apache::lonnet::homeserver($stuname,$domain));   my $oldscore = $record{"resource.$part.$type"};
   my %newrecord;   my $newscore = $ENV{"form.GRADE.$student.$part.$type"};
    if ($type eq 'solved') {
   foreach my $part (@parts) {      my $update = 0;
     my ($temp,$part,$type)=split(/_/,$part);      if ($newscore eq 'nothing' ) {
     my $oldscore=$record{"resource.$part.$type"};   if ($oldscore ne '') {
     my $newscore=$ENV{"form.GRADE.$student.$part.$type"};      $update = 1;
     if ($type eq 'solved') {      $newscore = '';
       my $update=0;   }
       if ($newscore eq 'nothing' ) {      } elsif ($oldscore !~ m/^$newscore/) {
  if ($oldscore ne '') {   $update=1;
   $update=1;   $result.="Updating $stuname to $newscore<br />\n";
   $newscore = '';   if ($newscore eq 'correct') { 
       $newscore = 'correct_by_override'; }
    if ($newscore eq 'incorrect') {
       $newscore = 'incorrect_by_override'; }
    if ($newscore eq 'excused') {
       $newscore = 'excused'; }
    if ($newscore eq 'ungraded') {
       $newscore = 'ungraded_attempted'; }
       } else {
    #$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";
       }
       if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }
    } else {
       if ($oldscore ne $newscore) {
    $newrecord{"resource.$part.$type"}=$newscore;
    $result .= "Updating $student"."'s status for $part.$type to ".
              "$newscore<br />\n";
       } else {
    #$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";
       }
  }   }
       } elsif ($oldscore !~ m/^$newscore/) {      }
  $update=1;      if ( scalar(keys(%newrecord)) > 0 ) {
  $result.="Updating $stuname to $newscore<br />\n";   $newrecord{"resource.regrader"} = $ENV{'user.name'}.':'.
  if ($newscore eq 'correct') { $newscore = 'correct_by_override'; }                                    $ENV{'user.domain'};
  if ($newscore eq 'incorrect') { $newscore = 'incorrect_by_override'; }   &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname);
  if ($newscore eq 'excused') { $newscore = 'excused'; }  
  if ($newscore eq 'ungraded') { $newscore = 'ungraded_attempted'; }   $result .= 'Stored away '.scalar(keys(%newrecord)).
       } else {              " elements.<br />\n";
  #$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";      }
       }      return $result;
       if ($update) { $newrecord{"resource.$part.$type"}=$newscore; }  
     } else {  
       if ($oldscore ne $newscore) {  
  $newrecord{"resource.$part.$type"}=$newscore;  
  $result.="Updating $student"."'s status for $part.$type to $newscore<br />\n";  
       } else {  
  #$result.="$stuname:$part:$type:unchanged  $oldscore to $newscore:<br />\n";  
       }  
     }  
   }  
   if ( scalar(keys(%newrecord)) > 0 ) {  
     $newrecord{"resource.regrader"}="$ENV{'user.name'}:$ENV{'user.domain'}";  
     &Apache::lonnet::cstore(\%newrecord,$symb,$courseid,$domain,$stuname,  
     &Apache::lonnet::homeserver($stuname,$domain));  
     $result.="Stored away ".scalar(keys(%newrecord))." elements.<br />\n";  
   }  
   return $result;  
 }  }
   
   
   # ========================================================== Attempt submission
 sub submission {  sub submission {
   my ($request) = @_;      my ($request) = @_;
   my $url=$ENV{'form.url'};      my $url = $ENV{'form.url'};
   $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;      $url =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
   if ($ENV{'form.student'} eq '') { &moreinfo($request,"Need student login id"); return ''; }      if ($ENV{'form.student'} eq '') { 
   my ($uname,$udom) = &finduser($ENV{'form.student'});   &moreinfo($request,"Need student login id"); return ''; }
   if ($uname eq '') { &moreinfo($request,"Unable to find student"); return ''; }  #  if ($ENV{'form.student'} eq '') { &listStudents($request); return ''; }
   my $symb=&Apache::lonnet::symbread($url);      my ($uname,$udom) = &finduser($ENV{'form.student'});
   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }      if ($uname eq '') {
   my $home=&Apache::lonnet::homeserver($uname,$udom);   &moreinfo($request,"Unable to find student"); return ''; }
   my $answer=&Apache::loncommon::get_previous_attempt($symb,$uname,$udom,$home,      my $symb=&Apache::lonnet::symbread($url);
       $ENV{'request.course.id'});      if ($symb eq '') {
   my $result="<h2> Submission Record </h2>  $uname:$udom for $url".$answer;   $request->print("Unable to handle ambiguous references:$url:.");
   return $result;   return ''; }
       my $answer = &Apache::loncommon::get_previous_attempt($symb,$uname,$udom,
    $ENV{'request.course.id'});
       my $result = "<h2> Submission Record </h2>  $uname:$udom for $url <br />".
            $answer;
       return $result;
 }  }
   
   # ================================================================= View grades
 sub viewgrades {  sub viewgrades {
   my ($request) = @_;      my ($request) = @_;
   my $result='';      my $result = '';
       
   #get resource reference      #get resource reference
   my $url=$ENV{'form.url'};      my $url = $ENV{'form.url'};
   $url=~s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;      $url =~ s-^http://($ENV{'SERVER_NAME'}|$ENV{'HTTP_HOST'})--;
   my $symb=$ENV{'form.symb'};      my $symb=$ENV{'form.symb'};
   if (!$symb) { $symb=&Apache::lonnet::symbread($url); }      if (!$symb) { $symb = &Apache::lonnet::symbread($url); }
   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$url:."); return ''; }      if ($symb eq '') { 
    $request->print("Unable to handle ambiguous references:$url:.");
   #get classlist   return '';
   my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});      }
   my $chome=$ENV{"course.$ENV{'request.course.id'}.home"};      
   #print "Found $cdom:$cnum:$chome<br />";      #get classlist
   my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');      my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
       my $chome = $ENV{"course.$ENV{'request.course.id'}.home"};
       #print "Found $cdom:$cnum:$chome<br />";
   #get list of parts for this problem      my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
   my (@parts) = &getpartlist($url);      my $headerclr = '"#ccffff"';
       my $cellclr = '"#ffffcc"';
   #start the form  
   $result = '<form action="/adm/grades" method="post">'."\n".      #get list of parts for this problem
     '<input type="hidden" name="symb" value="'.$symb.'"/>'."\n".      my (@parts) = &getpartlist($url);
       '<input type="hidden" name="url" value="'.$url.'"/>'."\n".  
  '<input type="hidden" name="command" value="editgrades" />'."\n".      $request->print("<h2><font color=\"#339966\">Manual Grading</font></h2>");
   '<input type="submit" name="submit" value="Submit Changes" />'."\n".      
     '<table>'."\n".      #start the form
       '<tr><td>UserId</td><td>Domain</td>'."\n";      $result = '<form action="/adm/grades" method="post">'."\n".
   foreach my $part (@parts) {        '<input type="hidden" name="symb" value="'.$symb.'"/>'."\n".
      my $display=&Apache::lonnet::metadata($url,$part.'.display');        '<input type="hidden" name="url" value="'.$url.'"/>'."\n".
      if  (!$display) { $display = &Apache::lonnet::metadata($url,$part.'.name'); }        '<input type="hidden" name="command" value="editgrades" />'."\n".
      $result.="<td>$display</td>\n";        '<input type="submit" name="submit" value="Submit Changes" />'.
    }        "\n".'<table border=0><tr><td bgcolor="#999999">'."\n".
   $result.="</tr>";        '<table border=0>'."\n".
   #get info for each student        '<tr><td bgcolor='.$headerclr.'>UserId</td><td bgcolor='.
   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {                $headerclr.'>Domain</td>'."\n";
     $result.=&viewstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);      foreach my $part (@parts) {
   }   my $display = &Apache::lonnet::metadata($url,$part.'.display');
   $result.='</table><input type="submit" name="submit" value="Submit Changes" /></form>';   if  (!$display) { 
       $display = &Apache::lonnet::metadata($url,$part.'.name'); }
    $result .= '<td bgcolor='.$headerclr.'>'.$display.'</td>'."\n";
       }
       $result .= "</tr>";
   
   return $result;      #get info for each student
       foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
    $result .= &viewstudentgrade($url,$symb,$ENV{'request.course.id'},
        $student,@parts);
       }
       $result .= '</table></td></tr></table><input type="submit" name="submit"'.
          'value="Submit Changes" /></form>';
       return $result;
 }  }
   
   # ================================================================= Edit grades
 sub editgrades {  sub editgrades {
   my ($request) = @_;      my ($request) = @_;
   my $result='';      my $result='';
   
   my $symb=$ENV{'form.symb'};      my $symb = $ENV{'form.symb'};
   if ($symb eq '') { $request->print("Unable to handle ambiguous references:$symb:$ENV{'form.url'}"); return ''; }      if ($symb eq '') {
   my $url=$ENV{'form.url'};   $request->print("Unable to handle ambiguous references:$symb:".
   #get classlist   $ENV{'form.url'});
   my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});   return '';
   my $chome=$ENV{"course.$ENV{'request.course.id'}.home"};      }
   #print "Found $cdom:$cnum:$chome<br />";      my $url = $ENV{'form.url'};
   my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');      #get classlist
       my ($cdom,$cnum) = split(/_/,$ENV{'request.course.id'});
   #get list of parts for this problem      my $chome = $ENV{"course.$ENV{'request.course.id'}.home"};
   my (@parts) = &getpartlist($url);      #print "Found $cdom:$cnum:$chome<br />";
       my (%classlist) = &getclasslist($cdom,$cnum,$chome,'0');
   $result.='<form action="/adm/grades" method="post">'."\n".      
     '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".      #get list of parts for this problem
       '<input type="hidden" name="url" value="'.$url.'" />'."\n".      my (@parts) = &getpartlist($url);
  '<input type="hidden" name="command" value="viewgrades" />'."\n".  
   '<input type="submit" name="submit" value="See Grades" /> <br />'."\n";      $result .= '<form action="/adm/grades" method="post">'."\n".
                  '<input type="hidden" name="symb" value="'.$symb.'" />'."\n".
   foreach my $student ( sort(@{ $classlist{'allids'} }) ) {                 '<input type="hidden" name="url" value="'.$url.'" />'."\n".
     $result.=&setstudentgrade($url,$symb,$ENV{'request.course.id'},$student,@parts);         '<input type="hidden" name="command" value="viewgrades" />'.
   }                 "\n".'<input type="submit" name="submit" value="See Grades" />'.
                  '<br />'."\n";
   
       foreach my $student ( sort(@{ $classlist{'allids'} }) ) {
           $result .= &setstudentgrade($url,$symb,$ENV{'request.course.id'},
       $student,@parts);
       }
   
   $result.='<input type="submit" name="submit" value="See Grades" /></table></form>';      $result .= '<input type="submit" name="submit" value="See Grades" />'.
   return $result;         '</table></form>';
       return $result;
 }  }
   
   # ================================================================= Send header
 sub send_header {  sub send_header {
   my ($request)= @_;      my ($request) = @_;
   $request->print(&Apache::lontexconvert::header());      $request->print(&Apache::lontexconvert::header());
 #  $request->print("  #  $request->print("
 #<script>  #<script>
 #remotewindow=open('','homeworkremote');  #remotewindow=open('','homeworkremote');
 #remotewindow.close();  #remotewindow.close();
 #</script>");   #</script>"); 
   $request->print('<body bgcolor="#FFFFFF">');      $request->print('<body bgcolor="#FFFFFF">');
 }  }
   
   # ================================================================= Send footer
 sub send_footer {  sub send_footer {
   my ($request)= @_;    my ($request) = @_;
   $request->print('</body>');    $request->print('</body>');
   $request->print(&Apache::lontexconvert::footer());    $request->print(&Apache::lontexconvert::footer());
 }  }
   
   # ===================================================================== Handler
 sub handler {  sub handler {
   my $request=$_[0];      my $request = $_[0];
       if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;}
   if ( $ENV{'user.name'} eq 'albertel' ) {$Apache::lonxml::debug=1;} else {$Apache::lonxml::debug=0;}      else {$Apache::lonxml::debug=0;}
         if ($ENV{'browser.mathml'}) {
   if ($ENV{'browser.mathml'}) {   $request->content_type('text/xml');
     $request->content_type('text/xml');      } else {
   } else {   $request->content_type('text/html');
     $request->content_type('text/html');      }
   }      $request->send_http_header;
   $request->send_http_header;      return OK if $request->header_only;
   return OK if $request->header_only;      my $url = $ENV{'form.url'};
   my $url=$ENV{'form.url'};      my $symb = $ENV{'form.symb'};
   my $symb=$ENV{'form.symb'};      my $command = $ENV{'form.command'};
   my $command=$ENV{'form.command'};      
         &send_header($request);
   &send_header($request);      if ($url eq '' && $symb eq '') {
   if ($url eq '' && $symb eq '') {   $request->print("Non-Contextual Access Unsupported:$command:$url:");
     $request->print("Non-Contextual Access Unsupported:$command:$url:");  
   } else {  
     $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'});  
     if ($command eq 'submission') {  
       $request->print(&submission($request));  
     } elsif ($command eq 'viewgrades') {  
       $request->print(&viewgrades($request));  
     } elsif ($command eq 'editgrades') {  
       $request->print(&editgrades($request));  
     } else {      } else {
       $request->print("Unknown action:$command:");   $Apache::grades::viewgrades=&Apache::lonnet::allowed('vgr',
       $ENV{'request.course.id'});
    if ($command eq 'submission') {
       $request->print(&listStudents($request))
    if ($ENV{'form.student'} eq '');
       $request->print(&submission($request))
    if ($ENV{'form.student'} ne '');
    } elsif ($command eq 'viewgrades') {
       $request->print(&viewgrades($request));
    } elsif ($command eq 'editgrades') {
       $request->print(&editgrades($request));
    } else {
       $request->print("Unknown action:$command:");
    }
     }      }
   }      &send_footer($request);
   &send_footer($request);      return OK;
   return OK;  
 }  }
   
 1;  1;
   
 __END__;  __END__

Removed from v.1.6  
changed lines
  Added in v.1.12


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