| … | |
… | |
| 158 | my $allAnswersCorrectQ = 1; |
158 | my $allAnswersCorrectQ = 1; |
| 159 | my $printedResponse=''; |
159 | my $printedResponse=''; |
| 160 | ###### Print appropriate response to submitted answers |
160 | ###### Print appropriate response to submitted answers |
| 161 | my ($i,$answerIsCorrectQ, $normalizedSubmittedAnswer,$normalizedCorrectAnswer,$ans_name,$errors); |
161 | my ($i,$answerIsCorrectQ, $normalizedSubmittedAnswer,$normalizedCorrectAnswer,$ans_name,$errors); |
| 162 | $i=0; |
162 | $i=0; |
| 163 | $printedResponse .= "\n<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"#cccccc\">\n"; |
163 | # $printedResponse .= "\n<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"#cccccc\">\n"; |
|
|
164 | # replace above line by next two lines as per Davide Cervone. AKP. |
|
|
165 | $printedResponse .= "\n<table border=0 cellpadding=7 cellspacing=0 bgcolor=\"#cccccc\">\n"; |
|
|
166 | $printedResponse .= "<tr><td><table border=0 cellpadding=0 cellspacing=0>\n"; |
| 164 | foreach my $key ( @answer_entry_order ) { |
167 | foreach my $key ( @answer_entry_order ) { |
| 165 | |
168 | |
| 166 | $i++; |
169 | $i++; |
| 167 | $answerIsCorrectQ = $rh_answer_results ->{$key} -> {score}; |
170 | $answerIsCorrectQ = $rh_answer_results ->{$key} -> {score}; |
| 168 | $normalizedSubmittedAnswer = $rh_answer_results ->{$key} -> {student_ans}; |
171 | $normalizedSubmittedAnswer = $rh_answer_results ->{$key} -> {student_ans}; |
| … | |
… | |
| 181 | $ans_name = $i; # just number the answers in order |
184 | $ans_name = $i; # just number the answers in order |
| 182 | $allAnswersCorrectQ = $allAnswersCorrectQ && $answerIsCorrectQ; |
185 | $allAnswersCorrectQ = $allAnswersCorrectQ && $answerIsCorrectQ; |
| 183 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><em>Answer $ans_name entered:</em>--> $normalizedSubmittedAnswer <-- "; |
186 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><em>Answer $ans_name entered:</em>--> $normalizedSubmittedAnswer <-- "; |
| 184 | $printedResponse .= "<B>Correct. </B></TD></TR>" if ($answerIsCorrectQ && $showPartialCorrectAnswers ); |
187 | $printedResponse .= "<B>Correct. </B></TD></TR>" if ($answerIsCorrectQ && $showPartialCorrectAnswers ); |
| 185 | $printedResponse .= "<B>Incorrect. </B></TD></TR>" if (!($answerIsCorrectQ) && $showPartialCorrectAnswers); |
188 | $printedResponse .= "<B>Incorrect. </B></TD></TR>" if (!($answerIsCorrectQ) && $showPartialCorrectAnswers); |
|
|
189 | $errors =~ s/\n/<BR>/g; ## convert newlines to <BR> in error messages as per Davide Cervone |
| 186 | # change 9/2/00 by MEG -- give width in pixels rather than %. |
190 | # change 9/2/00 by MEG -- give width in pixels rather than %. |
| 187 | # Some browsers break with % widht which is not the standard |
191 | # Some browsers break with % widht which is not the standard |
| 188 | $printedResponse .= "\n<TR> <TD align=left WIDTH = \"50\" ></TD><TD align=left>$errors</TD></TR>" if ($errors =~ /\w/); |
192 | $printedResponse .= "\n<TR> <TD align=left WIDTH = \"50\" > </TD><TD align=left>$errors</TD></TR>" if ($errors =~ /\w/); |
| 189 | |
193 | |
| 190 | $printedResponse .= "\n<TR><TD align=left WIDTH = \"50\"></TD> <TD align=left><em>Correct answer:</em> $normalizedCorrectAnswer</TD></TR>" if ($displayCorrectAnswersQ); |
194 | $printedResponse .= "\n<TR><TD align=left WIDTH = \"50\"> </TD> <TD align=left><em>Correct answer:</em> $normalizedCorrectAnswer</TD></TR>" if ($displayCorrectAnswersQ); |
| 191 | |
195 | |
| 192 | } |
196 | } |
| 193 | if ($i == 1) { |
197 | if ($i == 1) { |
| 194 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>The above answer is correct.</B><BR>" if ($allAnswersCorrectQ); |
198 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>The above answer is correct.</B><BR>" if ($allAnswersCorrectQ); |
| 195 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>The above answer is NOT correct.</B><BR>" if (!($allAnswersCorrectQ)); |
199 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>The above answer is NOT correct.</B><BR>" if (!($allAnswersCorrectQ)); |
| … | |
… | |
| 199 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>At least one of the above answers is NOT correct.</B><BR>" if (!($allAnswersCorrectQ)); |
203 | $printedResponse .= "\n<TR><TD align=left COLSPAN =2><B>At least one of the above answers is NOT correct.</B><BR>" if (!($allAnswersCorrectQ)); |
| 200 | } |
204 | } |
| 201 | my $percentCorr = int(100*$rh_problem_result->{score} +.5); |
205 | my $percentCorr = int(100*$rh_problem_result->{score} +.5); |
| 202 | |
206 | |
| 203 | $printedResponse .="\n<TR><TD align=left COLSPAN =2><B>Your score on this attempt is ${percentCorr}\%.</B><BR>"; |
207 | $printedResponse .="\n<TR><TD align=left COLSPAN =2><B>Your score on this attempt is ${percentCorr}\%.</B><BR>"; |
| 204 | $printedResponse .= "\n</table>\n"; |
208 | # $printedResponse .= "\n</table>\n"; |
|
|
209 | # replace above line by next line as per Davide Cervone. AKP. |
|
|
210 | $printedResponse .= "</td></tr>\n</table>\n</table>\n"; |
| 205 | # $printedResponse .="\n problem grader is ".$rh_problem_result->{type}." and the score is ".$rh_problem_result->{score}."<BR>\n"; |
211 | # $printedResponse .="\n problem grader is ".$rh_problem_result->{type}." and the score is ".$rh_problem_result->{score}."<BR>\n"; |
| 206 | $printedResponse; |
212 | $printedResponse; |
| 207 | } |
213 | } |
| 208 | |
214 | |
| 209 | ########################################################################################### |
215 | ########################################################################################### |
| … | |
… | |
| 226 | $ans_name = $rh_answer_results ->{$key} -> {ans_name}; |
232 | $ans_name = $rh_answer_results ->{$key} -> {ans_name}; |
| 227 | #$ans_name =~ s/$ANSWER_PREFIX//; # this handles implicitly defined answer names. #commented out by DME 6/6/2000 |
233 | #$ans_name =~ s/$ANSWER_PREFIX//; # this handles implicitly defined answer names. #commented out by DME 6/6/2000 |
| 228 | $original_student_ans = $rh_answer_results ->{$key} -> {original_student_ans}; |
234 | $original_student_ans = $rh_answer_results ->{$key} -> {original_student_ans}; |
| 229 | $normalizedSubmittedAnswer = $rh_answer_results ->{$key} -> {student_ans}; |
235 | $normalizedSubmittedAnswer = $rh_answer_results ->{$key} -> {student_ans}; |
| 230 | $errors = $rh_answer_results ->{$key} -> {ans_message}; |
236 | $errors = $rh_answer_results ->{$key} -> {ans_message}; |
|
|
237 | $errors =~ s/\n/<BR>/g; ## convert newlines to <BR> in error messages as per Davide Cervone |
| 231 | $preview_text_string =''; |
238 | $preview_text_string =''; |
| 232 | $preview_text_string = $rh_answer_results ->{$key} -> {preview_text_string} |
239 | $preview_text_string = $rh_answer_results ->{$key} -> {preview_text_string} |
| 233 | if defined $rh_answer_results ->{$key} -> {preview_text_string}; |
240 | if defined $rh_answer_results ->{$key} -> {preview_text_string}; |
| 234 | $preview_latex_string =''; |
241 | $preview_latex_string =''; |
| 235 | $preview_latex_string = $rh_answer_results ->{$key} -> {preview_latex_string} |
242 | $preview_latex_string = $rh_answer_results ->{$key} -> {preview_latex_string} |