| … | |
… | |
| 457 | my $showAttemptResults = $showAttemptAnswers && shift; |
457 | my $showAttemptResults = $showAttemptAnswers && shift; |
| 458 | my $showAttemptPreview = shift || 0; |
458 | my $showAttemptPreview = shift || 0; |
| 459 | my $problemResult = $pg->{result}; # the overall result of the problem |
459 | my $problemResult = $pg->{result}; # the overall result of the problem |
| 460 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
460 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
| 461 | |
461 | |
|
|
462 | my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; |
|
|
463 | |
| 462 | my $header = CGI::th("answer"); |
464 | my $header = CGI::th("part"); |
| 463 | $header .= $showAttemptAnswers ? CGI::th("attempt") : ""; |
465 | $header .= $showAttemptAnswers ? CGI::th("entered") : ""; |
| 464 | $header .= $showAttemptPreview ? CGI::th("preview") : ""; |
466 | $header .= $showAttemptPreview ? CGI::th("preview") : ""; |
| 465 | $header .= $showCorrectAnswers ? CGI::th("correct") : ""; |
467 | $header .= $showCorrectAnswers ? CGI::th("correct") : ""; |
| 466 | $header .= $showAttemptResults ? CGI::th("result") : ""; |
468 | $header .= $showAttemptResults ? CGI::th("result") : ""; |
| 467 | $header .= $showAttemptAnswers ? CGI::th("messages") : ""; |
469 | $header .= $showMessages ? CGI::th("messages") : ""; |
| 468 | my @tableRows = ( $header ); |
470 | my @tableRows = ( $header ); |
| 469 | my $numCorrect; |
471 | my $numCorrect; |
| 470 | foreach my $name (@answerNames) { |
472 | foreach my $name (@answerNames) { |
| 471 | my $answerResult = $pg->{answers}->{$name}; |
473 | my $answerResult = $pg->{answers}->{$name}; |
| 472 | my $studentAnswer = $answerResult->{student_ans}; # original_student_ans |
474 | my $studentAnswer = $answerResult->{student_ans}; # original_student_ans |
| 473 | my $preview = ($showAttemptPreview |
475 | my $preview = ($showAttemptPreview |
| 474 | ? $self->previewAnswer($answerResult) |
476 | ? $self->previewAnswer($answerResult) |
| 475 | : ""); |
477 | : ""); |
| 476 | my $correctAnswer = $answerResult->{correct_ans}; |
478 | my $correctAnswer = $answerResult->{correct_ans}; |
| 477 | my $answerScore = $answerResult->{score}; |
479 | my $answerScore = $answerResult->{score}; |
| 478 | my $answerMessage = $showAttemptAnswers ? $answerResult->{ans_message} : ""; |
480 | my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; |
| 479 | |
481 | |
| 480 | $numCorrect += $answerScore > 0; |
482 | $numCorrect += $answerScore > 0; |
| 481 | my $resultString = $answerScore ? "correct" : "incorrect"; |
483 | my $resultString = $answerScore ? "correct" : "incorrect"; |
| 482 | |
484 | |
| 483 | # get rid of the goofy prefix on the answer names (supposedly, the format |
485 | # get rid of the goofy prefix on the answer names (supposedly, the format |