--- loncom/interface/lonplacementtest.pm 2016/04/02 04:30:21 1.1 +++ loncom/interface/lonplacementtest.pm 2016/04/04 15:56:58 1.2 @@ -2,7 +2,7 @@ # Handler to manage dependencies for HTML files uploaded directly # to a course. # -# $Id: lonplacementtest.pm,v 1.1 2016/04/02 04:30:21 raeburn Exp $ +# $Id: lonplacementtest.pm,v 1.2 2016/04/04 15:56:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -140,16 +140,18 @@ sub check_completion { if ($tries < $maxtries) { $notdone ++; my $tries = $res->tries($part); - my @response_ids = $res->responseIds($part); - if (@response_ids) { - foreach my $id (@response_ids) { - $storetries{"resource.$part.$id.awarded"}=0; - $storetries{"resource.$part.$id.awarddetail"}='ASSIGNED_SCORE'; + if ($makenew) { + my @response_ids = $res->responseIds($part); + if (@response_ids) { + foreach my $id (@response_ids) { + $storetries{"resource.$part.$id.awarded"}=0; + $storetries{"resource.$part.$id.awarddetail"}='ASSIGNED_SCORE'; + } + $storetries{"resource.$part.tries"}=$maxtries; + $storetries{"resource.$part.solved"}='incorrect_by_override'; + $storetries{"resource.$part.award"}='ASSIGNED_SCORE'; + $storetries{"resource.$part.awarded"}=0; } - $storetries{"resource.$part.tries"}=$maxtries; - $storetries{"resource.$part.solved"}='incorrect_by_override'; - $storetries{"resource.$part.award"}='ASSIGNED_SCORE'; - $storetries{"resource.$part.awarded"}=0; } } else { my $awarded = $res->awarded($part); @@ -203,57 +205,104 @@ sub check_completion { return ($totalpoints,$incomplete); } +sub is_lastres { + my ($symb,$navmap) = @_; + return unless (ref($navmap)); + my $numforward = 0; + my $currRes = $navmap->getBySymb($symb); + if (ref($currRes)) { + my $it = $navmap->getIterator($currRes,undef,undef,1); + while ( my $res=$it->next()) { + if (ref($res)) { + unless ($res->symb() eq $symb) { + $numforward ++; + } + } + } + } + if (!$numforward) { + return 1; + } + return; +} + +sub has_tries { + my ($symb,$navmap) = @_; + return unless (ref($navmap)); + my $currRes = $navmap->getBySymb($symb); + if (ref($currRes)) { + if ($currRes->is_problem()) { + if ($currRes->tries < $currRes->maxtries) { + return 1; + } + } + } + return; +} + sub showresult { - my ($complete) = @_; + my ($complete,$inhibitmenu) = @_; my ($score) = &Apache::lonplacementtest::check_completion(1,undef,1); my %aclt = &test_action_text(); - my $brcrum = [{'href' => '/adm/flip?postdata=firstres%3a', - 'text' => 'Test Status'},]; - my $output = &Apache::loncommon::start_page('Placement Test Completed', - undef,{bread_crumbs=>$brcrum}); + my $output; + unless ($inhibitmenu) { + my $brcrum = [{'href' => '/adm/flip?postdata=firstres%3a', + 'text' => 'Test Status'},]; + $output = &Apache::loncommon::start_page('Placement Test Completed', + undef,{bread_crumbs=>$brcrum}); + } if ($complete) { $output .= '

'.&mt('Test is complete').'

'; } - return $output - .'

'.&mt('You scored [quant,_1,point].',$score).'

' - .&Apache::lonhtmlcommon::actionbox( - [''.$aclt{'newt'}.'', - ''.$aclt{'exit'}.'', - ]) - .&Apache::loncommon::end_page(); + $output .= '

'.&mt('You scored [quant,_1,point].',$score).'

' + .&Apache::lonhtmlcommon::actionbox( + [''.$aclt{'newt'}.'', + ''.$aclt{'exit'}.'', + ]); + unless ($inhibitmenu) { + $output .= &Apache::loncommon::end_page(); + } + return $output; } sub showincomplete { - my ($incomplete) = @_; + my ($incomplete,$inhibitmenu) = @_; my %aclt = &test_action_text(); + my $output; if ($incomplete == 100) { - my $brcrum = [{'href' => '/adm/flip?postdata=firstres%3a', - 'text' => 'Test Status'},]; - return &Apache::loncommon::start_page('Placement Test Unattempted', - undef,{bread_crumbs=>$brcrum}) - .'

'.&mt('Your Placement Test is incomplete.').'

' - .&mt('Currently, you have not submitted any answers for any of the questions.') - .'

' - .&Apache::lonhtmlcommon::actionbox( - [''.$aclt{'begin'}.'', - ''.$aclt{'exit'}.'', - ]) - .&Apache::loncommon::end_page(); + unless ($inhibitmenu) { + my $brcrum = [{'href' => '/adm/flip?postdata=firstres%3a', + 'text' => 'Test Status'},]; + $output = &Apache::loncommon::start_page('Placement Test Unattempted', + undef,{bread_crumbs=>$brcrum}); + } + $output .= '

'.&mt('Your Placement Test is incomplete.').'

' + .&mt('Currently, you have not submitted any answers for any of the questions.') + .'

' + .&Apache::lonhtmlcommon::actionbox( + [''.$aclt{'begin'}.'', + ''.$aclt{'exit'}.'', + ]); } elsif ($incomplete) { - my $brcrum = [{'href' => '/adm/flip?postdata=endplacement%3a', - 'text' => 'Test Status'},]; - return &Apache::loncommon::start_page('Incomplete Placement Test', - undef,{bread_crumbs=>$brcrum}) - .'

'.&mt('Your Placement Test is incomplete.').'

' - .&mt('Currently, you have not provided an answer for [_1]% of the questions.',$incomplete) - .'

' - .&Apache::lonhtmlcommon::actionbox( - [''.$aclt{'endt'}.'', - ''.$aclt{'comp'}.'', - ''.$aclt{'exit'}.'', - ]) - .&Apache::loncommon::end_page(); + unless ($inhibitmenu) { + my $brcrum = [{'href' => '/adm/flip?postdata=endplacement%3a', + 'text' => 'Test Status'},]; + $output .= &Apache::loncommon::start_page('Incomplete Placement Test', + undef,{bread_crumbs=>$brcrum}); + } + $output .= '

'.&mt('Your Placement Test is incomplete.').'

' + .&mt('Currently, you have not provided an answer for [_1]% of the questions.',$incomplete) + .'

' + .&Apache::lonhtmlcommon::actionbox( + [''.$aclt{'endt'}.'', + ''.$aclt{'comp'}.'', + ''.$aclt{'exit'}.'', + ]); + } + unless ($inhibitmenu) { + $output .= &Apache::loncommon::end_page(); } + return $output; } sub test_action_text {