[LON-CAPA-cvs] cvs: loncom /homework matchresponse.pm optionresponse.pm /publisher packages.tab
raeburn
raeburn at source.lon-capa.org
Fri Oct 7 18:40:10 EDT 2011
raeburn Fri Oct 7 22:40:10 2011 EDT
Modified files:
/loncom/homework optionresponse.pm matchresponse.pm
/loncom/publisher packages.tab
Log:
- Bug 2802.
Move determination of lenient vs non-lenient to subroutine to facilitate reuse
.
- Support lenient parameter for matchresponse as well as optionresponse.
- Use response::get_param_response() to retrieve lenient parm.
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.180 loncom/homework/optionresponse.pm:1.181
--- loncom/homework/optionresponse.pm:1.180 Fri Sep 30 16:47:08 2011
+++ loncom/homework/optionresponse.pm Fri Oct 7 22:39:59 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: optionresponse.pm,v 1.180 2011/09/30 16:47:08 raeburn Exp $
+# $Id: optionresponse.pm,v 1.181 2011/10/07 22:39:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -222,23 +222,6 @@
push (@{ $Apache::lonhomework::analyze{"$part_id.options"} }, at opt);
} elsif ( $target eq 'grade') {
- my $nonlenient=0;
- my $part=$Apache::inputtags::part;
- my $lenientparm=&Apache::lonnet::EXT("resource.$part.lenient");
-
- if ($Apache::lonhomework::scantronmode) {
- $nonlenient=0;
-# Grading an exam: we are grading lenient unless told not to
- if ($lenientparm=~/^0|off|no$/i) {
- $nonlenient=1;
- }
- } else {
-# Web mode: we are non-lenient unless told to
- $nonlenient=1;
- if ($lenientparm=~/^1|on|yes$/i) {
- $nonlenient=0;
- }
- }
if ( &Apache::response::submitted()) {
my @whichopt = &whichfoils($max,$randomize);
@@ -299,6 +282,7 @@
}
}
my $part=$Apache::inputtags::part;
+ my $nonlenient=&is_nonlenient($part);
my $id = $Apache::inputtags::response['-1'];
my $responsestr=&Apache::lonnet::hash2str(%responsehash);
my $gradestr =&Apache::lonnet::hash2str(%grade);
@@ -402,6 +386,26 @@
return $result;
}
+sub is_nonlenient {
+ my ($part) = @_;
+# Web mode: we are non-lenient unless told otherwise
+ my $defaultparm = 'off';
+ my $nonlenient = 0;
+# Grading a bubblesheet exam: we are grading lenient unless told otherwise
+ if ($Apache::lonhomework::scantronmode) {
+ $defaultparm = 'on';
+ $nonlenient = 1;
+ }
+ my $lenientparm =
+ &Apache::response::get_response_param($part,'lenient',$defaultparm);
+ if ($lenientparm=~/^0|off|no$/i) {
+ $nonlenient = 1;
+ } elsif ($lenientparm=~/^1|on|yes$/i) {
+ $nonlenient = 0;
+ }
+ return $nonlenient;
+}
+
sub getfoilcounts {
my ($max)=@_;
# +1 since instructors will count from 1
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.82 loncom/homework/matchresponse.pm:1.83
--- loncom/homework/matchresponse.pm:1.82 Tue Sep 13 21:42:58 2011
+++ loncom/homework/matchresponse.pm Fri Oct 7 22:39:59 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Full matching style response
#
-# $Id: matchresponse.pm,v 1.82 2011/09/13 21:42:58 raeburn Exp $
+# $Id: matchresponse.pm,v 1.83 2011/10/07 22:39:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -450,6 +450,7 @@
}
}
my $part=$Apache::inputtags::part;
+ my $nonlenient=&Apache::optionresponse::is_nonlenient($part);
my $id = $Apache::inputtags::response['-1'];
my $responsestr=&Apache::lonnet::hash2str(%responsehash);
my $itemstr =&Apache::lonnet::array2str(@items);
@@ -486,34 +487,37 @@
my $ad=$Apache::lonhomework::results{"resource.$part.$id.awarddetail"}='MISSING_ANSWER';
&Apache::response::handle_previous(\%previous,$ad);
}
- } elsif (!$Apache::lonhomework::scantronmode) {
- my $ad;
- if ($wrong==0 && $ignored==0) {
- $ad='EXACT_ANS';
- } elsif ($wrong==0 && $right==0) {
- #nothing submitted
- } else {
- if ($ignored==0) {
- $ad='INCORRECT';
- } else {
- $ad='MISSING_ANSWER';
- }
- }
- $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
- &Apache::response::handle_previous(\%previous,$ad);
+ } elsif ($nonlenient) {
+ my $ad;
+ if ($wrong==0 && $ignored==0) {
+ $ad='EXACT_ANS';
+ } elsif ($wrong==0 && $right==0) {
+ #nothing submitted
+ } else {
+ if ($ignored==0) {
+ $ad='INCORRECT';
+ } else {
+ $ad='MISSING_ANSWER';
+ }
+ }
+ $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
+ &Apache::response::handle_previous(\%previous,$ad);
} else {
- my $ad;
- if ($wrong==0 && $right==0) {
- #nothing submitted
- } else {
- $ad='ASSIGNED_SCORE';
- $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=
- $ad;
- $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
- $right/(scalar(@whichfoils));
- $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
- scalar(@whichfoils);
- }
+ my $ad;
+ if ($wrong==0 && $right==0) {
+ #nothing submitted only assign a score if we
+ #need to override a previous grade
+ if (defined($Apache::lonhomework::history{"resource.$part.$id.awarddetail"})) {
+ $ad='ASSIGNED_SCORE';
+ }
+ } else {
+ $ad='ASSIGNED_SCORE';
+ }
+ $Apache::lonhomework::results{"resource.$part.$id.awarddetail"}=$ad;
+ $Apache::lonhomework::results{"resource.$part.$id.awarded"}=
+ $right/(scalar(@whichfoils));
+ $Apache::lonhomework::results{"resource.$part.$id.numfoils"}=
+ scalar(@whichfoils);
}
}
Index: loncom/publisher/packages.tab
diff -u loncom/publisher/packages.tab:1.66 loncom/publisher/packages.tab:1.67
--- loncom/publisher/packages.tab:1.66 Thu Jun 9 15:44:00 2011
+++ loncom/publisher/packages.tab Fri Oct 7 22:40:10 2011
@@ -105,6 +105,9 @@
optionresponse&lenient&type:string
optionresponse&lenient&default:default
optionresponse&lenient&display:Lenient Grading (Partial Credit)
+matchresponse&lenient&type:string
+matchresponse&lenient&default:default
+matchresponse&lenient&display:Lenient Grading (Partial Credit)
#parameters for things by extension
extension_sequence&encrypturl&type:string_yesno
More information about the LON-CAPA-cvs
mailing list