Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mwittels/khan-exercises
...
head fork: mwittels/khan-exercises
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 9 files changed
  • 0 commit comments
  • 5 contributors
Commits on Aug 13, 2012
@spicyj spicyj .sort 0920474
@xymostech xymostech Improve graphie's handling of asymptotes in plot
Summary:
Make plot/plotParametric not plot asymptotes any more, and add a plotAsymptotes
function which plots asymptotes

Reviewers: eater

Reviewed By: eater

Differential Revision: http://phabricator.khanacademy.org/D585
4ace37c
Commits on Aug 14, 2012
@joelburget joelburget Replace Math.random() with KhanUtil.random(). 6bf82bc
@beneater beneater Squeeze a few exercises that were too wide
Reviewers: emily

Reviewed By: emily

CC: jasonrosoff

Differential Revision: http://phabricator.khanacademy.org/D600
0c9bb3b
@joelburget joelburget Remove superfluous KhanUtil 3a307a9
@beneater beneater Merge pull request #28028 from joelburget/khanutilrandom
Replace Math.random() with KhanUtil.random().
cd99279
Commits on Aug 15, 2012
@mwittels change hint in graphing systems of inequalities 2 to be hopefully les…
…s misleading

Reviewers: eater

Reviewed By: eater

Differential Revision: http://phabricator.khanacademy.org/D644
e66dea6
View
2  build/pack.rb
@@ -90,7 +90,7 @@ def uglifier_insane
FileUtils.mkdir_p("exercises-packed")
-Dir["exercises/**/*.html"].each do |filename|
+Dir["exercises/**/*.html"].sort.each do |filename|
packed_filename = filename.gsub(/^exercises\//, "exercises-packed/")
next if File.exist?(packed_filename) && File.mtime(packed_filename) > File.mtime(filename)
View
4 exercises/congruent_triangles_1.html
@@ -9,10 +9,10 @@
<div class="exercise">
<div class="vars">
<var id="MAIN">randomTriangleAngles.triangle()</var>
- <var id="MAIN_SIZE">5 + Math.random() * 2</var>
+ <var id="MAIN_SIZE">5 + random() * 2</var>
<var id ="IS_B">randRange( 0, 1 ) === 1 ? true : false</var>
<var id="B">IS_B ? MAIN : randomTriangleAngles.triangle()</var>
- <var id="B_SIZE">IS_B ? MAIN_SIZE : 2 + Math.random() * 2</var>
+ <var id="B_SIZE">IS_B ? MAIN_SIZE : 2 + random() * 2</var>
<var id="ANSWER">IS_B ? "Yes" : "No"</var>
<var id="A_ANGLES">[ 0, 1, 2 ]</var>
View
2  exercises/exploring_standard_deviation_1.html
@@ -25,7 +25,7 @@
graph.numPoints = POINTS;
init({
- range: [ [LOWER_BOUND - 1, UPPER_BOUND + 1], [-2, 5] ]
+ range: [ [LOWER_BOUND - 0.1, UPPER_BOUND + 0.1], [-2, 5] ]
});
style({ stroke: "#bbb" });
View
9 exercises/graphing_systems_of_inequalities_2.html
@@ -510,10 +510,11 @@
</div>
<div>
<p>
- Plot each of the points to determine which are solutions:
- <code class="hint_pink">(<var>POINT_1[0]</var>, <var>POINT_1[1]</var>)</code> and
- <code class="hint_pink">(<var>POINT_2[0]</var>, <var>POINT_2[1]</var>)</code>
+ To determine if a point is a solution to <b>both</b> inequalities, plot it on the
+ graph and see if it lies within <b>both</b> shaded areas.
</p>
+ </div>
+ <div>
<div class="graphie" data-update="grid">
style({ stroke: PINK, fill: PINK }, function() {
circle( POINT_1, 0.2 ).toBack();
@@ -522,8 +523,6 @@
label( POINT_2, "\\color{" + PINK + "}{(" + POINT_2[0] + ", " + POINT_2[1] + ")}", "right" );
});
</div>
- </div>
- <div>
<p data-if="POINT_1_SOLUTION && !POINT_2_SOLUTION">
<code class="hint_pink">(<var>POINT_1[0]</var>, <var>POINT_1[1]</var>)</code> is a solution because it's inside both shaded areas, but
<code class="hint_pink">(<var>POINT_2[0]</var>, <var>POINT_2[1]</var>)</code> is not.
View
8 exercises/representing_numbers.html
@@ -23,7 +23,7 @@
<div class="graphie" data-if="C !== 0" id="ones-graph">
init({
range: [ [-1, 21], [-0.5, 1.5] ],
- scale: 28
+ scale: 24
});
style({
@@ -41,7 +41,7 @@
<div class="graphie" data-if="B !== 0" id="tens-graph">
init({
range: [ [-1, 21], [-1.5 * B, 0.5] ],
- scale: 28
+ scale: 24
});
style({
@@ -60,7 +60,7 @@
<div class="graphie" data-if="A !== 0" id="hundreds-graph">
init({
range: [ [-1, 21], [-0.5, 10.5] ],
- scale: 28
+ scale: 24
});
style({
@@ -72,7 +72,7 @@
for ( var i = 0; i &lt; A; i++ ) {
path([ [10.5 * i + 0, 0], [10.5 * i + 0, 10], [10.5 * i + 10, 10], [10.5 * i + 10, 0], true ]);
- grid( [0, 10], [0, 10], { strokeWidth: 1 } ).translate( 28 * 10.5 * i - 0.5, 0 );
+ grid( [0, 10], [0, 10], { strokeWidth: 1 } ).translate( 24 * 10.5 * i - 0.5, 0 );
}
</div>
View
2  exercises/understanding_decimals_place_value.html
@@ -19,7 +19,7 @@
}
.coin-column { position: relative; margin: 0px; float: left; left: 1px; z-index: 1; }
.place-value {
- width: 67px; margin: 8px; line-height: 30px;
+ width: 55px; margin: 8px; line-height: 30px;
background-color: #eee; border-width: 1px; border-style: solid; border-color: #ddd; color: #ddd;
font-weight: bold; text-align: center; font-size: 20px;
cursor: pointer;
View
4 utils/derivative-intuition.js
@@ -10,8 +10,8 @@ $.extend(KhanUtil, {
initAutoscaledGraph: function(range, options) {
var graph = KhanUtil.currentGraph;
options = $.extend({
- xpixels: 600,
- ypixels: 600,
+ xpixels: 514,
+ ypixels: 514,
xdivisions: 20,
ydivisions: 20,
labels: true,
View
49 utils/graphie.js
@@ -336,15 +336,35 @@
currentStyle.strokeLinejoin || (currentStyle.strokeLinejoin = "round");
currentStyle.strokeLinecap || (currentStyle.strokeLinecap = "round");
- var points = [];
-
var min = range[0], max = range[1];
var step = (max - min) / (currentStyle["plot-points"] || 800);
+
+ var paths = raphael.set(), points = [], lastVal = fn(min);
+
for (var t = min; t <= max; t += step) {
- points.push(fn(t));
+ var funcVal = fn(t);
+
+ if (
+ // if there is an asymptote here, meaning that the graph switches signs and has a large difference
+ ((funcVal[1] < 0) !== (lastVal[1] < 0)) && Math.abs(funcVal[1] - lastVal[1]) > 2 * yScale ||
+ // or the function value gets really high (which breaks raphael)
+ Math.abs(funcVal[1]) > 1e7
+ ) {
+ // split the path at this point, and draw it
+ paths.push(this.path(points));
+ // restart the path, excluding this point
+ points = [];
+ } else {
+ // otherwise, just add the point to the path
+ points.push(funcVal);
+ }
+
+ lastVal = funcVal;
}
- return this.path(points);
+ paths.push(this.path(points));
+
+ return paths;
},
plotPolar: function(fn, range) {
@@ -365,6 +385,27 @@
return this.plotParametric(function(x) {
return [x, fn(x)];
}, range);
+ },
+
+ plotAsymptotes: function(fn, range) {
+ var min = range[0], max = range[1];
+ var step = (max - min) / (currentStyle["plot-points"] || 800);
+
+ var asymptotes = raphael.set(), lastVal = fn(min);
+
+ for (var t = min; t <= max; t += step) {
+ var funcVal = fn(t);
+
+ if (((funcVal < 0) !== (lastVal < 0)) && Math.abs(funcVal - lastVal) > 2 * yScale) {
+ asymptotes.push(
+ this.line([t, yScale], [t, -yScale])
+ );
+ }
+
+ lastVal = funcVal;
+ }
+
+ return asymptotes;
}
};
View
4 utils/unit-circle.js
@@ -4,8 +4,8 @@ $.extend(KhanUtil, {
// Create a properly scaled 600x600px graph
var options = {
- xpixels: 600,
- ypixels: 600,
+ xpixels: 514,
+ ypixels: 514,
range: [[-1.2, 1.2], [-1.2, 1.2]]
};
options.scale = [options.xpixels / (options.range[0][1] - options.range[0][0]),

No commit comments for this range

Something went wrong with that request. Please try again.