PGtextevaluators.pl - Macros that generate answer evaluators that handle questionnaires.
BEGIN_TEXT
WeBWorK is great.
\{ ans_radio_buttons(1=>"Agree",2=>"Disagree") \}
$PAR
If you disagree, why?
\{ ans_rule() \}
END_TEXT
ANS(ansradio(1));
ANS(anstext(2));
# FIXME show how to make a grader that sends email here!
This file contians macros for handling questionnaires. Questionnaires can consist of textual answers and radio buttons, and responses are reported via email.
ANS(anstext($num))
anstext() returns an answer evaluator which records the student's answer to a free-response question in the variable $QUESTIONNAIRE_ANSWERS for later retrieval. A header is added to the answer before it is added. The header format is:
"\n${setNumber}_${courseName}_$psvn-Problem-$probNum-Question-$num:\n"
Where $num is the argument passed to anstext().
To send the accumulated answers to the instructor via email, use mail_answers_to2().
ANS(anstext_non_anonymous($num))
anstext_non_anonymous() works like anstext(), except that the header added to the student's answer includes personally identifying information:
\n$psvn-Problem-$probNum-Question-$num:\n
$studentLogin $studentID $studentName\n
Where $num is the argument passed to anstext_non_anonymous().
ANS(ansradio($num))
ansradio() returns an answer evaluator which records the student's answer to a multiple-choice question in the variable $QUESTIONNAIRE_ANSWERS for later retrieval. A header is added to the answer before it is added. The header format is:
"\n$psvn-Problem-$probNum-RADIO-$num:\n"
Where $num is the question number passed to ansradio().
To send the accumulated answers to the instructor via email, use mail_answers_to2().
$answer = "";
ANS(store_ans_at(\$answer));
TEXT("Stored answer: '$answer');
Generates an answer evaluator which appends the student's answer to a scalar variable. In addition, the score for the answer is always set to 1. This macro is used internally by anstext(), anstest_non_anonymous(), and ans_radio().
ANS(mail_answers_to($to_address))
Returns an answer evaluator which accepts the last answer and then mails the answer to $to_address. It is unsupported and may not even work.
Use a normal textans() answer evaluator and mail_answers_to2() instead.
Returns an answer evaluator which accepts the last answer and then stores the answer to a file. It is unsupported and may not even work.
mail_answers_to2($to, $subject);
Sends the text accumulated in $QUESTIONNAIRE_ANSWERS to the address specified in $to. The email is given the subject line $subject.
The mail message is not sent right away; instead, the message is recorded and sent by WeBWorK after PG rendering has completed.
escapeHTML($string)
The misnamed macro returns a copy of $string in which each newline has been replaced with an HTML BR element.