--- loncom/homework/inputtags.pm 2008/12/06 12:49:12 1.250
+++ loncom/homework/inputtags.pm 2009/07/08 10:53:08 1.259
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# input definitons
#
-# $Id: inputtags.pm,v 1.250 2008/12/06 12:49:12 bisitz Exp $
+# $Id: inputtags.pm,v 1.259 2009/07/08 10:53:08 onken Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -388,12 +388,13 @@ sub start_textline {
&& $Apache::lonhomework::type ne 'exam') {
my $size = &Apache::lonxml::get_param('size',$parstack,$safeeval);
if ($size != 0) {$size=$size*2; $size.=' mm';} else {$size='40 mm';}
- if ($env{'form.pdfFormFields'} eq 'yes') {
+ if ($env{'form.pdfFormFields'} eq 'yes'
+ && $Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
my $fieldname = $env{'request.symb'}.
'&part_'. $Apache::inputtags::part.
'&textresponse'.
'&HWVAL_' . $Apache::inputtags::response['-1'];
- $result="\n\\\\\n".'\textField{'.$fieldname.'}{'.$size.'}{12 bp}';
+ $result='\textField{'.$fieldname.'}{'.$size.'}{12 bp}';
} else {
$result='\framebox['.$size.'][s]{\tiny\strut}';
}
@@ -461,16 +462,17 @@ sub end_hiddenline {
$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
=cut
sub file_selector {
- my ($part,$id,$uploadedfiletypes,$which,$extratext)=@_;
+ my ($part,$id,$uploadedfiletypes,$which,$extratext,$maxfilesize)=@_;
if (!$uploadedfiletypes) { return ''; }
my $jspart=$part;
@@ -479,9 +481,16 @@ sub file_selector {
my $result;
$result.='
';
- if ($uploadedfiletypes ne '*') {
- $result.=
- &mt('Allowed filetypes: [_1]',''.$uploadedfiletypes.'').' ';
+ if (($uploadedfiletypes ne '*') || ($maxfilesize)) {
+ if ($uploadedfiletypes ne '*') {
+ $result.=
+ &mt('Allowed filetypes: [_1]',''.$uploadedfiletypes.'').' ';
+ }
+ if ($maxfilesize) {
+ $result.=&mt('Combined size of files not to exceed: [_1] MB[_2].',
+ ''.$maxfilesize.'').' ';
+ }
+ $result .= ' ';
}
if ($which eq 'uploadonly' || $which eq 'both') {
$result.=&mt('Submit a file: (only one file can be uploaded)').
@@ -498,7 +507,6 @@ sub file_selector {
''.
' ';
$result .= &show_past_portfile_submission($part,$id);
-
}
$result.='
';
return $result;
@@ -562,7 +570,7 @@ sub valid_award {
'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',
@@ -577,7 +585,7 @@ sub valid_award {
'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');
@@ -625,6 +633,9 @@ sub finalizeawards {
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
@@ -671,6 +682,7 @@ sub finalizeawards {
sub decideoutput {
my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_;
+
my $message='';
my $button=0;
my $previousmsg;
@@ -724,7 +736,7 @@ sub decideoutput {
'.disable_receipt_display'} ne 'yes') &&
($Apache::lonhomework::type ne 'practice')) {
$message.=(($target eq 'web')?' ':' ').
- &mt('Your receipt is [_1]',
+ &mt('Your receipt no. is [_1]',
(&Apache::lonnet::receipt($Apache::inputtags::part).
(($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):'')));
}
@@ -805,9 +817,8 @@ sub decideoutput {
$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.');
+ $message = &mt("Submission won't be graded. The type of file submitted is not allowed.");
$css_class=$possible_class{'not_charged_try'};
$button=1;
} elsif ($award eq 'SIG_FAIL') {
@@ -849,6 +860,10 @@ sub decideoutput {
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'};
@@ -858,7 +873,7 @@ sub decideoutput {
$css_class=$possible_class{'no_grade'};
$button=1;
} elsif ($award eq 'DRAFT') {
- $message = &mt("A draft copy has been saved.");
+ $message = &mt("Copy saved but not submitted.");
$css_class=$possible_class{'not_charged_try'};
$button=1;
} elsif ($award eq 'ASSIGNED_SCORE') {
@@ -880,14 +895,27 @@ sub decideoutput {
my (undef,undef,$domain,$user)=&Apache::lonnet::whichuser();
foreach my $resid(@Apache::inputtags::response){
if ($Apache::lonhomework::history{"resource.$part.$resid.handback"}) {
- $message.=' ';
+ if ($target eq 'tex') {
+ $message.= "\\\\\n";
+ } else {
+ $message.=' ';
+ }
my @files = split(/\s*,\s*/,
$Apache::lonhomework::history{"resource.$part.$resid.handback"});
my $file_msg;
foreach my $file (@files) {
- $file_msg.= ' '.$file.'';
+ if ($target eq 'tex') {
+ $file_msg.= "\\\\\n".$file;
+ } else {
+ $file_msg.= ' '.$file.'';
+ }
}
$message .= &mt('Returned file(s): [_1]',$file_msg);
+ if ($target eq 'tex') {
+ $message.= "\\\\\n";
+ } else {
+ $message.=' ';
+ }
}
}
@@ -1209,7 +1237,7 @@ sub get_grade_messages {
$trystr = '\vskip 0 mm ';
}
} else {
- $trystr = "
".$tries_text." $tries";
+ $trystr = '
'.$tries_text." $tries";
if ($Apache::lonhomework::parsing_a_task) {
} elsif($env{'request.state'} ne 'construct') {
$trystr.="/$maxtries";
@@ -1218,7 +1246,7 @@ sub get_grade_messages {
$trystr.="/".$Apache::inputtags::params{'maxtries'};
}
}
- $trystr.="