version 1.414, 2007/06/16 20:24:25
|
version 1.416, 2007/06/17 02:11:44
|
Line 6453 sub assign_clicker_grades {
|
Line 6453 sub assign_clicker_grades {
|
my ($r)=@_; |
my ($r)=@_; |
my ($symb)=&get_symb($r); |
my ($symb)=&get_symb($r); |
if (!$symb) {return '';} |
if (!$symb) {return '';} |
|
# See which part we are saving to |
|
my ($partlist,$handgrade,$responseType) = &response_type($symb); |
|
# FIXME: This should probably look for the first handgradeable part |
|
my $part=$$partlist[0]; |
|
# Start screen output |
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); |
my ($result) = &showResourceInfo($symb,$env{'form.probTitle'}); |
|
|
my $heading=&mt('Assigning grades based on clicker file'); |
my $heading=&mt('Assigning grades based on clicker file'); |
$result.=(<<ENDHEADER); |
$result.=(<<ENDHEADER); |
<br /><table width="100%" border="0"><tr><td bgcolor="#777777"> |
<br /><table width="100%" border="0"><tr><td bgcolor="#777777"> |
Line 6463 ENDHEADER
|
Line 6469 ENDHEADER
|
# Get correct result |
# Get correct result |
# FIXME: Possibly need delimiter other than ":" |
# FIXME: Possibly need delimiter other than ":" |
my @correct=(); |
my @correct=(); |
if ($env{'form.gradingmechanism'} ne 'attendance') { |
my $gradingmechanism=$env{'form.gradingmechanism'}; |
|
my $number=$env{'form.number'}; |
|
if ($gradingmechanism ne 'attendance') { |
foreach my $key (keys(%env)) { |
foreach my $key (keys(%env)) { |
if ($key=~/^form\.correct\:/) { |
if ($key=~/^form\.correct\:/) { |
my @input=split(/\,/,$env{$key}); |
my @input=split(/\,/,$env{$key}); |
Line 6479 ENDHEADER
|
Line 6487 ENDHEADER
|
} |
} |
} |
} |
} |
} |
for (my $i=0;$i<$env{'form.number'};$i++) { |
for (my $i=0;$i<$number;$i++) { |
if (!$correct[$i]) { |
if (!$correct[$i]) { |
$result.='<br /><span class="LC_error">'. |
$result.='<br /><span class="LC_error">'. |
&mt('No correct result given for question "[_1]"!', |
&mt('No correct result given for question "[_1]"!', |
Line 6489 ENDHEADER
|
Line 6497 ENDHEADER
|
$result.='<br />'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct)); |
$result.='<br />'.&mt("Correct answer: [_1]",join(', ',map { ($_?$_:'-') } @correct)); |
} |
} |
# Start grading |
# Start grading |
$result.='</td></tr></table>'."\n". |
my $pcorrect=$env{'form.pcorrect'}; |
|
my $pincorrect=$env{'form.pincorrect'}; |
|
my $storecount=0; |
|
foreach my $key (keys(%env)) { |
|
if ($key=~/^form\.student\:(.*)$/) { |
|
my $user=$1; |
|
my @answer=split(/\,/,$env{$key}); |
|
my $sum=0; |
|
for (my $i=0;$i<$number;$i++) { |
|
if ($answer[$i]) { |
|
if ($gradingmechanism eq 'attendance') { |
|
$sum+=$pcorrect; |
|
} else { |
|
if ($answer[$i] eq $correct[$i]) { |
|
$sum+=$pcorrect; |
|
} else { |
|
$sum+=$pincorrect; |
|
} |
|
} |
|
} |
|
} |
|
my $ave=$sum/(100*$number); |
|
# Store |
|
my ($username,$domain)=split(/\:/,$user); |
|
my %grades=(); |
|
$grades{"resource.$part.solved"}='correct_by_override'; |
|
$grades{"resource.$part.awarded"}=$ave; |
|
$grades{"resource.regrader"}="$env{'user.name'}:$env{'user.domain'}"; |
|
my $returncode=&Apache::lonnet::cstore(\%grades,$symb, |
|
$env{'request.course.id'}, |
|
$domain,$username); |
|
if ($returncode ne 'ok') { |
|
$result.="<br /><span class=\"LC_error\">Failed to save student $username:$domain. Message when trying to save was ($returncode)</span>"; |
|
} else { |
|
$storecount++; |
|
} |
|
} |
|
} |
|
# We are done |
|
$result.='<br />'.&mt('Successfully stored grades for [_1] student(s).',$storecount). |
|
'</td></tr></table>'."\n". |
'</td></tr></table><br /><br />'."\n"; |
'</td></tr></table><br /><br />'."\n"; |
return $result.&show_grading_menu_form($symb); |
return $result.&show_grading_menu_form($symb); |
} |
} |