CompoundProblem5
Compound, MultiPart Problems Worked Sequentially
This is the PG code to create a problem with multiple parts that are displayed sequentially. This is a newer way to write compound (otherwise named "sequential" problems or more recently "scaffolded" problems. This method uses the macro compoundProblem5.pl to creates a clean, folding interface for the problem, showing labels for each step. See also CompoundProblems
valign="top">PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", # Standard macros for PG language "MathObjects.pl", # Using MathObjects "compoundProblem5.pl", #Required for the CompoundProblem "parserPopUp.pl" # Used in the popups ); $scaffold = Scaffold(); #$isInstructor = ($envir{effectivePermissionLevel} >= $envir{ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL}); $isInstructor=0; # This variable changes what the user can see. INITIALIZE_SCAFFOLD('$scaffold'); TEXT(beginproblem()); $showPartialCorrectAnswers = 1; #normal initialization |
Initialization:
First we have normal initialization inclusions. In this example we include |
############## # Section 1 ############## Context("Numeric"); $ans = Compute("0"); |
Part 1 Setup:
For this method of creating a Compound Problem, we can have a setup section for every part of the problem. So, for the first part, we do what would normally be required for the problem. In this case, we define an answer (which is arbitrary just to demonstrate an example) and set |
Context()->texStrings; DISPLAY_SECTION( { name=>"1: Set up problem", canshow =>1, #always true iscorrect=>$scaffold->requireCorrect(1), section=>1 #designates that this is the first section } , <<'END_SECTION'); Here we have the first part of the question. This should be accessible as soon as the student sees the problem. Answer "0" to move to the next section. $PAR Answer is: \{SECTION_ANS($ans->cmp), $ans->ans_rule(15)\} END_SECTION |
Part 1 Main Text: Similarly, we have separate "TEXT" sections for each part of the compound problem, so we write what we would like to appear in the first part. However, before that, we must include DISPLAY_SECTION( { name=>"1: Set up problem", canshow =>1, #always true iscorrect=>$scaffold->requireCorrect(1), section=>1 #designates that this is the first section } , <<'END_SECTION');
|
SECTION_SOLUTION({section=>1},<<'END_SOLUTION'); This is a sample solution for the section. It should be noted that you can have a solution for each section. END_SOLUTION |
Part 1 Answer evaluation and Solutions:
We've included the answer evaluators in the conditionals bracketing the display of the text, so they do not appear here. Solutions do, however, still show up here.
Note that each section can have a solution. The solution syntax is close to normal solution syntax, but we use |
############### # Section 2 ############### Context()->normalStrings; $ans = Compute("1"); $popup = PopUp(["Correct","Wrong","Extra Wrong"],"Correct"); |
Part 2 Setup: The same thing as for the first part, but for whatever is in the second part. |
Context()->texStrings; DISPLAY_SECTION( { name=>"2: Do something else", canshow =>$scaffold->requireCorrect(1). " or $isInstructor", iscorrect=>$scaffold->requireCorrect(2,3), section=>2 }, <<'END_SECTION'); Now again we have the problem text for the second part of the problem. We can have multiple answers for each part. $BR To move on, type "1" for the first answer, and select "Correct" for the pull-down menu. $PAR First Answer of Part 2: \{ans_rule(15) \} $BR Second Answer of Part 2: \{ $popup->menu() \} END_SECTION SECTION_ANS($ans->cmp, $popup->cmp); |
Part 2 Main Text: Again, we have another setup. This includes normal setup for the content of the part of the compound problem. We also have DISPLAY_SECTION( { name=>"2: Do something else", canshow =>$scaffold->requireCorrect(1). " or $isInstructor", iscorrect=>$scaffold->requireCorrect(2,3), section=>2 }, <<'END_SECTION');
|
Context()->normalStrings; ANS($ans->cmp, $popup->cmp); SECTION_SOLUTION({section=>2},<<'END_SOLUTION'); Here's a different solution. END_SOLUTION |
Part 2 Answer evaluation and Solutions: This is another solution one may have. Its syntax is identical to the first solution. |
Context()->normalStrings; ############## # Section 3 ############## Context("Point"); Context()->strings->add("yes"=>{}); $ans = Point(1,6); |
Part 3 Setup: Again, we have setup as we would as if the this part of the question were separate. We can, however, have problem-wide variables and functions. |
Context()->texStrings; DISPLAY_SECTION( { name=>"3: It's time for step 3!", canshow =>$scaffold->requireCorrect(1,2). " or $isInstructor", iscorrect=>$scaffold->requireCorrect(3), section=>3 }, <<'END_SECTION'); Finally, the fourth answer is: \{SECTION_ANS(Compute("yes")->cmp), Compute("yes")->ans_rule(15) \} $BR Look in the solution for the answer. END_SECTION |
Part 3 Main Text:
This follows the same method as the second part's Main Text. We set |
SECTION_SOLUTION({section=>3},<<'END_SOLUTION'); The solution is: Enter "yes". END_SOLUTION |
Part 3 Answer evaluation and Solutions: Essentially the same code as in part 1: we had the answers checked along with the answer blank. |
PROCESS_ANSWERS(); $last_correct_section = PROCESS_SECTIONS(); $opensection = $last_correct_section + 1; $scaffold->openSections($opensection); TEXT($END_ONE_COLUMN); ENDDOCUMENT(); |
Finish: Here we use some boiler plate actions to make sure the answers are processed and that the correct section is opened. These process the question in its entirety and open the correct sections for the whichever part of the problem the user is on. |
- PG macro: compoundProblem.pl