WeBWorK Problems

HTML INPUT(?) for dynamic problem adjustments

Re: HTML INPUT(?) for dynamic problem adjustments

by Michael Gage -
Number of replies: 0
Hi Brian,

I think that only the $inputs_ref variable is being used in this problem. The others are "no longer operative" :-)

To see which variables are available when authoring a webwork question you can use this snippet:


DOCUMENT();
loadMacros("PG.pl",
"PGstandard.pl",
"PGinfo.pl",
);

listVariables();

ENDDOCUMENT();


You can also load PGinfo.pl to any other question while you are authoring or debugging. That file defines the macro listVariables(); as well as listFormVariables(); etc. which are described at http://webwork.maa.org/pod/pg_TRUNK/macros/PGinfo.pl.html

It doesn't show the %in or %inputs hashes but it does show
$inputs_ref -- so I think the latter has replaced the former -- this problem was written in a transition stage where it needed to check in several places for the information it needed.

With that out of the way: answer blanks (and hidden answer blanks) are just HTML input types ( type = "text" or type="hidden") and the author can access the information entered into those blanks using their name as the key for $inputs_ref.

You can reference an answer blank if you give it a name or label

use labeled_ans_rule http://webwork.maa.org/wiki/Labeled_ans_rule

and then

LABELED_ANS();

to evaluate the student response.


(synonyms are NAMED_ANS_RULE and NAMED_ANS() )

(You could also try to guess the label that is automatically produced for ordinary ans_rule() but I discourage this because the method for generating these labels may change from time to time.)

Very interesting problems can be written using these techniques. Since they use some of the deeper internal mechanisms of the PG language these problems might require updating from time to time as we perfect the PG language but I expect to have higher level tools for accessing this information in some later release that will stabilize the situation. Meantime I encourage you to experiment and let us know what works and what doesn't and what additional tools you would like to have since that will guide the development of these higher level tools.

Hope this helped. If not ask again -- it's a nice project.

Take care,

Mike