[system] / branches / rel-2-2-dev / webwork2 / lib / WeBWorK / ContentGenerator / Problem.pm Repository:
ViewVC logotype

Diff of /branches/rel-2-2-dev/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm

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

Revision 2760 Revision 2761
211 $header .= $showAttemptAnswers ? CGI::th("Entered") : ""; 211 $header .= $showAttemptAnswers ? CGI::th("Entered") : "";
212 $header .= $showAttemptPreview ? CGI::th("Answer Preview") : ""; 212 $header .= $showAttemptPreview ? CGI::th("Answer Preview") : "";
213 $header .= $showCorrectAnswers ? CGI::th("Correct") : ""; 213 $header .= $showCorrectAnswers ? CGI::th("Correct") : "";
214 $header .= $showAttemptResults ? CGI::th("Result") : ""; 214 $header .= $showAttemptResults ? CGI::th("Result") : "";
215 $header .= $showMessages ? CGI::th("Messages") : ""; 215 $header .= $showMessages ? CGI::th("Messages") : "";
216 my $fully = '';
216 my @tableRows = ( $header ); 217 my @tableRows = ( $header );
217 my $numCorrect = 0; 218 my $numCorrect = 0;
218 foreach my $name (@answerNames) { 219 foreach my $name (@answerNames) {
219 my $answerResult = $pg->{answers}->{$name}; 220 my $answerResult = $pg->{answers}->{$name};
220 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans 221 my $studentAnswer = $answerResult->{student_ans}; # original_student_ans
222 ? $self->previewAnswer($answerResult, $imgGen) 223 ? $self->previewAnswer($answerResult, $imgGen)
223 : ""); 224 : "");
224 my $correctAnswer = $answerResult->{correct_ans}; 225 my $correctAnswer = $answerResult->{correct_ans};
225 my $answerScore = $answerResult->{score}; 226 my $answerScore = $answerResult->{score};
226 my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; 227 my $answerMessage = $showMessages ? $answerResult->{ans_message} : "";
227 #FIXME --Can we be sure that $answerScore is an integer-- could the problem give partial credit?
228 $numCorrect += $answerScore > 0; 228 $numCorrect += $answerScore >= 1;
229 my $resultString = $answerScore == 1 ? "correct" : "incorrect"; 229 my $resultString = $answerScore >= 1 ? "correct" :
230 $answerScore > 0 ? int($answerScore*100)."% correct" :
231 "incorrect";
232 $fully = 'completely ' if $answerScore >0 and $answerScore < 1;
230 233
231 # get rid of the goofy prefix on the answer names (supposedly, the format 234 # get rid of the goofy prefix on the answer names (supposedly, the format
232 # of the answer names is changeable. this only fixes it for "AnSwEr" 235 # of the answer names is changeable. this only fixes it for "AnSwEr"
233 #$name =~ s/^AnSwEr//; 236 #$name =~ s/^AnSwEr//;
234 237
253 my $summary = ""; 256 my $summary = "";
254 if (scalar @answerNames == 1) { 257 if (scalar @answerNames == 1) {
255 if ($numCorrect == scalar @answerNames) { 258 if ($numCorrect == scalar @answerNames) {
256 $summary .= CGI::div({class=>"ResultsWithoutError"},"The above answer is correct."); 259 $summary .= CGI::div({class=>"ResultsWithoutError"},"The above answer is correct.");
257 } else { 260 } else {
258 $summary .= CGI::div({class=>"ResultsWithError"},"The above answer is NOT correct."); 261 $summary .= CGI::div({class=>"ResultsWithError"},"The above answer is NOT ${fully}correct.");
259 } 262 }
260 } else { 263 } else {
261 if ($numCorrect == scalar @answerNames) { 264 if ($numCorrect == scalar @answerNames) {
262 $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the above answers are correct."); 265 $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the above answers are correct.");
263 } else { 266 } else {
264 $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the above answers is NOT correct."); 267 $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the above answers is NOT ${fully}correct.");
265 } 268 }
266 } 269 }
267 270
268 return 271 return
269 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) 272 CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows))

Legend:
Removed from v.2760  
changed lines
  Added in v.2761

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9