Permalink
Browse files

Change "percent" answer type to interpret answer key as a decimal; ac…

…cept percent in independent_probability Fix #37553

Test Plan: Ran `grep percent exercises/* | grep data-forms` to find all exercises using the percent data-form and tested several questions of each such problem type

Reviewers: alpert

Reviewed By: alpert

Differential Revision: http://phabricator.khanacademy.org/D1046
  • Loading branch information...
1 parent 71001a7 commit 83ab06dc30c3c2c21a36cf6b25d175f2ee89a3be @beneater beneater committed Jan 21, 2013
@@ -15,7 +15,7 @@
</div>
<p>Express the decimal as a percent.</p>
<p class="question"><code><var>DECIMAL</var></code></p>
- <p class="solution" data-forms="percent"><var>PERCENT</var></p>
+ <p class="solution" data-forms="percent"><var>DECIMAL</var></p>
<div class="hints">
<div>
<p>Rewrite the decimal as a fraction with a denominator of 100.</p>
@@ -51,7 +51,7 @@
<code><var>roundTo( 1, MEAN + STDDEV * Z )</var></code> years.
</p>
- <div class="solution" data-forms="percent"><var>ANSWER</var></div>
+ <div class="solution" data-forms="percent"><var>ANSWER / 100</var></div>
<div class="hints">
<p>We can try to estimate using the empirical rule, also known as the 68-95-99.7 percent rule.</p>
@@ -396,7 +396,7 @@
<code><var>roundTo( 1, MEAN + STDDEV * Z1 )</var></code> and <code><var>roundTo( 1, MEAN + STDDEV * Z2 )</var></code> years.
</p>
- <div class="solution" data-forms="percent"><var>AREA</var></div>
+ <div class="solution" data-forms="percent"><var>AREA / 100</var></div>
<div class="hints" data-apply="appendContents">
<div id="hintGoal">
@@ -41,7 +41,7 @@
If you flip a coin and roll a 6-sided die, what is the probability that you will flip a <var>HT</var> and roll <var>RESULT_DESC</var>?
</p>
- <div class="solution" data-forms="proper, decimal"><var>0.5 * RESULT_POSSIBLE.length / 6</var></div>
+ <div class="solution" data-forms="proper, decimal, percent"><var>0.5 * RESULT_POSSIBLE.length / 6</var></div>
<div class="hints">
<p>
@@ -408,7 +408,7 @@
If both fire their cannons at the same time, what is the probability that <var>QUESTION</var>?
</p>
- <div class="solution" data-forms="proper, decimal"><var>ANSWER</var></div>
+ <div class="solution" data-forms="proper, decimal, percent"><var>ANSWER</var></div>
<div class="hints">
<p>
@@ -42,7 +42,7 @@
</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? (Round your answer to the nearest hundredth of a percent.)</p>
- <p class="solution" data-forms="percent"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_FEWER) / 100</var></p>
+ <p class="solution" data-forms="percent"><var>roundTo(4, (BANK_MORE - BANK_FEWER) / BANK_FEWER)</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>
@@ -51,7 +51,7 @@
<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? (Round your answer to the nearest hundredth of a percent.)</p>
- <p class="solution" data-forms="percent"><var>round(((BANK_MORE - BANK_FEWER) * 10000) / BANK_MORE) / 100</var></p>
+ <p class="solution" data-forms="percent"><var>roundTo(4, (BANK_MORE - BANK_FEWER) / BANK_MORE)</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>
@@ -69,8 +69,8 @@
<div class="fake_row reading" data-each="ROWS as i, row">
<span><var>row</var></span><span data-each="ZGRID[i] as j, zgrid"><var>zgrid</var></span>
</div>
- <div class="solution" data-inexact data-max-error="0.01" data-forms="percent">
- <span><var>roundTo(2, ANSWER * 100)</var></span>
+ <div class="solution" data-inexact data-max-error="0.0001" data-forms="percent">
+ <span><var>roundTo(4, ANSWER)</var></span>
</div>
<div class="hints">
@@ -106,8 +106,8 @@
<div class="fake_row reading" data-each="ROWS as i, row">
<span><var>row</var></span><span data-each="ZGRID[i] as j, zgrid"><var>zgrid</var></span>
</div>
- <div class="solution" data-inexact data-max-error="0.01" data-forms="percent">
- <span><var>roundTo( 2, ANSWER * 100 )</var></span>
+ <div class="solution" data-inexact data-max-error="0.0001" data-forms="percent">
+ <span><var>roundTo(4, ANSWER)</var></span>
</div>
<div class="hints">
View
@@ -211,6 +211,15 @@ Khan.answerTypes = $.extend(Khan.answerTypes, {
}, $(solution).data());
var acceptableForms = options.forms.split(/\s*,\s*/);
+ // If percent is an acceptable form, make sure it's the last one
+ // in the list so we don't prematurely complain about not having
+ // a percent sign when the user entered the correct answer in a
+ // different form (such as a decimal or fraction)
+ if (_.contains(acceptableForms, "percent")) {
+ acceptableForms = _.without(acceptableForms, "percent");
+ acceptableForms.push("percent");
+ }
+
// Take text looking like a fraction, and turn it into a number
var fractionTransformer = function(text) {
text = text
@@ -374,6 +383,7 @@ Khan.answerTypes = $.extend(Khan.answerTypes, {
var transformed = forms.decimal(text);
$.each(transformed, function(ix, t) {
t.exact = hasPercentSign;
+ t.value = t.value / 100;
});
return transformed;
},

0 comments on commit 83ab06d

Please sign in to comment.