WeBWorK Problems

multiple question statements, figures, and answer checkers in same problem?

multiple question statements, figures, and answer checkers in same problem?

by Katie Evans -
Number of replies: 4
I am trying to code a problem for an assignment, but I want to include some different options so that not all the students in a class have the same basic problem structure, i.e. I want more randomization than just the parameters. I would like to word the problem several different ways, each displayed with a different figure, and each asking the student to answer a slightly different question(s). I am struggling to find a problem structure that would work for the coding of this type of problem. I have located the multiple choice and pop-up list structures, but those do not apply here. Any ideas? Thanks!
In reply to Katie Evans

Re: multiple question statements, figures, and answer checkers in same problem?

by Alex Jordan -
Hi Katie,

You can store test strings in perl, like:
$q[0] = "Find the slope of the line.";
$q[1] = "Find the intercept of the line.";
and now @q is an array with these two strings in it. It will help to understand the difference between single and double quotes. Then you can use randomization to generate the question. If you had also made an answer array:
$a[0] = Compute("$m");
$a[1] = Compute("$b");
you can correlate your question with its answer. When the problem begins, randomly generate an index:
$i = list_random(0..1);
and then use $q[$i] and $a[$i] appropriately. (Warning: you cannot direct refer to array elements using brackets like this if you are using PGML. If you use PGML, which I recommend, then just create $question = $q[$i], $answer = $a[$i]. Also, when using PGML, you may need to post-process your strings by using [$question]* or [$question]** rather than just plain [$question])

Different figures can be handled in the same way. Each can be its own $gr[$i] object.

I'm not entirely sure if this is the kind of answer you were looking for, but I hope it helps.


In reply to Alex Jordan

Re: multiple question statements, figures, and answer checkers in same problem?

by Katie Evans -
Thanks, Alex. Worked great!
In reply to Katie Evans

Re: multiple question statements, figures, and answer checkers in same problem?

by Hedley Pinsent -
I use the case statement a lot.

@caselist = list_random(0,1,2);
foreach $case (@caselist){

if ($case ==0){
... set parameters specific for case 0
} #end of case 0

if ($case ==1){
... set parameters specific for case 1
} #end of case 1

if ($case ==2){
... set parameters specific for case 2
} #end of case 2

In the "histogram.txt" example attached I repeated the if(s) with each of their own BEGIN_TEXT/END_TEXT


Contrary to what I have done in this case, it would have probably been in better form to supply ANS() with answer checkers next to (in the same "loop") where the question ans_rule is asked. They simply need to be paired.

Other examples are found at:
http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2966
http://webwork.maa.org/moodle/mod/forum/discuss.php?d=2799

Note that my thinking tends to be overly procedural: I jumped from fortran 4 with watfour and watfiv to this stuff.

ragards
hp

In reply to Hedley Pinsent

Re: multiple question statements, figures, and answer checkers in same problem?

by Hedley Pinsent -
If you were looking at the above attachment using microsoft it may have been gibberish. It looks fine when browsed with Linux. I know the carriage returns/white spaces are treated differently.

I guess common ground is the .pg form; upload to your server.

attached

hp