[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 03 Oct 2007 02:10:47 -0000
albertel Tue Oct 2 22:10:47 2007 EDT
Modified files:
/loncom/homework inputtags.pm
Log:
- BUG#5451 - need to summarize multiple response awards differently in
scanton mode, any assinged score means the part gets assigned
score and for multiple response in correct or not correct
states need to switch to assigned score and give a partial
credit
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.231 loncom/homework/inputtags.pm:1.232
--- loncom/homework/inputtags.pm:1.231 Wed Sep 26 15:30:30 2007
+++ loncom/homework/inputtags.pm Tue Oct 2 22:10:45 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.231 2007/09/26 19:30:30 albertel Exp $
+# $Id: inputtags.pm,v 1.232 2007/10/03 02:10:45 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -539,8 +539,17 @@
$i=0;
my %rev_awards = map { ($_,$i++) } @awards;
+sub awarddetail_to_awarded {
+ my ($awarddetail) = @_;
+ if ($awarddetail eq 'EXACT_ANS'
+ || $awarddetail eq 'APPROX_ANS') {
+ return 1;
+ }
+ return 0;
+}
+
sub finalizeawards {
- my ($awardref,$msgref,$nameref,$reverse)=@_;
+ my ($awardref,$msgref,$nameref,$reverse,$final_scantron)=@_;
my $result;
if ($#$awardref == -1) { $result = "NO_RESPONSE"; }
if ($result eq '' ) {
@@ -551,10 +560,29 @@
$blankcount++;
}
}
- if ($blankcount == ($#$awardref + 1)) { $result = 'NO_RESPONSE'; }
+ if ($blankcount == ($#$awardref + 1)) {
+ return ('NO_RESPONSE');
+ }
}
- if (defined($result)) { return ($result); }
+ if (!$final_scantron && defined($result)) { return ($result); }
+ # if in scantron mode, if the award for any response is
+ # assigned score, then the part gets an assigned score
+ if ($final_scantron
+ && grep {$_ eq 'ASSIGNED_SCORE'} (@$awardref)) {
+ return ('ASSIGNED_SCORE');
+ }
+
+ # if in scantron mode, if the award for any response is
+ # correct and there are non-correct responses,
+ # then the part gets an assigned score
+ if ($final_scantron
+ && (grep { $_ eq 'EXACT_ANS' ||
+ $_ eq 'APPROX_ANS' } (@$awardref))
+ && (grep { $_ ne 'EXACT_ANS' &&
+ $_ ne 'APPROX_ANS' } (@$awardref))) {
+ return ('ASSIGNED_SCORE');
+ }
# these awards are ordered from most important error through best correct
my $awards = (!$reverse) ? \%fwd_awards : \%rev_awards ;
@@ -568,6 +596,7 @@
}
$j++;
}
+
if (defined($which)) {
if (ref($nameref)) {
return ($$awardref[$which],$$msgref[$which],$$nameref[$which]);
@@ -873,8 +902,13 @@
my $numawards=scalar(@Apache::inputtags::response);
$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
foreach my $res (@Apache::inputtags::response) {
- $Apache::lonhomework::results{"resource.$id.awarded"}+=
- $Apache::lonhomework::results{"resource.$id.$res.awarded"};
+ if (defined($Apache::lonhomework::results{"resource.$id.$res.awarded"})) {
+ $Apache::lonhomework::results{"resource.$id.awarded"}+=
+ $Apache::lonhomework::results{"resource.$id.$res.awarded"};
+ } else {
+ $Apache::lonhomework::results{"resource.$id.awarded"}+=
+ &awarddetail_to_awarded($Apache::lonhomework::results{"resource.$id.$res.awarddetail"});
+ }
}
if ($numawards > 0) {
$Apache::lonhomework::results{"resource.$id.awarded"}/=
@@ -1006,7 +1040,9 @@
&Apache::lonxml::debug("got message $value from $response for $id");
push (@msgs,$value);
}
- my ($finalaward,$msg) = &finalizeawards(\@awards,\@msgs);
+ my ($finalaward,$msg) =
+ &finalizeawards(\@awards,\@msgs,undef,undef,
+ $Apache::lonhomework::scantronmode);
my $previously_used;
if ( $#Apache::inputtags::previous eq $#awards ) {
my ($match) =