| … | |
… | |
| 207 | my @incorrect_ids = (); |
207 | my @incorrect_ids = (); |
| 208 | |
208 | |
| 209 | |
209 | |
| 210 | my $problemResult = $pg->{result}; # the overall result of the problem |
210 | my $problemResult = $pg->{result}; # the overall result of the problem |
| 211 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
211 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
| 212 | |
212 | #warn "answer names are ", join(" ", @answerNames); |
| 213 | my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; |
213 | my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; |
| 214 | |
214 | |
| 215 | my $basename = "equation-" . $self->{set}->psvn. "." . $self->{problem}->problem_id . "-preview"; |
215 | my $basename = "equation-" . $self->{set}->psvn. "." . $self->{problem}->problem_id . "-preview"; |
| 216 | |
216 | |
| 217 | # to make grabbing these options easier, we'll pull them out now... |
217 | # to make grabbing these options easier, we'll pull them out now... |
| … | |
… | |
| 257 | my $resultString = $answerScore >= 1 ? CGI::span({class=>"ResultsWithoutError"}, "correct") : |
257 | my $resultString = $answerScore >= 1 ? CGI::span({class=>"ResultsWithoutError"}, "correct") : |
| 258 | $answerScore > 0 ? int($answerScore*100)."% correct" : |
258 | $answerScore > 0 ? int($answerScore*100)."% correct" : |
| 259 | CGI::span({class=>"ResultsWithError"}, "incorrect"); |
259 | CGI::span({class=>"ResultsWithError"}, "incorrect"); |
| 260 | $fully = 'completely ' if $answerScore >0 and $answerScore < 1; |
260 | $fully = 'completely ' if $answerScore >0 and $answerScore < 1; |
| 261 | |
261 | |
|
|
262 | #warn "answer $name score $answerScore"; |
| 262 | push @correct_ids, $name if $answerScore == 1; |
263 | push @correct_ids, $name if $answerScore == 1; |
| 263 | push @incorrect_ids, $name if $answerScore < 1; |
264 | push @incorrect_ids, $name if $answerScore < 1; |
| 264 | |
265 | |
| 265 | # get rid of the goofy prefix on the answer names (supposedly, the format |
266 | # need to capture auxiliary answers as well and identify their ids. |
| 266 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
267 | |
| 267 | #$name =~ s/^AnSwEr//; |
|
|
| 268 | |
268 | |
| 269 | my $row; |
269 | my $row; |
| 270 | #$row .= CGI::td($name); |
270 | #$row .= CGI::td($name); |
| 271 | #$row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; |
271 | #$row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; |
| 272 | $row .= $showAttemptPreview ? CGI::td({onmouseover=>qq!Tip('$studentAnswer',SHADOW, true, |
272 | $row .= $showAttemptPreview ? CGI::td({onmouseover=>qq!Tip('$studentAnswer',SHADOW, true, |
| … | |
… | |
| 300 | } |
300 | } |
| 301 | } else { |
301 | } else { |
| 302 | if ($numCorrect == scalar @answerNames) { |
302 | if ($numCorrect == scalar @answerNames) { |
| 303 | $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the answers above are correct."); |
303 | $summary .= CGI::div({class=>"ResultsWithoutError"},"All of the answers above are correct."); |
| 304 | } |
304 | } |
|
|
305 | #unless ($numCorrect + $numBlanks == scalar( @answerNames)) { # this allowed you to figure out if you got one answer right. |
| 305 | unless ($numCorrect + $numBlanks == scalar( @answerNames)) { |
306 | elsif ($numBlanks != scalar( @answerNames)) { |
| 306 | $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the answers above is NOT ${fully}correct."); |
307 | $summary .= CGI::div({class=>"ResultsWithError"},"At least one of the answers above is NOT ${fully}correct."); |
| 307 | } |
308 | } |
| 308 | if ($numBlanks) { |
309 | if ($numBlanks) { |
| 309 | my $s = ($numBlanks>1)?'':'s'; |
310 | my $s = ($numBlanks>1)?'':'s'; |
| 310 | $summary .= CGI::div({class=>"ResultsAlert"},"$numBlanks of the questions remain$s unanswered."); |
311 | $summary .= CGI::div({class=>"ResultsAlert"},"$numBlanks of the questions remain$s unanswered."); |
| … | |
… | |
| 1094 | ########################### |
1095 | ########################### |
| 1095 | # always show colors for checkAnswers |
1096 | # always show colors for checkAnswers |
| 1096 | # show colors for submit answer if |
1097 | # show colors for submit answer if |
| 1097 | if (($self->{checkAnswers}) or ($self->{submitAnswers} and $pg->{flags}->{showPartialCorrectAnswers}) ) { |
1098 | if (($self->{checkAnswers}) or ($self->{submitAnswers} and $pg->{flags}->{showPartialCorrectAnswers}) ) { |
| 1098 | print CGI::start_style({type=>"text/css"}); |
1099 | print CGI::start_style({type=>"text/css"}); |
|
|
1100 | #FIXME -- this hack is no longer needed? |
|
|
1101 | # my $string =""; |
|
|
1102 | # foreach my $ans_name (@{ $self->{correct_ids} }) { |
|
|
1103 | # $string .= '#'. ( $ans_name ). $ce->{pg}{options}{correct_answer}."\n"; |
|
|
1104 | # } |
|
|
1105 | # print $string; |
|
|
1106 | # $string =""; |
|
|
1107 | # foreach my $ans_name (@{ $self->{incorrect_ids} }) { |
|
|
1108 | # $string .= '#'. ($ ans_name). $ce->{pg}{options}{incorrect_answer}."\n"; |
|
|
1109 | # } |
|
|
1110 | # print $string; |
|
|
1111 | # the above method keeps one bad array ID from ruining all of the assignments. |
| 1099 | print '#'.join(', #', @{ $self->{correct_ids} }), $ce->{pg}{options}{correct_answer} if ref( $self->{correct_ids} )=~/ARRAY/; #correct green |
1112 | print '#'.join(', #', @{ $self->{correct_ids} }), $ce->{pg}{options}{correct_answer},"\n" if ref( $self->{correct_ids} )=~/ARRAY/; #correct green |
| 1100 | print '#'.join(', #', @{ $self->{incorrect_ids} }), $ce->{pg}{options}{incorrect_answer} if ref( $self->{incorrect_ids})=~/ARRAY/; #incorrect reddish |
1113 | print '#'.join(', #', @{ $self->{incorrect_ids} }), $ce->{pg}{options}{incorrect_answer},"\n" if ref( $self->{incorrect_ids})=~/ARRAY/; #incorrect reddish |
| 1101 | print CGI::end_style(); |
1114 | print CGI::end_style(); |
| 1102 | } |
1115 | } |
| 1103 | |
1116 | |
| 1104 | ########################### |
1117 | ########################### |
| 1105 | # main form |
1118 | # main form |