--- loncom/homework/inputtags.pm 2011/10/08 20:44:20 1.271.2.8 +++ loncom/homework/inputtags.pm 2011/07/12 12:55:50 1.292 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.271.2.8 2011/10/08 20:44:20 raeburn Exp $ +# $Id: inputtags.pm,v 1.292 2011/07/12 12:55:50 christianto Exp $ # # Copyright Michigan State University Board of Trustees # @@ -354,7 +354,6 @@ sub start_textline { unless ($newvariation) { $oldresponse = $Apache::lonhomework::history{"resource.$partid.$id.submission"}; &Apache::lonxml::debug("oldresponse $oldresponse is ".ref($oldresponse)); - if (ref($oldresponse) eq 'ARRAY') { $oldresponse = $oldresponse->[$#Apache::inputtags::inputlist]; } @@ -479,6 +478,7 @@ sub end_hiddenline { return ""; } + sub start_hiddensubmission { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $result = ""; @@ -728,7 +728,7 @@ sub valid_award { 'UNIT_FAIL', 'NO_UNIT', 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'NOT_FUNCTION', 'WRONG_FORMAT', - 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', + 'INTERNAL_ERROR', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', 'DRAFT', 'SUBMITTED', 'SUBMITTED_CREDIT', @@ -746,7 +746,7 @@ sub valid_award { 'UNIT_INVALID_INSTRUCTOR', 'UNIT_INVALID_STUDENT', 'UNIT_IRRECONCIBLE', 'UNIT_FAIL', 'NO_UNIT', 'UNIT_NOTNEEDED', 'WANTED_NUMERIC', 'BAD_FORMULA', 'NOT_FUNCTION', - 'WRONG_FORMAT', 'INTERNAL_ERROR', + 'WRONG_FORMAT', 'INTERNAL_ERROR', 'COMMA_FAIL', 'SIG_FAIL', 'INCORRECT', 'MISORDERED_RANK', 'INVALID_FILETYPE', 'EXCESS_FILESIZE', 'FILENAME_INUSE', 'DRAFT', 'SUBMITTED', @@ -862,13 +862,13 @@ sub decideoutput { my $part = $Apache::inputtags::part; my $tohandgrade = &Apache::lonnet::EXT("resource.$part.handgrade"); my $handgrade = ('yes' eq lc($tohandgrade)); - # # 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:"); @@ -886,7 +886,7 @@ sub decideoutput { $css_class=$possible_class{'charged_try'}; } if ($handgrade || - ($env{'request.filename'}=~ m{/res/lib/templates/(examupload|DropBox)\.problem$}) { + ($env{'request.filename'}=~/\/res\/lib\/templates\/(examupload|DropBox).problem$/)) { $message = &mt("A score has been assigned."); $added_computer_text=1; } else { @@ -911,7 +911,7 @@ sub decideoutput { } } } - $button=0; + if ($awarded==1) { $button=0; } else { $button=1; } $previousmsg=''; } elsif ($solved =~ /^excused/) { if ($target eq 'tex') { @@ -1047,7 +1047,7 @@ sub decideoutput { $message = &mt("Wrong format").'.'; $css_class=$possible_class{'not_charged_try'}; $button=1; - } elsif ($award eq 'INTERNAL_ERROR') { + } 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; @@ -1137,7 +1137,6 @@ sub decideoutput { } $message.=&mt('Submissions to practice problems are not permanently recorded.'); } - return ($button,$css_class,$message,$previousmsg); } @@ -1190,8 +1189,7 @@ sub setgradedata { $Apache::inputtags::status['-1'] ne 'CANNOT_ANSWER') { $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; return ''; - } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ - /^correct/ + } elsif ( $Apache::lonhomework::history{"resource.$id.awarded"} < 1 || $Apache::lonhomework::scantronmode || &Apache::lonhomework::hide_problem_status() ) { # the student doesn't already have it correct, @@ -1312,8 +1310,7 @@ sub setgradedata { $Apache::lonhomework::results{"resource.$id.previous"} = '0'; } } - } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~ - /^correct/ ) { + } elsif ( $Apache::lonhomework::history{"resource.$id.awarded"} == 1 ) { #delete all data as they student already has it correct &removealldata($id); #and since they didn't do anything we were never here @@ -1323,14 +1320,10 @@ sub setgradedata { if ($award eq 'SUBMITTED') { &Apache::response::add_to_gradingqueue(); } - if (($Apache::lonhomework::type eq 'anonsurvey') || - ($Apache::lonhomework::type eq 'anonsurveycred') || - ($Apache::lonhomework::type eq 'randomizetry')) { - $Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type; - } - if ($Apache::lonhomework::type eq 'randomizetry') { - $Apache::lonhomework::results{"resource.$id.rndseed"} = $env{'form.'.$id.'.rndseed'}; - } + $Apache::lonhomework::results{"resource.$id.type"} = $Apache::lonhomework::type; + $Apache::lonhomework::results{"resource.$id.duedate"} = &Apache::lonnet::EXT("resource.$id.duedate"); + $Apache::lonhomework::results{"resource.$id.hinttries"} = &Apache::lonnet::EXT("resource.$id.hinttries"); + $Apache::lonhomework::results{"resourse.$id.version"} = &Apache::lonnet::usedversion(); } sub find_which_previous { @@ -1449,24 +1442,24 @@ sub get_grade_messages { if ($env{'request.state'} ne "construct" && $Apache::lonhomework::type ne 'exam' && $env{'form.suppress_tries'} ne 'yes') { - $trystr ='{\vskip 1 mm \small ' + $trystr ='{\vskip 1 mm \small ' .&mt('[_1]'.$tries_text.'[_2] [_3]' - ,'\textit{','}',$tries.'/'.$maxtries ) + ,'\textit{','}',$tries.'/'.$maxtries ) .'} \vskip 2 mm'; } else { $trystr = '\vskip 0 mm '; } } else { - my $trial = $tries; + my $trial =$tries; if ($Apache::lonhomework::parsing_a_task) { } elsif($env{'request.state'} ne 'construct') { - $trial.="/$maxtries"; + $trial.="/".&Apache::lonhtmlcommon::direct_parm_link($maxtries,$env{'request.symb'},'maxtries',$id,$target); } else { if (defined($Apache::inputtags::params{'maxtries'})) { $trial.="/".$Apache::inputtags::params{'maxtries'}; } } - $trystr.=''.&mt("$tries_text [_1]",$trial).''; + $trystr = ''.&mt($tries_text.' [_1]',$trial).''; } } @@ -1556,7 +1549,6 @@ sub previous_tries { $count++; $count_lookup{$i} = $count; my $curr_rndseed = $Apache::lonhomework::history{"$prefix.rndseed"}; - my ($previousmsg,$latemessage,$message,$trystr); ($previousmsg,$latemessage,$message,$trystr) = @@ -1588,11 +1580,11 @@ sub previous_tries { {$1 $txt_correct. $3}s; } my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")"; - if (($curr_rndseed || $lastrndseed) && ($i > 1)) { + if ($curr_rndseed || $lastrndseed) { if ($curr_rndseed ne $lastrndseed) { $trystr .= '
'.&mt('New problem variation this try.').''; } - } + } $message =~ s{()}{ $trystr $1}; } my ($class) = ($message =~ m{