Forum archive 2000-2006

Michael Gage - Managing answers

Michael Gage - Managing answers

by Arnold Pizer -
Number of replies: 0
inactiveTopicManaging answers topic started 5/11/2000; 8:26:59 AM
last post 6/28/2000; 4:33:13 PM
userMichael Gage - Managing answers  blueArrow
5/11/2000; 8:26:59 AM (reads: 3482, responses: 1)

Managing answers

Overview

Three aspects of answers need to be coordinated:
  1. The answer blank

  2. The answer evaluator for the answer blank

  3. The response to the answer provided by WeBWorK when the answer is evaluated.

The answer blank and the answer_evaluator are matched by their labels. There is a provision for implicitly generating labels according to the order in which the answer blanks and answer evaluators are entered, but this is not required.

The answer blank and the response to the answer blank always occur in the same order, the order in which the answer blanks are rendered, which is stored in the flag PG_FLAGS{ANSWER_ENTRY_ORDER} which is returned by ENDDOCUMENT().

Answer blank labels

Every answer blank has a label. When the answer blank is rendered the label is registered in a queue and is also rendered into the HTML form.

Radio buttons and check forms have auxiliary parts (options) which can be printed separately in different parts of the form. Only one of them registers a label. For example: NAMED_ANS_RADIO('answer1'...) will register the label 'answer1' and print a labeled radio button. NAMED_ANS_RADIO_OPTION('answer1',...) ,however,will print a radio button, but will not register a new label.

Keeping the labels unique is the responsibility of the author. No checking is done. The second answer with the same name will overwrite the first.

Order of entry

WeBWorK responds to each answer in the order in which the answer blank appears in the form. This is accomplished using the answer label queue.

This coordinates the answer blanks and the order in which the answer responses appear when WeBWorK responds.

The answers are also evaluated in this order, (the order the answer blanks are rendered), although it may be a bit unreliable to try to rely on this order of evaluation. In general I think it is better if answers are independent of each other in order to minimize surprises when an instructor modifies a question.

Matching labels

The answer blanks and the answer_evaluators are matched by their labels.

The order in which answer_evaluators are processed depends on the order of entry of the answer blanks, not on the order of entry of the answer_evaluators. (But see implicit labeling below.)

This method allows storing answer_evaluators in any order, which may occasionally be convenient.

Implicit labeling

The most common way of entering answer blanks and answer evaluators also depends on the order of entry: Answer blanks without labels and answer_evaluators without labels are stored in the order they are processed on the problem template form and then provided with labels which identify them with each other by the ENDDOCUMENT() subroutine.

These implicitly defined labels all begin with something obscure like AnSwEr... (a prefix which can be set in PG.pl.) Explicitly labeled answer blanks should avoid using this prefix.

Processing answers

All code outside of the PG language sees every answer blank and every answer_evaluator as labeled. These labeled answer blanks and answer_evaluators and the array storing the order in which the answer blanks were rendered, completely determine how the answers will be evaluated. The answer labels themselves are never sorted, and any unique alphanumeric identifiers can be used.

Macros

Answer_evaluators

ANS(ans_eval1, ans_eval2,...)

Stores answer evaluators which will be implicitly labeled by ENDDOCUMENT()

NAMED_ANS(label1 => ans_eval1, label2 => ans_eval2, ...)

Stores labeled answer evaluators. Defined in PG.pl

Answer blanks
Answer rules family ( a single line of text)

ans_rule(length)

Creates an input text field of length characters, generates a number and registers a label (e.g. AnSwEr5).

ANS_RULE(num, length)

Creates an input text field of length characters and registers a label (e.g. AnSwErnum).

NAMED_ANS_RULE(label,length)

Automatically creates an input text field of length characters and registers a label (e.g. label) without adding a prefix.

Area text answers

ans_box(length)

Creates an input text area field of length characters, generates a number and registers a label (e.g. AnSwEr5).

ANS_BOX(num, length)

Creates an input text area field of length characters and registers a label (e.g. AnSwErnum).

NAMED_ANS_BOX(label,length)

Automatically creates an input text area field of length characters and registers a label (e.g. label) without adding a prefix.

Radio button answers

The design is not yet finalized.

Check box answers

The design is not yet finalized.

<| Post or View Comments |>


userDavid Etlinger - Re: Managing answers  blueArrow
6/28/2000; 4:33:13 PM (reads: 2912, responses: 0)
With regards to multi-part answers:

Multipart answers (such as checkboxes) are sent to WeBWorK by the CGI processor in the form of a single string, with "\0" used to delimit different parts. If the individual parts are needed, a statement like @ansParts = split( "\0", $ansAsString ); should be used. Currently, this is only done in l2h_sticky_answers (in displayMacros.pl) and in the checkbox_cmp answer evaluator. The end user should never need to know about this.

Radio buttons:

ans_radio_buttons( "%Name1" => "Label1", "Name2" => "Label2", ... ) Creates a group of radio buttons, only one of which can be selected at a time. The names are used internally to identify the correct answer, and the labels are what are displayed to the student. If one of the names starts with "%", it will be initially selected, otherwise none of them will be.

Checkboxes:

ans_checkbox( "%Name1" => "Label1", "Name2" => "Label2", "%Name3" => "Label3", ... ) Creates a group of checkboxes, none, some, or all of which can be selected at a time. The names are used internally to identify the correct answer(s), and the labels are what are displayed to the student. If one or more of the names starts with a "%", they will be initially selected, otherwise none of them will be.

<| Post or View Comments |>