Difference between revisions of "Scaffolding1"

From WeBWorK_wiki
Jump to navigation Jump to search
m
(Deprecate example using compoundProblem5.pl in favor of scaffold.pl)
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<h2>Sequentially Revealed (Scaffolded) Problems</h2>
+
<h2>Deprecated: Sequentially Revealed (Scaffolded) Problems</h2>
   
 
[[File:Scaffolding1.png|300px|thumb|right|Click to enlarge]]
 
[[File:Scaffolding1.png|300px|thumb|right|Click to enlarge]]
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
This PG code shows how to create multi-part questions that hide from students parts that have not yet been answered correct.
 
  +
This PG code shows how to create multi-part questions that hide from students parts that have not yet been answered correct. This example is deprecated: see [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/Scaffolding2_PGML.pg FortLewis/Authoring/Templates/Misc/Scaffolding2_PGML.pg] instead (requires macro file [https://github.com/openwebwork/pg/blob/master/macros/scaffold.pl scaffold.pl] from after December, 2014).
 
</p>
 
</p>
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/Scaffolding1.pg FortLewis/Authoring/Templates/Misc/Scaffolding1.pg]
 
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Misc/Scaffolding1.pg FortLewis/Authoring/Templates/Misc/Scaffolding1.pg]
Line 44: Line 44:
 
"MathObjects.pl",
 
"MathObjects.pl",
 
"compoundProblem5.pl",
 
"compoundProblem5.pl",
  +
#"scaffolding.pl", # alternate future name
 
"PGcourse.pl",
 
"PGcourse.pl",
 
);
 
);
Line 64: Line 65:
 
<p>
 
<p>
 
<b>Initialization:</b>
 
<b>Initialization:</b>
Use the <code>compoundProblem5.pl</code> macro to provide scaffolding (this macro may be renamed to <code>Scaffolding.pl</code> or <code>sequentiallyRevealed.pl</code> in the future).
+
Use the <code>compoundProblem5.pl</code> macro to provide scaffolding (this macro may be renamed to <code>scaffolding.pl</code> in the future as it is finalized).
 
We initialize the scaffolding with the name <code>$scaffold</code>.
 
We initialize the scaffolding with the name <code>$scaffold</code>.
 
Set <code>$isInstructor = 0;</code> when the problem is available to students, or set to 1 when debugging.
 
Set <code>$isInstructor = 0;</code> when the problem is available to students, or set to 1 when debugging.
Line 176: Line 177:
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<td style="background-color:#eeddff;border:black 1px dashed;">
 
<pre>
 
<pre>
$showPartialCorrectAnswers = 1;
 
  +
$answer3a = Compute("NONE");
  +
$answer3b = Compute("DNE");
   
ANS( $answer->cmp() );
 
  +
Context()->texStrings;
  +
DISPLAY_SECTION({
  +
section=>3,
  +
name=>"3: False concepts",
  +
canshow =>$scaffold->requireCorrect(3). " or $isInstructor",
  +
iscorrect=>$scaffold->requireCorrect(4,5),
  +
}, <<'END_SECTION');
  +
  +
Enter ${BTT}NONE${ETT}: \{SECTION_ANS($answer3a->cmp), $answer3a->ans_rule(10)\}
  +
$BR
  +
Enter ${BTT}DNE${ETT}: \{SECTION_ANS($answer3b->cmp), $answer3b->ans_rule(10) \}.
  +
  +
END_SECTION
  +
  +
SECTION_SOLUTION({section=>3},<<'END_SOLUTION');
  +
Solution text goes here.
  +
END_SOLUTION
  +
Context()->normalStrings;
 
</pre>
 
</pre>
 
<td style="background-color:#eeccff;padding:7px;">
 
<td style="background-color:#eeccff;padding:7px;">
 
<p>
 
<p>
<b>Answer Evaluation:</b>
+
<b>Section 3:</b>
  +
Same syntax as before.
  +
Since the third section is revealed only after the section section is correct, we can use <code>canshow =>$scaffold->requireCorrect(3)</code> to specify that this section (section 3) will be revealed only when answer blank 3 (the matrix from section 2) is correct.
  +
This section will be marked correct only when answer boxes 4 and 5 are both correct, as specified by <code>iscorrect=>$scaffold->requireCorrect(4,5)</code>.
 
</p>
 
</p>
 
</td>
 
</td>
 
</tr>
 
</tr>
   
<!-- Solution section -->
+
<!-- Section 4 -->
   
 
<tr valign="top">
 
<tr valign="top">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
  +
foreach my $i (1..5) {
  +
$answer4[$i] = Compute($i);
  +
}
  +
 
Context()->texStrings;
 
Context()->texStrings;
BEGIN_SOLUTION
 
  +
DISPLAY_SECTION({
${PAR}SOLUTION:${PAR}
 
  +
section=>4,
Solution explanation goes here.
 
  +
name=>"4: Superstition",
  +
canshow =>$scaffold->requireCorrect(5). " or $isInstructor",
  +
iscorrect=>$scaffold->requireCorrect(6..10),
  +
}, <<'END_SECTION');
  +
  +
Enter 1, 2, 3, 4, 5:
  +
\{$answer4[1]->ans_rule(3)\},
  +
\{$answer4[2]->ans_rule(3)\},
  +
\{$answer4[3]->ans_rule(3)\},
  +
\{$answer4[4]->ans_rule(3)\},
  +
\{$answer4[5]->ans_rule(3)\}.
  +
  +
END_SECTION
  +
  +
foreach my $i (1..5) {
  +
SECTION_ANS($answer4[$i]->cmp)
  +
}
  +
  +
SECTION_SOLUTION({section=>4},<<'END_SOLUTION');
  +
It's a little known fact that
  +
antiquated ideas, bungling, false concepts, and superstition
  +
are the labels on the file drawers inside of Donald Duck's brain
  +
in the movie Donald Duck in Mathmagic Land.
 
END_SOLUTION
 
END_SOLUTION
 
Context()->normalStrings;
 
Context()->normalStrings;
  +
</pre>
  +
<td style="background-color:#ddddff;padding:7px;">
  +
<p>
  +
<b>Section 4:</b>
  +
We use for loops to deal with the five answers and answer checkers in this section.
  +
Note that in the code we have pulled the <code>SECTION_ANS()</code> commands away from the <code>ans_rule(width)</code> answer boxes, which is to say that we're using the "standard approach" to formatting our code, which helps us use the for loops.
  +
</p>
  +
<p>
  +
The solution gives an answer to the question, "Where did the section titles come from?"
  +
</p>
  +
</td>
  +
</tr>
  +
  +
  +
  +
  +
<!-- Answer evaluation -->
  +
  +
<tr valign="top">
  +
<td style="background-color:#ffffdd;border:black 1px dashed;">
  +
<pre>
  +
PROCESS_ANSWERS();
  +
  +
$last_correct_section = PROCESS_SECTIONS();
  +
  +
#determine which section to leave open
  +
$opensection = $last_correct_section + 1;
  +
$scaffold->openSections($opensection);
   
COMMENT('MathObject version.');
+
COMMENT('MathObject version. Uses compoundProblem5.pl
  +
to hide parts that the student has not yet answered correct.');
   
 
ENDDOCUMENT();
 
ENDDOCUMENT();
 
</pre>
 
</pre>
<td style="background-color:#ddddff;padding:7px;">
 
  +
</td>
  +
<td style="background-color:#ffffcc;padding:7px;">
 
<p>
 
<p>
<b>Solution:</b>
+
<b>Answer evaluation:</b>
  +
Note that the answer rules and answer evaluators are matched up in the order in which they are entered, and that the question will not work otherwise.
  +
Use <code>PROCESS_SECTIONS()</code> to determine which sections should be revealed and which should be colored correct (green).
  +
Use <code>$scaffold->openSections($opensection);</code> to specify which sections actually get revealed to students.
 
</p>
 
</p>
 
</td>
 
</td>

Revision as of 00:15, 8 June 2015

Deprecated: Sequentially Revealed (Scaffolded) Problems

Click to enlarge

This PG code shows how to create multi-part questions that hide from students parts that have not yet been answered correct. This example is deprecated: see FortLewis/Authoring/Templates/Misc/Scaffolding2_PGML.pg instead (requires macro file scaffold.pl from after December, 2014).


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();  
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"compoundProblem5.pl",
#"scaffolding.pl", # alternate future name
"PGcourse.pl",
);

TEXT(beginproblem());
$showPartialCorrectAnswers = 1;

$scaffold = Scaffold();
INITIALIZE_SCAFFOLD('$scaffold');

$isInstructor = 0; # = 0 when students use it

TEXT(MODES(
HTML=>'Clicking on a section opens it 
provided that you have answered previous sections correctly.',
TeX=>''));

Initialization: Use the compoundProblem5.pl macro to provide scaffolding (this macro may be renamed to scaffolding.pl in the future as it is finalized). We initialize the scaffolding with the name $scaffold. Set $isInstructor = 0; when the problem is available to students, or set to 1 when debugging. Alternatively, we could set

$isInstructor =  ($envir{effectivePermissionLevel} >= 
$envir{ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL});

to ensure that only users that always have permission to show correct answers can open all of the sections of the scaffolding without needing to enter correct answers.

Context("Numeric");

$answer1a = Compute(11);
$answer1b = Compute(12);

Context()->texStrings;
DISPLAY_SECTION({  
    section=>1,
    name=>"1: Antiquated ideas (a descriptive title)", 
    canshow =>1,
    iscorrect=>$scaffold->requireCorrect(1,2), 
} , <<'END_SECTION'); 

Continue the pattern: 7, 8, 9, 10, 
\{SECTION_ANS($answer1a->cmp), $answer1a->ans_rule(3) \},
\{SECTION_ANS($answer1b->cmp), $answer1b->ans_rule(3)\}.

END_SECTION

SECTION_SOLUTION({section=>1},<<'END_SOLUTION');
$PAR
Put some text here for the solution to section 1.
END_SOLUTION
Context()->normalStrings;

Section 1: Use DISPLAY_SECTION to set the parameters for the first section. Use section=>1 to set the section number. Use name=>"1: Descriptive title" to give a title for the section. Since the first section should always be available to students, we set canshow=>1. Use iscorrect=>$scaffold->requireCorrect(1,2) to specify that this section will be marked all correct when the answers in answer boxes 1 and 2 are both correct.

The text that gets displayed to students starts at "Continue..."

Use SECTION_ANS() to record the correct weighted score into the grade book (i.e., database of scores). Note that we use SECTION_ANS($answer->cmp) before $answer->ans_rule(width), which is a bit different from how things are usually done.

It is also possible to provide a solution for each section.

Context('Matrix');

$M = Matrix([[1,2],[3,4]]);
$v = Matrix([[5],[6]]);

$answer2 = $M * $v;

Context()->texStrings;
DISPLAY_SECTION( { 
    section=>2,
    name=>"2: Bungling", 
    canshow =>$scaffold->requireCorrect(1,2). " or $isInstructor",
    iscorrect=>$scaffold->requireCorrect(3), 
},   <<'END_SECTION'); 

\( $M $v = \) \{SECTION_ANS($answer2->cmp()), $answer2->ans_array()\}

END_SECTION

SECTION_SOLUTION({section=>2},<<'END_SOLUTION');
Put solution text here.   
END_SOLUTION
Context()->normalStrings;

Section 2: For kicks, we change to the matrix context. Use canshow =>$scaffold->requireCorrect(1,2). " or $isInstructor" to specify that this section (section 2) can be revealed if answer boxes 1 and 2 are both correct (from section 1) or if the permission level of the user is high enough. Use iscorrect=>$scaffold->requireCorrect(3) to specify that this section (section 2) will be marked correct when the third answer (the entire matrix) is marked correct. We used $answer->ans_array(width) to generate an array of answer boxes with the same size as the correct answer that are treated as a single entity when grading.

$answer3a = Compute("NONE");
$answer3b = Compute("DNE");

Context()->texStrings;
DISPLAY_SECTION({	
    section=>3,
    name=>"3: False concepts", 
    canshow =>$scaffold->requireCorrect(3). " or $isInstructor",
    iscorrect=>$scaffold->requireCorrect(4,5), 
},   <<'END_SECTION'); 

Enter ${BTT}NONE${ETT}: \{SECTION_ANS($answer3a->cmp), $answer3a->ans_rule(10)\}
$BR
Enter ${BTT}DNE${ETT}: \{SECTION_ANS($answer3b->cmp), $answer3b->ans_rule(10) \}.

END_SECTION

SECTION_SOLUTION({section=>3},<<'END_SOLUTION');
Solution text goes here.
END_SOLUTION
Context()->normalStrings;

Section 3: Same syntax as before. Since the third section is revealed only after the section section is correct, we can use canshow =>$scaffold->requireCorrect(3) to specify that this section (section 3) will be revealed only when answer blank 3 (the matrix from section 2) is correct. This section will be marked correct only when answer boxes 4 and 5 are both correct, as specified by iscorrect=>$scaffold->requireCorrect(4,5).

foreach my $i (1..5) {
  $answer4[$i] = Compute($i);
}

Context()->texStrings;
DISPLAY_SECTION({	
    section=>4,
    name=>"4: Superstition", 
    canshow =>$scaffold->requireCorrect(5). " or $isInstructor",
    iscorrect=>$scaffold->requireCorrect(6..10), 
},   <<'END_SECTION'); 

Enter 1, 2, 3, 4, 5: 
\{$answer4[1]->ans_rule(3)\},
\{$answer4[2]->ans_rule(3)\},
\{$answer4[3]->ans_rule(3)\},
\{$answer4[4]->ans_rule(3)\},
\{$answer4[5]->ans_rule(3)\}.

END_SECTION

foreach my $i (1..5) {
  SECTION_ANS($answer4[$i]->cmp)
}

SECTION_SOLUTION({section=>4},<<'END_SOLUTION');
It's a little known fact that 
antiquated ideas, bungling, false concepts, and superstition
are the labels on the file drawers inside of Donald Duck's brain
in the movie Donald Duck in Mathmagic Land.
END_SOLUTION
Context()->normalStrings;

Section 4: We use for loops to deal with the five answers and answer checkers in this section. Note that in the code we have pulled the SECTION_ANS() commands away from the ans_rule(width) answer boxes, which is to say that we're using the "standard approach" to formatting our code, which helps us use the for loops.

The solution gives an answer to the question, "Where did the section titles come from?"

PROCESS_ANSWERS();

$last_correct_section = PROCESS_SECTIONS();

#determine which section to leave open
$opensection = $last_correct_section + 1;
$scaffold->openSections($opensection);

COMMENT('MathObject version.  Uses compoundProblem5.pl 
to hide parts that the student has not yet answered correct.');

ENDDOCUMENT();

Answer evaluation: Note that the answer rules and answer evaluators are matched up in the order in which they are entered, and that the question will not work otherwise. Use PROCESS_SECTIONS() to determine which sections should be revealed and which should be colored correct (green). Use $scaffold->openSections($opensection); to specify which sections actually get revealed to students.

Templates by Subject Area