[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator / Problem.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3390 Revision 3391
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2003 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: webwork2/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.173 2005/07/05 18:20:24 sh002i Exp $ 4# $CVSHeader: webwork-modperl/lib/WeBWorK/ContentGenerator/Problem.pm,v 1.176 2005/07/14 13:15:25 glarose Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
222 $header .= $showAttemptResults ? CGI::th("Result") : ""; 222 $header .= $showAttemptResults ? CGI::th("Result") : "";
223 $header .= $showMessages ? CGI::th("Messages") : ""; 223 $header .= $showMessages ? CGI::th("Messages") : "";
224 my $fully = ''; 224 my $fully = '';
225 my @tableRows = ( $header ); 225 my @tableRows = ( $header );
226 my $numCorrect = 0; 226 my $numCorrect = 0;
227 my $numBlanks =0;
227 my $tthPreambleCache; 228 my $tthPreambleCache;
228 foreach my $name (@answerNames) { 229 foreach my $name (@answerNames) {
229 my $answerResult = $pg->{answers}->{$name}; 230 my $answerResult = $pg->{answers}->{$name};
230 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans 231 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans
231 my $preview = ($showAttemptPreview 232 my $preview = ($showAttemptPreview
234 my $correctAnswer = $answerResult->{correct_ans}; 235 my $correctAnswer = $answerResult->{correct_ans};
235 my $answerScore = $answerResult->{score}; 236 my $answerScore = $answerResult->{score};
236 my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; 237 my $answerMessage = $showMessages ? $answerResult->{ans_message} : "";
237 $answerMessage =~ s/\n/<BR>/g; 238 $answerMessage =~ s/\n/<BR>/g;
238 $numCorrect += $answerScore >= 1; 239 $numCorrect += $answerScore >= 1;
240 $numBlanks++ unless $studentAnswer =~/\S/; # unless student answer contains entry
239 my $resultString = $answerScore >= 1 ? "correct" : 241 my $resultString = $answerScore >= 1 ? "correct" :
240 $answerScore > 0 ? int($answerScore*100)."% correct" : 242 $answerScore > 0 ? int($answerScore*100)."% correct" :
241 "incorrect"; 243 "incorrect";
242 $fully = 'completely ' if $answerScore >0 and $answerScore < 1; 244 $fully = 'completely ' if $answerScore >0 and $answerScore < 1;
243 245
262 my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100); 264 my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100);
263# FIXME -- I left the old code in in case we have to back out. 265# FIXME -- I left the old code in in case we have to back out.
264# my $summary = "On this attempt, you answered $numCorrect out of " 266# my $summary = "On this attempt, you answered $numCorrect out of "
265# . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; 267# . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent.";
266 my $summary = ""; 268 my $summary = "";
269 unless (defined($problemResult->{summary}) and $problemResult->{summary} =~ /\S/) {
267 if (scalar @answerNames == 1) { 270 if (scalar @answerNames == 1) { #default messages
268 if ($numCorrect == scalar @answerNames) { 271 if ($numCorrect == scalar @answerNames) {
269 $summary .= CGI::div({class=>"ResultsWithoutError"},"The above answer is correct."); 272 $summary .= CGI::div({class=>"ResultsWithoutError"},"The above answer is correct.");
270 } else { 273 } else {
271 $summary .= CGI::div({class=>"ResultsWithError"},"The above answer is NOT ${fully}correct."); 274 $summary .= CGI::div({class=>"ResultsWithError"},"The above answer is NOT ${fully}correct.");
272 } 275 }
276 } else {
277 if ($numCorrect == scalar @answerNames) {
278 $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the above answers are correct.");
279 }
280 unless ($numCorrect + $numBlanks == scalar( @answerNames)) {
281 $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the above answers is NOT ${fully}correct.");
282 }
283 if ($numBlanks) {
284 my $s = ($numBlanks>1)?'':'s';
285 $summary .= CGI::div({class=>"ResultsAlert"},"$numBlanks of the questions remain$s unanswered.");
286 }
287 }
273 } else { 288 } else {
274 if ($numCorrect == scalar @answerNames) { 289 $summary = $problemResult->{summary}; # summary has been defined by grader
275 $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the above answers are correct.");
276 } else {
277 $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the above answers is NOT ${fully}correct.");
278 }
279 } 290 }
280
281 return 291 return
282 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) 292 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows))
283 . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : ""); 293 . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : "");
284} 294}
285 295
1049 # $setClosedMessage .= " However, since you are a privileged user, additional attempts will be recorded."; 1059 # $setClosedMessage .= " However, since you are a privileged user, additional attempts will be recorded.";
1050 # } else { 1060 # } else {
1051 # $setClosedMessage .= " Additional attempts will not be recorded."; 1061 # $setClosedMessage .= " Additional attempts will not be recorded.";
1052 # } 1062 # }
1053 #} 1063 #}
1054 1064 unless (defined( $pg->{state}->{state_summary_msg}) and $pg->{state}->{state_summary_msg}=~/\S/) {
1055 my $notCountedMessage = ($problem->value) ? "" : "(This problem will not count towards your grade.)"; 1065 my $notCountedMessage = ($problem->value) ? "" : "(This problem will not count towards your grade.)";
1056 print CGI::p( 1066 print CGI::p(
1057 $submitAnswers ? $scoreRecordedMessage . CGI::br() : "", 1067 $submitAnswers ? $scoreRecordedMessage . CGI::br() : "",
1058 "You have attempted this problem $attempts $attemptsNoun.", CGI::br(), 1068 "You have attempted this problem $attempts $attemptsNoun.", CGI::br(),
1069 $submitAnswers ?"You received a score of ".sprintf("%.0f%%", $pg->{result}->{score} * 100)." for this attempt.".CGI::br():'',
1059 $problem->attempted 1070 $problem->attempted
1060 ? "Your recorded score is $lastScore. $notCountedMessage" . CGI::br() 1071 ? "Your overall recorded score is $lastScore. $notCountedMessage" . CGI::br()
1061 : "", 1072 : "",
1062 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining." 1073 $setClosed ? $setClosedMessage : "You have $attemptsLeft $attemptsLeftNoun remaining."
1063 ); 1074 );
1075 }else {
1076 print CGI::p($pg->{state}->{state_summary_msg});
1077 }
1064 print CGI::end_div(); 1078 print CGI::end_div();
1065 1079
1066 # save state for viewOptions 1080 # save state for viewOptions
1067 print CGI::hidden( 1081 print CGI::hidden(
1068 -name => "showOldAnswers", 1082 -name => "showOldAnswers",

Legend:
Removed from v.3390  
changed lines
  Added in v.3391

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9