Difference between revisions of "PopUpListsLong"
(New page: <h2>Pop-Up Lists That Are Long: PG Code Snippet</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This code snippet shows the PG code to create lengthy pop...) |
|||
Line 46: | Line 46: | ||
<td style="background-color:#ffffcc;padding:7px;"> |
<td style="background-color:#ffffcc;padding:7px;"> |
||
<p> |
<p> |
||
− | Set-up: An array in which questions alternate with answers. |
+ | Set-up: An array in which questions alternate with answers. This is the only part of this example that needs to be modified. Answers can be any string. |
</p> |
</p> |
||
</td> |
</td> |
||
Line 62: | Line 62: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | Instructions and Question for all parts: self explanatory. |
||
+ | Instructions and Question for all parts: Modify the instructions if you want. You should give what the possible answers are here so that students who have a pdf hardcopy / paper-copy can work directly from it. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 87: | Line 87: | ||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
− | Main Text and Answer Evaluation: Shuffle the order of the questions, then use a for loop to generate one question and answer for each pair in the array @questions_and_answers. |
+ | Main Text and Answer Evaluation: Shuffle the order of the questions, then use a for loop to generate one question and answer evaluator for each pair in the array @questions_and_answers. You can change the pop-up list options ['?','True','False'] to any number of strings you want. |
</p> |
</p> |
||
</td> |
</td> |
Revision as of 10:59, 19 October 2009
Pop-Up Lists That Are Long: PG Code Snippet
This code snippet shows the PG code to create lengthy pop-up lists in a WeBWorK problem. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGstandard.pl", "PGcourse.pl", "PGchoicemacros.pl", ); TEXT(beginproblem); |
Initialization: We need to include the |
@questions_and_answers = ( "Larry is one of the three stooges.","True", "\(\pi\) is rational","False", "Gandalf is one of the three stooges.","False" ); |
Set-up: An array in which questions alternate with answers. This is the only part of this example that needs to be modified. Answers can be any string. |
BEGIN_TEXT Are the following statements true or false? $PAR END_TEXT |
Instructions and Question for all parts: Modify the instructions if you want. You should give what the possible answers are here so that students who have a pdf hardcopy / paper-copy can work directly from it. |
$n = scalar(@questions_and_answers)/2; @shuffle = shuffle($n); @abc = (a..z); for $jj (0..$n-1) { $j = $shuffle[$jj]; BEGIN_TEXT @abc[$jj]. \{ pop_up_list(['?', 'True', 'False']) \} $SPACE $questions_and_answers[2*$j] $BR$BR END_TEXT ANS(str_cmp($questions_and_answers[2*$j+1], filters=>["trim_whitespace","compress_whitespace"])); } ENDDOCUMENT(); |
Main Text and Answer Evaluation: Shuffle the order of the questions, then use a for loop to generate one question and answer evaluator for each pair in the array @questions_and_answers. You can change the pop-up list options ['?','True','False'] to any number of strings you want. |