Browse files

Space/tab cleanup

  • Loading branch information...
1 parent a13484e commit 075f731ffc4910e7dc98af6476fd2b5908b8dd39 @spicyj spicyj committed Jun 2, 2011
View
28 exercises/divisibility_intro.html
@@ -6,13 +6,13 @@
</head>
<body>
<div class="exercise">
- <!-- TODO: What happens when there is more than one right answer?
- For example: "What is a # btwn 0 and 10 that divides into 54?"
- This could be solved by making the question multiple choice or accepting multiple answers
- or changing the question altogether. This exercise does not map to a live exercise.
- -->
+ <!-- TODO: What happens when there is more than one right answer?
+ For example: "What is a # btwn 0 and 10 that divides into 54?"
+ This could be solved by making the question multiple choice or accepting multiple answers
+ or changing the question altogether. This exercise does not map to a live exercise.
+ -->
<div class="vars">
- <var id="NUMBER">randRange( 0, 1 ) ? getOddComposite( 50 ) : getEvenComposite( 50 )</var>
+ <var id="NUMBER">randRange( 0, 1 ) ? getOddComposite( 50 ) : getEvenComposite( 50 )</var>
<var id="ANSWER">
var factorization = getPrimeFactorization( NUMBER ),
num_factors = round( factorization.length / 2 ),
@@ -40,14 +40,14 @@
</div>
<div class="hints">
- <p>In other words, we are looking for a number between <var>LOW</var> and <var>HIGH</var> such that <var>NUMBER</var> is divisible by it.</p>
- <div>
- <p>We see that <var>NUMBER</var> is divisible by <var>ANSWER</var>.</p>
- <p><var>NUMBER</var>'s prime factorization is <var>NUMBER_FACTORS</var>.</p>
- <p><var>ANSWER</var>'s prime factorization is <var>ANSWER_FACTORS</var>.</p>
- <p>It isn't a coincidence that <var>NUMBER</var>'s prime factorization includes <var>ANSWER</var>'s prime factorization!</p>
- </div>
- </div>
+ <p>In other words, we are looking for a number between <var>LOW</var> and <var>HIGH</var> such that <var>NUMBER</var> is divisible by it.</p>
+ <div>
+ <p>We see that <var>NUMBER</var> is divisible by <var>ANSWER</var>.</p>
+ <p><var>NUMBER</var>'s prime factorization is <var>NUMBER_FACTORS</var>.</p>
+ <p><var>ANSWER</var>'s prime factorization is <var>ANSWER_FACTORS</var>.</p>
+ <p>It isn't a coincidence that <var>NUMBER</var>'s prime factorization includes <var>ANSWER</var>'s prime factorization!</p>
+ </div>
+ </div>
</body>
</html>
View
44 exercises/evaluating_expressions_1.html
@@ -7,23 +7,23 @@
<body>
<div class="exercise">
<div class="vars">
- <var id="X">randRange( 1, 10 )</var>
- <var id="COEFF">
- if ( randRange( 0, 1 ) ) {
- return randRange( 3, 10 );
- } else {
- return -1 * randRange( 3, 10 );
- }
- </var>
- <var id="CONSTANT">
- if ( randRange( 0, 1 ) ) {
- return randRange( 3, 10 );
- } else {
- return -1 * randRange( 3, 10 );
- }
- </var>
+ <var id="X">randRange( 1, 10 )</var>
+ <var id="COEFF">
+ if ( randRange( 0, 1 ) ) {
+ return randRange( 3, 10 );
+ } else {
+ return -1 * randRange( 3, 10 );
+ }
+ </var>
+ <var id="CONSTANT">
+ if ( randRange( 0, 1 ) ) {
+ return randRange( 3, 10 );
+ } else {
+ return -1 * randRange( 3, 10 );
+ }
+ </var>
- <var id="SOLUTION">(X * COEFF) + CONSTANT</var>
+ <var id="SOLUTION">(X * COEFF) + CONSTANT</var>
</div>
<div class="problems">
@@ -35,14 +35,14 @@
</div>
<div class="hints">
- <div>
- <p>Plug in <code class="hint_orange"><var>X</var></code> for <code>x</code>.</p>
- <p><code>= (<var>COEFF</var>) \cdot </code> <code class="hint_orange">(<var>X</var>)</code> <code> + <var>CONSTANT</var></code></p>
- </div>
+ <div>
+ <p>Plug in <code class="hint_orange"><var>X</var></code> for <code>x</code>.</p>
+ <p><code>= (<var>COEFF</var>) \cdot </code> <code class="hint_orange">(<var>X</var>)</code> <code> + <var>CONSTANT</var></code></p>
+ </div>
- <p><code>= </code> <code class="hint_orange"><var>COEFF * X</var></code> <code> + <var>CONSTANT</var></code></p>
+ <p><code>= </code> <code class="hint_orange"><var>COEFF * X</var></code> <code> + <var>CONSTANT</var></code></p>
- <p><code>= <var>SOLUTION</var></code></p>
+ <p><code>= <var>SOLUTION</var></code></p>
</div>
</div>
</body>
View
136 exercises/exponents_1.html
@@ -1,84 +1,84 @@
<!DOCTYPE html>
<html data-require="math mathformat">
<head>
- <title>Exponents 1</title>
- <script src="../khan-exercise.js"></script>
+ <title>Exponents 1</title>
+ <script src="../khan-exercise.js"></script>
</head>
<body>
- <div class="exercise">
- <p class="summary">This exercise covers exponential arithmetic with, in general, integer bases raised to nonnegative integer exponents. Handles three specific cases: integers raised to positive integers (this is the most common case); nonzero integers raised to 0; and -1, 0, and 1 raised to arbitrarily large positive integers.</p>
+ <div class="exercise">
+ <p class="summary">This exercise covers exponential arithmetic with, in general, integer bases raised to nonnegative integer exponents. Handles three specific cases: integers raised to positive integers (this is the most common case); nonzero integers raised to 0; and -1, 0, and 1 raised to arbitrarily large positive integers.</p>
- <!-- FIXME: this entire structure could be easily integrated into one problem more elegantly if the REASONABLE_EXPS array is expanded and if there is better templating support to allow for more elegant hints. without better templating support, it seems to be most elegant to just use separate problems. -->
- <div class="problems">
- <!-- Nonzero and nonunity integers raised to positive integers. Bases are chosen from [-10,10] excluding -1, 0, and 1; exponents are chosen such that the exponent is smaller than 4 result is smaller than 300. -->
- <div id="original" data-weight="3">
- <div class="vars">
- <var id="BASE">randRangeExclude( -10, 10, [0, 1, -1] )</var>
- <var id="BASE_STRING">BASE < 0 ? "(" + BASE + ")" : BASE</var>
- <!-- an array of reasonable exponents for specific bases; the ith element is the highest exponent which is reasonable to raise i to. note that this is somewhat arbitrary. -->
- <var id="REASONABLE_EXPS">[ undefined, undefined, 5, 4, 4, 4, 3, 3, 3, 3, 10 ]</var>
- <!-- we limit the occurrences of 1 as an exponent because it is to easy, but we want it to appear at least a little. -->
- <var id="EXP">randRangeWeighted( 1, REASONABLE_EXPS[abs( BASE )], 1, .1 )</var>
- <var id="SOLUTION">round( pow( BASE, EXP ) )</var>
- <var id="HINT">function() {
- var result = BASE_STRING;
- for ( var i = 1; i < EXP; i++ ) {
- result += " \\cdot" + BASE_STRING;
- }
- return result;
- }()</var>
- </div>
+ <!-- FIXME: this entire structure could be easily integrated into one problem more elegantly if the REASONABLE_EXPS array is expanded and if there is better templating support to allow for more elegant hints. without better templating support, it seems to be most elegant to just use separate problems. -->
+ <div class="problems">
+ <!-- Nonzero and nonunity integers raised to positive integers. Bases are chosen from [-10,10] excluding -1, 0, and 1; exponents are chosen such that the exponent is smaller than 4 result is smaller than 300. -->
+ <div id="original" data-weight="3">
+ <div class="vars">
+ <var id="BASE">randRangeExclude( -10, 10, [0, 1, -1] )</var>
+ <var id="BASE_STRING">BASE < 0 ? "(" + BASE + ")" : BASE</var>
+ <!-- an array of reasonable exponents for specific bases; the ith element is the highest exponent which is reasonable to raise i to. note that this is somewhat arbitrary. -->
+ <var id="REASONABLE_EXPS">[ undefined, undefined, 5, 4, 4, 4, 3, 3, 3, 3, 10 ]</var>
+ <!-- we limit the occurrences of 1 as an exponent because it is to easy, but we want it to appear at least a little. -->
+ <var id="EXP">randRangeWeighted( 1, REASONABLE_EXPS[abs( BASE )], 1, .1 )</var>
+ <var id="SOLUTION">round( pow( BASE, EXP ) )</var>
+ <var id="HINT">function() {
+ var result = BASE_STRING;
+ for ( var i = 1; i < EXP; i++ ) {
+ result += " \\cdot" + BASE_STRING;
+ }
+ return result;
+ }()</var>
+ </div>
- <p class="question"><code><var>BASE_STRING</var>^{<var>EXP</var>}</code></p>
- <p class="solution" data-type="decimal"><var>SOLUTION</var></p>
+ <p class="question"><code><var>BASE_STRING</var>^{<var>EXP</var>}</code></p>
+ <p class="solution" data-type="decimal"><var>SOLUTION</var></p>
- <div class="hints">
- <!-- FIXME: once we have templating loops, will need to implement a dynamic number of hints, with collapsing multiplication, like: 2x2x2x2 then 4x2x2 then 8x2 then 16 -->
- <div><code>= <var>HINT</var></code></div>
- <div><code>= <var>SOLUTION</var></code></div>
- </div>
- </div>
+ <div class="hints">
+ <!-- FIXME: once we have templating loops, will need to implement a dynamic number of hints, with collapsing multiplication, like: 2x2x2x2 then 4x2x2 then 8x2 then 16 -->
+ <div><code>= <var>HINT</var></code></div>
+ <div><code>= <var>SOLUTION</var></code></div>
+ </div>
+ </div>
- <!-- Nonzero integers raised to 0. Base is chosen from [-500,500]. -->
- <div id="zero-exp">
- <div class="vars">
- <var id="BASE">randRangeNonZero( -500, 500 )</var>
- <var id="BASE_STRING">BASE < 0 ? "(" + BASE + ")" : BASE</var>
- </div>
+ <!-- Nonzero integers raised to 0. Base is chosen from [-500,500]. -->
+ <div id="zero-exp">
+ <div class="vars">
+ <var id="BASE">randRangeNonZero( -500, 500 )</var>
+ <var id="BASE_STRING">BASE < 0 ? "(" + BASE + ")" : BASE</var>
+ </div>
- <p class="question"><code><var>BASE_STRING</var>^{0}</code></p>
- <p class="solution" data-type="decimal">1</p>
+ <p class="question"><code><var>BASE_STRING</var>^{0}</code></p>
+ <p class="solution" data-type="decimal">1</p>
- <div class="hints">
- <div>Anything to the 0th power equals...?</div>
- <div>Anything to the 0th power equals 1.</div>
- </div>
- </div>
+ <div class="hints">
+ <div>Anything to the 0th power equals...?</div>
+ <div>Anything to the 0th power equals 1.</div>
+ </div>
+ </div>
- <!-- -1, 0, and 1 raised to arbitrarily large positive integers. Exponents are chosen from [1,1000]. -->
- <div id="easy-base">
- <div class="vars">
- <!-- -1 is the most interesting case, so we choose -1 half the time, 0 a quarter of the time, and 1 a quarter of the time. -->
- <var id="BASE">random() < 0.5 ? -1 : (random() < 0.5 ? 0 : 1)</var>
- <var id="BASE_STRING">BASE === -1 ? "(-1)" : BASE</var>
- <var id="EXP">randRange( 1, 1000 )</var>
- <var id="SOLUTION">round( pow( BASE, EXP ) )</var>
- <var id="POWER_HINT">function() {
- if (BASE === 0) return "nonzero";
- else if (BASE === 1) return "";
- else return isEven( EXP ) ? "even" : "odd";
- }()</var>
- </div>
+ <!-- -1, 0, and 1 raised to arbitrarily large positive integers. Exponents are chosen from [1,1000]. -->
+ <div id="easy-base">
+ <div class="vars">
+ <!-- -1 is the most interesting case, so we choose -1 half the time, 0 a quarter of the time, and 1 a quarter of the time. -->
+ <var id="BASE">random() < 0.5 ? -1 : (random() < 0.5 ? 0 : 1)</var>
+ <var id="BASE_STRING">BASE === -1 ? "(-1)" : BASE</var>
+ <var id="EXP">randRange( 1, 1000 )</var>
+ <var id="SOLUTION">round( pow( BASE, EXP ) )</var>
+ <var id="POWER_HINT">function() {
+ if (BASE === 0) return "nonzero";
+ else if (BASE === 1) return "";
+ else return isEven( EXP ) ? "even" : "odd";
+ }()</var>
+ </div>
- <p class="question"><code><var>BASE_STRING</var>^{<var>EXP</var>}</code></p>
- <p class="solution" data-type="decimal"><var>SOLUTION</var></p>
+ <p class="question"><code><var>BASE_STRING</var>^{<var>EXP</var>}</code></p>
+ <p class="solution" data-type="decimal"><var>SOLUTION</var></p>
- <div class="hints">
- <div><var>Cardinal(BASE)</var> to any <var>POWER_HINT</var> power equals...?</div>
- <div><var>Cardinal(BASE)</var> to any <var>POWER_HINT</var> power equals <var>SOLUTION</var>.</div>
- </div>
- </div>
- </div>
- </div>
+ <div class="hints">
+ <div><var>Cardinal(BASE)</var> to any <var>POWER_HINT</var> power equals...?</div>
+ <div><var>Cardinal(BASE)</var> to any <var>POWER_HINT</var> power equals <var>SOLUTION</var>.</div>
+ </div>
+ </div>
+ </div>
+ </div>
</body>
</html>
View
78 exercises/exponents_2.html
@@ -1,49 +1,49 @@
<!DOCTYPE html>
<html data-require="math">
<head>
- <title>Exponents 2</title>
- <script src="../khan-exercise.js"></script>
+ <title>Exponents 2</title>
+ <script src="../khan-exercise.js"></script>
</head>
<body>
- <div class="exercise">
- <p class="summary">This exercise covers exponential arithmetic with rational bases and integer (primarily negative) exponents.</p>
+ <div class="exercise">
+ <p class="summary">This exercise covers exponential arithmetic with rational bases and integer (primarily negative) exponents.</p>
- <div class="problems">
- <div>
- <div class="vars" data-ensure="BASE_NUM !== BASE_DENOM">
- <var id="BASE_NUM">randRange( 1, 10 )</var>
- <!-- we want 25% of the exercises to have integer bases. -->
- <var id="BASE_DENOM">randRangeWeighted( 1, 10, 1, .25 )</var>
- <!-- we want 50% of the exercises to have negative bases. -->
- <var id="BASE_NEG">random() < 0.5</var>
- <!-- an array of reasonable exponents for specific bases; the ith element is the highest exponent which is reasonable to raise i to. note that this is somewhat arbitrary. -->
- <var id="REASONABLE_EXPS">[ undefined, 1000, 5, 4, 4, 4, 3, 3, 3, 3, 10 ]</var>
- <!-- we want only 10% of the exercises to have 1 as an exponent. -->
- <var id="EXP">randRangeWeighted( 1, min( REASONABLE_EXPS[BASE_NUM], REASONABLE_EXPS[BASE_DENOM] ), 1, .1)</var>
- <!-- we want 75% of the exercises to have negative exponents. -->
- <var id="EXP_NEG">random() < 0.75</var>
- <var id="BASE_STRING">function() {
- var result = BASE_NUM;
- if ( BASE_DENOM !== 1 )
- result = "\\frac{BASE_NUM}{BASE_DENOM}";
- if ( BASE_NEG )
- result = "\\left(-" + result + "\\right)";
- return result;
- }()</var>
- <var id="HINT">function() {
- /* FIXME: implement! */
- }()</var>
- <var id="SOLUTION">round( pow( BASE_NUM / BASE_DENOM, EXP ) )</var>
- </div>
+ <div class="problems">
+ <div>
+ <div class="vars" data-ensure="BASE_NUM !== BASE_DENOM">
+ <var id="BASE_NUM">randRange( 1, 10 )</var>
+ <!-- we want 25% of the exercises to have integer bases. -->
+ <var id="BASE_DENOM">randRangeWeighted( 1, 10, 1, .25 )</var>
+ <!-- we want 50% of the exercises to have negative bases. -->
+ <var id="BASE_NEG">random() < 0.5</var>
+ <!-- an array of reasonable exponents for specific bases; the ith element is the highest exponent which is reasonable to raise i to. note that this is somewhat arbitrary. -->
+ <var id="REASONABLE_EXPS">[ undefined, 1000, 5, 4, 4, 4, 3, 3, 3, 3, 10 ]</var>
+ <!-- we want only 10% of the exercises to have 1 as an exponent. -->
+ <var id="EXP">randRangeWeighted( 1, min( REASONABLE_EXPS[BASE_NUM], REASONABLE_EXPS[BASE_DENOM] ), 1, .1)</var>
+ <!-- we want 75% of the exercises to have negative exponents. -->
+ <var id="EXP_NEG">random() < 0.75</var>
+ <var id="BASE_STRING">function() {
+ var result = BASE_NUM;
+ if ( BASE_DENOM !== 1 )
+ result = "\\frac{BASE_NUM}{BASE_DENOM}";
+ if ( BASE_NEG )
+ result = "\\left(-" + result + "\\right)";
+ return result;
+ }()</var>
+ <var id="HINT">function() {
+ /* FIXME: implement! */
+ }()</var>
+ <var id="SOLUTION">round( pow( BASE_NUM / BASE_DENOM, EXP ) )</var>
+ </div>
- <p class="question"><code><var>BASE_STRING</var>^{<var>(EXP_NEG ? "-" : "")+EXP</var>}</code></p>
- <p class="solution" data-type="rational"><var>SOLUTION</var></p>
+ <p class="question"><code><var>BASE_STRING</var>^{<var>(EXP_NEG ? "-" : "")+EXP</var>}</code></p>
+ <p class="solution" data-type="rational"><var>SOLUTION</var></p>
- <div class="hints">
- <!-- FIXME: IMPLEMENT! -->
- </div>
- </div>
- </div>
- </div>
+ <div class="hints">
+ <!-- FIXME: IMPLEMENT! -->
+ </div>
+ </div>
+ </div>
+ </div>
</body>
</html>
View
74 exercises/linear_equations_1.html
@@ -1,48 +1,48 @@
<!DOCTYPE html>
<html data-require="math mathformat">
<head>
- <title>Linear Equations 1</title>
- <script src="../khan-exercise.js"></script>
+ <title>Linear Equations 1</title>
+ <script src="../khan-exercise.js"></script>
</head>
<body>
- <div class="exercise">
- <div class="vars">
- <!--
- An example where some form of exercise inheritance would be useful.
- Linear Eq 1 ==> AX = D
- Linear Eq 2 ==> AX + B = CX
- Linear Eq 3 ==> AX + B = CX + D
+ <div class="exercise">
+ <div class="vars">
+ <!--
+ An example where some form of exercise inheritance would be useful.
+ Linear Eq 1 ==> AX = D
+ Linear Eq 2 ==> AX + B = CX
+ Linear Eq 3 ==> AX + B = CX + D
- Issue #36 for reference.
- -->
- <var id="A">randRange( 2, 10 )</var>
- <var id="D">randRange( 2, 10 )</var>
- <var id="SOLUTION">fraction( D, A )</var>
- <var id="ONE_OVER_A">fraction( 1, A )</var>
- </div>
+ Issue #36 for reference.
+ -->
+ <var id="A">randRange( 2, 10 )</var>
+ <var id="D">randRange( 2, 10 )</var>
+ <var id="SOLUTION">fraction( D, A )</var>
+ <var id="ONE_OVER_A">fraction( 1, A )</var>
+ </div>
- <div class="problems">
- <div>
- <p class="question">Solve for <code>x</code>:</p>
- <div><code><var>A</var>x = <var>D</var></code></div>
+ <div class="problems">
+ <div>
+ <p class="question">Solve for <code>x</code>:</p>
+ <div><code><var>A</var>x = <var>D</var></code></div>
- <!-- In prod, it's multiple choice, but I'd like to make this free answer.
- Custom answer input for fractional answers? Issue #35 -->
- <p class="solution">SOLUTION</p>
- </div>
- </div>
+ <!-- In prod, it's multiple choice, but I'd like to make this free answer.
+ Custom answer input for fractional answers? Issue #35 -->
+ <p class="solution">SOLUTION</p>
+ </div>
+ </div>
- <div class="hints">
- <!-- Below data-if required to sneak around Issue #34. -->
- <div data-if="true">
- <p>Multiply both sides by <code><var>ONE_OVER_A</var></code>.</p>
- <p><code>(<var>ONE_OVER_A</var>) \cdot (<var>A</var>x) = (<var>ONE_OVER_A</var>) \cdot (<var>D</var>)</code></p>
- </div>
- <div>
- <p>Simplify.</p>
- <p><code>x = <var>SOLUTION</var></code></p>
- </div>
- </div>
- </div>
+ <div class="hints">
+ <!-- Below data-if required to sneak around Issue #34. -->
+ <div data-if="true">
+ <p>Multiply both sides by <code><var>ONE_OVER_A</var></code>.</p>
+ <p><code>(<var>ONE_OVER_A</var>) \cdot (<var>A</var>x) = (<var>ONE_OVER_A</var>) \cdot (<var>D</var>)</code></p>
+ </div>
+ <div>
+ <p>Simplify.</p>
+ <p><code>x = <var>SOLUTION</var></code></p>
+ </div>
+ </div>
+ </div>
</body>
</html>
View
46 exercises/logarithms_1.html
@@ -14,23 +14,23 @@
function get_number( base ) {
var number;
do {
- /* Note: This will tend to use smaller powers. */
+ /* Note: This will tend to use smaller powers. */
answer = KhanUtil.randRange ( 2, 5 );
number = Math.pow( base, answer );
} while ( number > LARGEST_NUMBER );
return number;
}
- /* This is used for hints. Given the number you're taking a logarithim of, and
- * a base, breaks the number into base x base x base... x base.
- * Returns a string. */
- function get_power_string(number, base) {
- var result = base;
- for (var i=base; i<number; i*=base){
- result += "\\times" + base;
- }
- return result;
- }
+ /* This is used for hints. Given the number you're taking a logarithim of, and
+ * a base, breaks the number into base x base x base... x base.
+ * Returns a string. */
+ function get_power_string(number, base) {
+ var result = base;
+ for (var i=base; i<number; i*=base){
+ result += "\\times" + base;
+ }
+ return result;
+ }
</script>
</head>
<body>
@@ -39,30 +39,30 @@
<var id="base">KhanUtil.randRange( 2, 16 )</var>
<var id="number">get_number(base)</var>
<var id="answer">answer</var>
- <var id="power_string">get_power_string(number, base)</var>
+ <var id="power_string">get_power_string(number, base)</var>
</div>
<div class="problems">
<div>
<p class="question"><code>log_{<var>base</var>}<var>number</var> = </code></p>
<p class="solution"><var>answer</var></p>
<ul class="choices" data-show="5">
- <li><var>1</var></li>
- <li><var>2</var></li>
- <li><var>3</var></li>
- <li><var>4</var></li>
- <li><var>5</var></li>
- <li><var>6</var></li>
+ <li><var>1</var></li>
+ <li><var>2</var></li>
+ <li><var>3</var></li>
+ <li><var>4</var></li>
+ <li><var>5</var></li>
+ <li><var>6</var></li>
</ul>
</div>
</div>
<div class="hints">
- <p>If <code>b^e=x</code> ,then <code>log_{b}x=e</code></p>
- <p>First, try to write <code><var>number</var></code>, the number we are taking the logarithm of, as a power of <code><var>base</var></code>, the base of the logarithm.</p>
- <p><code><var>number</var></code> can be expressed as <code><var>power_string</var></code></p>
- <p><var>number</var> can be expressed as <code><var>base</var>^<var>answer</var></code>.</p>
- <p><code><var>base</var>^<var>answer</var>=<var>number</var></code> so <code>log_{<var>base</var>}<var>number</var>=<var>answer</var></p>
+ <p>If <code>b^e=x</code> ,then <code>log_{b}x=e</code></p>
+ <p>First, try to write <code><var>number</var></code>, the number we are taking the logarithm of, as a power of <code><var>base</var></code>, the base of the logarithm.</p>
+ <p><code><var>number</var></code> can be expressed as <code><var>power_string</var></code></p>
+ <p><var>number</var> can be expressed as <code><var>base</var>^<var>answer</var></code>.</p>
+ <p><code><var>base</var>^<var>answer</var>=<var>number</var></code> so <code>log_{<var>base</var>}<var>number</var>=<var>answer</var></p>
</div>
</div>
</body>
View
52 exercises/multiplication_1.html
@@ -1,36 +1,36 @@
<!DOCTYPE html>
<html data-require="math">
<head>
- <title>Multiplication 1</title>
- <script src="../khan-exercise.js"></script>
-<style>
- .mult_bullet {
- font-size: 7em;
- color: blue;
- }
-</style>
+ <title>Multiplication 1</title>
+ <script src="../khan-exercise.js"></script>
+ <style>
+ .mult_bullet {
+ font-size: 7em;
+ color: blue;
+ }
+ </style>
</head>
<body>
- <div class="exercise">
- <div class="vars">
- <var id="A">rand( 12 )</var>
- <var id="B">rand( 12 )</var>
- </div>
+ <div class="exercise">
+ <div class="vars">
+ <var id="A">rand( 12 )</var>
+ <var id="B">rand( 12 )</var>
+ </div>
- <div class="problems">
- <div>
- <p class="question"><code><var>A</var> \times <var>B</var> = ?</code></p>
- <div class="solution"><var>A * B</var></div>
- </div>
- </div>
+ <div class="problems">
+ <div>
+ <p class="question"><code><var>A</var> \times <var>B</var> = ?</code></p>
+ <div class="solution"><var>A * B</var></div>
+ </div>
+ </div>
- <div class="hints">
- <!-- TODO use (currently nonexistent) loop template to create square of dots -->
- <div class="mult_bullet">&bull; &bull; &bull;</div>
- <div>There are <var>A</var> rows and <var>B</var> columns.</div>
- <div>In total, there are <var>A * B</var> circles.</div>
- </div>
+ <div class="hints">
+ <!-- TODO use (currently nonexistent) loop template to create square of dots -->
+ <div class="mult_bullet">&bull; &bull; &bull;</div>
+ <div>There are <var>A</var> rows and <var>B</var> columns.</div>
+ <div>In total, there are <var>A * B</var> circles.</div>
+ </div>
- </div>
+ </div>
</body>
</html>
View
214 exercises/percentage_word_problems_1.html
@@ -1,114 +1,114 @@
<!DOCTYPE html>
<html data-require="math word-problems">
<head>
- <title>Percentage Word Problems 1</title>
- <script src="../khan-exercise.js"></script>
+ <title>Percentage Word Problems 1</title>
+ <script src="../khan-exercise.js"></script>
</head>
<body>
- <div class="exercise">
- <div class="problems">
- <div id="simple-percentages">
- <div class="vars">
- <var id="A_SIMPLE">KhanUtil.randRange( 1, 150 )</var>
- <var id="B_SIMPLE">KhanUtil.randRange( 2, 100 )</var>
- </div>
- <p class="question">
- What is <var>A_SIMPLE</var>% of <var>B_SIMPLE</var>? (Round to nearest whole number)
- </p>
- <p class="solution" data-type="decimal"><var>round((A_SIMPLE * B_SIMPLE) / 100)</var></p>
- <div class="hints">
- <p>
- <code><var>A_SIMPLE / 100</var> * <var>B_SIMPLE</var> \approx <var>round((A_SIMPLE * B_SIMPLE) / 100)</var> </code>
- </p>
- </div>
- </div>
- <div id="backward-percentages" data-type="simple-percentages">
- <p class="question">
- <var>B_SIMPLE</var> is <var>A_SIMPLE</var>% of what number? (Round to the hundredths place)
- </p>
- <p class="solution" data-type="decimal"><var>round(((B_SIMPLE * 100) / A_SIMPLE) * 100) / 100</var></p>
- <div class="hints">
- <p>Let <code>x</code> be the number that <var>B_SIMPLE</var> is <var>A_SIMPLE</var>% of.</p>
- <p><code><var>A_SIMPLE / 100</var> * x = <var>B_SIMPLE</var></code></p>
- <p><code>x=<var>B_SIMPLE</var>/<var>A_SIMPLE / 100</var></code></p>
- <p><code>x \approx<var>round((B_SIMPLE * 100/A_SIMPLE * 100))/100</var></code></p>
- </div>
- </div>
- <div id="bank-percentages">
- <div class="vars">
- <var id="BANK_FEWER">KhanUtil.randRange( 2, 100 )</var>
- <var id="BANK_MORE">BANK_FEWER + KhanUtil.randRange(5, 2 * BANK_FEWER + 10 )</var>
- </div>
- <p class="question">
- <var>person(1)</var> has <var>BANK_MORE</var> dollars in the bank today. Yesterday, <var>he(1)</var> had <var>BANK_FEWER</var> dollars in the bank. By what percentage did <var>person(1)</var>'s bank account increase over the past day? (Enter your answer as a percentage rounded to the hundredths place. For example, if your answer is 95.678%, enter 95.68 for your answer) </p>
- <p class="solution" data-type="decimal"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_FEWER) / 100</var></p>
- <div class="hints">
- <p>The bank account grew by <code><var>BANK_MORE</var> - <var>BANK_FEWER</var> = <var>BANK_MORE - BANK_FEWER</var></code> dollars </p>
- <p> <code>\frac{<var>BANK_MORE - BANK_FEWER</var>}{<var>BANK_FEWER</var>} \approx <var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_FEWER) / 100</var>\%</code></p>
- </div>
- </div>
- <div id="bank-percentages-loss" data-type="bank-percentages">
- <p class="question">
- <var>person(1)</var> has <var>BANK_FEWER</var> dollars in the bank today. Yesterday, <var>he(1)</var> had <var>BANK_MORE</var> dollars in the bank. By what percentage did <var>person(1)</var>'s bank account decrease over the past day? (Enter your answer as a percentage rounded to the hundredths place. For example, if your answer is 95.678%, enter 95.68 for your answer.)
- </p>
- <p class="solution" data-type="decimal"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_MORE) / 100</var></p>
- <div class="hints">
- <p>The bank account decreased by <code><var>BANK_MORE</var> - <var>BANK_FEWER</var> = <var>BANK_MORE - BANK_FEWER</var></code> dollars </p>
- <p> <code>\frac{<var>BANK_MORE - BANK_FEWER</var>}{<var>BANK_MORE</var>} \approx <var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_MORE) / 100</var>\%</code></p>
- </div>
- </div>
- <div id="yearly-percentages">
- <div class="vars">
- <var id="YEAR_PERCENT_MORE">KhanUtil.randRange( 10, 150 )</var>
- <var id="YEAR_THIS">KhanUtil.randRange( 50, 999 )</var>
- <var id="YEAR_LAST">round(YEAR_THIS * 10000 / (100 + YEAR_PERCENT_MORE)) / 100</var>
- </div>
- <p class="question">
- <var>person(1)</var> has <var>YEAR_PERCENT_MORE</var>% more money today than <var>he(1)</var> did this time last year. If <var>person(1)</var> has <var>YEAR_THIS</var> dollars today, how many dollars did she have this time last year? (round to the nearest cent [hundredth of a dollar])</p>
- <p class="solution" data-type="decimal"><var>YEAR_LAST</var></p>
- <div class="hints">
- <p>Let <code>x</code> be the amount of money that she had last year.</p>
- <p><code>x + <var>YEAR_PERCENT_MORE / 100</var>x = <var>YEAR_THIS</var></code></p>
- <p><code><var>(100 + YEAR_PERCENT_MORE) / 100</var>x = <var>YEAR_THIS</var></code></p>
- <p><code>x = \frac{<var>YEAR_THIS</var>}{<var>(100 + YEAR_PERCENT_MORE) / 100</var>}</code></p>
- <p><code>x \approx <var>YEAR_LAST</var></code></p>
- </div>
- </div>
- <div id="yearly-percentages-2" data-type="yearly-percentages">
- <p class="question">
- <var>person(1)</var> has <var>YEAR_PERCENT_MORE</var>% more money today than <var>he(1)</var> did this time last year. If <var>person(1)</var> has <var>YEAR_THIS</var> dollars today, how many dollars did she make over this past year? (round to the nearest cent [hundredth of a dollar])</p>
- <p class="solution" data-type="decimal"><var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var></p>
- <div class="hints">
- <p>Let <code>x</code> be the amount of money that she had last year.</p>
- <p><code>x + <var>YEAR_PERCENT_MORE / 100</var>x = <var>YEAR_THIS</var></code></p>
- <p><code><var>(100 + YEAR_PERCENT_MORE) / 100</var>x = <var>YEAR_THIS</var></code></p>
- <p><code>x = \frac{<var>YEAR_THIS</var>}{<var>(100 + YEAR_PERCENT_MORE) / 100</var>}</code></p>
- <p><code>x \approx <var>YEAR_LAST</var></code></p>
- <p>So, she had <var>YEAR_LAST</var> dollars last year. However, we need to know how much she has made <b>over the past year!</b></p>
- <p>If she had <var>YEAR_LAST</var> dollars last year and now has <var>YEAR_THIS</var> dollars this year, then she has made <code><var>YEAR_THIS</var>-<var>YEAR_LAST</var> \approx <var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var></code> dollars over the course of the year.</p>
- <p>So, the answer is <var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var> dollars.</p>
- </div>
- </div>
- <!--TODO: replace get_random_person_name() with function that works -->
- <div class="store-percentages">
- <div class="vars">
- <var id="PERCENT_OFF">KhanUtil.randRange( 10, 25 )</var>
- <var id="DOLLARS">KhanUtil.randRange( 5, 100 )</var>
- <var id="HIGHEST_PRICE">round(DOLLARS * 100 * 100 / (100 - PERCENT_OFF)) / 100 </var>
- </div>
- <div class="problem">
- <p class="question"> <var>person(1)</var> has <var>DOLLARS</var> dollars to spend at a store. The store currently has a sale where the sale price is <var>PERCENT_OFF</var>% off the marked price. What is the highest marked price that <var>person(1)</var> can afford?</p>
- <p class="solution"><var>HIGHEST_PRICE</var></p>
- </div>
- <div class="hints">
- <p>Let <code>x</code> be the highest marked price that <var>person(1)</var></code> can afford.</p>
- <p><code>x-<var>(PERCENT_OFF/100)</var>x = </code> sale price</p>
- <p><code><var>((100-PERCENT_OFF)/100)</var>x = </code> sale price</p>
- <p><code><var>((100-PERCENT_OFF/100)</var>x = <var>DOLLARS</var></code></p>
- <p><code>x = <var>HIGHEST_PRICE</var></code> dollars</p>
- </div>
- </div>
- </div>
- </div>
+ <div class="exercise">
+ <div class="problems">
+ <div id="simple-percentages">
+ <div class="vars">
+ <var id="A_SIMPLE">KhanUtil.randRange( 1, 150 )</var>
+ <var id="B_SIMPLE">KhanUtil.randRange( 2, 100 )</var>
+ </div>
+ <p class="question">
+ What is <var>A_SIMPLE</var>% of <var>B_SIMPLE</var>? (Round to nearest whole number)
+ </p>
+ <p class="solution" data-type="decimal"><var>round((A_SIMPLE * B_SIMPLE) / 100)</var></p>
+ <div class="hints">
+ <p>
+ <code><var>A_SIMPLE / 100</var> * <var>B_SIMPLE</var> \approx <var>round((A_SIMPLE * B_SIMPLE) / 100)</var> </code>
+ </p>
+ </div>
+ </div>
+ <div id="backward-percentages" data-type="simple-percentages">
+ <p class="question">
+ <var>B_SIMPLE</var> is <var>A_SIMPLE</var>% of what number? (Round to the hundredths place)
+ </p>
+ <p class="solution" data-type="decimal"><var>round(((B_SIMPLE * 100) / A_SIMPLE) * 100) / 100</var></p>
+ <div class="hints">
+ <p>Let <code>x</code> be the number that <var>B_SIMPLE</var> is <var>A_SIMPLE</var>% of.</p>
+ <p><code><var>A_SIMPLE / 100</var> * x = <var>B_SIMPLE</var></code></p>
+ <p><code>x=<var>B_SIMPLE</var>/<var>A_SIMPLE / 100</var></code></p>
+ <p><code>x \approx<var>round((B_SIMPLE * 100/A_SIMPLE * 100))/100</var></code></p>
+ </div>
+ </div>
+ <div id="bank-percentages">
+ <div class="vars">
+ <var id="BANK_FEWER">KhanUtil.randRange( 2, 100 )</var>
+ <var id="BANK_MORE">BANK_FEWER + KhanUtil.randRange(5, 2 * BANK_FEWER + 10 )</var>
+ </div>
+ <p class="question">
+ <var>person(1)</var> has <var>BANK_MORE</var> dollars in the bank today. Yesterday, <var>he(1)</var> had <var>BANK_FEWER</var> dollars in the bank. By what percentage did <var>person(1)</var>'s bank account increase over the past day? (Enter your answer as a percentage rounded to the hundredths place. For example, if your answer is 95.678%, enter 95.68 for your answer) </p>
+ <p class="solution" data-type="decimal"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_FEWER) / 100</var></p>
+ <div class="hints">
+ <p>The bank account grew by <code><var>BANK_MORE</var> - <var>BANK_FEWER</var> = <var>BANK_MORE - BANK_FEWER</var></code> dollars </p>
+ <p> <code>\frac{<var>BANK_MORE - BANK_FEWER</var>}{<var>BANK_FEWER</var>} \approx <var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_FEWER) / 100</var>\%</code></p>
+ </div>
+ </div>
+ <div id="bank-percentages-loss" data-type="bank-percentages">
+ <p class="question">
+ <var>person(1)</var> has <var>BANK_FEWER</var> dollars in the bank today. Yesterday, <var>he(1)</var> had <var>BANK_MORE</var> dollars in the bank. By what percentage did <var>person(1)</var>'s bank account decrease over the past day? (Enter your answer as a percentage rounded to the hundredths place. For example, if your answer is 95.678%, enter 95.68 for your answer.)
+ </p>
+ <p class="solution" data-type="decimal"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_MORE) / 100</var></p>
+ <div class="hints">
+ <p>The bank account decreased by <code><var>BANK_MORE</var> - <var>BANK_FEWER</var> = <var>BANK_MORE - BANK_FEWER</var></code> dollars </p>
+ <p> <code>\frac{<var>BANK_MORE - BANK_FEWER</var>}{<var>BANK_MORE</var>} \approx <var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_MORE) / 100</var>\%</code></p>
+ </div>
+ </div>
+ <div id="yearly-percentages">
+ <div class="vars">
+ <var id="YEAR_PERCENT_MORE">KhanUtil.randRange( 10, 150 )</var>
+ <var id="YEAR_THIS">KhanUtil.randRange( 50, 999 )</var>
+ <var id="YEAR_LAST">round(YEAR_THIS * 10000 / (100 + YEAR_PERCENT_MORE)) / 100</var>
+ </div>
+ <p class="question">
+ <var>person(1)</var> has <var>YEAR_PERCENT_MORE</var>% more money today than <var>he(1)</var> did this time last year. If <var>person(1)</var> has <var>YEAR_THIS</var> dollars today, how many dollars did she have this time last year? (round to the nearest cent [hundredth of a dollar])</p>
+ <p class="solution" data-type="decimal"><var>YEAR_LAST</var></p>
+ <div class="hints">
+ <p>Let <code>x</code> be the amount of money that she had last year.</p>
+ <p><code>x + <var>YEAR_PERCENT_MORE / 100</var>x = <var>YEAR_THIS</var></code></p>
+ <p><code><var>(100 + YEAR_PERCENT_MORE) / 100</var>x = <var>YEAR_THIS</var></code></p>
+ <p><code>x = \frac{<var>YEAR_THIS</var>}{<var>(100 + YEAR_PERCENT_MORE) / 100</var>}</code></p>
+ <p><code>x \approx <var>YEAR_LAST</var></code></p>
+ </div>
+ </div>
+ <div id="yearly-percentages-2" data-type="yearly-percentages">
+ <p class="question">
+ <var>person(1)</var> has <var>YEAR_PERCENT_MORE</var>% more money today than <var>he(1)</var> did this time last year. If <var>person(1)</var> has <var>YEAR_THIS</var> dollars today, how many dollars did she make over this past year? (round to the nearest cent [hundredth of a dollar])</p>
+ <p class="solution" data-type="decimal"><var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var></p>
+ <div class="hints">
+ <p>Let <code>x</code> be the amount of money that she had last year.</p>
+ <p><code>x + <var>YEAR_PERCENT_MORE / 100</var>x = <var>YEAR_THIS</var></code></p>
+ <p><code><var>(100 + YEAR_PERCENT_MORE) / 100</var>x = <var>YEAR_THIS</var></code></p>
+ <p><code>x = \frac{<var>YEAR_THIS</var>}{<var>(100 + YEAR_PERCENT_MORE) / 100</var>}</code></p>
+ <p><code>x \approx <var>YEAR_LAST</var></code></p>
+ <p>So, she had <var>YEAR_LAST</var> dollars last year. However, we need to know how much she has made <b>over the past year!</b></p>
+ <p>If she had <var>YEAR_LAST</var> dollars last year and now has <var>YEAR_THIS</var> dollars this year, then she has made <code><var>YEAR_THIS</var>-<var>YEAR_LAST</var> \approx <var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var></code> dollars over the course of the year.</p>
+ <p>So, the answer is <var>round((YEAR_THIS - YEAR_LAST) * 100) / 100</var> dollars.</p>
+ </div>
+ </div>
+ <!--TODO: replace get_random_person_name() with function that works -->
+ <div class="store-percentages">
+ <div class="vars">
+ <var id="PERCENT_OFF">KhanUtil.randRange( 10, 25 )</var>
+ <var id="DOLLARS">KhanUtil.randRange( 5, 100 )</var>
+ <var id="HIGHEST_PRICE">round(DOLLARS * 100 * 100 / (100 - PERCENT_OFF)) / 100 </var>
+ </div>
+ <div class="problem">
+ <p class="question"> <var>person(1)</var> has <var>DOLLARS</var> dollars to spend at a store. The store currently has a sale where the sale price is <var>PERCENT_OFF</var>% off the marked price. What is the highest marked price that <var>person(1)</var> can afford?</p>
+ <p class="solution"><var>HIGHEST_PRICE</var></p>
+ </div>
+ <div class="hints">
+ <p>Let <code>x</code> be the highest marked price that <var>person(1)</var></code> can afford.</p>
+ <p><code>x-<var>(PERCENT_OFF/100)</var>x = </code> sale price</p>
+ <p><code><var>((100-PERCENT_OFF)/100)</var>x = </code> sale price</p>
+ <p><code><var>((100-PERCENT_OFF/100)</var>x = <var>DOLLARS</var></code></p>
+ <p><code>x = <var>HIGHEST_PRICE</var></code> dollars</p>
+ </div>
+ </div>
+ </div>
+ </div>
</body>
</html>
View
68 exercises/place_value.html
@@ -5,56 +5,56 @@
<script src="../khan-exercise.js"></script>
</head>
<body>
- <!-- Note that this exercise does not map to a live exercise.
- (Was suggested recently by one of our teachers.)
- -->
+ <!-- Note that this exercise does not map to a live exercise.
+ (Was suggested recently by one of our teachers.)
+ -->
<div class="exercise">
<div class="vars">
- <var id="DIGITS">KhanUtil.shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9]).slice( 0, 4 )</var>
+ <var id="DIGITS">KhanUtil.shuffle([1, 2, 3, 4, 5, 6, 7, 8, 9]).slice( 0, 4 )</var>
- <var id="THOUSANDS">DIGITS[0]</var>
- <var id="HUNDREDS">DIGITS[1]</var>
- <var id="TENS">DIGITS[2]</var>
- <var id="ONES">DIGITS[3]</var>
+ <var id="THOUSANDS">DIGITS[0]</var>
+ <var id="HUNDREDS">DIGITS[1]</var>
+ <var id="TENS">DIGITS[2]</var>
+ <var id="ONES">DIGITS[3]</var>
- <var id="NUM">1000 * THOUSANDS + 100 * HUNDREDS + 10 * TENS + ONES</var>
+ <var id="NUM">1000 * THOUSANDS + 100 * HUNDREDS + 10 * TENS + ONES</var>
- <var id="PLACES">["thousands", "hundreds", "tens", "ones"]</var>
- <var id="QUESTION_TYPE">randRange( 0, 3 )</var>
+ <var id="PLACES">["thousands", "hundreds", "tens", "ones"]</var>
+ <var id="QUESTION_TYPE">randRange( 0, 3 )</var>
- <var id="QUESTION_PLACE">DIGITS[QUESTION_TYPE]</var>
- <var id="SOLUTION">PLACES.splice( QUESTION_TYPE, 1 )</var>
- <var id="WRONG_1">PLACES[0]</var>
- <var id="WRONG_2">PLACES[1]</var>
- <var id="WRONG_3">PLACES[2]</var>
+ <var id="QUESTION_PLACE">DIGITS[QUESTION_TYPE]</var>
+ <var id="SOLUTION">PLACES.splice( QUESTION_TYPE, 1 )</var>
+ <var id="WRONG_1">PLACES[0]</var>
+ <var id="WRONG_2">PLACES[1]</var>
+ <var id="WRONG_3">PLACES[2]</var>
</div>
<div class="problems">
<div>
- <p class="question">What is the place value of <var>QUESTION_PLACE</var> in <var>NUM</var>?</p>
- <p class="solution"><var>SOLUTION</var></p>
+ <p class="question">What is the place value of <var>QUESTION_PLACE</var> in <var>NUM</var>?</p>
+ <p class="solution"><var>SOLUTION</var></p>
<ul class="choices">
- <li><var>WRONG_1</var></li>
- <li><var>WRONG_2</var></li>
- <li><var>WRONG_3</var></li>
- </ul>
+ <li><var>WRONG_1</var></li>
+ <li><var>WRONG_2</var></li>
+ <li><var>WRONG_3</var></li>
+ </ul>
</div>
</div>
<div class="hints">
- <div>
- <p><var>NUM</var> can be represented as follows.</p>
- <p><code>= (<var>THOUSANDS</var> \cdot 1000)
- + (<var>HUNDREDS</var> \cdot 100)
- + (<var>TENS</var> \cdot 10)
- + (<var>ONES</var> \cdot 1) </code></p>
- </div>
- <p><code>= </code> <var>plural( THOUSANDS, "thousand", "thousands" )</var>
- + <var>plural(HUNDREDS, "hundred")</var>
- + <var>plural(TENS, "ten")</var>
- + <var>plural(ONES, "one")</var></p>
+ <div>
+ <p><var>NUM</var> can be represented as follows.</p>
+ <p><code>= (<var>THOUSANDS</var> \cdot 1000)
+ + (<var>HUNDREDS</var> \cdot 100)
+ + (<var>TENS</var> \cdot 10)
+ + (<var>ONES</var> \cdot 1) </code></p>
+ </div>
+ <p><code>= </code> <var>plural( THOUSANDS, "thousand", "thousands" )</var>
+ + <var>plural(HUNDREDS, "hundred")</var>
+ + <var>plural(TENS, "ten")</var>
+ + <var>plural(ONES, "one")</var></p>
- <p class="final_hint">Thus, <var>QUESTION_PLACE</var> is in the <var>SOLUTION</var> place.</p>
+ <p class="final_hint">Thus, <var>QUESTION_PLACE</var> is in the <var>SOLUTION</var> place.</p>
</div>
</div>
</body>
View
8 exercises/prime_numbers.html
@@ -28,10 +28,10 @@
<p class="question">Which of these numbers is prime?</p>
<p class="solution"><var>PRIME</var></p>
<ul class="choices" data-show="5">
- <li><var>WRONG_1</var></li>
- <li><var>WRONG_2</var></li>
- <li><var>WRONG_3</var></li>
- <li><var>WRONG_4</var></li>
+ <li><var>WRONG_1</var></li>
+ <li><var>WRONG_2</var></li>
+ <li><var>WRONG_3</var></li>
+ <li><var>WRONG_4</var></li>
</ul>
</div>
</div>
View
31 exercises/recognizing_fractions.html
@@ -7,8 +7,8 @@
<body>
<div class="exercise">
<div class="vars" data-ensure="NUMERATOR < DENOMINATOR">
- <var id="NUMERATOR">randRange( 1, 11 )</var>
- <var id="DENOMINATOR">randRange( 2, 12 )</var>
+ <var id="NUMERATOR">randRange( 1, 11 )</var>
+ <var id="DENOMINATOR">randRange( 2, 12 )</var>
</div>
<div class="problems">
@@ -17,25 +17,24 @@
<p class="problem">What is the fraction's numerator?</p>
<p class="solution"><var>NUMERATOR</var></p>
<div class="hints" data-apply="appendContents">
- <p id="answer_hint">Thus, the numerator is <var>NUMERATOR</var>.</p>
- </div>
+ <p id="answer_hint">Thus, the numerator is <var>NUMERATOR</var>.</p>
+ </div>
</div>
<div data-type="original">
- <p class="problem">What is the fraction's denominator?</p>
- <p class="solution"><var>DENOMINATOR</var></p>
- <div class="hints" data-apply="appendContents">
- <p id="answer_hint">Thus, the denominator is <var>DENOMINATOR</var>.</p>
- </div>
- </div>
+ <p class="problem">What is the fraction's denominator?</p>
+ <p class="solution"><var>DENOMINATOR</var></p>
+ <div class="hints" data-apply="appendContents">
+ <p id="answer_hint">Thus, the denominator is <var>DENOMINATOR</var>.</p>
+ </div>
+ </div>
</div>
<div class="hints">
- <p>Fractions help represent parts of a whole.</p>
- <!-- TODO: Drawing a pie would be great. -->
- <p>You can think of this fraction as representing <var>NUMERATOR</var> out of <var>DENOMINATOR</var> slices of pie. In other words, the pie has been cut into <var>DENOMINATOR</var> slices, and we are only considering <var>NUMERATOR</var> of those slices.</p>
- <p>The numerator is the number of slices we care about, and it is written above the fraction line. The denominator is the total number of slices, and it is written below the line.</p>
- <p id="answer_hint"></p>
-
+ <p>Fractions help represent parts of a whole.</p>
+ <!-- TODO: Drawing a pie would be great. -->
+ <p>You can think of this fraction as representing <var>NUMERATOR</var> out of <var>DENOMINATOR</var> slices of pie. In other words, the pie has been cut into <var>DENOMINATOR</var> slices, and we are only considering <var>NUMERATOR</var> of those slices.</p>
+ <p>The numerator is the number of slices we care about, and it is written above the fraction line. The denominator is the total number of slices, and it is written below the line.</p>
+ <p id="answer_hint"></p>
</div>
</div>
</body>
View
70 exercises/simplifying_fractions.html
@@ -7,12 +7,12 @@
<body>
<div class="exercise">
<div class="vars" data-ensure="! (getGCD ( NUM, DENOM ) === NUM || getGCD ( NUM, DENOM) === DENOM)">
- <var id="FACTOR">randRange( 3, 15 )</var>
- <var id="NUM">randRange(2, 10) * FACTOR</var>
- <var id="DENOM">randRange(2, 10) * FACTOR</var>
- <var id="GCD">getGCD( NUM, DENOM )</var>
- <var id="GCD_FACTORS">getPrimeFactorization( GCD )</var>
- <var id="GCD_FACTORS_SENTENCE">toSentence( GCD_FACTORS )</var>
+ <var id="FACTOR">randRange( 3, 15 )</var>
+ <var id="NUM">randRange(2, 10) * FACTOR</var>
+ <var id="DENOM">randRange(2, 10) * FACTOR</var>
+ <var id="GCD">getGCD( NUM, DENOM )</var>
+ <var id="GCD_FACTORS">getPrimeFactorization( GCD )</var>
+ <var id="GCD_FACTORS_SENTENCE">toSentence( GCD_FACTORS )</var>
</div>
<div class="problems">
@@ -24,35 +24,35 @@
</div>
<div class="hints">
- <p data-if="GCD_FACTORS.length !== 1">There are several ways to tackle this problem.</p>
-
- <p>What is the GCD of <var>NUM</var> and <var>DENOM</var>?</p>
-
- <p>GCD(<var>NUM</var>, <var>DENOM</var>) = <var>GCD</var></p>
-
- <p>
- <code>\dfrac{<var>NUM</var>}{<var>DENOM</var>}</code>
- </p>
-
- <p>
- <code>= \dfrac{<var>NUM / GCD</var> \cdot <var>GCD</var>}{ <var>DENOM / GCD</var>\cdot <var>GCD</var>}</code>
- </p>
-
- <p>
- <code>= \dfrac{<var>NUM / GCD</var>}{<var>DENOM / GCD</var>} \cdot \dfrac{<var>GCD</var>}{<var>GCD</var>}</code>
- </p>
-
- <p>
- <code>= \dfrac{<var>NUM / GCD</var>}{<var>DENOM / GCD</var>}</code>
- </p>
- <div data-if="GCD_FACTORS.length !== 1">
- <p>You can also solve this problem by repeatedly dividing the numerator and denominator by smaller factors.</p>
- <p>For example:</p>
- <!-- TODO: iterate prettily to walk student through
- 48 / 64 to 24 / 32 to 3 / 4
- -->
- <p><var>GCD_FACTORS_SENTENCE</var></p>
- </div>
+ <p data-if="GCD_FACTORS.length !== 1">There are several ways to tackle this problem.</p>
+
+ <p>What is the GCD of <var>NUM</var> and <var>DENOM</var>?</p>
+
+ <p>GCD(<var>NUM</var>, <var>DENOM</var>) = <var>GCD</var></p>
+
+ <p>
+ <code>\dfrac{<var>NUM</var>}{<var>DENOM</var>}</code>
+ </p>
+
+ <p>
+ <code>= \dfrac{<var>NUM / GCD</var> \cdot <var>GCD</var>}{ <var>DENOM / GCD</var>\cdot <var>GCD</var>}</code>
+ </p>
+
+ <p>
+ <code>= \dfrac{<var>NUM / GCD</var>}{<var>DENOM / GCD</var>} \cdot \dfrac{<var>GCD</var>}{<var>GCD</var>}</code>
+ </p>
+
+ <p>
+ <code>= \dfrac{<var>NUM / GCD</var>}{<var>DENOM / GCD</var>}</code>
+ </p>
+ <div data-if="GCD_FACTORS.length !== 1">
+ <p>You can also solve this problem by repeatedly dividing the numerator and denominator by smaller factors.</p>
+ <p>For example:</p>
+ <!-- TODO: iterate prettily to walk student through
+ 48 / 64 to 24 / 32 to 3 / 4
+ -->
+ <p><var>GCD_FACTORS_SENTENCE</var></p>
+ </div>
</div>
</div>
</body>
View
20 exercises/special_derivatives.html
@@ -10,14 +10,14 @@
<var id="FUNC">generateSpecialFunction("x")</var>
<var id="NOTATION">funcNotation("x")</var>
- </div>
+ </div>
- <div class="problems">
- <div>
+ <div class="problems">
+ <div>
<p class="problem"><code><var>NOTATION.f</var> = <var>FUNC.f</var></code></p>
- <p class="question"><code><var>NOTATION.ddxF</var> = {?}</code></p>
+ <p class="question"><code><var>NOTATION.ddxF</var> = {?}</code></p>
- <p class="solution"><code><var>FUNC.ddxF</var></code></p>
+ <p class="solution"><code><var>FUNC.ddxF</var></code></p>
<ul class="choices" data-show="5" data-none="true">
<li><code><var>FUNC.wrongs[0]</var></code></li>
@@ -26,12 +26,12 @@
<li><code><var>FUNC.wrongs[3]</var></code></li>
<li><code><var>FUNC.wrongs[4]</var></code></li>
</ul>
- </div>
- </div>
+ </div>
+ </div>
- <div class="hints">
+ <div class="hints">
<p><code><var>NOTATION.ddxF</var> = <var>FUNC.ddxF</var></code></p>
- </div>
- </div>
+ </div>
+ </div>
</body>
</html>
View
52 exercises/subtraction_2.html
@@ -6,33 +6,33 @@
</head>
<body>
<div class="exercise">
- <div class="vars">
- <var id="A">randRange(10,99)</var>
- <var id="B">randRange(1,9)</var>
- <var id="A_1">A%10</var>
- <var id="A_2">(A-(A%10))/10</var>
- <var id="After_Borrow1">(B > A_1 ? A_1+10 : A_1)</var>
- <var id="After_Borrow2">(B > A_1 ? A_2-1 : A_2)</var>
- </div>
+ <div class="vars">
+ <var id="A">randRange(10,99)</var>
+ <var id="B">randRange(1,9)</var>
+ <var id="A_1">A%10</var>
+ <var id="A_2">(A-(A%10))/10</var>
+ <var id="After_Borrow1">(B > A_1 ? A_1+10 : A_1)</var>
+ <var id="After_Borrow2">(B > A_1 ? A_2-1 : A_2)</var>
+ </div>
- <div class="problems">
- <div>
- <p class="question"><var>A</var> - <var>B</var> = ?</p>
- <div class="solution"><var>A - B</var></div>
- </div>
- </div>
- <div class="hints">
- <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
- <p data-if="A_1<B">
- <span> <var>A_1</var> is less then <var> B</var>, so we'll have to borrow.</span>
- </p>
- <p data-if="A_1<B">
- <span> <var>A_2</var> - 1 = <var>After_Borrow2</var>, <var>A_1</var> + 10 = <var>After_Borrow1</var>
- </p>
- <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
- <p>Units digit: <var>After_Borrow1</var> - <var>B</var> = <var>After_Borrow1-B</var></p>
- <p>Bring down the <var>After_Borrow2</var> to get <var>(After_Borrow2*10)+After_Borrow1-B</var>.</p>
- </div>
+ <div class="problems">
+ <div>
+ <p class="question"><var>A</var> - <var>B</var> = ?</p>
+ <div class="solution"><var>A - B</var></div>
+ </div>
+ </div>
+ <div class="hints">
+ <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
+ <p data-if="A_1<B">
+ <span> <var>A_1</var> is less then <var> B</var>, so we'll have to borrow.</span>
+ </p>
+ <p data-if="A_1<B">
+ <span> <var>A_2</var> - 1 = <var>After_Borrow2</var>, <var>A_1</var> + 10 = <var>After_Borrow1</var>
+ </p>
+ <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
+ <p>Units digit: <var>After_Borrow1</var> - <var>B</var> = <var>After_Borrow1-B</var></p>
+ <p>Bring down the <var>After_Borrow2</var> to get <var>(After_Borrow2*10)+After_Borrow1-B</var>.</p>
+ </div>
</div>
</body>
</html>
View
52 exercises/subtraction_3.html
@@ -6,33 +6,33 @@
</head>
<body>
<div class="exercise">
- <div class="vars">
- <var id="A">randRange(100,999)</var>
- <var id="B">randRange(10,99)</var>
- <var id="A_Array">digits(A)</var>
- <var id="B_Array">digits(B)</var>
- </div>
+ <div class="vars">
+ <var id="A">randRange(100,999)</var>
+ <var id="B">randRange(10,99)</var>
+ <var id="A_Array">digits(A)</var>
+ <var id="B_Array">digits(B)</var>
+ </div>
- <div class="problems">
- <div>
- <p class="question"><var>A</var> - <var>B</var> = ?</p>
- <div class="solution"><var>A - B</var></div>
- </div>
- </div>
- <div class="hints">
- <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
- <!-- first digit -->
- <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[0]</var> is less then <var> B_Array[0]</var>, so we'll have to borrow.</p>
- <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[1]</var> - 1 = <var>A_Array[1]=A_Array[1]-1</var>, <var>A_Array[0]</var>+10=<var>A_Array[0]=A_Array[0]+10</var></p>
- <!-- second digit -->
- <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[1]</var> is less then <var> B_Array[1]</var>, so we'll have to borrow.</p>
- <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[2]</var> - 1 = <var>A_Array[2]=A_Array[2]-1</var>, <var>A_Array[1]</var>+10=<var>A_Array[1]=A_Array[1]+10</var></p>
- <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
- <p>Units digit: <var>A_Array[0]</var> - <var>B_Array[0]</var> = <var>A_Array[0]-B_Array[0]</var></p>
- <p>Tens digit: <var>A_Array[1]</var> - <var>B_Array[1]</var> = <var>A_Array[1]-B_Array[1]</var></p>
- <p>Bring down the <var>A_Array[2]</var> to get <var>A_Array[2]</var>.</p>
- <p>Answer: <var>A-B</var></p>
- </div>
+ <div class="problems">
+ <div>
+ <p class="question"><var>A</var> - <var>B</var> = ?</p>
+ <div class="solution"><var>A - B</var></div>
+ </div>
+ </div>
+ <div class="hints">
+ <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
+ <!-- first digit -->
+ <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[0]</var> is less then <var> B_Array[0]</var>, so we'll have to borrow.</p>
+ <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[1]</var> - 1 = <var>A_Array[1]=A_Array[1]-1</var>, <var>A_Array[0]</var>+10=<var>A_Array[0]=A_Array[0]+10</var></p>
+ <!-- second digit -->
+ <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[1]</var> is less then <var> B_Array[1]</var>, so we'll have to borrow.</p>
+ <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[2]</var> - 1 = <var>A_Array[2]=A_Array[2]-1</var>, <var>A_Array[1]</var>+10=<var>A_Array[1]=A_Array[1]+10</var></p>
+ <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
+ <p>Units digit: <var>A_Array[0]</var> - <var>B_Array[0]</var> = <var>A_Array[0]-B_Array[0]</var></p>
+ <p>Tens digit: <var>A_Array[1]</var> - <var>B_Array[1]</var> = <var>A_Array[1]-B_Array[1]</var></p>
+ <p>Bring down the <var>A_Array[2]</var> to get <var>A_Array[2]</var>.</p>
+ <p>Answer: <var>A-B</var></p>
+ </div>
</div>
</body>
</html>
View
62 exercises/subtraction_4.html
@@ -6,38 +6,38 @@
</head>
<body>
<div class="exercise">
- <div class="vars">
- <var id="A">randRange(10000,99999)</var>
- <var id="B">randRange(100,999)</var>
- <var id="A_Array">digits(A)</var>
- <var id="B_Array">digits(B)</var>
- </div>
+ <div class="vars">
+ <var id="A">randRange(10000,99999)</var>
+ <var id="B">randRange(100,999)</var>
+ <var id="A_Array">digits(A)</var>
+ <var id="B_Array">digits(B)</var>
+ </div>
- <div class="problems">
- <div>
- <p class="question"><var>A</var> - <var>B</var> = ?</p>
- <div class="solution"><var>A - B</var></div>
- </div>
- </div>
- <div class="hints">
- <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
- <!-- first digit -->
- <p data-if="A_Array[0]<B_Array[0]"> For the units digit, <var>A_Array[0]</var> is less then <var> B_Array[0]</var>, so we'll have to borrow.</p>
- <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[1]</var> - 1 = <var>A_Array[1]=A_Array[1]-1</var>, <var>A_Array[0]</var> + 10 = <var>A_Array[0]=A_Array[0]+10</var></p>
- <!-- second digit -->
- <p data-if="A_Array[1]<B_Array[1]"> For the tens digit, <var>A_Array[1]</var> is less then <var> B_Array[1]</var>, so we'll have to borrow.</p>
- <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[2]</var> - 1 = <var>A_Array[2]=A_Array[2]-1</var>, <var>A_Array[1]</var> + 10 = <var>A_Array[1]=A_Array[1]+10</var></p>
- <!-- second digit -->
- <p data-if="A_Array[2]<B_Array[2]"> For the hundreds digit, <var>A_Array[2]</var> is less then <var> B_Array[2]</var>, so we'll have to borrow.</p>
- <p data-if="A_Array[2]<B_Array[2]"> <var>A_Array[3]</var> - 1 = <var>A_Array[3]=A_Array[3]-1</var>, <var>A_Array[2]</var> + 10 = <var>A_Array[2]=A_Array[2]+10</var></p>
- <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
- <p>Units digit: <var>A_Array[0]</var> - <var>B_Array[0]</var> = <var>A_Array[0]-B_Array[0]</var></p>
- <p>Tens digit: <var>A_Array[1]</var> - <var>B_Array[1]</var> = <var>A_Array[1]-B_Array[1]</var></p>
- <p>Hundreds digit: <var>A_Array[2]</var> - <var>B_Array[2]</var> = <var>A_Array[2]-B_Array[2]</var></p>
- <p>Thousands digit: Bring down the <var>A_Array[3]</var> to get <var>A_Array[3]</var>.</p>
- <p>Ten thousands digit: Bring down the <var>A_Array[4]</var> to get <var>A_Array[4]</var>.</p>
- <p>Answer: <var>A-B</var></p>
- </div>
+ <div class="problems">
+ <div>
+ <p class="question"><var>A</var> - <var>B</var> = ?</p>
+ <div class="solution"><var>A - B</var></div>
+ </div>
+ </div>
+ <div class="hints">
+ <p>First we need to make sure that all the digits in the top number are greater than or equal to the digit below it.</p>
+ <!-- first digit -->
+ <p data-if="A_Array[0]<B_Array[0]"> For the units digit, <var>A_Array[0]</var> is less then <var> B_Array[0]</var>, so we'll have to borrow.</p>
+ <p data-if="A_Array[0]<B_Array[0]"> <var>A_Array[1]</var> - 1 = <var>A_Array[1]=A_Array[1]-1</var>, <var>A_Array[0]</var> + 10 = <var>A_Array[0]=A_Array[0]+10</var></p>
+ <!-- second digit -->
+ <p data-if="A_Array[1]<B_Array[1]"> For the tens digit, <var>A_Array[1]</var> is less then <var> B_Array[1]</var>, so we'll have to borrow.</p>
+ <p data-if="A_Array[1]<B_Array[1]"> <var>A_Array[2]</var> - 1 = <var>A_Array[2]=A_Array[2]-1</var>, <var>A_Array[1]</var> + 10 = <var>A_Array[1]=A_Array[1]+10</var></p>
+ <!-- second digit -->
+ <p data-if="A_Array[2]<B_Array[2]"> For the hundreds digit, <var>A_Array[2]</var> is less then <var> B_Array[2]</var>, so we'll have to borrow.</p>
+ <p data-if="A_Array[2]<B_Array[2]"> <var>A_Array[3]</var> - 1 = <var>A_Array[3]=A_Array[3]-1</var>, <var>A_Array[2]</var> + 10 = <var>A_Array[2]=A_Array[2]+10</var></p>
+ <p>All the top digits are greater than or equal to all the bottom digits, so we can start subtracting.</p>
+ <p>Units digit: <var>A_Array[0]</var> - <var>B_Array[0]</var> = <var>A_Array[0]-B_Array[0]</var></p>
+ <p>Tens digit: <var>A_Array[1]</var> - <var>B_Array[1]</var> = <var>A_Array[1]-B_Array[1]</var></p>
+ <p>Hundreds digit: <var>A_Array[2]</var> - <var>B_Array[2]</var> = <var>A_Array[2]-B_Array[2]</var></p>
+ <p>Thousands digit: Bring down the <var>A_Array[3]</var> to get <var>A_Array[3]</var>.</p>
+ <p>Ten thousands digit: Bring down the <var>A_Array[4]</var> to get <var>A_Array[4]</var>.</p>
+ <p>Answer: <var>A-B</var></p>
+ </div>
</div>
</body>
</html>
View
4 khan-exercise.js
@@ -20,7 +20,7 @@ var Khan = {
// Load in a collection of scripts, execute callback upon completion
loadScripts: function( urls, callback ) {
var loaded = 0,
- loading = urls.length;
+ loading = urls.length;
// Ehhh... not a huge fan of this
this.scriptWait = function( callback ) {
@@ -82,7 +82,7 @@ var Khan = {
// Get the problem we'll be using
var problems = exercise.find(".problems").children(),
- problem;
+ problem;
// Check to see if we want to test a specific problem
if ( Khan.query.problem ) {
View
32 utils/angles.js
@@ -1,24 +1,24 @@
jQuery.extend( KhanUtil, {
commonAngles: [
{deg: 30, rad: "\\frac{\\pi}{6}"},
- {deg: 45, rad: "\\frac{\\pi}{4}"},
- {deg: 60, rad: "\\frac{\\pi}{3}"},
- {deg: 90, rad: "\\frac{\\pi}{2}"},
- {deg: 120, rad: "\\frac{2\\pi}{3}"},
- {deg: 135, rad: "\\frac{3\\pi}{4}"},
- {deg: 150, rad: "\\frac{5\\pi}{6}"},
- {deg: 180, rad: "\\pi"},
- {deg: 210, rad: "\\frac{7\\pi}{6}"},
- {deg: 225, rad: "\\frac{5\\pi}{4}"},
- {deg: 240, rad: "\\frac{4\\pi}{3}"},
- {deg: 270, rad: "\\frac{3\\pi}{2}"},
- {deg: 300, rad: "\\frac{5\\pi}{3}"},
- {deg: 315, rad: "\\frac{7\\pi}{4}"},
- {deg: 330, rad: "\\frac{11\\pi}{6}"},
- {deg: 360, rad: "2\\pi"}
+ {deg: 45, rad: "\\frac{\\pi}{4}"},
+ {deg: 60, rad: "\\frac{\\pi}{3}"},
+ {deg: 90, rad: "\\frac{\\pi}{2}"},
+ {deg: 120, rad: "\\frac{2\\pi}{3}"},
+ {deg: 135, rad: "\\frac{3\\pi}{4}"},
+ {deg: 150, rad: "\\frac{5\\pi}{6}"},
+ {deg: 180, rad: "\\pi"},
+ {deg: 210, rad: "\\frac{7\\pi}{6}"},
+ {deg: 225, rad: "\\frac{5\\pi}{4}"},
+ {deg: 240, rad: "\\frac{4\\pi}{3}"},
+ {deg: 270, rad: "\\frac{3\\pi}{2}"},
+ {deg: 300, rad: "\\frac{5\\pi}{3}"},
+ {deg: 315, rad: "\\frac{7\\pi}{4}"},
+ {deg: 330, rad: "\\frac{11\\pi}{6}"},
+ {deg: 360, rad: "2\\pi"}
],
- // Convert a degree value to a radian value
+ // Convert a degree value to a radian value
toRadians: function( degrees ) {
return degrees * Math.PI / 180;
}
View
66 utils/calculus.js
@@ -13,7 +13,7 @@ jQuery.extend(KhanUtil, {
// ensure that the function isn"t just 0 as well
var f;
do {
- f = KhanUtil.randFromArray(KhanUtil.funcGens)( variable );
+ f = KhanUtil.randFromArray(KhanUtil.funcGens)( variable );
} while (f.fofx === "0");
return f;
},
@@ -142,15 +142,17 @@ jQuery.extend(KhanUtil, {
var f = new KhanUtil.Polynomial(minDegree, maxDegree, coefs, variable);
- return { f: f.text(),
- ddxF: KhanUtil.ddxPolynomial(f).text(),
- wrongs: [
- KhanUtil.ddxPolynomialWrong1(f).text(),
- KhanUtil.ddxPolynomialWrong2(f).text(),
- KhanUtil.ddxPolynomialWrong3(f).text(),
- KhanUtil.ddxPolynomialWrong4(f).text(),
- KhanUtil.ddxPolynomialWrong5(f).text()
- ] };
+ return {
+ f: f.text(),
+ ddxF: KhanUtil.ddxPolynomial(f).text(),
+ wrongs: [
+ KhanUtil.ddxPolynomialWrong1(f).text(),
+ KhanUtil.ddxPolynomialWrong2(f).text(),
+ KhanUtil.ddxPolynomialWrong3(f).text(),
+ KhanUtil.ddxPolynomialWrong4(f).text(),
+ KhanUtil.ddxPolynomialWrong5(f).text()
+ ]
+ };
},
function( variable ) {
@@ -165,9 +167,11 @@ jQuery.extend(KhanUtil, {
wrongs[4] = "-\\sec{" + variable + "}";
wrongs[5] = "-\\cos{" + variable + "}";
- return { f: KhanUtil.trigFuncs[idx] + "{" + variable + "}",
- ddxF: KhanUtil.ddxTrigFuncs[ KhanUtil.trigFuncs[idx] ] + "{" + variable + "}",
- wrongs: wrongs };
+ return {
+ f: KhanUtil.trigFuncs[idx] + "{" + variable + "}",
+ ddxF: KhanUtil.ddxTrigFuncs[ KhanUtil.trigFuncs[idx] ] + "{" + variable + "}",
+ wrongs: wrongs
+ };
},
function( variable ) {
@@ -181,15 +185,17 @@ jQuery.extend(KhanUtil, {
var f = new KhanUtil.Polynomial(minDegree, maxDegree, coefs, variable);
- return { f: f.text(),
- ddxF: KhanUtil.ddxPolynomial(f).text(),
- wrongs: [
- KhanUtil.ddxPolynomialWrong1(f).text(),
- KhanUtil.ddxPolynomialWrong2(f).text(),
- KhanUtil.ddxPolynomialWrong3(f).text(),
- KhanUtil.ddxPolynomialWrong4(f).text(),
- KhanUtil.ddxPolynomialWrong5(f).text()
- ] };
+ return {
+ f: f.text(),
+ ddxF: KhanUtil.ddxPolynomial(f).text(),
+ wrongs: [
+ KhanUtil.ddxPolynomialWrong1(f).text(),
+ KhanUtil.ddxPolynomialWrong2(f).text(),
+ KhanUtil.ddxPolynomialWrong3(f).text(),
+ KhanUtil.ddxPolynomialWrong4(f).text(),
+ KhanUtil.ddxPolynomialWrong5(f).text()
+ ]
+ };
},
function( variable ) {
@@ -204,9 +210,11 @@ jQuery.extend(KhanUtil, {
wrongs[4] = "\\frac{1}{"+variable+"^2}";
wrongs[5] = variable;
- return { f: "\\ln " + variable,
- ddxF: "\\frac{1}{" + variable + "}",
- wrongs: wrongs };
+ return {
+ f: "\\ln " + variable,
+ ddxF: "\\frac{1}{" + variable + "}",
+ wrongs: wrongs
+ };
} else {
wrongs[0] = variable + "e^{"+variable+"-1}";
wrongs[1] = "\\frac{1}{"+ variable+"}";
@@ -215,9 +223,11 @@ jQuery.extend(KhanUtil, {
wrongs[4] = "(e-"+variable+")^{"+variable+"}";
wrongs[5] = "\\frac{e}{" + variable + "}";
- return { f: "e^"+ variable,
- ddxF: "e^"+ variable,
- wrongs: wrongs };
+ return {
+ f: "e^" + variable,
+ ddxF: "e^" + variable,
+ wrongs: wrongs
+ };
}
} ]
});
View
233 utils/math.js
@@ -32,31 +32,31 @@ jQuery.extend(KhanUtil, {
return list;
},
- getGCD: function( a, b ) {
- var mod;
+ getGCD: function( a, b ) {
+ var mod;
- a = Math.abs( a );
- b = Math.abs( b );
+ a = Math.abs( a );
+ b = Math.abs( b );
- while ( b ) {
- mod = a % b;
- a = b;
- b = mod;
- }
+ while ( b ) {
+ mod = a % b;
+ a = b;
+ b = mod;
+ }
- return a;
- },
+ return a;
+ },
- getLCM: function( a, b ) {
- return ( a * b ) / this.getGCD( a, b );
- },
+ getLCM: function( a, b ) {
+ return ( a * b ) / this.getGCD( a, b );
+ },
primes: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],
- getPrime: function() {
- return this.primes[ this.rand( this.primes.length ) ];
- },
+ getPrime: function() {
+ return this.primes[ this.rand( this.primes.length ) ];
+ },
isPrime: function(n) {
if (n <= 1) {
@@ -77,95 +77,94 @@ jQuery.extend(KhanUtil, {
}
},
- isOdd: function(n) {
- return n % 2 == 1;
- },
-
- isEven: function(n) {
- return n % 2 == 0;
- },
-
- getOddComposite: function( min, max ) {
- if ( min === undefined ) {
- min = 0;
- }
-
- if ( max === undefined ) {
- max = 100;
- }
-
- var oddComposites = [9, 15, 21, 25, 27, 33, 35, 39, 45, 49, 51, 55];
- oddComposites = oddComposites.concat([57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]);
-
- var result = -1;
- while ( result < min || result > max ) {
- result = oddComposites[ this.rand( oddComposites.length ) ];
- }
- return result;
- },
-
- getEvenComposite: function( min, max ) {
- if ( min === undefined ) {
- min = 0;
- }
-
- if ( max === undefined ) {
- max = 100;
- }
-
- var evenComposites = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26];
- evenComposites = evenComposites.concat([28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]);
- evenComposites = evenComposites.concat([50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72]);
- evenComposites = evenComposites.concat([74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]);
-
- var result = -1;
- while ( result < min || result > max ) {
- result = evenComposites[ this.rand( evenComposites.length ) ];
- }
- return result;
- },
-
- getPrimeFactorization: function( number ) {
- if ( jQuery.inArray(number, this.primes) !== -1 ) {
- return [number];
- }
-
- var maxf = Math.sqrt( number );
- for (var f = 2; f <= maxf; f++) {
- if ( number % f == 0 ) {
- return jQuery.merge(this.getPrimeFactorization( f ), this.getPrimeFactorization( number / f ));
- }
- }
- },
-
- getFactors: function( number ) {
- var factors = [];
- var maxf = Math.sqrt( number );
- for (var f = 1; f <= maxf; f++) {
- if (! ( number % f ) ) {
- factors.push( f );
- factors.push( number / f );
- }
- }
- return factors.sort( function( a, b ) {
- return a - b;
- });
- },
+ isOdd: function(n) {
+ return n % 2 == 1;
+ },
+
+ isEven: function(n) {
+ return n % 2 == 0;
+ },
+
+ getOddComposite: function( min, max ) {
+ if ( min === undefined ) {
+ min = 0;
+ }
+
+ if ( max === undefined ) {
+ max = 100;
+ }
+
+ var oddComposites = [9, 15, 21, 25, 27, 33, 35, 39, 45, 49, 51, 55];
+ oddComposites = oddComposites.concat([57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]);
+
+ var result = -1;
+ while ( result < min || result > max ) {
+ result = oddComposites[ this.rand( oddComposites.length ) ];
+ }
+ return result;
+ },
+
+ getEvenComposite: function( min, max ) {
+ if ( min === undefined ) {
+ min = 0;
+ }
+
+ if ( max === undefined ) {
+ max = 100;
+ }
+
+ var evenComposites = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26];
+ evenComposites = evenComposites.concat([28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]);
+ evenComposites = evenComposites.concat([50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72]);
+ evenComposites = evenComposites.concat([74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]);
+
+ var result = -1;
+ while ( result < min || result > max ) {
+ result = evenComposites[ this.rand( evenComposites.length ) ];
+ }
+ return result;
+ },
+
+ getPrimeFactorization: function( number ) {
+ if ( jQuery.inArray(number, this.primes) !== -1 ) {
+ return [number];
+ }
+
+ var maxf = Math.sqrt( number );
+ for (var f = 2; f <= maxf; f++) {
+ if ( number % f == 0 ) {
+ return jQuery.merge(this.getPrimeFactorization( f ), this.getPrimeFactorization( number / f ));
+ }
+ }
+ },
+
+ getFactors: function( number ) {
+ var factors = [];
+ var maxf = Math.sqrt( number );
+ for (var f = 1; f <= maxf; f++) {
+ if (! ( number % f ) ) {
+ factors.push( f );
+ factors.push( number / f );
+ }
+ }
+ return factors.sort( function( a, b ) {
+ return a - b;
+ });
+ },
// Get a random factor of a composite number which is not 1 or that number
getNontrivialFactor: function( number ) {
var factors = this.getFactors( number );
return factors[ this.randRange( 1, factors.length - 2 ) ];
},
- getMultiples: function( number, upperLimit ) {
- var multiples = [];
- for ( var i = 1; i * number <= upperLimit; i++ ) {
- multiples.push( i * number );
- }
- return multiples;
- },
-
+ getMultiples: function( number, upperLimit ) {
+ var multiples = [];
+ for ( var i = 1; i * number <= upperLimit; i++ ) {
+ multiples.push( i * number );
+ }
+ return multiples;
+ },
// Get a random integer between min and max, inclusive
// If a count is passed, it gives an array of random numbers in the range
@@ -179,25 +178,25 @@ jQuery.extend(KhanUtil, {
}
},
- // Get a random integer between min and max with a perc chance of hitting
- // target (which is assumed to be in the range, but it doesn't have to be).
- randRangeWeighted: function( min, max, target, perc ) {
- if ( KhanUtil.random() < perc ) return target;
- else return this.randRangeExclude( min, max, [target] );
- },
-
- // Get a random integer between min and max that is never any of the values
- // in the excludes array.
- randRangeExclude: function( min, max, excludes ) {
- var result;
- while ( result === undefined || excludes.indexOf(result) !== -1 )
- result = this.randRange( min, max );
- return result;
- },
+ // Get a random integer between min and max with a perc chance of hitting
+ // target (which is assumed to be in the range, but it doesn't have to be).
+ randRangeWeighted: function( min, max, target, perc ) {
+ if ( KhanUtil.random() < perc ) return target;
+ else return this.randRangeExclude( min, max, [target] );
+ },
+
+ // Get a random integer between min and max that is never any of the values
+ // in the excludes array.
+ randRangeExclude: function( min, max, excludes ) {
+ var result;
+ while ( result === undefined || excludes.indexOf(result) !== -1 )
+ result = this.randRange( min, max );
+ return result;
+ },
// From limits_1
randRangeNonZero: function( min, max ) {
- return this.randRangeExclude( min, max, [0] );
+ return this.randRangeExclude( min, max, [0] );
},
// Returns a random member of the given array
@@ -296,7 +295,7 @@ jQuery.fn.extend({
vars.children().each(function() {
// And load in their values
var value = jQuery.getVAR( this ),
- name = this.id;
+ name = this.id;
if ( name ) {
// Show an error if a variable definition is overriding a built-in method
@@ -399,7 +398,7 @@ jQuery.extend({
with ( Math ) {
// Use all the computed variables
with ( VARS ) {
- return eval( "(" + code + ")" );
+ return eval( "(" + code + ")" );
}
}
}
View
58 utils/mathformat.js
@@ -55,7 +55,7 @@ jQuery.extend(KhanUtil, {
/* formattedSquareRootOf(24) gives 2\sqrt{6} */
formattedSquareRootOf: function( n ) {
- if( n === 1 || n === 0 ) {
+ if( n === 1 || n === 0 ) {
/* so as to not return "" or "\\sqrt{0}" later */
return n.toString();
} else {
@@ -114,34 +114,34 @@ jQuery.extend(KhanUtil, {
return str;
};
- if ( n == 0 ) return "zero";
- else {
- var neg = false;
- if ( n < 0 ) {
- neg = true;
- n = Math.abs( n );
- }
-
- var words = [];
- var scale = 0;
- while ( n > 0 ) {
- var end = n % 1000;
-
- if ( end > 0 ) {
- if ( scale > 0 ) {
- words.unshift( cardinalScales[ scale ] );
- }
-
- words.unshift( smallNumberWords( end ) );
- }
-
- n = Math.floor( n / 1000 );
- scale += 1;
- }
-
- if ( neg ) words.unshift( "negative" );
- return words.join( " " );
- }
+ if ( n == 0 ) return "zero";
+ else {
+ var neg = false;
+ if ( n < 0 ) {
+ neg = true;
+ n = Math.abs( n );
+ }
+
+ var words = [];
+ var scale = 0;
+ while ( n > 0 ) {
+ var end = n % 1000;
+
+ if ( end > 0 ) {
+ if ( scale > 0 ) {
+ words.unshift( cardinalScales[ scale ] );
+ }
+
+ words.unshift( smallNumberWords( end ) );
+ }
+
+ n = Math.floor( n / 1000 );
+ scale += 1;
+ }
+
+ if ( neg ) words.unshift( "negative" );
+ return words.join( " " );
+ }
},
Cardinal: function( n ) {
View
2 utils/word-problems.js
@@ -273,7 +273,7 @@ jQuery.fn[ "word-problemsLoad" ] = function() {
},
group: function( i ) {
- return collections[i - 1][1];
+ return collections[i - 1][1];
},
groupVerb: function( i ) {

0 comments on commit 075f731

Please sign in to comment.