[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm lonhomework.pm response.pm structuretags.pm

albertel lon-capa-cvs-allow@mail.lon-capa.org
Wed, 17 Oct 2007 00:22:51 -0000


This is a MIME encoded message

--albertel1192580571
Content-Type: text/plain

albertel		Tue Oct 16 20:22:51 2007 EDT

  Modified files:              
    /loncom/homework	inputtags.pm lonhomework.pm response.pm 
                    	structuretags.pm 
  Log:
   - BUG#5395, split feedback off into two options, no feedback at all, and no feedback on correct/incorrect (but allow unit/malformed answer feedback)
  
  
--albertel1192580571
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20071016202251.txt"

Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.232 loncom/homework/inputtags.pm:1.233
--- loncom/homework/inputtags.pm:1.232	Tue Oct  2 22:10:45 2007
+++ loncom/homework/inputtags.pm	Tue Oct 16 20:22:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.232 2007/10/03 02:10:45 albertel Exp $
+# $Id: inputtags.pm,v 1.233 2007/10/17 00:22:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -548,6 +548,18 @@
     return 0;
 }
 
+sub hide_award {
+    my ($award) = @_;
+    if (&Apache::lonhomework::show_no_problem_status()) {
+	return 1;
+    }
+    if ($award =~
+	/^(?:EXACT_ANS|APPROX_ANS|SUBMITTED|ASSIGNED_SCORE|INCORRECT)/) {
+	return 1;
+    }
+    return 0;
+}
+
 sub finalizeawards {
     my ($awardref,$msgref,$nameref,$reverse,$final_scantron)=@_;
     my $result;
@@ -815,8 +827,9 @@
 	}
     }
 
-    if (lc($Apache::lonhomework::problemstatus) eq 'no'  && 
-	$Apache::inputtags::status[-1] ne 'SHOW_ANSWER') {
+    if (&Apache::lonhomework::hide_problem_status()
+	&& $Apache::inputtags::status[-1] ne 'SHOW_ANSWER'
+	&& &hide_award($award)) {
 	$message = &mt("Answer Submitted: Your final submission will be graded after the due date.");
 	$css_class=$possible_class{'no_grade'};
 	$button=1;
@@ -879,8 +892,9 @@
 	$Apache::lonhomework::results{"resource.$id.afterduedate"}=$award;
 	return '';
     } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~
-	      /^correct/ || $Apache::lonhomework::scantronmode ||
-	      lc($Apache::lonhomework::problemstatus) eq 'no') {
+	      /^correct/ 
+	      || $Apache::lonhomework::scantronmode 
+	      || &Apache::lonhomework::hide_problem_status()  ) {
         # the student doesn't already have it correct,
 	# or we are in a mode (scantron orno problem status) where a correct 
         # can become incorrect
@@ -923,8 +937,8 @@
 	} elsif ( $award eq 'INCORRECT' ) {
 	    $Apache::lonhomework::results{"resource.$id.tries"} =
 		$Apache::lonhomework::history{"resource.$id.tries"} + 1;
-	    if (lc($Apache::lonhomework::problemstatus) eq 'no' ||
-		$Apache::lonhomework::scantronmode) {
+	    if (&Apache::lonhomework::hide_problem_status()
+		|| $Apache::lonhomework::scantronmode) {
 		$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
 	    }
 	    $Apache::lonhomework::results{"resource.$id.solved"} =
@@ -943,12 +957,18 @@
 	} else {
 	    $Apache::lonhomework::results{"resource.$id.solved"} =
 		'incorrect_attempted';
-	    if (lc($Apache::lonhomework::problemstatus) eq 'no' ||
-		$Apache::lonhomework::scantronmode) {
+	    if (&Apache::lonhomework::show_no_problem_status()
+		|| $Apache::lonhomework::scantronmode) {
 		$Apache::lonhomework::results{"resource.$id.tries"} =
 		    $Apache::lonhomework::history{"resource.$id.tries"} + 1;
 		$Apache::lonhomework::results{"resource.$id.awarded"} = 0;
 	    }
+
+	    if (&Apache::lonhomework::show_some_problem_status()) {
+		# clear out the awarded if they had gotten it wrong/right
+		# and are now in an error mode	
+		$Apache::lonhomework::results{"resource.$id.awarded"} = '';
+	    }
 	}
 	if (defined($msg)) {
 	    $Apache::lonhomework::results{"resource.$id.awardmsg"} = $msg;
@@ -962,7 +982,7 @@
 	    # check if this was a previous submission if it was delete the
 	    # unneeded data and update the previously_used attribute
 	    if ( $previously_used eq 'PREVIOUSLY_USED') {
-		if (lc($Apache::lonhomework::problemstatus) ne 'no') {
+		if (&Apache::lonhomework::show_problem_status()) {
 		    delete($Apache::lonhomework::results{"resource.$id.tries"});
 		    $Apache::lonhomework::results{"resource.$id.previous"} = '1';
 		}
@@ -1221,7 +1241,7 @@
 	    my $previous = $count_lookup{$which};
 	    $message =~ s{(</td>)}{ as submission \# $previous $1};
 	} elsif ($Apache::lonhomework::history{"$prefix.tries"}) {
-	    if (!(lc($Apache::lonhomework::problemstatus) eq 'no'
+	    if (!(&Apache::lonhomework::hide_problem_status()
 		  && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER')
 		&& $Apache::lonhomework::history{"$prefix.solved"} =~/^correct/
 		) {
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.276 loncom/homework/lonhomework.pm:1.277
--- loncom/homework/lonhomework.pm:1.276	Mon Oct  8 05:22:50 2007
+++ loncom/homework/lonhomework.pm	Tue Oct 16 20:22:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.276 2007/10/08 09:22:50 foxr Exp $
+# $Id: lonhomework.pm,v 1.277 2007/10/17 00:22:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -398,8 +398,8 @@
     if ($env{'request.state'} eq "construct") {
 	if ($env{'form.problemstate'}) {
 	    if ($env{'form.problemstate'} =~ /^CANNOT_ANSWER/) {
-		if ( ! ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct' &&
-			lc($Apache::lonhomework::problemstatus) eq 'no')) {
+		if ( ! ($env{'form.problemstate'} eq 'CANNOT_ANSWER_correct' 
+			&& &hide_problem_status())) {
 		    return ('CANNOT_ANSWER',
 			    &mt('is in this state due to author settings.'));
 		}
@@ -489,7 +489,7 @@
 	# if (correct and show prob status) or excused then CANNOT_ANSWER
 	if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/
 	    &&
-	    lc($Apache::lonhomework::problemstatus) ne 'no')
+	    &show_problem_status())
 	   ||
 	   $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) {
 	    $status = 'CANNOT_ANSWER';
@@ -861,6 +861,36 @@
     return $result;
 }
 
+{
+    my $show_problem_status;
+    sub reset_show_problem_status {
+	undef($show_problem_status);
+    }
+
+    sub set_show_problem_status {
+	my ($new_status) = @_;
+	$show_problem_status = lc($new_status);
+    }
+
+    sub hide_problem_status {
+	return ($show_problem_status eq 'no'
+		|| $show_problem_status eq 'no_feedback_ever');
+    }
+
+    sub show_problem_status {
+	return ($show_problem_status eq 'yes'
+		|| $show_problem_status eq '');
+    }
+    
+    sub show_some_problem_status {
+	return ($show_problem_status eq 'no');
+    }
+
+    sub show_no_problem_status {
+	return ($show_problem_status eq 'no_feedback_ever');
+    }
+}
+
 sub editxmlmode {
     my ($request,$file) = @_;
     my $result;
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.180 loncom/homework/response.pm:1.181
--- loncom/homework/response.pm:1.180	Mon Oct 15 05:47:29 2007
+++ loncom/homework/response.pm	Tue Oct 16 20:22:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.180 2007/10/15 09:47:29 foxr Exp $
+# $Id: response.pm,v 1.181 2007/10/17 00:22:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1050,7 +1050,7 @@
     my $award  = $Apache::lonhomework::history{"resource.$part.solved"};
     my $status = $Apache::inputtags::status[-1];
     return  ( ($award =~ /^correct/
-	       && lc($Apache::lonhomework::problemstatus) ne 'no')
+	       && &Apache::lonhomework::show_problem_status())
 	      || $status eq "SHOW_ANSWER");
 }
 
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.404 loncom/homework/structuretags.pm:1.405
--- loncom/homework/structuretags.pm:1.404	Tue Oct 16 19:20:25 2007
+++ loncom/homework/structuretags.pm	Tue Oct 16 20:22:51 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.404 2007/10/16 23:20:25 albertel Exp $
+# $Id: structuretags.pm,v 1.405 2007/10/17 00:22:51 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -360,7 +360,7 @@
     if (!$Apache::lonhomework::parsing_a_task) {
 	$result.="
 <nobr>
-Problem Status:
+".&mt("Problem Status:")."
 <select name='problemstate'>
   <option value=''></option>
   ".&option('CLOSED'               ,'problemstate').&mt("Closed")."</option>
@@ -371,7 +371,7 @@
 </select>
 </nobr>
 <nobr>
-Problem Type:
+".&mt("Problem Type:")."
 <select name='problemtype'>
   <option value=''></option>
   ".&option('exam'   ,'problemtype').&mt("Exam Problem")."</option>
@@ -380,11 +380,12 @@
 </select>
 </nobr>
 <nobr>
-Feedback Mode:
+".&mt("Feedback Mode:")."
 <select name='problemstatus'>
   <option value=''></option>
   ".&option('yes','problemstatus').&mt("Show Feedback")."</option>
-  ".&option('no', 'problemstatus').&mt("Don't Show Feedback")."</option>
+  ".&option('no', 'problemstatus').&mt("Don't Show Incorect/Correct Feedback")."</option>
+  ".&option('no_feedback_ever', 'problemstatus').&mt("Don't Show Any Feedback")."</option>
 </select>
 </nobr>
 <input type='submit' name='changeproblemmode' value='".&mt("Change")."' />
@@ -401,7 +402,7 @@
     } elsif ($Apache::lonhomework::parsing_a_task) {
 	$result.="
 <nobr>
-Problem Status:
+".&mt("Problem Status:")."
 <select name='problemstate'>
   <option value=''></option>
   ".&option('CLOSED'               ,'problemstate').&mt("Closed")."</option>
@@ -576,19 +577,19 @@
     if ($type eq 'problem') {
 	$Apache::inputtags::part='0';
 	@Apache::inputtags::partlist=('0');
-	$Apache::lonhomework::problemstatus=&get_problem_status('0');
+	&Apache::lonhomework::set_show_problem_status(&get_problem_status('0'));
 	$Apache::lonhomework::ignore_response_errors=0;
 
     } elsif ($type eq 'library') {
 	$Apache::inputtags::part='';
 	@Apache::inputtags::partlist=();
-	$Apache::lonhomework::problemstatus='';	
+	&Apache::lonhomework::reset_show_problem_status();
 	$Apache::lonhomework::ignore_response_errors=1;
 
     } elsif ($type eq 'Task') {
 	$Apache::inputtags::part='0';
 	@Apache::inputtags::partlist=('0');
-	$Apache::lonhomework::problemstatus='';	
+	&Apache::lonhomework::reset_show_problem_status();
 	$Apache::lonhomework::ignore_response_errors=1;
     }
     @Apache::inputtags::responselist = ();
@@ -617,8 +618,8 @@
     undef($Apache::lonhomework::default_type);
     undef($Apache::lonhomework::type);
     undef($Apache::lonhomework::scantronmode);
-    undef($Apache::lonhomework::problemstatus);
     undef($Apache::lonhomework::ignore_response_errors);
+    &Apache::lonhomework::reset_show_problem_status();
 }
 
 sub set_problem_state {
@@ -1488,7 +1489,7 @@
     @Apache::inputtags::response=();
     @Apache::inputtags::previous=();
     @Apache::inputtags::previous_version=();
-    $Apache::lonhomework::problemstatus=&get_problem_status($id);
+    &Apache::lonhomework::set_show_problem_status(&get_problem_status($id));
     &Apache::response::reset_params();
 
     my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);

--albertel1192580571--