[LON-CAPA-cvs] cvs: loncom(version_2_10_X) /homework inputtags.pm

raeburn raeburn at source.lon-capa.org
Sat Oct 8 16:44:20 EDT 2011


raeburn		Sat Oct  8 20:44:20 2011 EDT

  Modified files:              (Branch: version_2_10_X)
    /loncom/homework	inputtags.pm 
  Log:
  - Backport 1,282, 1.291, 1.292, 1.294, 1.295.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.271.2.7 loncom/homework/inputtags.pm:1.271.2.8
--- loncom/homework/inputtags.pm:1.271.2.7	Mon May 16 01:02:57 2011
+++ loncom/homework/inputtags.pm	Sat Oct  8 20:44:20 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.271.2.7 2011/05/16 01:02:57 raeburn Exp $
+# $Id: inputtags.pm,v 1.271.2.8 2011/10/08 20:44:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -844,7 +844,7 @@
 }
 
 sub decideoutput {
-    my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
+    my ($award,$awarded,$awardmsg,$solved,$previous,$target,$nocorrect)=@_;
 
     my $message='';
     my $button=0;
@@ -862,8 +862,14 @@
     my $part = $Apache::inputtags::part;
     my $tohandgrade = &Apache::lonnet::EXT("resource.$part.handgrade");
     my $handgrade = ('yes' eq lc($tohandgrade)); 
-    
-    my $computer = ($handgrade)? ''
+ 
+#
+# Should "Computer's Answer" be displayed?
+# Should not be displayed if still answerable,
+# if the problem is handgraded,
+# or if the problem does not give a correct answer
+#
+    my $computer = ($handgrade || $nocorrect)? ''
 	                       : " ".&mt("Computer's answer now shown above.");
     &Apache::lonxml::debug("handgrade has :$handgrade:");
 
@@ -879,8 +885,8 @@
 	    $message=&mt('Incorrect.');
 	    $css_class=$possible_class{'charged_try'};
 	}
-	if ($env{'request.filename'} =~ 
-	    m|/res/lib/templates/examupload.problem$|) {
+	if ($handgrade || 
+            ($env{'request.filename'}=~ m{/res/lib/templates/(examupload|DropBox)\.problem$}) {
 	    $message = &mt("A score has been assigned.");
 	    $added_computer_text=1;
 	} else {
@@ -1404,8 +1410,8 @@
 }
 
 sub get_grade_messages {
-    my ($id,$prefix,$target,$status) = @_;
-
+    my ($id,$prefix,$target,$status,$nocorrect) = @_;
+# nocorrect suppresses "Computer's answer now shown above"
     my ($message,$latemessage,$trystr,$previousmsg);
     my $showbutton = 1;
 
@@ -1419,7 +1425,7 @@
 	&Apache::lonxml::debug('Getting message');
 	($showbutton,my $css_class,$message,$previousmsg) =
 	    &decideoutput($award,$awarded,$awardmsg,$solved,$previous,
-			  $target);
+			  $target,(($status eq 'CAN_ANSWER') || $nocorrect));
 	if ($target eq 'tex') {
 	    $message='\vskip 2 mm '.$message.' ';
 	} else {
@@ -1437,28 +1443,30 @@
     if ( $tries eq '' ) { $tries = '0'; }
     if ( $maxtries eq '' ) { $maxtries = '2'; } 
     if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
-    my $tries_text= &get_tries_text();;
+    my $tries_text= &get_tries_text();
     if ($showbutton) {
 	if ($target eq 'tex') {
 	    if ($env{'request.state'} ne "construct"
 		&& $Apache::lonhomework::type ne 'exam'
 		&& $env{'form.suppress_tries'} ne 'yes') {
-		$trystr = ' {\vskip 1 mm \small \textit{'.$tries_text.'} '.
-		    $tries.'/'.$maxtries.'} \vskip 2 mm ';
+                $trystr ='{\vskip 1 mm \small '
+                        .&mt('[_1]'.$tries_text.'[_2] [_3]'
+                                ,'\textit{','}',$tries.'/'.$maxtries )
+                        .'} \vskip 2 mm';
 	    } else {
 		$trystr = '\vskip 0 mm ';
 	    }
 	} else {
-	    $trystr = '<td><span class="LC_nobreak">'.&mt($tries_text)." $tries";
+            my $trial = $tries;
 	    if ($Apache::lonhomework::parsing_a_task) {
 	    } elsif($env{'request.state'} ne 'construct') {
-		$trystr.="/$maxtries";
+		$trial.="/$maxtries";
 	    } else {
 		if (defined($Apache::inputtags::params{'maxtries'})) {
-		    $trystr.="/".$Apache::inputtags::params{'maxtries'};
+		    $trial.="/".$Apache::inputtags::params{'maxtries'};
 		}
 	    }
-	    $trystr.="</span></td>";
+	    $trystr.='<td><span class="LC_nobreak">'.&mt("$tries_text [_1]",$trial).'</span></td>';
 	}
     }
 
@@ -1580,7 +1588,7 @@
                              {$1 <strong>$txt_correct</strong>. $3}s;
 	    }
             my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")";
-            if ($curr_rndseed || $lastrndseed) {
+            if (($curr_rndseed || $lastrndseed) && ($i > 1)) {
                 if ($curr_rndseed ne $lastrndseed) {
                     $trystr .= '<br /><span style="color: green; white-space: nowrap; font-style: italic; font-weight: bold; font-size: 80%;">'.&mt('New problem variation this try.').'</span>';
                 }




More information about the LON-CAPA-cvs mailing list