--- loncom/homework/inputtags.pm 2007/10/03 02:10:45 1.232 +++ loncom/homework/inputtags.pm 2008/03/03 19:37:27 1.240 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.232 2007/10/03 02:10:45 albertel Exp $ +# $Id: inputtags.pm,v 1.240 2008/03/03 19:37:27 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -548,6 +548,18 @@ sub awarddetail_to_awarded { return 0; } +sub hide_award { + my ($award) = @_; + if (&Apache::lonhomework::show_no_problem_status()) { + return 1; + } + if ($award =~ + /^(?:EXACT_ANS|APPROX_ANS|SUBMITTED|ASSIGNED_SCORE|INCORRECT)/) { + return 1; + } + return 0; +} + sub finalizeawards { my ($awardref,$msgref,$nameref,$reverse,$final_scantron)=@_; my $result; @@ -624,8 +636,8 @@ sub decideoutput { ); my $part = $Apache::inputtags::part; - my $handgrade = - ('yes' eq lc(&Apache::lonnet::EXT("resource.$part.handgrade"))); + my $tohandgrade = &Apache::lonnet::EXT("resource.$part.handgrade"); + my $handgrade = ('yes' eq lc($tohandgrade)); my $computer = ($handgrade)? '' : " ".&mt("Computer's answer now shown above."); @@ -655,14 +667,18 @@ sub decideoutput { $message.= $computer; } $added_computer_text=1; - my ($symb) = &Apache::lonnet::whichuser(); - if (($symb ne '') - && - ($env{'course.'.$env{'request.course.id'}. - '.disable_receipt_display'} ne 'yes')) { - $message.=(($target eq 'web')?'
':' '). - &mt('Your receipt is').' '.&Apache::lonnet::receipt($Apache::inputtags::part). - (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''); + if ($awarded > 0) { + my ($symb) = &Apache::lonnet::whichuser(); + if (($symb ne '') + && + ($env{'course.'.$env{'request.course.id'}. + '.disable_receipt_display'} ne 'yes') && + ($Apache::lonhomework::type ne 'practice')) { + $message.=(($target eq 'web')?'
':' '). + &mt('Your receipt is [_1]', + (&Apache::lonnet::receipt($Apache::inputtags::part). + (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''))); + } } } $button=0; @@ -689,12 +705,14 @@ sub decideoutput { $message.= $computer; } $added_computer_text=1; - unless ($env{'course.'. + if ($awarded > 0 + && $env{'course.'. $env{'request.course.id'}. - '.disable_receipt_display'} eq 'yes') { + '.disable_receipt_display'} ne 'yes') { $message.=(($target eq 'web')?'
':' '). - 'Your receipt is '.&Apache::lonnet::receipt($Apache::inputtags::part). - (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''); + &mt('Your receipt is [_1]', + (&Apache::lonnet::receipt($Apache::inputtags::part). + (($target eq 'web')?&Apache::loncommon::help_open_topic('Receipt'):''))); } $css_class=$possible_class{'correct'}; $button=0; @@ -727,7 +745,7 @@ sub decideoutput { } elsif ($award eq 'MISORDERED_RANK') { $message = &mt('You have provided an invalid ranking'); if ($target ne 'tex') { - $message.=', '.&mt('please refer to').' '.&Apache::loncommon::help_open_topic('Ranking_Problems','help on ranking problems'); + $message.=', '.&mt('please refer to').' '.&Apache::loncommon::help_open_topic('Ranking_Problems',&mt('help on ranking problems')); } $css_class=$possible_class{'not_charged_try'}; $button=1; @@ -770,7 +788,8 @@ sub decideoutput { $css_class=$possible_class{'not_charged_try'}; $button=1; } elsif ($award eq 'BAD_FORMULA') { - $message = &mt("Unable to understand formula"); + $message = &mt("Unable to understand formula").'.'; + if ($target ne 'tex') {$message.=&Apache::loncommon::help_open_topic('Formula_Answers')}; $css_class=$possible_class{'not_charged_try'}; $button=1; } elsif ($award eq 'INCORRECT') { @@ -815,8 +834,9 @@ sub decideoutput { } } - if (lc($Apache::lonhomework::problemstatus) eq 'no' && - $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') { + if (&Apache::lonhomework::hide_problem_status() + && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER' + && &hide_award($award)) { $message = &mt("Answer Submitted: Your final submission will be graded after the due date."); $css_class=$possible_class{'no_grade'}; $button=1; @@ -826,6 +846,10 @@ sub decideoutput { $message.= $computer; $added_computer_text=1; } + if ($Apache::lonhomework::type eq 'practice') { + $message.='
'.&mt('Submissions to practice problems are not permanently recorded.'); + } + return ($button,$css_class,$message,$previousmsg); } @@ -879,8 +903,9 @@ sub setgradedata { $Apache::lonhomework::results{"resource.$id.afterduedate"}=$award; return ''; } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} !~ - /^correct/ || $Apache::lonhomework::scantronmode || - lc($Apache::lonhomework::problemstatus) eq 'no') { + /^correct/ + || $Apache::lonhomework::scantronmode + || &Apache::lonhomework::hide_problem_status() ) { # the student doesn't already have it correct, # or we are in a mode (scantron orno problem status) where a correct # can become incorrect @@ -923,8 +948,8 @@ sub setgradedata { } elsif ( $award eq 'INCORRECT' ) { $Apache::lonhomework::results{"resource.$id.tries"} = $Apache::lonhomework::history{"resource.$id.tries"} + 1; - if (lc($Apache::lonhomework::problemstatus) eq 'no' || - $Apache::lonhomework::scantronmode) { + if (&Apache::lonhomework::hide_problem_status() + || $Apache::lonhomework::scantronmode) { $Apache::lonhomework::results{"resource.$id.awarded"} = 0; } $Apache::lonhomework::results{"resource.$id.solved"} = @@ -943,12 +968,18 @@ sub setgradedata { } else { $Apache::lonhomework::results{"resource.$id.solved"} = 'incorrect_attempted'; - if (lc($Apache::lonhomework::problemstatus) eq 'no' || - $Apache::lonhomework::scantronmode) { + if (&Apache::lonhomework::show_no_problem_status() + || $Apache::lonhomework::scantronmode) { $Apache::lonhomework::results{"resource.$id.tries"} = $Apache::lonhomework::history{"resource.$id.tries"} + 1; $Apache::lonhomework::results{"resource.$id.awarded"} = 0; } + + if (&Apache::lonhomework::show_some_problem_status()) { + # clear out the awarded if they had gotten it wrong/right + # and are now in an error mode + $Apache::lonhomework::results{"resource.$id.awarded"} = ''; + } } if (defined($msg)) { $Apache::lonhomework::results{"resource.$id.awardmsg"} = $msg; @@ -962,7 +993,7 @@ sub setgradedata { # check if this was a previous submission if it was delete the # unneeded data and update the previously_used attribute if ( $previously_used eq 'PREVIOUSLY_USED') { - if (lc($Apache::lonhomework::problemstatus) ne 'no') { + if (&Apache::lonhomework::show_problem_status()) { delete($Apache::lonhomework::results{"resource.$id.tries"}); $Apache::lonhomework::results{"resource.$id.previous"} = '1'; } @@ -1221,16 +1252,16 @@ sub previous_tries { my $previous = $count_lookup{$which}; $message =~ s{()}{ as submission \# $previous $1}; } elsif ($Apache::lonhomework::history{"$prefix.tries"}) { - if (!(lc($Apache::lonhomework::problemstatus) eq 'no' + if (!(&Apache::lonhomework::hide_problem_status() && $Apache::inputtags::status[-1] ne 'SHOW_ANSWER') && $Apache::lonhomework::history{"$prefix.solved"} =~/^correct/ ) { + my $txt_correct = &mt('Correct'); $message =~ s{()(.*?)()} - {$1 Correct. $3}s; + {$1 $txt_correct. $3}s; } - my $trystr = "(Try ". - $Apache::lonhomework::history{"$prefix.tries"}.')'; + my $trystr = "(".&mt('Try [_1]',$Apache::lonhomework::history{"$prefix.tries"}).")"; $message =~ s{()}{ $trystr $1}; } my ($class) = ($message =~ m{ //