Scaffolding1

From WeBWorK
Jump to: navigation, search

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

follow us