Difference between revisions of "Labeled ans rule"

From WeBWorK_wiki
Jump to navigation Jump to search
m (LabeledAnsRule moved to Labeled ans rule: consistent naming)
m (Added missing ')' in the Example)
 
Line 19: Line 19:
 
'''Examples'''
 
'''Examples'''
   
<blockquote><code><br /> BEGIN_TEXT<blockquote> Complete the sentence. Hello \{labeled_ans_rule("string_answer",20)\}<br /> 4+8 = \{labeled_ans_rule("numerical_answer"\}</blockquote><br /> END_TEXT<br /> LABELED_ANS("numerical_answer" =&gt; num_cmp(12),"string_answer" =&gt; str_cmp("World") ); <br /></code><br /> 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.</blockquote>
+
<blockquote><code><br /> BEGIN_TEXT<blockquote> Complete the sentence. Hello \{labeled_ans_rule("string_answer",20)\}<br /> 4+8 = \{labeled_ans_rule("numerical_answer")\}</blockquote><br /> END_TEXT<br /> LABELED_ANS("numerical_answer" =&gt; num_cmp(12),"string_answer" =&gt; str_cmp("World") ); <br /></code><br /> 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.</blockquote>
   
 
'''Notes'''
 
'''Notes'''

Latest revision as of 03:32, 30 December 2011

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.