From: Gavin L. v. a. <we...@ma...> - 2010-05-27 14:26:20
|
Log Message: ----------- Correct logical bug in GatewayQuiz module that didn't honor time_limit_cap, gracefully deal with null values of problem_value in the database (which occurs when creating a set from the Library Browser), round reported allowed time (which may be useful when time_limit_cap is specified). Modified Files: -------------- webwork2/lib/WeBWorK/ContentGenerator: GatewayQuiz.pm ProblemSets.pm Revision Data ------------- Index: GatewayQuiz.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -u -r1.54 -r1.55 --- lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -829,9 +829,13 @@ $set->due_date(); $set->version_creation_time( $timeNow ); $set->open_date( $timeNow ); - $set->due_date( $timeNow+$timeLimit ) - if (! $set->time_limit_cap || - $timeNow+$timeLimit<$set->due_date); + # figure out the due date, taking into account + # any time limit cap + my $dueTime = + ( $set->time_limit_cap && + $timeNow+$timeLimit > $set->due_date ) ? + $set->due_date : $timeNow+$timeLimit; + $set->due_date( $dueTime ); $set->answer_date($set->due_date + $ansOffset); $set->version_last_attempt_time( 0 ); @@ -1677,8 +1681,9 @@ my $recordedScore = 0; my $totPossible = 0; foreach ( @problems ) { - $totPossible += $_->value(); - $recordedScore += $_->status*$_->value() if (defined($_->status)); + my $pv = ( $_->value() ) ? $_->value() : 1; + $totPossible += $pv; + $recordedScore += $_->status*$pv if (defined($_->status)); push( @probStatus, ($r->param("probstatus" . $_->problem_id) || $_->status || 0) ); } @@ -1693,7 +1698,7 @@ if ( $submitAnswers || $checkAnswers ) { my $i=0; foreach my $pg ( @pg_results ) { - my $pValue = $problems[$i]->value(); + my $pValue = $problems[$i]->value() ? $problems[$i]->value() : 1; my $pScore = 0; my $numParts = 0; if ( ref( $pg ) ) { # then we have a pg object @@ -1713,9 +1718,8 @@ } } - # we want to print elapsed and allowed times; allowed is easy (we assume - # this is an even number of minutes) - my $allowed = ($set->due_date - $set->open_date)/60; + # we want to print elapsed and allowed times; allowed is easy + my $allowed = sprintf( "%.0f", 10*($set->due_date - $set->open_date)/6 )/100; # elapsed is a little harder; we're counting to the last submission # time, or to the current time if the test hasn't been submitted, # and if the submission fell in the grace period round it to the @@ -2067,8 +2071,9 @@ print CGI::start_div({class=>"gwProblem"}); my $i1 = $i+1; - my $points = ($problems[$probOrder[$i]]->value() > 1) ? - " (" . $problems[$probOrder[$i]]->value() . " points)" : + my $pv = $problems[$probOrder[$i]]->value() ? $problems[$probOrder[$i]]->value() : 1; + my $points = ($pv > 1) ? + " (" . $$pv . " points)" : " (1 point)"; print CGI::a({-name=>"#$i1"},""); print CGI::strong("Problem $problemNumber."), Index: ProblemSets.pm =================================================================== RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/ProblemSets.pm,v retrieving revision 1.94 retrieving revision 1.95 diff -Llib/WeBWorK/ContentGenerator/ProblemSets.pm -Llib/WeBWorK/ContentGenerator/ProblemSets.pm -u -r1.94 -r1.95 --- lib/WeBWorK/ContentGenerator/ProblemSets.pm +++ lib/WeBWorK/ContentGenerator/ProblemSets.pm @@ -508,13 +508,14 @@ my $possible = 0; $score = 0; foreach my $pRec ( @problemRecords ) { + my $pval = $pRec->value() ? $pRec->value() : 1; if ( defined( $pRec ) && $score ne 'undef' ) { - $score += $pRec->status()*$pRec->value() || 0; + $score += $pRec->status()*$pval || 0; } else { $score = 'undef'; } - $possible += $pRec->value(); + $possible += $pval; } $score = "$score/$possible"; } else { |