Difference between revisions of "Scaffold"
(Created page with "<h2>Scaffolded, MultiPart Problems Worked Sequentially</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This is the PG code to create a scaff...") |
|||
Line 1: | Line 1: | ||
− | <h2>Scaffolded, MultiPart Problems Worked Sequentially</h2> |
+ | <h2>Simple Scaffolded, MultiPart Problems Worked Sequentially</h2> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
Line 9: | Line 9: | ||
</p> |
</p> |
||
− | <strong>Using answer hashes</strong> |
||
− | <p> |
||
− | This way of creating a compound problem has the advantage of being slightly cleaner from the perspective of students working the problem. |
||
− | </p> |
||
<table cellspacing="0" cellpadding="2" border="0"> |
<table cellspacing="0" cellpadding="2" border="0"> |
||
<tr valign="top"> |
<tr valign="top"> |
||
Line 24: | Line 20: | ||
DOCUMENT(); |
DOCUMENT(); |
||
loadMacros( |
loadMacros( |
||
− | "PGstandard.pl", |
+ | "PGstandard.pl", |
− | " |
+ | "PGML.pl", |
− | " |
+ | "MathObjects.pl", |
+ | "parserMultiAnswer.pl", |
||
+ | "scaffold-simple.pl", |
||
+ | "PGcourse.pl", |
||
); |
); |
||
TEXT(beginproblem()); |
TEXT(beginproblem()); |
||
+ | $showPartialCorrectAnswers = 1; |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 34: | Line 31: | ||
<p> |
<p> |
||
<b>Initialization:</b> |
<b>Initialization:</b> |
||
− | We need make no changes to the initialization section of the file. In this example we include <code> |
+ | We need make no changes to the initialization section of the file besides including <code>scaffold.pl</code>. In this example we include <code>parserMultiAnswer.pl</code> so that we can use that. |
</p> |
</p> |
||
</td> |
</td> |
||
Line 43: | Line 40: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | $a = random(1,9,2); |
||
+ | Context("Numeric"); |
||
− | $evenOdd = PopUp( [ "?", "even", "odd" ], |
||
+ | Context()->variables->are(x => 'Real'); |
||
− | "odd" ); |
||
− | $evenNum = Compute( 2 ); |
||
+ | $a = Compute(random(2,9,1)); |
||
+ | $c = Compute(random(1,9,1)); |
||
+ | $b = Compute(random(2,6,1)); |
||
+ | if ($a*$c > 0) {$b += floor(sqrt(4*$a*$c))} |
||
+ | |||
+ | $quadratic = Formula("$a x^2 + $b x + $c"); |
||
+ | $x1 = (-$b + sqrt($b**2-4*$a*$c))/(2*$a); |
||
+ | $x2 = (-$b - sqrt($b**2-4*$a*$c))/(2*$a); |
||
+ | ########################################### |
||
+ | # The scaffold |
||
+ | Scaffold::Begin(); |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 53: | Line 59: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
− | In the problem set-up section of the file we define some variables that we will use in the problem, as usual. |
+ | In the problem set-up section of the file we define some variables that we will use in the problem, as usual. In addition, we begin the scaffold by <code>Scaffold::Begin()</code>. Giving arguments to this changes when sections will open, and when they will be able to be opened. Options are listed below: |
</p> |
</p> |
||
+ | <pre> |
||
+ | Scaffold::Begin( |
||
+ | can_open => "when_previous_correct", #first_incorrect, correct_or_first_incorrect, incorrect, always, or never |
||
+ | is_open => "first_incorrect" #when_previous_correct, correct_or_first_incorrect, incorrect, always, or never |
||
+ | instructor_can_open => "when_previous_correct", #first_incorrect, correct_or_first_incorrect, incorrect, always, or never |
||
+ | ); |
||
+ | </pre> |
||
</td> |
</td> |
||
</tr> |
</tr> |
||
Line 129: | Line 142: | ||
</table> |
</table> |
||
− | <p> |
||
− | <strong>Using compoundProblem.pl</strong> |
||
− | </p> |
||
<p> |
<p> |
||
This way of creating a compound problem has the advantage of being slightly easer to manage. |
This way of creating a compound problem has the advantage of being slightly easer to manage. |
Revision as of 11:41, 22 August 2014
Simple Scaffolded, MultiPart Problems Worked Sequentially
This is the PG code to create a scaffolded problem with multiple parts that are displayed sequentially. This way uses a recent macro, scaffold.pl
that creates a neat student interface - similar to that of CompoundProblem5.pl but with a much cleaner style for authors. The interface has tabs containing sections of the problem that can open and close.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGML.pl", "MathObjects.pl", "parserMultiAnswer.pl", "scaffold-simple.pl", "PGcourse.pl", ); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; |
Initialization:
We need make no changes to the initialization section of the file besides including |
Context("Numeric"); Context()->variables->are(x => 'Real'); $a = Compute(random(2,9,1)); $c = Compute(random(1,9,1)); $b = Compute(random(2,6,1)); if ($a*$c > 0) {$b += floor(sqrt(4*$a*$c))} $quadratic = Formula("$a x^2 + $b x + $c"); $x1 = (-$b + sqrt($b**2-4*$a*$c))/(2*$a); $x2 = (-$b - sqrt($b**2-4*$a*$c))/(2*$a); ########################################### # The scaffold Scaffold::Begin(); |
Setup:
In the problem set-up section of the file we define some variables that we will use in the problem, as usual. In addition, we begin the scaffold by Scaffold::Begin( can_open => "when_previous_correct", #first_incorrect, correct_or_first_incorrect, incorrect, always, or never is_open => "first_incorrect" #when_previous_correct, correct_or_first_incorrect, incorrect, always, or never instructor_can_open => "when_previous_correct", #first_incorrect, correct_or_first_incorrect, incorrect, always, or never ); |
Context()->texStrings; BEGIN_TEXT ${BBOLD}Part 1 of 2:$EBOLD $PAR Is \( $a \) even or odd? \{ $evenOdd->menu() \} END_TEXT Context()->normalStrings; ANS( $evenOdd->cmp() ); $ans_hash1 = $evenOdd->cmp()->evaluate( $inputs_ref->{ANS_NUM_TO_NAME(1)} ); if ( $ans_hash1->{score} == 1 ) { Context()->texStrings; BEGIN_TEXT ${BBOLD}Part 2 of 2:$EBOLD $PAR Enter an example of an even number, \(n\): \(n = \) \{ $evenNum->ans_rule() \} END_TEXT Context()->normalStrings; ANS( $evenNum->cmp( checker=>sub { my ( $cor, $stu, $ans ) = @_; return 0 == ($stu % 2); } ) ); } # ends if ( $ans_hash1->{score} ) |
Main Text: The text section of the problem is now broken into the parts that we want the student to work sequentially. Here we always display the first part of the problem, and then display the second part only after the student has correctly worked the first part.
Note that if we have multiple answer blanks in the first part of the problem the numbers used to dereference the answer numbers must increment: e.g., if we had two true/false pop-ups, $ans_hash1 = $evenNum1->cmp()->evaluate( $inputs_ref->{ANS_NUM_TO_NAME(1)} ); $ans_hash2 = $evenNum2->cmp()->evaluate( $inputs_ref->{ANS_NUM_TO_NAME(2)} ); if ( $ans_hash1->{score} == 1 && $ans_hash2->{score} == 1 ) { # part 2 of the problem
(The line breaks putting the argument of the |
ENDDOCUMENT(); |
Answer evaluation: We've included the answer evaluators in the conditionals bracketing the display of the text, so they do not appear here. Solutions would, of course. |
This way of creating a compound problem has the advantage of being slightly easer to manage.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserPopUp.pl", "compoundProblem.pl", ); TEXT(beginproblem()); |
Initialization:
In the initialization section of the file, load |
$a = random(1,9,2); $evenOdd = PopUp( [ "?", "even", "odd" ], "odd" ); $evenNum = Compute( 2 ); $cp = new compoundProblem( parts=>2, weights=>[1,2], nextStyle=>'Forced' ); |
Setup:
In the problem set-up section of the file we define some variables that we will use in the problem, and then define the compoundProblem object
The key method of the |
Context()->texStrings; BEGIN_TEXT Is \( $a \) even or odd? \{ $evenOdd->menu() \} END_TEXT Context()->normalStrings; ANS( $evenOdd->cmp() ); if ( $cp->part > 1 ) { Context()->texStrings; BEGIN_TEXT Enter an example of an even number, \(n\): \(n = \) \{ $evenNum->ans_rule() \} END_TEXT Context()->normalStrings; ANS( $evenNum->cmp( checker=>sub { my ( $cor, $stu, $ans ) = @_; return 0 == ($stu % 2); } ) ); } # ends if ( $cp->part > 1 ) |
Main Text: The text section of the problem is now broken into the parts that we want the student to work sequentially. Here we always display the first part of the problem, and then display the second part only after the student has correctly worked the first part and clicked "submit" to continue to the second part. The answer checkers are similarly associated with the text sections that are being displayed. |
ENDDOCUMENT(); |
Answer evaluation: We've included the answer evaluators in the conditionals bracketing the display of the text, so they do not appear here. Solutions would, of course. |
As noted above, there are a number of other options that can be supplied to the compoundProblem
object. These include:
-
parts => n
: The number of parts in the problem. If not provided, defaults to 1, which rather defeats the point of using this in the first place. -
weights => [n1,...,nm]
: The relative weights to give to each part in the problem. For example, weights => [2,1,1] would cause the first part to be worth 50% of the points (twice the amount for each of the other two), while the second and third part would be worth 25% each. If weights are not supplied, the parts are weighted by the number of answer blanks in each part (and you must provide the total number of blanks in all the parts by supplying the totalAnswers option). -
totalAnswers => n
: The total number of answer blanks in all the parts put together (this is used when computing the per-part scores, if part weights are not provided). -
saveAllAnswers => 0 or 1
: Usually, the contents of named answer blanks from previous parts are made available to later parts using variables with the same name as the answer blank. Setting saveAllAnswers to 1 will cause ALL answer blanks to be available (via variables like $AnSwEr1, and so on). If not provided, defaults to 0. -
parserValues => 0 or 1
: Determines whether the answers from previous parts are returned as MathObjects (like those returned from Real(), Vector(), etc) or as strings (the unparsed contents of the student answer). If you intend to use the previous answers as numbers, for example, you would want to set this to 1 so that you would get the final result of any formula the student typed, rather than the formula itself as a character string. If not provided, defaults to 0. -
nextVisible => type
: Tells when the "go on to the next part" option is available to the student. The possible types include:ifCorrect
(the default; next is available only when all the answers are correct),Always
(next is always available (but note that students can't go back once they go on), andNever
(the problem controls going on by itself). -
nextStyle => type
: Determines the style of "next" indicator to display (when it is available). The possible types include:CheckBox
(the default),Button
,Forced
(forces students to go on when they next submit answers), andHTML
(provide an arbitrary HTML string).
(These are all taken directly from the documentation in the macro file.)
- PG macro: compoundProblem.pl