--- loncom/homework/inputtags.pm 2008/11/25 13:16:17 1.249 +++ loncom/homework/inputtags.pm 2008/12/11 14:52:30 1.253 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.249 2008/11/25 13:16:17 jms Exp $ +# $Id: inputtags.pm,v 1.253 2008/12/11 14:52:30 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -461,16 +461,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 +480,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 +506,6 @@ sub file_selector { ''. '
'; $result .= &show_past_portfile_submission($part,$id); - } $result.=''; return $result; @@ -516,7 +523,7 @@ sub show_past_file_submission { my $icon=&Apache::loncommon::icon($url); my $curfile=''.$uploadedfile.''; - return &mt('Currently submitted: [_1]',$curfile); + return &mt('Currently submitted: [_1]',''.$curfile.''); } @@ -546,7 +553,9 @@ sub show_past_portfile_submission { my $bad_files = ''. join(', ',@bad_file_list). ''; - $result.='
'.&mt('These file(s) don\'t exist: [_1]',$bad_files); + $result.='

' + .&mt("These file(s) don't exist: [_1]",$bad_files) + .'

'; } return $result; @@ -560,7 +569,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', @@ -575,7 +584,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'); @@ -623,6 +632,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 @@ -669,6 +681,7 @@ sub finalizeawards { sub decideoutput { my ($award,$awarded,$awardmsg,$solved,$previous,$target)=@_; + my $message=''; my $button=0; my $previousmsg; @@ -803,7 +816,6 @@ 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.'); $css_class=$possible_class{'not_charged_try'}; @@ -811,7 +823,7 @@ sub decideoutput { } elsif ($award eq 'SIG_FAIL') { my ($used,$min,$max)=split(':',$awardmsg); my $word = ($used < $min) ? 'more' : 'fewer'; - $message = &mt("Submission not graded. Use $word digits.",$used); + $message = &mt("Submission not graded. Use $word digits.",$used); $css_class=$possible_class{'not_charged_try'}; $button=1; } elsif ($award eq 'UNIT_INVALID_INSTRUCTOR') { @@ -847,6 +859,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'}; @@ -1207,7 +1223,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"; @@ -1216,7 +1232,7 @@ sub get_grade_messages { $trystr.="/".$Apache::inputtags::params{'maxtries'}; } } - $trystr.=""; + $trystr.=""; } }