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

raeburn raeburn@source.lon-capa.org
Mon, 14 Sep 2009 16:39:21 -0000


raeburn		Mon Sep 14 16:39:21 2009 EDT

  Modified files:              (Branch: GCI_1)
    /loncom/homework	inputtags.pm 
  Log:
  - Backport 1.251, 1.252, 1.253, 1.254 for GCI_1 branch.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.248 loncom/homework/inputtags.pm:1.248.4.1
--- loncom/homework/inputtags.pm:1.248	Sun Nov 16 02:46:25 2008
+++ loncom/homework/inputtags.pm	Mon Sep 14 16:39:21 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.248 2008/11/16 02:46:25 raeburn Exp $
+# $Id: inputtags.pm,v 1.248.4.1 2009/09/14 16:39:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -427,13 +427,14 @@
 # $part -> partid
 # $id -> responseid
 # $uploadefiletypes -> comma seperated list of extensions allowed or * for any
-# $which -> 'uploadedonly'  -> only newly uploaded files
+# $which -> 'uploadonly'  -> only newly uploaded files
 #           'portfolioonly' -> only allow files from portfolio
 #           'both' -> allow files from either location
 # $extratext -> additional text to go between the link and the input box
+# $maxfilesize -> maximum cumulative filesize for submitted files (in MB).
 # returns a table row <tr> 
 sub file_selector {
-    my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_;
+    my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;
     if (!$uploadedfiletypes) { return ''; }
 
     my $jspart=$part;
@@ -442,9 +443,16 @@
     my $result;
     
     $result.='<tr><td>';
-    if ($uploadedfiletypes ne '*') {
-	$result.=
-	    &mt('Allowed filetypes: <b>[_1]</b>',$uploadedfiletypes).'<br />';
+    if (($uploadedfiletypes ne '*') || ($maxfilesize)) {
+        if ($uploadedfiletypes ne '*') {
+            $result.=
+                &mt('Allowed filetypes: [_1]','<b>'.$uploadedfiletypes.'</b>').'<br />';
+        }
+        if ($maxfilesize) {
+            $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',
+                         '<b>'.$maxfilesize.'</b>').'<br />';
+        }
+        $result .= '<br />';
     }
     if ($which eq 'uploadonly' || $which eq 'both') { 
 	$result.=&mt('Submit a file: (only one file can be uploaded)').
@@ -461,7 +469,6 @@
 	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
 	    '<br />';
 	$result .= &show_past_portfile_submission($part,$id);
-
     }
     $result.='</td></tr>'; 
     return $result;
@@ -523,7 +530,7 @@
 			       'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE',
 			       'UNIT_FAIL', 'NO_UNIT',
 			       'UNIT_NOTNEEDED', 'WANTED_NUMERIC',
-			       'BAD_FORMULA', 'SIG_FAIL', 'INCORRECT', 
+			       'BAD_FORMULA', 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', 
 			       'MISORDERED_RANK', 'INVALID_FILETYPE',
                                'EXCESS_FILESIZE', 'DRAFT',
 			       'SUBMITTED', 'ASSIGNED_SCORE',
@@ -538,7 +545,7 @@
 		  'TOO_LONG',
 		  'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT',
 		  'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT',
-		  'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA',
+		  'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'INTERNAL_ERROR',
 		  'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK',
 		  'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'DRAFT', 'SUBMITTED',
                   'ASSIGNED_SCORE', 'APPROX_ANS', 'EXACT_ANS');
@@ -586,6 +593,9 @@
 	    return ('NO_RESPONSE');
 	}
     }
+
+    if ($Apache::lonxml::internal_error) { $result='INTERNAL_ERROR'; }
+
     if (!$final_scantron && defined($result)) { return ($result); }
 
     # if in scantron mode, if the award for any response is 
@@ -766,7 +776,6 @@
         $message = &mt('Submission won\'t be graded. The combined size of submitted files exceeded the amount allowed.');
         $css_class=$possible_class{'not_charged_try'};
         $button=1;
-
     } elsif ($award eq 'INVALID_FILETYPE') {
 	$message = &mt('Submission won\'t be graded. The type of file submitted is not allowed.');
 	$css_class=$possible_class{'not_charged_try'};
@@ -810,6 +819,10 @@
         if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Formula_Answers')};
 	$css_class=$possible_class{'not_charged_try'};
 	$button=1;
+    } elsif ($award eq 'INTERNAL_ERROR') {
+        $message = &mt("An internal error occurred while processing your answer. Please try again later.");
+        $css_class=$possible_class{'not_charged_try'};
+        $button=1;
     } elsif ($award eq 'INCORRECT') {
 	$message = &mt("Incorrect").'.';
 	$css_class=$possible_class{'charged_try'};
@@ -841,14 +854,27 @@
     my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
     foreach my $resid(@Apache::inputtags::response){
         if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
-	    $message.='<br />';
+            if ($target eq 'tex') {
+                $message.= "\\\\\n";
+            } else {
+                $message.='<br />';
+            }
 	    my @files = split(/\s*,\s*/,
 			      $Apache::lonhomework::history{"resource.$part.$resid.handback"});
 	    my $file_msg;
 	    foreach my $file (@files) {
-		$file_msg.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$file.'">'.$file.'</a>';
+                if ($target eq 'tex') {
+                    $file_msg.= "\\\\\n".$file;
+                } else {
+                    $file_msg.= '<br /><a href="/uploaded/'."$domain/$user".'/'.$file.'">'.$file.'</a>';
+                }
 	    }
 	    $message .= &mt('Returned file(s): [_1]',$file_msg);
+            if ($target eq 'tex') {
+                $message.= "\\\\\n";
+            } else {
+                $message.='<br />';
+            }
 	}
     }
 
@@ -1170,7 +1196,7 @@
 		$trystr = '\vskip 0 mm ';
 	    }
 	} else {
-	    $trystr = "<td><nobr>".$tries_text." $tries";
+	    $trystr = '<td><span class="LC_nobreak">'.$tries_text." $tries";
 	    if ($Apache::lonhomework::parsing_a_task) {
 	    } elsif($env{'request.state'} ne 'construct') {
 		$trystr.="/$maxtries";
@@ -1179,7 +1205,7 @@
 		    $trystr.="/".$Apache::inputtags::params{'maxtries'};
 		}
 	    }
-	    $trystr.="</nobr></td>";
+	    $trystr.="</span></td>";
 	}
     }