Skip to content

Commit

Permalink
Merge with stable master.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed May 16, 2013
2 parents b8d0f86 + a78c02e commit 67a7f4f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
3 changes: 2 additions & 1 deletion css/khan-exercise.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ body.debug .graphie { outline: 1px dashed #fdd; }
#answer_area #answercontent { position: relative; z-index: 2; }
#answer_area .hint-box { position: relative; z-index: 1;}
#answer_area #examples-show {
display: none;
float: right;
margin-top: -2px;
background: #F7F7F7;
Expand Down Expand Up @@ -878,4 +879,4 @@ body.debug span.error {
font-size: 1.4em;
padding: 0.2em;
text-decoration: line-through;
}
}
12 changes: 6 additions & 6 deletions exercises/limits_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
</div>

<div class="question">
<p>Find <code>\displaystyle\lim_{x \to <var>K</var>}\dfrac{<var>A</var>}{<var>B</var>x + <var>-K</var>}</code>.</p>
<p>Find <code>\displaystyle\lim_{x \to <var>K</var>}\dfrac{<var>A</var>}{x + <var>-K</var>}</code>.</p>
</div>

<p class="solution">undefined</p>
Expand All @@ -119,8 +119,8 @@

<div class="hints">
<p>Consider the behavior of the function as <code>x \to <var>K</var></code> from each direction.</p>
<p>As <code>x</code> approaches <code><var>K</var></code> from the left, <code><var>B</var>x + <var>-K</var></code> starts negative and increases as it approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{<var>B</var>x + <var>-K</var>}</code> approaches <code><var>SIGN_LIM_LEFT</var>\infty</code>.</p>
<p>As <code>x</code> approaches <code><var>K</var></code> from the right, <code><var>B</var>x + <var>-K</var></code> starts positive and decreases as it approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{<var>B</var>x + <var>-K</var>}</code> approaches <code><var>SIGN_LIM_RIGHT</var>\infty</code>.</p>
<p>As <code>x</code> approaches <code><var>K</var></code> from the left, <code>x + <var>-K</var></code> starts negative and increases as it approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{x + <var>-K</var>}</code> approaches <code><var>SIGN_LIM_LEFT</var>\infty</code>.</p>
<p>As <code>x</code> approaches <code><var>K</var></code> from the right, <code>x + <var>-K</var></code> starts positive and decreases as it approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{x + <var>-K</var>}</code> approaches <code><var>SIGN_LIM_RIGHT</var>\infty</code>.</p>
<p>Since the left- and right-hand limits are not equal, the limit is not defined.</p>
</div>
</div>
Expand All @@ -134,7 +134,7 @@
</div>

<div class="question">
<p>Find <code>\displaystyle\lim_{x \to <var>K</var>}\dfrac{<var>A</var>}{(<var>B</var>x + <var>-K</var>\smash{)}^2}</code>.</p>
<p>Find <code>\displaystyle\lim_{x \to <var>K</var>}\dfrac{<var>A</var>}{(x + <var>-K</var>\smash{)}^2}</code>.</p>
</div>

<p class="solution"><code><var>RIGHT_SIGN</var>\infty</code></p>
Expand All @@ -148,8 +148,8 @@

<div class="hints">
<p>Consider the behavior of the function as <code>x \to <var>K</var></code> from each direction.</p>
<p>In either direction, <code>(x + <var>-K</var>)^2</code> approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{(<var>B</var>x + <var>-K</var>\smash{)}^2}</code> diverges.</p>
<p data-if="A > 0">Because <code>(x + <var>-K</var>)^2</code> is always positive and <code><var>A</var></code> is positive, <code>\dfrac{<var>A</var>}{(<var>B</var>x + <var>-K</var>\smash{)}^2}</code> approaches <code><var>RIGHT_SIGN</var>\infty</code>.</p><p data-else="">Because <code>(x + <var>-K</var>)^2</code> is always positive and <code><var>A</var></code> is negative, <code>\dfrac{<var>A</var>}{(<var>B</var>x + <var>-K</var>\smash{)}^2}</code> approaches <code><var>RIGHT_SIGN</var>\infty</code>.</p>
<p>In either direction, <code>(x + <var>-K</var>)^2</code> approaches <code>0</code>, so <code>\dfrac{<var>A</var>}{(x + <var>-K</var>\smash{)}^2}</code> diverges.</p>
<p data-if="A > 0">Because <code>(x + <var>-K</var>)^2</code> is always positive and <code><var>A</var></code> is positive, <code>\dfrac{<var>A</var>}{(x + <var>-K</var>\smash{)}^2}</code> approaches <code><var>RIGHT_SIGN</var>\infty</code>.</p><p data-else="">Because <code>(x + <var>-K</var>)^2</code> is always positive and <code><var>A</var></code> is negative, <code>\dfrac{<var>A</var>}{(x + <var>-K</var>\smash{)}^2}</code> approaches <code><var>RIGHT_SIGN</var>\infty</code>.</p>
</div>
</div>
</div>
Expand Down
27 changes: 20 additions & 7 deletions interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ var PerseusBridge = Exercises.PerseusBridge,
attempts,
numHints,
hintsUsed,
lastAttemptOrHint;
lastAttemptOrHint,
firstProblem = true;

$(Exercises)
.bind("problemTemplateRendered", problemTemplateRendered)
Expand Down Expand Up @@ -135,7 +136,8 @@ function newProblem(e, data) {
.addClass("framework-" + framework);

// Enable/disable the get hint button
$("#hint").attr("disabled", numHints === 0);
updateHintButtonText();
$("#hint").attr("disabled", hintsUsed >= numHints);
}

function handleCheckAnswer() {
Expand Down Expand Up @@ -332,11 +334,11 @@ function updateHintButtonText() {
"Show next step (" + hintsLeft + " left)" :
"Show solution");
} else {
$hintButton.val("I'd like another hint (" +
(hintsLeft === 1 ?
"1 hint left" :
hintsLeft + " hints left")
+ ")");
$hintButton.val(hintsUsed ?
"I'd like another hint (" +
(hintsLeft === 1 ? "1 hint left" : hintsLeft + " hints left")
+ ")" :
"I'd like a hint");
}
}

Expand Down Expand Up @@ -463,8 +465,19 @@ function request(method, data) {


function readyForNextProblem(e, data) {
if (firstProblem) {
firstProblem = false;
// As both of the following variables are only used to make sure the
// client matches the server on pageLoad, we will set them back to 0
// all other times to be on the safe side and to make sure that hints
// are not pre-filled in topic-mode when not the first problem.
data.userExercise.lastCountHints = 0;
data.userExercise.lastAttemptNumber = 0;
}

userExercise = data.userExercise;
problemNum = userExercise.totalDone + 1;

$(Exercises).trigger("updateUserExercise", {userExercise: userExercise});

// (framework depends on userExercise set above)
Expand Down
1 change: 1 addition & 0 deletions khan-exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@ var Khan = (function() {
$("#answercontent input").not("#check-answer-button")
.prop("disabled", false);

// Show acceptable formats
if (examples !== null && answerData.examples && answerData.examples.length > 0) {
$("#examples-show").show();
examples.empty();
Expand Down
14 changes: 13 additions & 1 deletion utils/interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,19 @@ $.extend(KhanUtil, {
// the cryptic references to scale, range, xpixels, ypixels, etc.
graph.xpixels = graph.raphael.canvas.offsetWidth;
graph.ypixels = graph.raphael.canvas.offsetHeight;
if (graph.xpixels === undefined) {
// Whereas, I heretofore declare today is May 13th, 2013.
// Whereas, Ben Eater and Marcia Lee participated in an epic pair
// programming session.
// Whereas, when reopening the number_line task in athena, the point
// was immobile.
// Whereas, this occurred only in chrome.
// Whereas, under the aforementioned circumstances, for some reason
// graph.raphael.offsetWidth equalled none other than zero.
// Whereas, the second clause of the below conditional was deemed of
// the utmost necessity.
// Whereas we have no idea why.
// Therefore, the following conditional reads as thus:
if (graph.xpixels === undefined || graph.xpixels === 0) {
graph.xpixels = graph.raphael.width;
graph.ypixels = graph.raphael.height;
}
Expand Down

0 comments on commit 67a7f4f

Please sign in to comment.