[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm lonhomework.pm matchresponse.pm optionresponse.pm response.pm /homework/templates custompartial.problem

raeburn raeburn at source.lon-capa.org
Tue Nov 29 08:24:41 EST 2011


raeburn		Tue Nov 29 13:24:41 2011 EDT

  Modified files:              
    /loncom/homework	inputtags.pm lonhomework.pm matchresponse.pm 
                    	optionresponse.pm response.pm 
    /loncom/homework/templates	custompartial.problem 
  Log:
  - Bug 2802.
    - optionresponse::is_nonlenient() moved to inputtags::grading_is_nonlenient()
      to facilitate re-use.
    - where solved is "correct", awarded value < 1 permits new submission,
      only if lenient grading applies.                               
    - add lenient parameter to custompartial.problem template.
  
  
-------------- next part --------------
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.295 loncom/homework/inputtags.pm:1.296
--- loncom/homework/inputtags.pm:1.295	Sat Oct  8 19:19:58 2011
+++ loncom/homework/inputtags.pm	Tue Nov 29 13:24:38 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.295 2011/10/08 19:19:58 raeburn Exp $
+# $Id: inputtags.pm,v 1.296 2011/11/29 13:24:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -843,6 +843,26 @@
 }
 }
 
+sub grading_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 decideoutput {
     my ($award,$awarded,$awardmsg,$solved,$previous,$target,$nocorrect)=@_;
 
@@ -911,7 +931,13 @@
 		}
 	    }
 	}
-        if ($awarded==1) { $button=0; } else { $button=1; }
+        if (&grading_is_nonlenient($part)) {
+            $button=0;
+        } elsif ($awarded==1) {
+            $button=0;
+        } else { 
+            $button=1;
+        }
 	$previousmsg='';
     } elsif ($solved =~ /^excused/) {
 	if ($target eq 'tex') {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.330 loncom/homework/lonhomework.pm:1.331
--- loncom/homework/lonhomework.pm:1.330	Mon Nov 14 00:20:39 2011
+++ loncom/homework/lonhomework.pm	Tue Nov 29 13:24:38 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.330 2011/11/14 00:20:39 raeburn Exp $
+# $Id: lonhomework.pm,v 1.331 2011/11/29 13:24:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -442,13 +442,13 @@
 	$Apache::lonhomework::results{'resource.'.$id.'.maxtries'}=$maxtries;
 	if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; }
 	# if (correct and show prob status) or excused then CANNOT_ANSWER
-	if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
-	    &&
-	    &show_problem_status()
-            &&
-            $Apache::lonhomework::history{"resource.$id.awarded"}==1)
-	   ||
-	   $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
+	if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/)
+	      && (&show_problem_status()) ) {
+            if (&Apache::inputtags::grading_is_nonlenient($id) || 
+                $Apache::lonhomework::history{"resource.$id.awarded"} == 1) {
+	        $status = 'CANNOT_ANSWER';
+            }
+        } elsif ($Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
 	    $status = 'CANNOT_ANSWER';
 	}
 	if ($status eq 'CANNOT_ANSWER'
Index: loncom/homework/matchresponse.pm
diff -u loncom/homework/matchresponse.pm:1.84 loncom/homework/matchresponse.pm:1.85
--- loncom/homework/matchresponse.pm:1.84	Tue Nov  8 01:33:14 2011
+++ loncom/homework/matchresponse.pm	Tue Nov 29 13:24:38 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Full matching style response
 #
-# $Id: matchresponse.pm,v 1.84 2011/11/08 01:33:14 raeburn Exp $
+# $Id: matchresponse.pm,v 1.85 2011/11/29 13:24:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -30,6 +30,7 @@
 use strict;
 use HTML::Entities();
 use Math::Random();
+use Apache::inputtags();
 use Apache::optionresponse();
 use Apache::lonlocal;
 use Apache::lonnet;
@@ -462,7 +463,7 @@
 	}
     }
     my $part=$Apache::inputtags::part;
-    my $nonlenient=&Apache::optionresponse::is_nonlenient($part);
+    my $nonlenient=&Apache::inputtags::grading_is_nonlenient($part);
     my $id = $Apache::inputtags::response['-1'];
     my $responsestr=&Apache::lonnet::hash2str(%responsehash);
     my $itemstr    =&Apache::lonnet::array2str(@items);
Index: loncom/homework/optionresponse.pm
diff -u loncom/homework/optionresponse.pm:1.182 loncom/homework/optionresponse.pm:1.183
--- loncom/homework/optionresponse.pm:1.182	Tue Nov  8 05:19:14 2011
+++ loncom/homework/optionresponse.pm	Tue Nov 29 13:24:38 2011
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # option list style responses
 #
-# $Id: optionresponse.pm,v 1.182 2011/11/08 05:19:14 raeburn Exp $
+# $Id: optionresponse.pm,v 1.183 2011/11/29 13:24:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 
 package Apache::optionresponse;
 use strict;
+use Apache::inputtags();
 use Apache::response();
 use Apache::lonlocal;
 use Apache::lonnet;
@@ -282,7 +283,7 @@
 	  }
 	}
 	my $part=$Apache::inputtags::part;
-        my $nonlenient=&is_nonlenient($part);
+        my $nonlenient=&Apache::inputtags::grading_is_nonlenient($part);
 	my $id = $Apache::inputtags::response['-1'];
 	my $responsestr=&Apache::lonnet::hash2str(%responsehash);
 	my $gradestr   =&Apache::lonnet::hash2str(%grade);
@@ -386,26 +387,6 @@
   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/response.pm
diff -u loncom/homework/response.pm:1.227 loncom/homework/response.pm:1.228
--- loncom/homework/response.pm:1.227	Mon Nov 14 03:08:01 2011
+++ loncom/homework/response.pm	Tue Nov 29 13:24:38 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.227 2011/11/14 03:08:01 raeburn Exp $
+# $Id: response.pm,v 1.228 2011/11/29 13:24:38 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -53,6 +53,7 @@
 use strict;
 use Apache::lonlocal;
 use Apache::lonnet;
+use Apache::inputtags();
 use Apache::lonmaxima();
 use Apache::lonr();
 
@@ -1181,11 +1182,17 @@
 
 sub show_answer {
     my $part   = $Apache::inputtags::part;
-    my $award  = $Apache::lonhomework::history{"resource.$part.awarded"};
+    my $award  = $Apache::lonhomework::history{"resource.$part.solved"};
     my $status = $Apache::inputtags::status[-1];
-    return  ( ($award ==1
-	       && &Apache::lonhomework::show_problem_status())
-	      || $status eq "SHOW_ANSWER");
+    my $canshow = 0;
+    if ($award =~ /^correct/) {
+        if ((&Apache::inputtags::grading_is_nonlenient($part)) ||
+            ($Apache::lonhomework::history{"resource.$part.awarded"} == 1)) {
+            $canshow = 1;
+        }   
+    }
+    return  (($canshow && &Apache::lonhomework::show_problem_status()) 
+	     || $status eq "SHOW_ANSWER");
 }
 
 sub analyze_store_foilgroup {
Index: loncom/homework/templates/custompartial.problem
diff -u loncom/homework/templates/custompartial.problem:1.2 loncom/homework/templates/custompartial.problem:1.3
--- loncom/homework/templates/custompartial.problem:1.2	Mon Jul  6 17:12:47 2009
+++ loncom/homework/templates/custompartial.problem	Tue Nov 29 13:24:41 2011
@@ -1,4 +1,5 @@
 <problem>
+ <parameter name="lenient" type="string_lenient" description="Lenient Grading (Partial Credit)" default="yes" />
 
 <startouttext />
 Complete the sentence:


More information about the LON-CAPA-cvs mailing list