Difference between revisions of "MatchingStaticGraphs"
m |
(add historical tag and give links to newer problems.) |
||
(15 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | <h2>Matching Problems That Have Static Graphic Images</h2> |
||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/MatchingGraphs.html a newer version of this problem]</p> |
||
+ | |||
+ | <h2>Matching Problems that have Graphic Images</h2> |
||
+ | |||
+ | <p> |
||
+ | There are three different kinds of matching problems with static graphics given here. |
||
+ | </p> |
||
+ | <ul type="square"> |
||
+ | <li><b>Example 1:</b> (Recommended:) Matching functions and static graphs using imageChoice.</li> |
||
+ | <li>(Old:) Matching functions and their graphs without imageChoice.</li> |
||
+ | <li>(Old:) Matching graphs to other graphs without imageChoice.</li> |
||
+ | </ul> |
||
+ | <br /> |
||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code shows how to create a matching problem for functions and their graphs using |
+ | <em><b>Example 1:</b> Matching functions and static graphs with imageChoice. This code shows how to create a matching problem for functions and their graphs using imageChoice. |
Students input their answers using drop-down select lists (popup lists). |
Students input their answers using drop-down select lists (popup lists). |
||
</em> |
</em> |
||
Line 21: | Line 35: | ||
loadMacros( |
loadMacros( |
||
− | + | "PGstandard.pl", |
|
− | + | "PGunion.pl", |
|
− | + | "imageChoice.pl", |
|
− | "contextABCD.pl", |
||
− | "imageChoice.pl", |
||
− | "PGcourse.pl", |
||
); |
); |
||
+ | |||
+ | TEXT(beginproblem()); |
||
+ | $refreshCachedImages=1; |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
<td style="background-color:#ccffcc;padding:7px;"> |
<td style="background-color:#ccffcc;padding:7px;"> |
||
<p> |
<p> |
||
− | Initialization: |
+ | <b>Initialization:</b> |
+ | We need to include many macro files. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 36: | Line 53: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | $size = [150,150]; # the size of the images |
||
− | $tsize = 250; # tex size of the images |
||
− | |||
− | # |
||
− | # Array of functions and their associated GIFs or PNGs |
||
− | # |
||
@QA = ( |
@QA = ( |
||
"\( f(x,y) = \displaystyle \frac{1}{x^2 + y^2} \)", |
"\( f(x,y) = \displaystyle \frac{1}{x^2 + y^2} \)", |
||
Line 57: | Line 68: | ||
$ml = new_image_match_list( |
$ml = new_image_match_list( |
||
link => 1, # do not link to separate image |
link => 1, # do not link to separate image |
||
− | size => |
+ | size => [150,150], # image width, height in pixels |
− | tex_size => |
+ | tex_size => 310, # tex size in precent times 10 |
columns => 3, # number of columns |
columns => 3, # number of columns |
||
+ | separation => 20, # space between images |
||
); |
); |
||
− | $ml->{separation} = 3; # separation for questions in the list |
||
$ml->rf_print_q(~~&pop_up_list_print_q); # use pop-up-lists |
$ml->rf_print_q(~~&pop_up_list_print_q); # use pop-up-lists |
||
− | $ml -> ra_pop_up_list( |
+ | $ml -> ra_pop_up_list( |
+ | [ No_answer=>"?", A=>"A", B=>"B", C=>"C", D=>"D", E=>"E" ] ); |
||
$ml->qa(@QA); # set the questions and answers |
$ml->qa(@QA); # set the questions and answers |
||
$ml->choose(5); # select 5 of them |
$ml->choose(5); # select 5 of them |
||
− | #$ml->choose_extra(1); |
+ | #$ml->choose_extra(1); # and show the other 1 |
</pre> |
</pre> |
||
</td> |
</td> |
||
<td style="background-color:#ffffcc;padding:7px;"> |
<td style="background-color:#ffffcc;padding:7px;"> |
||
<p> |
<p> |
||
− | Set-up: This is probably the only section you need to modify. |
||
+ | <b>Setup:</b> |
||
+ | This is probably the only section you need to modify. |
||
Create an array of questions (functions) and a corresponding |
Create an array of questions (functions) and a corresponding |
||
array of images. You probably want six or fewer |
array of images. You probably want six or fewer |
||
graphs to be displayed. Image files must be GIF or PNG and |
graphs to be displayed. Image files must be GIF or PNG and |
||
be located in the same directory as the pg file. |
be located in the same directory as the pg file. |
||
+ | </p> |
||
+ | <p> |
||
+ | You may need to add more strings ("F", "G", etc.) to the <code>ra_pop_up_list</code> if you have more than five graphs. |
||
+ | </p> |
||
+ | <p> |
||
+ | For each PG problem with static images, you should put both the PG file and the image files into their own separate subdirectory. This subdirectory should be located somewhere under the course <code>templates</code> directory. The name of the subdirectory should be the same as the root name of the PG file, and there should be only one PG file in this subdirectory. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 84: | Line 102: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | TEXT(beginproblem()); |
||
− | |||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | |||
Match each function with its graph. Click on a graph to make it larger. |
Match each function with its graph. Click on a graph to make it larger. |
||
− | |||
+ | $BR |
||
− | $PAR |
||
\{$ml->print_q\} |
\{$ml->print_q\} |
||
− | $PAR |
||
+ | $BR |
||
\{$ml->print_a\} |
\{$ml->print_a\} |
||
− | $PAR |
||
+ | $BR |
||
− | |||
END_TEXT |
END_TEXT |
||
</pre> |
</pre> |
||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | Main Text: Modify the instructions if you want. |
||
+ | <b>Main Text:</b> |
||
+ | Modify the instructions if you want. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 107: | Line 121: | ||
<td style="background-color:#eeddff;border:black 1px dashed;"> |
<td style="background-color:#eeddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | Context("ABCD")->strings->add("E" => {},"F" => {}); |
||
− | |||
install_problem_grader(~~&std_problem_grader); |
install_problem_grader(~~&std_problem_grader); |
||
− | |||
$showPartialCorrectAnswers = 0; |
$showPartialCorrectAnswers = 0; |
||
− | ANS( |
+ | ANS(str_cmp($ml->ra_correct_ans)); |
ENDDOCUMENT(); |
ENDDOCUMENT(); |
||
Line 119: | Line 130: | ||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
− | Answer Evaluation: You may need to add more strings to the context. |
||
+ | <b>Answer Evaluation:</b> |
||
+ | As expected. |
||
</p> |
</p> |
||
</td> |
</td> |
||
</tr> |
</tr> |
||
</table> |
</table> |
||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Line 144: | Line 148: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code shows how to create a matching problem for functions and their graphs without using |
+ | <em><b>Matching functions and graphs without imageChoice:</b> This code shows how to create a matching problem for functions and their graphs without using imageChoice. |
− | Students input their answers using drop-down select lists (popup lists). |
+ | Students input their answers using drop-down select lists (popup lists). This code is old, and some of its routines have been deprecated. |
</em> |
</em> |
||
</p> |
</p> |
||
Line 167: | Line 171: | ||
"PGchoicemacros.pl", |
"PGchoicemacros.pl", |
||
"PGanswermacros.pl", |
"PGanswermacros.pl", |
||
+ | "PGcourse.pl", |
||
); |
); |
||
</pre> |
</pre> |
||
Line 223: | Line 228: | ||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | $BEGIN_ONE_COLUMN |
||
+ | |||
Match each function with its graph. If you click on a graph, |
Match each function with its graph. If you click on a graph, |
||
a larger graph will appear in a new window. |
a larger graph will appear in a new window. |
||
Line 239: | Line 244: | ||
BEGIN_TEXT |
BEGIN_TEXT |
||
+ | |||
\{imageRow(~~@shuffled_subset_of_images,~~@captions)\} |
\{imageRow(~~@shuffled_subset_of_images,~~@captions)\} |
||
− | $END_ONE_COLUMN |
||
+ | |||
END_TEXT |
END_TEXT |
||
</pre> |
</pre> |
||
Line 267: | Line 273: | ||
</tr> |
</tr> |
||
</table> |
</table> |
||
+ | |||
+ | |||
+ | |||
Line 275: | Line 284: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em>This code shows how to create a matching problem for graphs and other graphs without using |
+ | <em><b>Matching graphs and graphs without imageChoice:</b> This code shows how to create a matching problem for graphs and other graphs without using imageChoice. |
− | Students input their answers using drop-down select lists (popup lists). |
+ | Students input their answers using drop-down select lists (popup lists). This code is old, and some of its routines have been deprecated. |
</em> |
</em> |
||
</p> |
</p> |
||
Line 296: | Line 305: | ||
"PGchoicemacros.pl", |
"PGchoicemacros.pl", |
||
"PGanswermacros.pl", |
"PGanswermacros.pl", |
||
+ | "PGcourse.pl", |
||
); |
); |
||
</pre> |
</pre> |
||
Line 322: | Line 332: | ||
); |
); |
||
− | $n = scalar(@ |
+ | $n = scalar(@surfaces); |
$k = $n; # $k can be less than $n |
$k = $n; # $k can be less than $n |
||
@subset = NchooseK($n,$k); |
@subset = NchooseK($n,$k); |
||
Line 353: | Line 363: | ||
BEGIN_TEXT |
BEGIN_TEXT |
||
− | $BEGIN_ONE_COLUMN |
||
+ | |||
Match each graph with its contour plot. If you click on a graph, |
Match each graph with its contour plot. If you click on a graph, |
||
a larger graph will appear in a new window. Green contours represent |
a larger graph will appear in a new window. Green contours represent |
||
Line 372: | Line 382: | ||
\{imageRow(~~@subset_of_surfaces,~~@numbercaptions)\} |
\{imageRow(~~@subset_of_surfaces,~~@numbercaptions)\} |
||
\{imageRow(~~@shuffled_subset_of_contours,~~@alphacaptions)\} |
\{imageRow(~~@shuffled_subset_of_contours,~~@alphacaptions)\} |
||
− | $END_ONE_COLUMN |
||
END_TEXT |
END_TEXT |
||
</pre> |
</pre> |
Latest revision as of 09:02, 16 July 2023
This problem has been replaced with a newer version of this problem
Matching Problems that have Graphic Images
There are three different kinds of matching problems with static graphics given here.
- Example 1: (Recommended:) Matching functions and static graphs using imageChoice.
- (Old:) Matching functions and their graphs without imageChoice.
- (Old:) Matching graphs to other graphs without imageChoice.
Example 1: Matching functions and static graphs with imageChoice. This code shows how to create a matching problem for functions and their graphs using imageChoice. Students input their answers using drop-down select lists (popup lists).
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGunion.pl", "imageChoice.pl", ); TEXT(beginproblem()); $refreshCachedImages=1; |
Initialization: We need to include many macro files. |
@QA = ( "\( f(x,y) = \displaystyle \frac{1}{x^2 + y^2} \)", "plot1.png", "\( f(x,y) = - y^2 \)", "plot2.png", "\( f(x,y) = x^3 - \sin(y) \)", "plot3.png", "\( f(x,y) = x + 2y + 3 \)", "plot4.png", "\( f(x,y) = - 4 e^{-x^2 - y^2} \)", "plot5.png", ); $ml = new_image_match_list( link => 1, # do not link to separate image size => [150,150], # image width, height in pixels tex_size => 310, # tex size in precent times 10 columns => 3, # number of columns separation => 20, # space between images ); $ml->rf_print_q(~~&pop_up_list_print_q); # use pop-up-lists $ml -> ra_pop_up_list( [ No_answer=>"?", A=>"A", B=>"B", C=>"C", D=>"D", E=>"E" ] ); $ml->qa(@QA); # set the questions and answers $ml->choose(5); # select 5 of them #$ml->choose_extra(1); # and show the other 1 |
Setup: This is probably the only section you need to modify. Create an array of questions (functions) and a corresponding array of images. You probably want six or fewer graphs to be displayed. Image files must be GIF or PNG and be located in the same directory as the pg file.
You may need to add more strings ("F", "G", etc.) to the
For each PG problem with static images, you should put both the PG file and the image files into their own separate subdirectory. This subdirectory should be located somewhere under the course |
BEGIN_TEXT Match each function with its graph. Click on a graph to make it larger. $BR \{$ml->print_q\} $BR \{$ml->print_a\} $BR END_TEXT |
Main Text: Modify the instructions if you want. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS(str_cmp($ml->ra_correct_ans)); ENDDOCUMENT(); |
Answer Evaluation: As expected. |
Matching functions and graphs without imageChoice: This code shows how to create a matching problem for functions and their graphs without using imageChoice. Students input their answers using drop-down select lists (popup lists). This code is old, and some of its routines have been deprecated.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGcourse.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); |
Set-up: This is probably the only section you need to modify. Create an array of questions (functions) and a corresponding array of images. Set the number of questions displayed, $k, manually if you like. You probably don't want more than five graphs to be displayed. Image files must be GIF or PNG and be located in the same directory as the pg file. |
@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 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 (1..$k) { BEGIN_TEXT $j. \{ pop_up_list(['?', @captions]) \} $SPACE @subset_of_questions[$j-1] $BR$BR END_TEXT } BEGIN_TEXT \{imageRow(~~@shuffled_subset_of_images,~~@captions)\} END_TEXT |
Main Text: You may modify the instructions if you want. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS(str_cmp([@ALPHABET[invert(@permutation)]])); ENDDOCUMENT(); |
Answer Evaluation: You should not need to modify this section at all. |
Matching graphs and graphs without imageChoice: This code shows how to create a matching problem for graphs and other graphs without using imageChoice. Students input their answers using drop-down select lists (popup lists). This code is old, and some of its routines have been deprecated.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGcourse.pl", ); |
Initialization: We need to include the |
@surfaces = ( "Surface02.png", "Surface04.png", "Surface09.png", "Surface10.png", ); @contours = ( "Contour02.png", "Contour04.png", "Contour09.png", "Contour10.png", ); $n = scalar(@surfaces); $k = $n; # $k can be less than $n @subset = NchooseK($n,$k); |
Set-up: This is probably the only section you need to modify. Create an array of surfaces and a corresponding array of contour plots. You could also do this for functions and their derivatives. Set the number of questions displayed, $k, manually if you like. You probably don't want more than five graphs to be displayed. Image files must be GIF or PNG and be located in the same directory as the pg file. |
@subset_of_surfaces = @surfaces[@subset]; @subset_of_contours = @contours[@subset]; @permutation = NchooseK($k,$k); @shuffled_subset_of_contours = @subset_of_contours[@permutation]; @numbercaptions = (1..$k); @alphacaptions = @ALPHABET[0..$k-1]; TEXT(beginproblem()); BEGIN_TEXT Match each graph with its contour plot. If you click on a graph, a larger graph will appear in a new window. Green contours represent lower elevations, and red contours represent higher elevations. In the contour plots, the x-axis is horizontal and the y-axis is vertical, as usual. $BR$BR END_TEXT for $j (1..$k) { BEGIN_TEXT $j. \{ pop_up_list(['?', @alphacaptions]) \} $SPACE$SPACE$SPACE$SPACE$SPACE END_TEXT } BEGIN_TEXT \{imageRow(~~@subset_of_surfaces,~~@numbercaptions)\} \{imageRow(~~@shuffled_subset_of_contours,~~@alphacaptions)\} END_TEXT |
Main Text: You may modify the instructions if you want. We display the popup lists on a single line so that they are visually arranged in the same way as the graphs. |
install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS(str_cmp([@ALPHABET[invert(@permutation)]])); ENDDOCUMENT(); |
Answer Evaluation: You should not need to modify this section at all. |