-
Notifications
You must be signed in to change notification settings - Fork 865
More on Multiple Problems
If you want to have one problem come up more frequently than another, add a data-weight
attribute to its containing <div>
. You can think of this attribute as a ratio. So if you want two types of questions to come up 60% and 40% of the time, use weights of 3 and 2:
<div id="problem-type-or-description-ONE" data-weight="3">
...
</div>
<div id="problem-type-or-description-TWO" data-weight="2">
...
</div>
In this example, the first problem will appear 60% of the time and the second problem 40%. With 3 problems, you could have a 6:3:1 ratio, etc. Any problem types without a weight will be given a weight of 1.
If the different problems you are considering have different variables, then you can declare variables individually for each problem. You can also declare any shared variables globally, and only define the ones that differ in each problem. For example, an exercise using word problems will probably require very different variables for each problem type. Here is the structure that would be used to define problem-specific variables:
<div class="vars">
<!-- global variables used by all problem types -->
<!-- this div is OPTIONAL -->
</div>
<div class="problems">
<div id="original">
<div class="vars">
<!-- variables specific to problem "original" -->
</div>
...
</div>
<div id="second">
<div class="vars">
<!-- variables specific to problem "second" -->
</div>
...
</div>
</div>
You could also attach a data-apply="original"
attribute to the second problem, and then all the variables declared in the first problem would be accessible in the second problem.
If you wish to provide hints that are specific to the problem that the user is working on (rather than generic to the overall problem). You can do this by providing hints within a problem itself. These hints will override hints in the base "hints" block.
If you would like separate hints for each problem, you can leave out any generic/base "hints" block, and define all your hints in the individual problems.
If there are both generic and problem-specific hints, the class-based inheritance system kicks in. For example, in this particular exercise there is a hint block that contains two placeholders: "hint1" and "hint2". These placeholders do not contain any hints and will be populated later by specific problems.
<div class="hints">
<p>Let's break this problem into smaller and easier pieces.</p>
<p class="hint1"></p>
<p><code><var>A</var> * x = </code><code class="hint_orange"><var>A</var>x</code></p>
<p class="hint2"></p>
<p><code class="hint_orange"><var>A</var>x</code><code class="hint_blue"> + <var>B</var></code></p>
<p>So, the original phrase can be written as <code><var>A</var>x + <var>B</var></code></p>
</div>
Inside a problem the author may write something like the following:
<div data-type="original">
...
<div class="hints">
<p class="hint1">What is <span class="hint_orange">the product of <var>A</var> and x</span>?</p>
<p class="hint2">What is <span class="hint_blue">the sum of <var>B</var></span> and <code class="hint_orange"><var>A</var>x</code>?</p>
</div>
</div>
The framework will take the above markup contained within the <div class="hints"> ... </div>
, go through each of the child elements (in this case, the paragraphs), and replace the associated paragraphs in the main "hints" block (thus "hint1" will replace "hint1", "hint2" will replace "hint2" and so on). What class names you wish to use can be completely at your discretion.
Back to Writing Exercises: Home