| … | |
… | |
| 200 | my $showSummary = shift; |
200 | my $showSummary = shift; |
| 201 | my $showAttemptPreview = shift || 0; |
201 | my $showAttemptPreview = shift || 0; |
| 202 | |
202 | |
| 203 | my $ce = $self->r->ce; |
203 | my $ce = $self->r->ce; |
| 204 | |
204 | |
|
|
205 | # for color coding the responses. |
|
|
206 | my @correct_ids = (); |
|
|
207 | my @incorrect_ids = (); |
|
|
208 | |
|
|
209 | |
| 205 | my $problemResult = $pg->{result}; # the overall result of the problem |
210 | my $problemResult = $pg->{result}; # the overall result of the problem |
| 206 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
211 | my @answerNames = @{ $pg->{flags}->{ANSWER_ENTRY_ORDER} }; |
| 207 | |
212 | |
| 208 | my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; |
213 | my $showMessages = $showAttemptAnswers && grep { $pg->{answers}->{$_}->{ans_message} } @answerNames; |
| 209 | |
214 | |
| … | |
… | |
| 224 | dvipng_depth_db => $imagesModeOptions{dvipng_depth_db}, |
229 | dvipng_depth_db => $imagesModeOptions{dvipng_depth_db}, |
| 225 | ); |
230 | ); |
| 226 | |
231 | |
| 227 | my $header; |
232 | my $header; |
| 228 | #$header .= CGI::th("Part"); |
233 | #$header .= CGI::th("Part"); |
| 229 | $header .= $showAttemptAnswers ? CGI::th("Entered") : ""; |
234 | #$header .= $showAttemptAnswers ? CGI::th("Entered") : ""; |
| 230 | $header .= $showAttemptPreview ? CGI::th("Answer Preview") : ""; |
235 | $header .= $showAttemptPreview ? CGI::th("Answer Preview") : ""; |
| 231 | $header .= $showCorrectAnswers ? CGI::th("Correct") : ""; |
236 | $header .= $showCorrectAnswers ? CGI::th("Correct") : ""; |
| 232 | $header .= $showAttemptResults ? CGI::th("Result") : ""; |
237 | $header .= $showAttemptResults ? CGI::th("Result") : ""; |
| 233 | $header .= $showMessages ? CGI::th("Messages") : ""; |
238 | $header .= $showMessages ? CGI::th("Messages") : ""; |
| 234 | my $fully = ''; |
239 | my $fully = ''; |
| … | |
… | |
| 247 | my $answerScore = $answerResult->{score}; |
252 | my $answerScore = $answerResult->{score}; |
| 248 | my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; |
253 | my $answerMessage = $showMessages ? $answerResult->{ans_message} : ""; |
| 249 | $answerMessage =~ s/\n/<BR>/g; |
254 | $answerMessage =~ s/\n/<BR>/g; |
| 250 | $numCorrect += $answerScore >= 1; |
255 | $numCorrect += $answerScore >= 1; |
| 251 | $numBlanks++ unless $studentAnswer =~/\S/ || $answerScore >= 1; # unless student answer contains entry |
256 | $numBlanks++ unless $studentAnswer =~/\S/ || $answerScore >= 1; # unless student answer contains entry |
| 252 | my $resultString = $answerScore >= 1 ? "correct" : |
257 | my $resultString = $answerScore >= 1 ? CGI::span({class=>"ResultsWithoutError"}, "correct") : |
| 253 | $answerScore > 0 ? int($answerScore*100)."% correct" : |
258 | $answerScore > 0 ? int($answerScore*100)."% correct" : |
| 254 | "incorrect"; |
259 | CGI::span({class=>"ResultsWithError"}, "incorrect"); |
| 255 | $fully = 'completely ' if $answerScore >0 and $answerScore < 1; |
260 | $fully = 'completely ' if $answerScore >0 and $answerScore < 1; |
|
|
261 | |
|
|
262 | push @correct_ids, $name if $answerScore == 1; |
|
|
263 | push @incorrect_ids, $name if $answerScore < 1; |
| 256 | |
264 | |
| 257 | # get rid of the goofy prefix on the answer names (supposedly, the format |
265 | # get rid of the goofy prefix on the answer names (supposedly, the format |
| 258 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
266 | # of the answer names is changeable. this only fixes it for "AnSwEr" |
| 259 | #$name =~ s/^AnSwEr//; |
267 | #$name =~ s/^AnSwEr//; |
| 260 | |
268 | |
| 261 | my $row; |
269 | my $row; |
| 262 | #$row .= CGI::td($name); |
270 | #$row .= CGI::td($name); |
| 263 | $row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; |
271 | #$row .= $showAttemptAnswers ? CGI::td($self->nbsp($studentAnswer)) : ""; |
| 264 | $row .= $showAttemptPreview ? CGI::td({onmouseover=>qq!Tip('$studentAnswer',SHADOW, true, |
272 | $row .= $showAttemptPreview ? CGI::td({onmouseover=>qq!Tip('$studentAnswer',SHADOW, true, |
| 265 | DELAY, 1000, FADEIN, 300, FADEOUT, 300, STICKY, 1, OFFSETX, -20, CLOSEBTN, true, CLICKCLOSE, false, |
273 | DELAY, 1000, FADEIN, 300, FADEOUT, 300, STICKY, 1, OFFSETX, -20, CLOSEBTN, true, CLICKCLOSE, false, |
| 266 | BGCOLOR, '#F4FF91', TITLE, 'Entered:',TITLEBGCOLOR, '#F4FF91', TITLEFONTCOLOR, '#000000')!}, |
274 | BGCOLOR, '#F4FF91', TITLE, 'Entered:',TITLEBGCOLOR, '#F4FF91', TITLEFONTCOLOR, '#000000')!}, |
| 267 | $self->nbsp($preview)) : ""; |
275 | $self->nbsp($preview)) : ""; |
| 268 | $row .= $showCorrectAnswers ? CGI::td({onmouseover=> qq!Tip('$correctAnswer',SHADOW, true, |
276 | $row .= $showCorrectAnswers ? CGI::td({onmouseover=> qq!Tip('$correctAnswer',SHADOW, true, |
| … | |
… | |
| 303 | } |
311 | } |
| 304 | } |
312 | } |
| 305 | } else { |
313 | } else { |
| 306 | $summary = $problemResult->{summary}; # summary has been defined by grader |
314 | $summary = $problemResult->{summary}; # summary has been defined by grader |
| 307 | } |
315 | } |
|
|
316 | |
|
|
317 | $self->{correct_ids}=[@correct_ids] if @correct_ids; |
|
|
318 | $self->{incorrect_ids} = [@incorrect_ids] if @incorrect_ids; |
|
|
319 | |
| 308 | return |
320 | return |
| 309 | CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) |
321 | CGI::table({-class=>"attemptResults"}, CGI::Tr(\@tableRows)) |
| 310 | . ($showSummary ? CGI::p({class=>'attemptResultsSummary'},$summary) : ""); |
322 | . ($showSummary ? CGI::p({class=>'attemptResultsSummary'},$summary) : ""); |
| 311 | } |
323 | } |
| 312 | |
324 | |
| … | |
… | |
| 865 | my $db = $r->db; |
877 | my $db = $r->db; |
| 866 | my $authz = $r->authz; |
878 | my $authz = $r->authz; |
| 867 | my $urlpath = $r->urlpath; |
879 | my $urlpath = $r->urlpath; |
| 868 | my $user = $r->param('user'); |
880 | my $user = $r->param('user'); |
| 869 | my $effectiveUser = $r->param('effectiveUser'); |
881 | my $effectiveUser = $r->param('effectiveUser'); |
| 870 | |
|
|
| 871 | if ( $self->{invalidSet} ) { |
882 | if ( $self->{invalidSet} ) { |
| 872 | return CGI::div({class=>"ResultsWithError"}, |
883 | return CGI::div({class=>"ResultsWithError"}, |
| 873 | CGI::p("The selected problem set (" . |
884 | CGI::p("The selected problem set (" . |
| 874 | $urlpath->arg("setID") . ") is not " . |
885 | $urlpath->arg("setID") . ") is not " . |
| 875 | "a valid set for $effectiveUser:"), |
886 | "a valid set for $effectiveUser:"), |
| … | |
… | |
| 1031 | } |
1042 | } |
| 1032 | |
1043 | |
| 1033 | debug("end answer processing"); |
1044 | debug("end answer processing"); |
| 1034 | ##### javaScripts ############# |
1045 | ##### javaScripts ############# |
| 1035 | my $site_url = $ce->{webworkURLs}->{htdocs}; |
1046 | my $site_url = $ce->{webworkURLs}->{htdocs}; |
| 1036 | print qq!<script type="text/javascript" src="$site_url/js/wz_tooltip.js"></script>!; |
1047 | print CGI::start_script({type=>"text/javascript", src=>"$site_url/js/wz_tooltip.js"}), CGI::end_script(); |
| 1037 | |
1048 | |
| 1038 | |
|
|
| 1039 | ##### output ##### |
1049 | ##### output ##### |
| 1040 | # custom message for editor |
1050 | # custom message for editor |
| 1041 | if ($authz->hasPermissions($user, "modify_problem_sets") and defined $editMode) { |
1051 | if ($authz->hasPermissions($user, "modify_problem_sets") and defined $editMode) { |
| 1042 | if ($editMode eq "temporaryFile") { |
1052 | if ($editMode eq "temporaryFile") { |
| 1043 | print CGI::p(CGI::div({class=>'temporaryFile'}, "Viewing temporary file: ", $problem->source_file)); |
1053 | print CGI::p(CGI::div({class=>'temporaryFile'}, "Viewing temporary file: ", $problem->source_file)); |
| … | |
… | |
| 1076 | # show attempt previews |
1086 | # show attempt previews |
| 1077 | } |
1087 | } |
| 1078 | |
1088 | |
| 1079 | print CGI::end_div(); |
1089 | print CGI::end_div(); |
| 1080 | |
1090 | |
|
|
1091 | |
|
|
1092 | ########################### |
|
|
1093 | # print style sheet for correct and incorrect answers |
|
|
1094 | ########################### |
|
|
1095 | |
|
|
1096 | print CGI::start_style({type=>"text/css"}); |
|
|
1097 | print '#'.join(', #', @{ $self->{correct_ids} }), "{background-color:#8F8;}" if ref( $self->{correct_ids} )=~/ARRAY/; #green |
|
|
1098 | print '#'.join(', #', @{ $self->{incorrect_ids} }), "{background-color:#FA0;}" if ref( $self->{incorrect_ids})=~/ARRAY/; #orange |
|
|
1099 | print CGI::end_style(); |
|
|
1100 | |
|
|
1101 | ########################### |
| 1081 | # main form |
1102 | # main form |
|
|
1103 | ########################### |
| 1082 | print "\n"; |
1104 | print "\n"; |
| 1083 | print CGI::start_form(-method=>"POST", -action=> $r->uri,-name=>"problemMainForm", onsubmit=>"submitAction()"); |
1105 | print CGI::start_form(-method=>"POST", -action=> $r->uri,-name=>"problemMainForm", onsubmit=>"submitAction()"); |
| 1084 | print $self->hidden_authen_fields; |
1106 | print $self->hidden_authen_fields; |
| 1085 | print "\n"; |
1107 | print "\n"; |
| 1086 | print CGI::start_div({class=>"problem"}); |
1108 | print CGI::start_div({class=>"problem"}); |