| … | |
… | |
| 616 | # save state for viewOptions |
616 | # save state for viewOptions |
| 617 | print CGI::hidden( |
617 | print CGI::hidden( |
| 618 | -name => "showOldAnswers", |
618 | -name => "showOldAnswers", |
| 619 | -value => $will{showOldAnswers} |
619 | -value => $will{showOldAnswers} |
| 620 | ), |
620 | ), |
| 621 | CGI::hidden( |
621 | |
| 622 | -name => "showCorrectAnswers", |
|
|
| 623 | -value => $will{showCorrectAnswers} |
|
|
| 624 | ), |
|
|
| 625 | CGI::hidden( |
|
|
| 626 | -name => "showHints", |
|
|
| 627 | -value => $will{showHints}), |
|
|
| 628 | CGI::hidden( |
|
|
| 629 | -name => "showSolutions", |
|
|
| 630 | -value => $will{showSolutions}, |
|
|
| 631 | ), |
|
|
| 632 | CGI::hidden( |
622 | CGI::hidden( |
| 633 | -name => "displayMode", |
623 | -name => "displayMode", |
| 634 | -value => $self->{displayMode} |
624 | -value => $self->{displayMode} |
| 635 | ); |
625 | ); |
| 636 | |
626 | |
| … | |
… | |
| 767 | ? $self->previewAnswer($answerResult, $imgGen) |
757 | ? $self->previewAnswer($answerResult, $imgGen) |
| 768 | : ""); |
758 | : ""); |
| 769 | my $correctAnswer = $answerResult->{correct_ans}; |
759 | my $correctAnswer = $answerResult->{correct_ans}; |
| 770 | my $answerScore = $answerResult->{score}; |
760 | my $answerScore = $answerResult->{score}; |
| 771 | my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; |
761 | my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; |
| 772 | |
762 | #FIXME --Can we be sure that $answerScore is an integer-- could the problem give partial credit? |
| 773 | $numCorrect += $answerScore > 0; |
763 | $numCorrect += $answerScore > 0; |
| 774 | my $resultString = $answerScore ? "correct" : "incorrect"; |
764 | my $resultString = $answerScore ? "correct" : "incorrect"; |
| 775 | |
765 | |
| 776 | # get rid of the goofy prefix on the answer names (supposedly, the format |
766 | # get rid of the goofy prefix on the answer names (supposedly, the format |
| 777 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
767 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
| 778 | $name =~ s/^AnSwEr//; |
768 | #$name =~ s/^AnSwEr//; |
| 779 | |
769 | |
| 780 | my $row; |
770 | my $row; |
| 781 | #$row .= CGI::td($name); |
771 | #$row .= CGI::td($name); |
| 782 | $row .= $showAttemptAnswers ? CGI::td(nbsp($studentAnswer)) : ""; |
772 | $row .= $showAttemptAnswers ? CGI::td(nbsp($studentAnswer)) : ""; |
| 783 | $row .= $showAttemptPreview ? CGI::td(nbsp($preview)) : ""; |
773 | $row .= $showAttemptPreview ? CGI::td(nbsp($preview)) : ""; |
| … | |
… | |
| 788 | } |
778 | } |
| 789 | |
779 | |
| 790 | # render equation images |
780 | # render equation images |
| 791 | $imgGen->render(refresh => 1); |
781 | $imgGen->render(refresh => 1); |
| 792 | |
782 | |
| 793 | my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions"; |
783 | # my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions"; |
| 794 | my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100); |
784 | my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100); |
|
|
785 | # FIXME -- I left the old code in in case we have to back out. |
| 795 | my $summary = "On this attempt, you answered $numCorrect out of " |
786 | # my $summary = "On this attempt, you answered $numCorrect out of " |
| 796 | . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; |
787 | # . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; |
|
|
788 | my $summary = ""; |
|
|
789 | if (scalar @answerNames == 1) { |
|
|
790 | if ($numCorrect == scalar @answerNames) { |
|
|
791 | $summary .= "The above answer is correct."; |
|
|
792 | } else { |
|
|
793 | $summary .= "The above answer is NOT correct."; |
|
|
794 | } |
|
|
795 | } else { |
|
|
796 | if ($numCorrect == scalar @answerNames) { |
|
|
797 | $summary .= "All of the above answers are correct."; |
|
|
798 | } else { |
|
|
799 | $summary .= "At least one of the above answers is NOT correct."; |
|
|
800 | } |
|
|
801 | } |
| 797 | return CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : ""); |
802 | return CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) . ($showSummary ? CGI::p({class=>'emphasis'},$summary) : ""); |
| 798 | } |
803 | } |
| 799 | sub nbsp { |
804 | sub nbsp { |
| 800 | my $str = shift; |
805 | my $str = shift; |
| 801 | ($str =~/\S/) ? $str : ' ' ; # returns non-breaking space for empty strings |
806 | ($str =~/\S/) ? $str : ' ' ; # returns non-breaking space for empty strings |