# MatchingStaticGraphs

Jump to navigation
Jump to search

## Matching Problems That Have Static Graphic Images

*This code shows how to create a matching problem for functions and their graphs.
Students input their answers using drop-down select lists (popup lists).
*

PG problem file | Explanation |
---|---|

DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", ); |
Initialization: We need to include the |

@questions = ( "\( f(x,y) = \displaystyle \frac{1}{x^2 + y^2} \)", "\( f(x,y) = - y^2 \)", "\( f(x,y) = x^3 - \sin(y) \)", "\( f(x,y) = x + 2y + 3 \)", "\( f(x,y) = - e^{-x^2 - y^2} \)", ); @images = ( "12-2-9a.gif", "12-2-9b.gif", "12-2-9c.gif", "12-2-9d.gif", "12-2-9e.gif", ); $n = scalar(@questions); $k = $n; # $k can be less than $n @subset = NchooseK($n,$k); @numq = (1..$k); |
Set-up: Create an array of questions (functions) and another of images. Set $k, the number of questions displayed, manually if you like. This is probably the only section you need to modify. You probably don't want more than five graphs to be displayed. |

@subset_of_questions = @questions[@subset]; @subset_of_images = @images[@subset]; @permutation = NchooseK($k,$k); @shuffled_subset_of_images = @subset_of_images[@permutation]; @captions = @ALPHABET[0..$k-1]; TEXT(beginproblem()); BEGIN_TEXT $BEGIN_ONE_COLUMN Match each function with its graph. If you click on a graph, a larger graph will appear in a new window. $BR$BR END_TEXT for $j (0..$k-1) { BEGIN_TEXT @numq[$j]. \{ pop_up_list(['?', @captions]) \} $SPACE @subset_of_questions[$j] $BR$BR END_TEXT } BEGIN_TEXT \{imageRow(~~@shuffled_subset_of_images,~~@captions)\} $END_ONE_COLUMN END_TEXT |
Main Text: You may modify the instructions if you want. |

$showPartialCorrectAnswers = 0; ANS(str_cmp([@ALPHABET[invert(@permutation)]])); ENDDOCUMENT(); |
Answer Evaluation: You should not need to modify this section at all. |