Skip to content

Instantly share code, notes, and snippets.

@sophiebits
Created July 12, 2011 01:26
Show Gist options
  • Select an option

  • Save sophiebits/1077199 to your computer and use it in GitHub Desktop.

Select an option

Save sophiebits/1077199 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html data-require="math expressions">
<head>
<title>Writing Expressions 2</title>
<script src="../khan-exercise.js"></script>
</head>
<body>
<!--1. I am including all the comments here for logic
I also have 6 problem types which is a little excessive (4 is probably enough)
but 6 is the smallest number that gives each
2. I wrote up all the intermediate hints and put them in the right order for each problem type
but I didn't put it in the code (they are commented out) because I don't know how the hint system will be coded
3. This means there are a lot of comments in this code, but I think that they are all useful
-->
<!-- COMMENTS FOR LOGIC, actual code below long comment section
Questions can be:
class = "problem" is constant
class = middle" is constant
class = "question" can be:
1 <p class="question">the sum of <code><var>A</var></code> and the product of <code><var>B</var></code> and <code>x</code></p>
2 <p class="question">the sum of <code><var>A</var></code> and the quantity of <code><var>B</var></code> times <code>x</code></p>
3 <p class="question"><code><var>A</var></code> plus the product of <code><var>B</var></code> and <code>x</code></p>
4 <p class="question"><code><var>A</var></code> plus the quantity of <code><var>B</var></code> times <code>x</code></p>
5 <p class="question">Take the the product of <code><var>B</var></code> and <code>x</code> and add <code><var>A</var></code>.</p>
6 <p class="question">Take the quantity of <code><var>B</var></code> times <code>x</code> and add <code><var>A</var></code>.</p>
class = "part-two" can be:
1 <p class="part-two"><b>the sum of <code><var>D</var></code> and the product of <code><var>C</var></code> and that expression</b>
2 <p class="part-two"><b>the sum of <code><var>D</var></code> and the quantity of <code><var>C</var></code> times that expression</b>
3 <p class="part-two"><b><code><var>D</var></code> plus the product of <code><var>C</var></code> and that expression</b>
4 <p class="part-two"><b><code><var>D</var></code> plus the quantity of <code><var>C</var></code> times that expression</b>
5 <p class="part-two"><b>Take the product of <code><var>C</var></code> and that expression and then add <code><var>D</var></code>.</b>
6 <p class="part-two"><b>Take the quantity of <code><var>C</var></code> times that expression and then add <code><var>D</var></code>.</b>
six problem types are 1-4 2-3 3-6 4-5 5-2 6-1, this gives two of each type of phrase every six questions
Hint1: ODD-EVEN for class = "question" (product / quantity)
What is <span class="hint_orange">the product of <code><var>B</var></code> and <code>x</code></span>?
What is <span class="hint_orange">the quantity of <code><var>B</var></code> times <code>x</code></span>?
Hint2: 12 34 56 for class = "question"(the sum of / plus / and add)
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?
What does <span class="hint_blue">adding <code><var>A</var></code></span> to <code class="hint_orange"><var>expr(["*", B, "x"])</var></code> do?
Hint3: ODD-EVEN for class = "part-two"(product / quantity)
What is <span class="hint_orange">the product of <code><var>C</var></code> times that expression</span>?
What is <span class="hint_orange">the quantity of <code><var>C</var></code> times that expression</span>?
Hint 4: 12 34 56 for class = "part-two" (the sum of / plus / and add)
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?
What does <span class="hint_blue">adding <code><var>D</var></code></span> to <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code> do?
-->
<div class="exercise">
<div class="vars">
<var id="A">(random() > 0.5 ? -1 : 1) * (rand(9) + 1)</var>
<var id="B">(random() > 0.5 ? -1 : 1) * (rand(9) + 1)</var>
<var id="C">(random() > 0.5 ? -1 : 1) * (rand(9) + 1)</var>
<var id="D">(random() > 0.5 ? -1 : 1) * (rand(9) + 1)</var>
</div> <!-- C ( Bx + A ) + D is the expression we are creating -->
<div class="problems">
<div id="original">
<div class="problem">
<p>First consider the expression for:</p>
</div>
<p class="question">The sum of <code><var>A</var></code> and the product of <code><var>B</var></code> and <code>x</code>.</p>
<p class="middle">Now select the answer that matches the following:</p>
<p class="part-two"><b><code><var>D</var></code> plus the quantity of <code><var>C</var></code> times that expression</b>
<br><br>
<code><var>expr(["+",["*", C,["+",["*", B, "x"], A]], D])</var></code></p>
<p class="solution"><code><var>expr(["+",["*", C,["+",["*", B, "x"], A]], D])</var></code></p>
<!-- Solution: C ( A + Bx ) + D, wrong 1: -C SAME, wrong 2: -C (B + Ax) - D, wrong 3: D ( -A + Bx ) + C, wrong 4: D ( -B + Ax ) + C -->
<ul class="choices" data-show="5" data-none="true">
<li><code><var>expr(["+",["*", -C,["+",["*", B, "x"], A]], D])</var></code></li>
<li><code><var>expr(["+",["*", -C,["+",["*", A, "x"], B]], D])</var></code></li>
<li><code><var>expr(["+",["*", D,["+",["*", B, "x"], -A]], C])</var></code></li>
<li><code><var>expr(["+",["*", D,["+",["*", A, "x"], -B]], C])</var></code></li>
</ul>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the product of <code><var>B</var></code> and <code>x</code></span>?</p>
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?</p>
What is <span class="hint_orange">the quantity of <code><var>C</var></code> times that expression</span>?</p>
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?</p>
-->
</div>
</div>
<div id="type-2" data-type="original">
<p class="question">the sum of <code><var>A</var></code> and the quantity of <code><var>B</var></code> times <code>x</code></p>
<p class="part-two"><b><code><var>D</var></code> plus the product of <code><var>C</var></code> and that expression</b>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the quantity of <code><var>B</var></code> times <code>x</code></span>?</p>
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?</p>
What is <span class="hint_orange">the product of <code><var>C</var></code> times that expression</span>?</p>
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?</p>
-->
</div>
</div>
<div id="type-3" data-type="original">
<p class="question"><code><var>A</var></code> plus the product of <code><var>B</var></code> and <code>x</code></p>
<p class="part-two"><b>Take the quantity of <code><var>C</var></code> times that expression and then add <code><var>D</var></code>.</b>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the product of <code><var>B</var></code> and <code>x</code></span>?</p>
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?</p>
What is <span class="hint_orange">the quantity of <code><var>C</var></code> times that expression</span>?</p>
What does <span class="hint_blue">adding <code><var>D</var></code></span> to <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code> do?</p>
-->
</div>
</div>
<div id="type-4" data-type="original">
<p class="question"><code><var>A</var></code> plus the quantity of <code><var>B</var></code> times <code>x</code></p>
<p class="part-two"><b>Take the product of <code><var>C</var></code> and that expression and then add <code><var>D</var></code>.</b>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the quantity of <code><var>B</var></code> times <code>x</code></span>?</p>
What is <span class="hint_blue"><code><var>A</var></code> plus</span> <code class="hint_orange"><var>expr(["*", B, "x"])</var></code>?</p>
What is <span class="hint_orange">the product of <code><var>C</var></code> times that expression</span>?</p>
What does <span class="hint_blue">adding <code><var>D</var></code></span> to <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code> do?</p>
-->
</div>
</div>
<div id="type-5" data-type="original">
<p class="question">Take the the product of <code><var>B</var></code> and <code>x</code> and add <code><var>A</var></code>.</p>
<p class="part-two"><b>The sum of <code><var>D</var></code> and the product of <code><var>C</var></code> and that expression.</b>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the product of <code><var>B</var></code> and <code>x</code></span>?</p>
What does <span class="hint_blue">adding <code><var>A</var></code></span> to <code class="hint_orange"><var>expr(["*", B, "x"])</var></code> do?</p>
What is <span class="hint_orange">the quantity of <code><var>C</var></code> times that expression</span>?</p>
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?</p>
-->
</div>
</div>
<div id="type-6" data-type="original">
<p class="question">Take the quantity of <code><var>B</var></code> times <code>x</code> and add <code><var>A</var></code>.</p>
<p class="part-two"><b>the sum of <code><var>D</var></code> and the product of <code><var>C</var></code> and that expression</b>
<div class="hints" data-apply="appendContents">
<!--
What is <span class="hint_orange">the quantity of <code><var>B</var></code> times <code>x</code></span>?</p>
What does <span class="hint_blue">adding <code><var>A</var></code></span> to <code class="hint_orange"><var>expr(["*", B, "x"])</var></code> do?</p>
What is <span class="hint_orange">the product of <code><var>C</var></code> times that expression</span>?</p>
What is <span class="hint_blue">the sum of <code><var>A</var></code></span> and <code>\color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code>?</p>
-->
</div>
</div>
</div>
<div class="hints">
<p>Let's break this problem into smaller and easier pieces.</p>
<p id="hint1"></p> <!-- What is <span class="hint_orange">the product of B and x</span>? -->
<p><code><var>B</var> \times x = \color{orange}{<var>expr(["*", B, "x"])</var>}</code></p>
<p id="hint2"></p> <!-- What is <span class="hint_orange">the sum of Bx</span> and <span class="hint_blue">A</span>? -->
<p><code class="hint_orange"><var>B</var>x</code><code class="hint_blue">{} + <var>A</var></code></p>
<p id="hint3"></p> <!-- What is <span class="hint_orange">the quantity of C times that expression</span>? -->
<p><code><var>C</var> \times (<var>B</var>x + <var>A</var>) = \color{orange}{<var>expr(["*", C,["+",["*", B, "x"], A]])</var>}</code></p>
<p id="hint4"></p> <!-- What does <span class="hint_blue">adding D do</span>? -->
<p><code class="hint_orange"><var>expr(["*", C,["+",["*", B, "x"], A]])</var></code><code class="hint_blue">{} + <var>D</var></code></p>
<p>Answer: The entire expression can be written as <code><var>expr(["+",["*", C,["+",["*", B, "x"], A]], D])</var></code></p>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment