Difference between revisions of "AlignedChoice"
(New page: <h2>Aligned Answer Blanks</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This PG code s...) |
|||
(8 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This style is outdated and recommended to use PGML now.</p> |
||
<h2>Aligned Answer Blanks</h2> |
<h2>Aligned Answer Blanks</h2> |
||
Line 48: | Line 51: | ||
Context("Numeric"); |
Context("Numeric"); |
||
− | $f1 = Formula("sin(pi/ |
+ | $f1 = Formula("sin(pi/4)"); |
− | $f2 = Formula("sin(pi |
+ | $f2 = Formula("sin(pi)"); |
− | $f3 = Formula("sin(pi/3)"); |
||
− | $f4 = Formula("sin(pi/2)"); |
||
− | $f5 = Formula("sin(pi)"); |
||
− | $f6 = Formula("sin(2pi)"); |
||
− | |||
− | Parser::Context::Functions::Disable('All'); |
||
− | Parser::Context::Functions::Enable('sqrt'); |
||
+ | Context()->functions->disable("All"); |
||
+ | Context()->functions->enable("sqrt"); |
||
Context()->texStrings; |
Context()->texStrings; |
||
$al = new_aligned_list(ans_rule_len=>10, numbered=>1, tex_spacing=>"3pt"); |
$al = new_aligned_list(ans_rule_len=>10, numbered=>1, tex_spacing=>"3pt"); |
||
$al->qa( |
$al->qa( |
||
− | "\($f1\)", Real($f1->eval)->cmp, |
+ | "\($f1\)", Real($f1->eval)->cmp(), |
− | "\($f2\)", Real($f2->eval)->cmp, |
+ | "\($f2\)", Real($f2->eval)->cmp(), |
− | "\($f3\)", Real($f3->eval)->cmp, |
||
− | "\($f4\)", Real($f4->eval)->cmp, |
||
− | "\($f5\)", Real($f5->eval)->cmp, |
||
− | "\($f6\)", Real($f6->eval)->cmp, |
||
); |
); |
||
Context()->normalStrings; |
Context()->normalStrings; |
||
Line 64: | Line 69: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
− | We disable all functions, and then enable square root. |
+ | We disable all functions, and then enable square root. The aligned list is an array of pairs of questions and answers (with answer evaluators). We can add as many question and answer pairs to the list as we like. |
</p> |
</p> |
||
<p> |
<p> |
||
− | The options for aligned list are vertical alignment, horizontal alignment, cellspacing, tex spacing (which must include units of measure, such as " |
+ | The options for aligned list are vertical alignment, horizontal alignment, cellspacing, tex spacing (which must include units of measure, such as "3pt"), whether or not the list is numbered, whether there is a column of equals signs, and the length of each answer rule. The defaults and other options are given below, and quotes are required around most of the options. |
<ul type="square"> |
<ul type="square"> |
||
<li><code>valign=>"MIDDLE"</code> or <code>TOP</code> or <code>BOTTOM</code></li> |
<li><code>valign=>"MIDDLE"</code> or <code>TOP</code> or <code>BOTTOM</code></li> |
||
Line 89: | Line 94: | ||
Find the sine of each of the following angles. |
Find the sine of each of the following angles. |
||
$PAR |
$PAR |
||
− | \{$al->print_q\} |
+ | \{ $al->print_q() \} |
$PAR |
$PAR |
||
− | Remark: Your answer cannot contain trigonometric functions |
+ | Remark: Your answer cannot contain trigonometric functions. |
− | + | It must be an arithmetic expression or number. |
|
END_TEXT |
END_TEXT |
||
</pre> |
</pre> |
||
Line 98: | Line 103: | ||
<p> |
<p> |
||
<b>Main Text:</b> |
<b>Main Text:</b> |
||
− | It's a good idea to explain to students that |
+ | It's a good idea to explain to students that certain types of answers are not allowed. |
</p> |
</p> |
||
</td> |
</td> |
Latest revision as of 08:06, 28 June 2023
This style is outdated and recommended to use PGML now.
Aligned Answer Blanks
This PG code shows how to align answer blanks and restrict the type of student answer allowed.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGunion.pl", "MathObjects.pl", "alignedChoice.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macro file |
Context("Numeric"); $f1 = Formula("sin(pi/4)"); $f2 = Formula("sin(pi)"); Context()->functions->disable("All"); Context()->functions->enable("sqrt"); Context()->texStrings; $al = new_aligned_list(ans_rule_len=>10, numbered=>1, tex_spacing=>"3pt"); $al->qa( "\($f1\)", Real($f1->eval)->cmp(), "\($f2\)", Real($f2->eval)->cmp(), ); Context()->normalStrings; |
Setup: We disable all functions, and then enable square root. The aligned list is an array of pairs of questions and answers (with answer evaluators). We can add as many question and answer pairs to the list as we like. The options for aligned list are vertical alignment, horizontal alignment, cellspacing, tex spacing (which must include units of measure, such as "3pt"), whether or not the list is numbered, whether there is a column of equals signs, and the length of each answer rule. The defaults and other options are given below, and quotes are required around most of the options.
|
BEGIN_TEXT Find the sine of each of the following angles. $PAR \{ $al->print_q() \} $PAR Remark: Your answer cannot contain trigonometric functions. It must be an arithmetic expression or number. END_TEXT |
Main Text: It's a good idea to explain to students that certain types of answers are not allowed. |
$showPartialCorrectAnswers = 1; ANS( $al->correct_ans ); ENDDOCUMENT(); |
Answer Evaluation: As expected. |