| … | |
… | |
| 681 | # get rid of the goofy prefix on the answer names (supposedly, the format |
681 | # get rid of the goofy prefix on the answer names (supposedly, the format |
| 682 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
682 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
| 683 | $name =~ s/^AnSwEr//; |
683 | $name =~ s/^AnSwEr//; |
| 684 | |
684 | |
| 685 | my $row = CGI::td($name); |
685 | my $row = CGI::td($name); |
| 686 | $row .= $showAttemptAnswers ? CGI::td($studentAnswer) : ""; |
686 | $row .= $showAttemptAnswers ? CGI::td(nbsp($studentAnswer)) : ""; |
| 687 | $row .= $showAttemptPreview ? CGI::td($preview) : ""; |
687 | $row .= $showAttemptPreview ? CGI::td(nbsp($preview)) : ""; |
| 688 | $row .= $showCorrectAnswers ? CGI::td($correctAnswer) : ""; |
688 | $row .= $showCorrectAnswers ? CGI::td(nbsp($correctAnswer)) : ""; |
| 689 | $row .= $showAttemptResults ? CGI::td($resultString) : ""; |
689 | $row .= $showAttemptResults ? CGI::td(nbsp($resultString)) : ""; |
| 690 | $row .= $answerMessage ? CGI::td($answerMessage) : ""; |
690 | $row .= $answerMessage ? CGI::td(nbsp($answerMessage)) : ""; |
| 691 | push @tableRows, $row; |
691 | push @tableRows, $row; |
| 692 | } |
692 | } |
| 693 | |
693 | |
| 694 | my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions"; |
694 | my $numIncorrectNoun = scalar @answerNames == 1 ? "question" : "questions"; |
| 695 | my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100); |
695 | my $scorePercent = sprintf("%.0f%%", $problemResult->{score} * 100); |
| 696 | my $summary = "On this attempt, you answered $numCorrect out of " |
696 | my $summary = "On this attempt, you answered $numCorrect out of " |
| 697 | . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; |
697 | . scalar @answerNames . " $numIncorrectNoun correct, for a score of $scorePercent."; |
| 698 | return CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) . ($showSummary ? CGI::p($summary) : ""); |
698 | return CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) . ($showSummary ? CGI::p($summary) : ""); |
| 699 | } |
699 | } |
| 700 | |
700 | sub nbsp { |
|
|
701 | my $str = shift; |
|
|
702 | ($str) ? $str : ' '; # returns non-breaking space for empty strings |
|
|
703 | } |
| 701 | sub viewOptions($) { |
704 | sub viewOptions($) { |
| 702 | my $self = shift; |
705 | my $self = shift; |
| 703 | my $displayMode = $self->{displayMode}; |
706 | my $displayMode = $self->{displayMode}; |
| 704 | my %must = %{ $self->{must} }; |
707 | my %must = %{ $self->{must} }; |
| 705 | my %can = %{ $self->{can} }; |
708 | my %can = %{ $self->{can} }; |