Diff for /loncom/homework/grades.pm between versions 1.413 and 1.414

version 1.413, 2007/06/16 14:38:45 version 1.414, 2007/06/16 20:24:25
Line 6144  sub gather_clicker_ids { Line 6144  sub gather_clicker_ids {
         my $clickers =          my $clickers =
     (&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1];      (&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1];
         foreach my $id (split(/\,/,$clickers)) {          foreach my $id (split(/\,/,$clickers)) {
             $id=~s/^0+//;              $id=~s/^[\#0]+//;
             if (exists($clicker_ids{$id})) {              if (exists($clicker_ids{$id})) {
  $clicker_ids{$id}.=','.$username.':'.$domain;   $clicker_ids{$id}.=','.$username.':'.$domain;
             } else {              } else {
Line 6166  sub gather_adv_clicker_ids { Line 6166  sub gather_adv_clicker_ids {
             my $clickers =              my $clickers =
  (&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1];   (&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1];
             foreach my $id (split(/\,/,$clickers)) {              foreach my $id (split(/\,/,$clickers)) {
  $id=~s/^0+//;   $id=~s/^[\#0]+//;
  if (exists($clicker_ids{$id})) {   if (exists($clicker_ids{$id})) {
     $clicker_ids{$id}.=','.$puname.':'.$pudom;      $clicker_ids{$id}.=','.$puname.':'.$pudom;
  } else {   } else {
Line 6219  sub process_clicker { Line 6219  sub process_clicker {
     my $type=&mt("Type");      my $type=&mt("Type");
     my $attendance=&mt("Award points just for participation");      my $attendance=&mt("Award points just for participation");
     my $personnel=&mt("Correctness determined from response by course personnel");      my $personnel=&mt("Correctness determined from response by course personnel");
     my $specific=&mt("Correctness determined from response with clicker ID");       my $specific=&mt("Correctness determined from response with clicker ID(s)"); 
     my $pcorrect=&mt("Percentage points for correct solution");      my $pcorrect=&mt("Percentage points for correct solution");
     my $pincorrect=&mt("Percentage points for incorrect solution");      my $pincorrect=&mt("Percentage points for incorrect solution");
     my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',      my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
Line 6275  function sanitycheck() { Line 6275  function sanitycheck() {
 <br /><label>$attendance: <input type="radio" name="gradingmechanism" value="attendance" $checked{'attendance'} onClick="sanitycheck()" /></label>  <br /><label>$attendance: <input type="radio" name="gradingmechanism" value="attendance" $checked{'attendance'} onClick="sanitycheck()" /></label>
 <br /><label>$personnel: <input type="radio" name="gradingmechanism" value="personnel" $checked{'personnel'} onClick="sanitycheck()" /></label>  <br /><label>$personnel: <input type="radio" name="gradingmechanism" value="personnel" $checked{'personnel'} onClick="sanitycheck()" /></label>
 <br /><label>$specific: <input type="radio" name="gradingmechanism" value="specific" $checked{'specific'} onClick="sanitycheck()" /></label>  <br /><label>$specific: <input type="radio" name="gradingmechanism" value="specific" $checked{'specific'} onClick="sanitycheck()" /></label>
 <input type="text" name="specificid" value="$env{'form.specificid'}" size="15" />  <input type="text" name="specificid" value="$env{'form.specificid'}" size="20" />
 <input type="hidden" name="waschecked" value="$env{'form.gradingmechanism'}" />  <input type="hidden" name="waschecked" value="$env{'form.gradingmechanism'}" />
 <br /><label>$pcorrect: <input type="text" name="pcorrect" size="4" value="$env{'form.pcorrect'}" onChange="sanitycheck()" /></label>  <br /><label>$pcorrect: <input type="text" name="pcorrect" size="4" value="$env{'form.pcorrect'}" onChange="sanitycheck()" /></label>
 <br /><label>$pincorrect: <input type="text" name="pincorrect" size="4" value="$env{'form.pincorrect'}" onChange="sanitycheck()" /></label>  <br /><label>$pincorrect: <input type="text" name="pincorrect" size="4" value="$env{'form.pincorrect'}" onChange="sanitycheck()" /></label>
Line 6308  sub process_clicker_file { Line 6308  sub process_clicker_file {
  %correct_ids=&gather_adv_clicker_ids();   %correct_ids=&gather_adv_clicker_ids();
     }      }
     if ($env{'form.gradingmechanism'} eq 'specific') {      if ($env{'form.gradingmechanism'} eq 'specific') {
  my $correct_id=$env{'form.specificid'};   foreach my $correct_id (split(/[\s\,]/,$env{'form.specificid'})) {;
  $correct_id=~tr/a-z/A-Z/;     $correct_id=~tr/a-z/A-Z/;
  $correct_id=~s/\s//gs;     $correct_id=~s/\s//gs;
  $correct_id=~s/^0+//;     $correct_id=~s/^[\#0]+//;
  $correct_ids{$correct_id}='specified';             if ($correct_id) {
         $correct_ids{$correct_id}='specified';
              }
           }
     }      }
     if ($env{'form.gradingmechanism'} eq 'attendance') {      if ($env{'form.gradingmechanism'} eq 'attendance') {
  $result.=&mt('Score based on attendance only');   $result.=&mt('Score based on attendance only');
Line 6372  ENDHEADER Line 6375  ENDHEADER
              &mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',               &mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',
                  $env{'form.pcorrect'},$env{'form.pincorrect'}).                   $env{'form.pcorrect'},$env{'form.pincorrect'}).
              '<br />';               '<br />';
   # Remember Question Titles
   # FIXME: Possibly need delimiter other than ":"
       for (my $i=0;$i<$number;$i++) {
           $result.='<input type="hidden" name="question:'.$i.'" value="'.
                    &HTML::Entities::encode($questiontitles[$i],'"&<>').'" />';
       }
     my $correct_count=0;      my $correct_count=0;
     my $student_count=0;      my $student_count=0;
     my $unknown_count=0;      my $unknown_count=0;
   # Match answers with usernames
   # FIXME: Possibly need delimiter other than ":"
     foreach my $id (keys(%responses)) {      foreach my $id (keys(%responses)) {
        if ($correct_ids{$id}) {         if ($correct_ids{$id}) {
           $result.="\n".'<input type="hidden" name="correct:'.$correct_ids{$id}.'" value="'.$responses{$id}.'" />';            $result.="\n".'<input type="hidden" name="correct:'.$correct_count.':'.$correct_ids{$id}.'" value="'.$responses{$id}.'" />';
           $correct_count++;            $correct_count++;
        } elsif ($clicker_ids{$id}) {         } elsif ($clicker_ids{$id}) {
           $result.="\n".'<input type="hidden" name="student:'.$clicker_ids{$id}.'" value="'.$responses{$id}.'" />';            $result.="\n".'<input type="hidden" name="student:'.$clicker_ids{$id}.'" value="'.$responses{$id}.'" />';
Line 6398  ENDHEADER Line 6409  ENDHEADER
        if ($correct_count==0) {         if ($correct_count==0) {
           $errormsg.="Found no correct answers answers for grading!";            $errormsg.="Found no correct answers answers for grading!";
        } elsif ($correct_count>1) {         } elsif ($correct_count>1) {
           $result.='<br /><span class="LC_warning">'.&mt("Found [_1] entries for grading!").'</span>';            $result.='<br /><span class="LC_warning">'.&mt("Found [_1] entries for grading!",$correct_count).'</span>';
        }         }
     }      }
     if ($errormsg) {      if ($errormsg) {
Line 6438  sub iclicker_eval { Line 6449  sub iclicker_eval {
     return ($errormsg,$number);      return ($errormsg,$number);
 }  }
   
   sub assign_clicker_grades {
       my ($r)=@_;
       my ($symb)=&get_symb($r);
       if (!$symb) {return '';}
       my ($result) = &showResourceInfo($symb,$env{'form.probTitle'});
       my $heading=&mt('Assigning grades based on clicker file');
       $result.=(<<ENDHEADER);
   <br /><table width="100%" border="0"><tr><td bgcolor="#777777">
   <table width="100%" border="0"><tr bgcolor="#e6ffff"><td>
   <b>$heading</b></td></tr><tr bgcolor=#ffffe6><td>
   ENDHEADER
   # Get correct result
   # FIXME: Possibly need delimiter other than ":"
       my @correct=();
       if ($env{'form.gradingmechanism'} ne 'attendance') {
          foreach my $key (keys(%env)) {
             if ($key=~/^form\.correct\:/) {
                my @input=split(/\,/,$env{$key});
                for (my $i=0;$i<=$#input;$i++) {
                    if (($correct[$i]) && ($input[$i]) &&
                        ($correct[$i] ne $input[$i])) {
                       $result.='<br /><span class="LC_warning">'.
                                &mt('More than one correct result given for question "[_1]": [_2] versus [_3].',
                                    $env{'form.question:'.$i},$correct[$i],$input[$i]).'</span>';
                    } elsif ($input[$i]) {
                       $correct[$i]=$input[$i];
                    }
                }
             }
          }
          for (my $i=0;$i<$env{'form.number'};$i++) {
             if (!$correct[$i]) {
                $result.='<br /><span class="LC_error">'.
                         &mt('No correct result given for question "[_1]"!',
                             $env{'form.question:'.$i}).'</span>';
             }
          }
          $result.='<br />'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct));
       }
   # Start grading
       $result.='</td></tr></table>'."\n".
                '</td></tr></table><br /><br />'."\n";
       return $result.&show_grading_menu_form($symb);
   }
   
 sub handler {  sub handler {
     my $request=$_[0];      my $request=$_[0];
   
Line 6509  sub handler { Line 6565  sub handler {
             $request->print(&process_clicker($request));              $request->print(&process_clicker($request));
         } elsif ($command eq 'processclickerfile' && $perm{'mgr'}) {          } elsif ($command eq 'processclickerfile' && $perm{'mgr'}) {
             $request->print(&process_clicker_file($request));              $request->print(&process_clicker_file($request));
           } elsif ($command eq 'assignclickergrades' && $perm{'mgr'}) {
               $request->print(&assign_clicker_grades($request));
  } elsif ($command eq 'csvform' && $perm{'mgr'}) {   } elsif ($command eq 'csvform' && $perm{'mgr'}) {
     $request->print(&upcsvScores_form($request));      $request->print(&upcsvScores_form($request));
  } elsif ($command eq 'csvupload' && $perm{'mgr'}) {   } elsif ($command eq 'csvupload' && $perm{'mgr'}) {

Removed from v.1.413  
changed lines
  Added in v.1.414


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