[LON-CAPA-cvs] cvs: loncom /homework grades.pm
www
lon-capa-cvs-allow@mail.lon-capa.org
Sat, 16 Jun 2007 20:24:25 -0000
www Sat Jun 16 16:24:25 2007 EDT
Modified files:
/loncom/homework grades.pm
Log:
More than one specific ID,
find correct answer
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.413 loncom/homework/grades.pm:1.414
--- loncom/homework/grades.pm:1.413 Sat Jun 16 10:38:45 2007
+++ loncom/homework/grades.pm Sat Jun 16 16:24:25 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.413 2007/06/16 14:38:45 www Exp $
+# $Id: grades.pm,v 1.414 2007/06/16 20:24:25 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -6144,7 +6144,7 @@
my $clickers =
(&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1];
foreach my $id (split(/\,/,$clickers)) {
- $id=~s/^0+//;
+ $id=~s/^[\#0]+//;
if (exists($clicker_ids{$id})) {
$clicker_ids{$id}.=','.$username.':'.$domain;
} else {
@@ -6166,7 +6166,7 @@
my $clickers =
(&Apache::lonnet::userenvironment($pudom,$puname,'clickers'))[1];
foreach my $id (split(/\,/,$clickers)) {
- $id=~s/^0+//;
+ $id=~s/^[\#0]+//;
if (exists($clicker_ids{$id})) {
$clicker_ids{$id}.=','.$puname.':'.$pudom;
} else {
@@ -6219,7 +6219,7 @@
my $type=&mt("Type");
my $attendance=&mt("Award points just for participation");
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 $pincorrect=&mt("Percentage points for incorrect solution");
my $selectform=&Apache::loncommon::select_form($env{'form.upfiletype'},'upfiletype',
@@ -6275,7 +6275,7 @@
<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>$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'}" />
<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>
@@ -6308,11 +6308,14 @@
%correct_ids=&gather_adv_clicker_ids();
}
if ($env{'form.gradingmechanism'} eq 'specific') {
- my $correct_id=$env{'form.specificid'};
- $correct_id=~tr/a-z/A-Z/;
- $correct_id=~s/\s//gs;
- $correct_id=~s/^0+//;
- $correct_ids{$correct_id}='specified';
+ foreach my $correct_id (split(/[\s\,]/,$env{'form.specificid'})) {;
+ $correct_id=~tr/a-z/A-Z/;
+ $correct_id=~s/\s//gs;
+ $correct_id=~s/^[\#0]+//;
+ if ($correct_id) {
+ $correct_ids{$correct_id}='specified';
+ }
+ }
}
if ($env{'form.gradingmechanism'} eq 'attendance') {
$result.=&mt('Score based on attendance only');
@@ -6372,12 +6375,20 @@
&mt('Awarding [_1] percent for correct and [_2] percent for incorrect responses',
$env{'form.pcorrect'},$env{'form.pincorrect'}).
'<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 $student_count=0;
my $unknown_count=0;
+# Match answers with usernames
+# FIXME: Possibly need delimiter other than ":"
foreach my $id (keys(%responses)) {
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++;
} elsif ($clicker_ids{$id}) {
$result.="\n".'<input type="hidden" name="student:'.$clicker_ids{$id}.'" value="'.$responses{$id}.'" />';
@@ -6398,7 +6409,7 @@
if ($correct_count==0) {
$errormsg.="Found no correct answers answers for grading!";
} 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) {
@@ -6438,6 +6449,51 @@
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 {
my $request=$_[0];
@@ -6509,6 +6565,8 @@
$request->print(&process_clicker($request));
} elsif ($command eq 'processclickerfile' && $perm{'mgr'}) {
$request->print(&process_clicker_file($request));
+ } elsif ($command eq 'assignclickergrades' && $perm{'mgr'}) {
+ $request->print(&assign_clicker_grades($request));
} elsif ($command eq 'csvform' && $perm{'mgr'}) {
$request->print(&upcsvScores_form($request));
} elsif ($command eq 'csvupload' && $perm{'mgr'}) {