Difference between revisions of "Labeled ans rule"

From WeBWorK_wiki
Jump to navigation Jump to search
(from ur manpages)
 
m (LabeledAnsRule moved to Labeled ans rule: consistent naming)
(No difference)

Revision as of 21:16, 18 November 2009

labeled_ans_rule

Description

This enters an answer rule attached to a specific label. This allows more control when matching student answers with answer evaluators

Syntax

labeled_ans_rule(label,width)

Params

The first parameter is the label and is required.
The second parameter is the width of the ans_rule and defaults to 20 (characters) if omitted.

Returns

The HTML (or TeX) code for an answer blank.

Examples


BEGIN_TEXT

Complete the sentence. Hello \{labeled_ans_rule("string_answer",20)\}
4+8 = \{labeled_ans_rule("numerical_answer"\}


END_TEXT
LABELED_ANS("numerical_answer" => num_cmp(12),"string_answer" => str_cmp("World") );

checks that the first answer is "World" and that the second answer is numerically equivalent to 12, despite entering the answer evaluators in an order which does not match the appearance of the answer blanks.

Notes

This is essentially syntactic sugar for "NAMED_ANS_RULE". It provides a default for the width, and labeled_ans_rule seems a more descriptive title than named_answer_rule. The low level (capitalized) subroutines will retain the titles NAMED... for backward compatibility.
The labeled (or NAMED) versions of answer blanks and answer evaluators can be useful in situations where the order of the answer blanks is not obvious.