[LON-CAPA-cvs] cvs: loncom /homework grades.pm
www
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 24 May 2008 00:34:13 -0000
www Fri May 23 20:34:13 2008 EDT
Modified files:
/loncom/homework grades.pm
Log:
Free clicker input field
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.521 loncom/homework/grades.pm:1.522
--- loncom/homework/grades.pm:1.521 Fri May 23 18:14:25 2008
+++ loncom/homework/grades.pm Fri May 23 20:34:12 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.521 2008/05/23 22:14:25 www Exp $
+# $Id: grades.pm,v 1.522 2008/05/24 00:34:12 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -8325,15 +8325,18 @@
$result.='<span class="LC_error">'.&mt('You need to specify a clicker ID for the correct answer').'</span>';
return $result.&show_grading_menu_form($symb);
}
- if (($env{'form.gradingmechanism'} eq 'given') && ($env{'form.givenanswer'}!~/\w/)) {
+ if (($env{'form.gradingmechanism'} eq 'given') && ($env{'form.givenanswer'}!~/\S/)) {
$result.='<span class="LC_error">'.&mt('You need to specify the correct answer').'</span>';
return $result.&show_grading_menu_form($symb);
}
+ my $foundgiven=0;
if ($env{'form.gradingmechanism'} eq 'given') {
$env{'form.givenanswer'}=~s/^\s*//gs;
$env{'form.givenanswer'}=~s/\s*$//gs;
$env{'form.givenanswer'}=~s/[^a-zA-Z0-9\.\*\-]+/\,/g;
$env{'form.givenanswer'}=uc($env{'form.givenanswer'});
+ my @answers=split(/\,/,$env{'form.givenanswer'});
+ $foundgiven=$#answers+1;
}
my %clicker_ids=&gather_clicker_ids();
my %correct_ids;
@@ -8354,7 +8357,7 @@
if ($env{'form.gradingmechanism'} eq 'attendance') {
$result.=&mt('Score based on attendance only');
} elsif ($env{'form.gradingmechanism'} eq 'given') {
- $result.=&mt('Score based on [_1]','<tt>'.$env{'form.givenanswer'}.'</tt>');
+ $result.=&mt('Score based on [_1] ([_2] answers)','<tt>'.$env{'form.givenanswer'}.'</tt>',$foundgiven);
} else {
my $number=0;
$result.='<p><b>'.&mt('Correctness determined by the following IDs').'</b>';
@@ -8397,10 +8400,12 @@
<input type="hidden" name="probTitle" value="$env{'form.probTitle'}" />
<input type="hidden" name="saveState" value="$env{'form.saveState'}" />
<input type="hidden" name="gradingmechanism" value="$env{'form.gradingmechanism'}" />
-<input type="hidden" name="givenanswer" value="$env{'form.givenanswer'}" />
<input type="hidden" name="pcorrect" value="$env{'form.pcorrect'}" />
<input type="hidden" name="pincorrect" value="$env{'form.pincorrect'}" />
ENDHEADER
+ if ($env{'form.gradingmechanism'} eq 'given') {
+ $result.='<input type="hidden" name="correct:given" value="'.$env{'form.givenanswer'}.'" />';
+ }
my %responses;
my @questiontitles;
my $errormsg='';
@@ -8416,6 +8421,10 @@
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',
$env{'form.pcorrect'},$env{'form.pincorrect'}).
'<br />';
+ if (($env{'form.gradingmechanism'} eq 'given') && ($number!=$foundgiven)) {
+ $result.='<span class="LC_error">'.&mt('Number of given answers does not agree with number of questions in file.').'</span>';
+ return $result.&show_grading_menu_form($symb);
+ }
# Remember Question Titles
# FIXME: Possibly need delimiter other than ":"
for (my $i=0;$i<$number;$i++) {
@@ -8604,10 +8613,15 @@
if ($user) {
my @answer=split(/\,/,$env{$key});
my $sum=0;
+ my $realnumber=$number;
for (my $i=0;$i<$number;$i++) {
if ($answer[$i]) {
if ($gradingmechanism eq 'attendance') {
$sum+=$pcorrect;
+ } elsif ($answer[$i] eq '*') {
+ $sum+=$pcorrect;
+ } elsif ($answer[$i] eq '-') {
+ $realnumber--;
} else {
if ($answer[$i] eq $correct[$i]) {
$sum+=$pcorrect;
@@ -8617,7 +8631,7 @@
}
}
}
- my $ave=$sum/(100*$number);
+ my $ave=$sum/(100*$realnumber);
# Store
my ($username,$domain)=split(/\:/,$user);
my %grades=();