NAME

PGtextevaluators.pl - Macros that generate answer evaluators that handle questionnaires.

SYNOPSIS

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!

DESCRIPTION

This file contians macros for handling questionnaires. Questionnaires can consist of textual answers and radio buttons, and responses are reported via email.

ANSWER EVALUATORS

anstext

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().

anstext

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().

ansradio

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().

store_ans_at

$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().

[DEPRECATED] mail_answers_to

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.

[DEPRECATED] save_answer_to_file

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.

OTHER MACROS

mail_answers_to2

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

escapeHTML($string)

The misnamed macro returns a copy of $string in which each newline has been replaced with an HTML BR element.

[DEPRECATED] save_questionnaire_answers_to

[DEPRECATED] DUMMY_ANSWER

SEE ALSO

PGanswermacros.pl, UsingMathObjects.