| … | |
… | |
| 2367 | my $string = shift; |
2367 | my $string = shift; |
| 2368 | $string =~ s/\n/$BR/ge; |
2368 | $string =~ s/\n/$BR/ge; |
| 2369 | $string; |
2369 | $string; |
| 2370 | } |
2370 | } |
| 2371 | |
2371 | |
| 2372 | # these next two subroutines show how to modify the "store_and_at()" answer |
2372 | # these next three subroutines show how to modify the "store_ans_at()" answer |
| 2373 | # evaluator to add extra information before storing the info |
2373 | # evaluator to add extra information before storing the info |
| 2374 | # They provide a good model for how to tweak answer evaluators in special cases. |
2374 | # They provide a good model for how to tweak answer evaluators in special cases. |
| 2375 | |
2375 | |
| 2376 | sub anstext { |
2376 | sub anstext { |
| 2377 | my $num = shift; |
2377 | my $num = shift; |
| … | |
… | |
| 2403 | $out; |
2403 | $out; |
| 2404 | }; |
2404 | }; |
| 2405 | |
2405 | |
| 2406 | $ans_eval; |
2406 | $ans_eval; |
| 2407 | } |
2407 | } |
|
|
2408 | |
|
|
2409 | sub anstext_non_anonymous { |
|
|
2410 | ## this emails identifying information |
|
|
2411 | my $num = shift; |
|
|
2412 | my $ans_eval_template = store_ans_at(\$QUESTIONNAIRE_ANSWERS); |
|
|
2413 | my $ans_eval = sub { |
|
|
2414 | my $text = shift; |
|
|
2415 | $text = '' unless defined($text); |
|
|
2416 | my $new_text = "\n$main::psvnNumber-Problem-$main::probNum-Question-$num:\n$main::studentLogin $main::studentID $main::studentName\n$text "; # modify entered text |
|
|
2417 | my $out = &$ans_eval_template($new_text); # standard evaluator |
|
|
2418 | #warn "$QUESTIONNAIRE_ANSWERS"; |
|
|
2419 | $out->{student_ans} = escapeHTML($text); # restore original entered text |
|
|
2420 | $out->{correct_ans} = "Question $num answered"; |
|
|
2421 | $out->{original_student_ans} = escapeHTML($text); |
|
|
2422 | $out; |
|
|
2423 | }; |
|
|
2424 | $ans_eval; |
|
|
2425 | } |
|
|
2426 | |
| 2408 | |
2427 | |
| 2409 | # This is another example of how to modify an answer evaluator to obtain |
2428 | # This is another example of how to modify an answer evaluator to obtain |
| 2410 | # the desired behavior in a special case. Here the object is to have |
2429 | # the desired behavior in a special case. Here the object is to have |
| 2411 | # have the last answer trigger the send_mail_to subroutine which mails |
2430 | # have the last answer trigger the send_mail_to subroutine which mails |
| 2412 | # all of the answers to the designated address. |
2431 | # all of the answers to the designated address. |