Diff for /loncom/homework/optionresponse.pm between versions 1.199 and 1.200

version 1.199, 2015/04/21 12:28:05 version 1.200, 2015/04/28 13:12:52
Line 300  sub end_foilgroup { Line 300  sub end_foilgroup {
  my $wrong=0;   my $wrong=0;
  my $ignored=0;   my $ignored=0;
         my $checked=0;          my $checked=0;
           my $corrchkd=0;
           my $corrunchkd=0;
           my $incorrchkd=0;
           my $incorrunchkd=0;
         my ($numrows,$bubbles_per_row);          my ($numrows,$bubbles_per_row);
         if ($Apache::lonhomework::scantronmode) {          if ($Apache::lonhomework::scantronmode) {
             my $numitems = scalar(@opt);              my $numitems = scalar(@opt);
Line 329  sub end_foilgroup { Line 333  sub end_foilgroup {
                 }                  }
             }              }
         }          }
           my $part=$Apache::inputtags::part;
           my $id = $Apache::inputtags::response['-1'];
           my @relweights;
           my $nonlenient=&grading_is_nonlenient($part,$id,\@relweights);
  foreach $name (@whichopt) {   foreach $name (@whichopt) {
   my $response;    my $response;
           if ($env{'form.submitted'} eq 'scantron') {            if ($env{'form.submitted'} eq 'scantron') {
Line 369  sub end_foilgroup { Line 377  sub end_foilgroup {
             if ($checkboxopt) {              if ($checkboxopt) {
                 if ($response eq $checkboxopt) {                  if ($response eq $checkboxopt) {
                     $checked++;                      $checked++;
                       if ($grade{$name}) {
                           $corrchkd ++;
                       } else {
                           $incorrchkd ++;
                       }
                   } else {
                       if ($grade{$name}) {
                           $corrunchkd ++;
                       } else {
                           $incorrunchkd ++;
                       }
                 }                  }
             }               }
   } else {    } else {
     $ignored++;      $ignored++;
   }    }
  }   }
  my $part=$Apache::inputtags::part;  
         my $id = $Apache::inputtags::response['-1'];  
         my $nonlenient=&grading_is_nonlenient($part,$id);  
  my $responsestr=&Apache::lonnet::hash2str(%responsehash);   my $responsestr=&Apache::lonnet::hash2str(%responsehash);
  my $gradestr   =&Apache::lonnet::hash2str(%grade);   my $gradestr   =&Apache::lonnet::hash2str(%grade);
  my %previous=&Apache::response::check_for_previous($responsestr,   my %previous=&Apache::response::check_for_previous($responsestr,
Line 453  sub end_foilgroup { Line 469  sub end_foilgroup {
     $ad='ASSIGNED_SCORE';      $ad='ASSIGNED_SCORE';
         }          }
         $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;          $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
                   my $awarded;
                   my $totalfoils = $#{ $Apache::response::foilgroup{'names'} }+1;
                   if (($checkboxopt) && ($max >= $totalfoils) && (@relweights > 0)) {
                       if ($right == scalar(@whichopt)) {
                           $awarded = 1;
                       } else {
                           $awarded = ($corrchkd*$relweights[0] + $corrunchkd*$relweights[1] +
                                       $incorrchkd*$relweights[2] + $incorrunchkd*$relweights[3])/(scalar(@whichopt));
                           $awarded = 1 if ($awarded > 1);
                           $awarded = 0 if ($awarded < 0);
                       }
                   } else {
                       $awarded = $right/(scalar(@whichopt));
                   }
         $Apache::lonhomework::results{"resource.$part.$id.awarded"}=          $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
     $right/(scalar(@whichopt));      $awarded;
         $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=          $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
     scalar(@whichopt);      scalar(@whichopt);
      }       }
Line 492  sub end_foilgroup { Line 522  sub end_foilgroup {
 }  }
   
 sub grading_is_nonlenient {  sub grading_is_nonlenient {
     my ($part,$id) = @_;      my ($part,$id,$relweights) = @_;
 # Web mode: we are non-lenient unless told otherwise  # Web mode: we are non-lenient unless told otherwise
     my $defaultparm = 'off';      my $defaultparm = 'off';
     my $nonlenient = 1;      my $nonlenient = 1;
Line 511  sub grading_is_nonlenient { Line 541  sub grading_is_nonlenient {
     if ($lenientparm eq 'default') {      if ($lenientparm eq 'default') {
         $lenientparm = $defaultparm;          $lenientparm = $defaultparm;
     }      }
     if ($lenientparm=~/^0|off|no$/i) {      if ($lenientparm=~/^(?:0|off|no)$/i) {
         $nonlenient = 1;          $nonlenient = 1;
     } elsif ($lenientparm=~/^1|on|yes$/i) {      } elsif ($lenientparm=~/^(?:1|on|yes)$/i) {
           $nonlenient = 0;
       } elsif ($lenientparm =~ /^\-?[.\d]+,\-?[.\d]+,\-?[.\d]+,\-?[.\d]+$/) {
           if (ref($relweights) eq 'ARRAY') {
               @{$relweights} = split(/,/,$lenientparm);
           }
         $nonlenient = 0;          $nonlenient = 0;
     }      }
     if (!$nonlenient) {      if (!$nonlenient) {

Removed from v.1.199  
changed lines
  Added in v.1.200


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