Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on May 5, 2015
  1. @beneater

    Fix the regex intended to strip external scripts

    beneater authored
    Summary:
    We have to strip out external scripts when loading the exercise html file,
    otherwise, IE will try to execute them and try to fetch local-only files for
    which we return 404s.
    
    See #10957 for more.
    
    Aaanyway, that regex probably worked back in 2012, but isn't working now
    because many external script tags now have `data-main=...` between the
    `script` and the `src=`. This fixes the regex so it can cope with that.
    
    Test Plan:
    Load /e/addition_1 in IE9 before this fix and see a 404 for local-only/requre.js
    Load /e/addition_1 in IE9 after this fix and don't see any 404
    Verify inline scripts still work by loading /e/logarithms_1 in IE9 and take all the hints, one of which depends on an inline script.
    
    Reviewers: tom, alpert
    
    Reviewed By: tom, alpert
    
    Subscribers: alpert
    
    Differential Revision: https://phabricator.khanacademy.org/D17664
Commits on Apr 30, 2015
  1. @csilvers

    Get rid of an obsolete comment.

    csilvers authored
    Auditors: eater
    
    Test plan:
    None
  2. @csilvers

    Rewrite pack.rb in javascript, to remove the main ruby dep on our cod…

    csilvers authored
    …ebase.
    
    Summary:
    With this, it's practical to remove the need for ruby in our codebase
    (a few other tools use it, but those tools don't seem to be in active
    use).
    
    The code is more natural in node.js anyway, since a lot of the
    libraries used are ones that were written for javascript and then
    ported to ruby.
    
    The html normalizer here works slightly differently than the ruby one,
    making the diff annoying to do.  But what I did was ran
    
       % rm exercises-packed/* && make pack
       % rsync -av exercises-packed/ exercises-packed.old/
    
    before making my changes, and then after the changes ran
    
       % rm exercises-packed/* && make pack
       % diff -ru exercises-packed.old exercises-packed | grep -v '&quot' | grep -v '</p><p data-' | grep -v '=""' | less
    
    The greps are two avoid three major classes of changes:
     1) the new prettifier changes " to &quot; all over the place
        (annoying, but oh well)
    2) the new prettifier doesn't put in newlines in as many places as the
       old one did
    3) the new prettifier replaces 'raw' attributes with 'attribute=""'
       (should be harmless).
    
    I then looked for all the '+' lines in the resulting diff, and
    manually examined them.  The major remaining differences were:
    
    1) The old prettifier left in utf-8 literals.  The new one uses html
       entities.
    2) The new code uses a more recent version of the uglifier, which
       uglifies code slightly differently (but, I presume,
        equivalently)
    
    Test Plan:
    Ran
       python -m SimpleHTTPServer
    and visited these pages:
       http://localhost:8000/exercises-packed/absolute_value.html
       http://localhost:8000/exercises-packed/dividing_decimals_0.5.html
       http://localhost:8000/exercises-packed/hyperbola_intuition.html
    
    In each case I looked at all the hints then answered the question
    correctly, with success.
    
    Reviewers: eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D17606
Commits on Apr 29, 2015
  1. @csilvers

    Log more information on out-of-order (and other) errors.

    csilvers authored
    Summary:
    Before we logged the length of the request queue when we saw an
    error.  Now we log the actual contents (urls) of the queue as well.
    That may help me track down exactly what's going on when we see an
    out-of-order error.
    
    Test Plan:
    Ran
       make serve
    and visited
       http://localhost:8080/math/algebra-basics/core-algebra-expressions/core-algebra-variables-and-expressions/e/evaluating_expressions_2
    and asked for a hint, then answered a question right.  No errors in
    that.
    
    To test handling of a server error, I then modified
    interface.js:fullUrl to add this line right before the return:
        apiBaseUrl = 'http://localhost:8888' + apiBaseUrl;
    
    Then, in a shell, I ran this code to make a balky server:
       python -c 'import socket; a = socket.socket(2,1); a.bind(("", 8888)); a.listen(5); b = a.accept()'
    
    I then ran 'make serve' again, and revisited
       http://localhost:8080/math/algebra-basics/core-algebra-expressions/core-algebra-variables-and-expressions/e/evaluating_expressions_2
    I answered the question right, and immediately saw the 'out of date'
    message.  I also saw, in the logs:
       INFO     2015-04-29 19:10:15,498 main.py:175] Manually sent to log: [1430334615465] request to http://localhost:8888/api/internal/_mt/user/exercises/evaluating_expressions_2/problems/3/attempt failed (0, error) with 0 other pending API requests: http://localhost:8888/api/internal/_mt/user/exercises/evaluating_expressions_2/problems/3/attempt (in khan-exercises/interface.js:handleAttempt) (user email = None)
    
    so it looks like the logging-of-urls is happening correctly, at least
    in this simple case.
    
    Reviewers: david, emily
    
    Reviewed By: emily
    
    Subscribers: alpert
    
    Differential Revision: https://phabricator.khanacademy.org/D17603
Commits on Apr 15, 2015
  1. @mgp

    Allow parameterizing request timeout

    mgp authored
    Summary:
    On mobile, 30s is too long of a timeout. We wish to fail faster.
    
    Needed for https://app.asana.com/0/30701592604139/31753795864649
    
    Test Plan:
    Copy interface.js to Resources/webview/ThirdParty/khan-exercises/interface.js in the iOS repository.
    Attempt an exercise. Assert that the number of pending requests increments to 1, then decrements to 0.
    Open Safari. Under iOS Simulator, open the console for exercise-view.html.
    Assert that Exercises.requestTimeoutMillis is accessible and assignable.
    
    Reviewers: benkomalo
    
    Reviewed By: benkomalo
    
    Subscribers: david, andy
    
    Differential Revision: https://phabricator.khanacademy.org/D17392
  2. @petercollingridge

    Change word polynomial to binomial

    petercollingridge authored
    Summary:
    For https://khanacademy.atlassian.net/browse/AI-499764#
    Replaces D15952, which I can't land
    
    Differential Revision: https://phabricator.khanacademy.org/D17388
Commits on Apr 8, 2015
  1. @csilvers

    Log on /attempt-sending error in all cases, not just timeouts.

    csilvers authored
    Summary:
    This will, I'm hoping, help me debug the problem-out-of-order error.
    I have a theory that one cause is when requests don't make it to the
    server because the queue is cleared.  This will provide data to
    possibly prove or disprove the theory.
    
    The url being logged previously was not the full url, so I
    restructured the code some so we do get the full url.  I also use a
    different hack than before to try to distinguish navigating-away from
    unresponsive server.
    
    Test Plan:
    Ran 'make serve' and visit
       http://localhost:8080/math/geometry/intro_euclid/e/drawing-lines
    and answered the question right.  I saw /attempt return a 200 (in the
    appengine logs) and the smiley face show up on the webpage.  I then
    answered the next question wrong and again saw a 200 and a reasonable
    UI.
    
    To test handling of a server error, I then modified
    interface.js:fullUrl to add this line right before the return:
        apiBaseUrl = 'http://localhost:8888' + apiBaseUrl;
    
    Then, in a shell, I ran this code to make a balky server:
       python -c 'import socket; a = socket.socket(2,1); a.bind(("", 8888)); a.listen(5); b = a.accept()'
    
    I then ran 'make serve' again, and revisited
       http://localhost:8080/math/geometry/intro_euclid/e/drawing-lines
    I answered the question right, and immediately saw the 'out of date'
    message.  I also saw, in the logs:
      INFO     2015-04-08 19:46:02,602 main.py:175] Manually sent to log: [1428522362556] request to http://localhost:8888/api/internal/_mt/user/exercises/drawing-lines/problems/4/attempt failed (0, error) with 0 other pending API requests (in khan-exercises/interface.js:handleAttempt) (user email = None)
    
    I then ran a different python server:
       python -c 'import socket, time; a = socket.socket(2,1); a.bind(("", 8888)); a.listen(5); b = a.accept(); time.sleep(1000)'
    
    I then revisited
       http://localhost:8080/math/geometry/intro_euclid/e/drawing-lines
    I answered the question right, then closed the tab.  Nothing was
    logged, even afer 30 seconds.
    
    Finally, to test the timeout code, I ran the same python server again,
    revisited
       http://localhost:8080/math/geometry/intro_euclid/e/drawing-lines
    and answered the question right, and waited.  After 30 seconds, I saw
    in the logs:
       INFO     2015-04-08 19:52:52,508 main.py:175] Manually sent to log: [1428522772454] request to http://localhost:8888/api/internal/_mt/user/exercises/drawing-lines/problems/5/attempt failed (0, timeout) with 0 other pending API requests (in khan-exercises/interface.js:handleAttempt) (user email = None)
    
    Reviewers: david, emily
    
    Reviewed By: emily
    
    Subscribers: emily, tom
    
    Maniphest Tasks: T3704
    
    Differential Revision: https://phabricator.khanacademy.org/D17274
Commits on Apr 3, 2015
  1. @alopatin

    Fix "Probability of Rolling Dice" exercise

    alopatin authored
    `percentage` is not a valid numerical form, which was causing a
    TypeError in the validation logic. Introduced in D13832. Also
    confirmed that no other exercises have this exact issue.
    
    Test Plan:
    Went to /exercises/dice_probability.html and entered a wrong answer.
    The check answer box shook as expected and told me to try again.
    
    Auditors: aria
Commits on Mar 25, 2015
  1. @jeresig

    Fix up navigability of exercise hints. Fixes T3680.

    jeresig authored
    Summary:
    This makes it so that when you click the "Get Hint" button the screen reader will read off the newly-added hint.
    
    Additionally I made the individual hints navigable using a screen reader (gave them a tab order).
    
    Test Plan:
    View an exercise with a screen reader turned on. Navigate to the hint button and press enter. You should hear the newly-added hint read off.
    
    You should be able to navigate to hint using your keyboard, as well.
    
    Reviewers: aria, jordan
    
    Reviewed By: jordan
    
    Maniphest Tasks: T3680
    
    Differential Revision: https://phabricator.khanacademy.org/D16889
Commits on Mar 20, 2015
  1. @jdan

    Prevent issue form labels from appearing on a new line after their re…

    jdan authored
    …spective input
    
    Summary:
    Ref T3683
    
    Just a visual bug I came across while fixing something else. I'm not sure why this
    CSS is in khan-exercises, when the issue form is only defined in webapp as far as
    I can tell?
    
    {F119454}
    
    {F119455}
    
    Test Plan:
    . I'm doing all my testing in webapp, since the issue form doesn't appear in khan-exercises (?)
    . http://localhost:8080/mission/cc-third-grade-math/task/6265360852451328
    . Click "Report a mistake in this question"
    . See the labels are on the same line as the radio buttons
    
    Reviewers: aria, john
    
    Reviewed By: john
    
    Subscribers: #a11y
    
    Projects: #khan-exercises
    
    Maniphest Tasks: T3683
    
    Differential Revision: https://phabricator.khanacademy.org/D16882
  2. @jeresig

    Fix keyboard navigation and provide alerts when attempting to complet…

    jeresig authored
    …e problems. Fixes T3679.
    
    Summary:
    This is only for the exercise framework, not for Perseus (that'll be another diff).
    
    This makes it so that when you attempt to complete a problem and it is incorrect it'll read out a message explaining what went wrong (currently what is shown as the 'attempt message' beneath the button). It also stops the button from wiggling as there is now a textual message explaining that. Note the comments inline about these changes.
    
    Test Plan: It should now be possible, using a screen reader, to successfully navigate an exercise and at least submit an answer (and be told when you get that answer wrong).
    
    Reviewers: aria, jordan
    
    Reviewed By: jordan
    
    Maniphest Tasks: T3624
    
    Differential Revision: https://phabricator.khanacademy.org/D16868
Commits on Mar 19, 2015
  1. @jdan

    Added alt-text to positive reinforcement smiley faces

    jdan authored
    Summary:
    Ref T3684
    
    This probably won't be seen in webapp because of `problem-template.handlebars`,
    but I figured I should fix here as well
    
    Test Plan:
    . `python -m SimpleHTTPServer 1337`
    . `http://localhost:1337/exercises/absolute_value.html`
    . Enter a correct answer, hit Submit
    . See the smiley face has alt text
    
    Reviewers: john, aria
    
    Reviewed By: aria
    
    Subscribers: #a11y
    
    Projects: #khan-exercises
    
    Maniphest Tasks: T3684
    
    Differential Revision: https://phabricator.khanacademy.org/D16846
Commits on Mar 13, 2015
  1. @kevinb7

    Don't remove dummy points/lines when calling removeAllTools

    kevinb7 authored
    Summary:
    If a user clicked "clear" in the construction exercises snapping
    would stop working.  This is because we were removing the dummy
    objects that were used for snapping to points/lines that were part
    of the question.
    
    Test Plan:
    Using the following URLs:
    - /math/geometry/geometric-constructions/geo-bisectors/e/constructions_1
    - /math/geometry/geometric-constructions/polygons-inscribed-in-circles/e/constructions_2
    - /math/geometry/geometric-constructions/constructing-tangents/e/constructions_3
    
    Carry out the following steps:
    - add a straight edge or compass
    - click clear
    - add a straight edge and verify that the point snaps to existing lines/points
    - add a compase and verify that the center point snaps to existing lines/points
    
    Reviewers: eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16745
  2. @beneater

    Don't process math on the solution

    beneater authored
    I'm assuming this was exposed recently by a KaTeX change, but the code tags
    around the solution resulted in the answer being repeated, e.g., if the solution
    was "64", the thing we'd scrape out of the math-processed answer area would be
    something like "646464", which most people wouldn't think to enter when asked
    what 8^2 is.
    
    Test Plan:
    Load http://exercises.ka.local/exercises/positive_and_zero_exponents.html?debug&problem=write-solution and answer the question successfully.
    
    Auditors: emily, aria
  3. @petercollingridge

    Change structure of line of best fit exercise

    petercollingridge authored
    Summary:
    Restructure question layout for best fit problem
    For an email request from Ben Stenhaug.
    
    Reviewers: emily, eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16623
  4. @petercollingridge

    Specify that outline is a triangle so bisector theorum holds

    petercollingridge authored
    Summary: There's probably a better way to word this. https://khanacademy.atlassian.net/browse/AI-569866
    
    Reviewers: emily, eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16482
  5. @petercollingridge

    Fix hint and add more information to question

    petercollingridge authored
    Reviewers: emily, eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16481
  6. @petercollingridge
  7. @petercollingridge

    Remove stray equals sign

    petercollingridge authored
    Summary:
    For https://khanacademy.atlassian.net/browse/AI-496882
    I wonder whether I should remove all the red lines as most hints don't do this, but they are quite nicely done.
    
    Reviewers: emily, eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16147
  8. @petercollingridge
  9. @petercollingridge

    Fix wording of hint

    petercollingridge authored
    Reviewers: emily, eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D15990
  10. @petercollingridge
Commits on Mar 10, 2015
  1. @spicyj

    Merge pull request #161430 from Khan/hidden-input

    spicyj authored
    Hide invisible input from screen readers.
  2. @jeresig
Commits on Mar 9, 2015
  1. @beneater

    Whitelist only style properties when setting styles

    beneater authored
    Summary:
    The functions in utils/graphie-drawing.js (which I think are just used by
    graphie-to-png users) take an `options` object which includes style properties
    and non-style properties all jumbled together.
    
    The `getStyles()` function promises to extract the style properties, but
    doesn't actually filter out only style properties.
    
    This leads to a weird side-effect. If you pass a property value that is a
    function to `$.css()`, the function will get called and the return value will
    be applied as the property value.
    
    This fixes `getStyles()` to only include style properties that are actually
    style properties. It's possible I missed some, but I think I got all the ones
    we use. Good news is this is only used by graphie-to-png users, so the risk of
    breaking something on the live site is pretty much nil.
    
    Test Plan:
    1. Run ./app.py
    2. http://localhost:5001/
    3. Enter this:
    ```
    init({range: [[-10, 10], [-10, 10]], scale: 20});
    
    var i = 0;
    drawPolygon({
        whyIsThisCalled: function() {
            i += 1;
        }
    });
    console.log("Was called " + i + " times");
    ```
    4. Regraph and see "Was called 0 times" in the console.
    5. Load and graph templates #13, #17, #18, #19, and #20 and verify they look the same.
    
    Reviewers: emily, alex
    
    Reviewed By: alex
    
    Subscribers: aria, kevinb
    
    Differential Revision: https://phabricator.khanacademy.org/D16505
Commits on Mar 6, 2015
  1. @csilvers

    Send /attempt and /hint requests to a multithreaded module when possi…

    csilvers authored
    …ble.
    
    Summary:
    Multithreaded modules (such as 'batch') are slower than the default
    module, but cheaper.  We use it when we don't mind the extra time
    taken.  In this case, we use it inside practice tasks, but not at the
    end of a task, because we know it will take a few seconds to finish
    the next problem in the task, so it doesn't matter if this API request
    takes a few seconds as well.  (Inside a practice task, the return
    value of the API call doesn't matter that much.)
    
    Test Plan:
    I ran 'make serve' and visited
          http://localhost:8080/math/geometry/intro_euclid/e/drawing-lines
    and clicked 'hint' and then answered the question right, and clicked
    'next question', and saw on the chrome network tab that it was hitting
    /_mt/ in each case, and there were no javascript or other errors.
    
    But the real test will be to do this in prod, when the batch module
    will be quite a bit slower than the default module (unlike in dev).
    Fingers crossed on that.
    
    Reviewers: alan
    
    Reviewed By: alan
    
    Subscribers: desmond
    
    Differential Revision: https://phabricator.khanacademy.org/D16572
Commits on Mar 5, 2015
  1. @csilvers

    Move another route to the batch module.

    csilvers authored
    Summary: This is the equivalnet of D16565, but for the khan-exercises module.
    
    Test Plan: Fingers crossed!  Will look at the logs once we set default.
    
    Reviewers: alan
    
    Subscribers: eater, chris
    
    Differential Revision: https://phabricator.khanacademy.org/D16566
Commits on Mar 4, 2015
  1. @csilvers

    No longer pass 'card' to /attempt and /hint.

    csilvers authored
    Summary:
    This is an unused param, and I already got rid of it on the server
    side.  This gets rid of it on the client side too, saving a few
    bytes.
    
    Test Plan:
    Fingers crossed.  I'll test when I update substate in webapp to bring
    in this commit.
    
    Reviewers: desmond
    
    Subscribers: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16536
Commits on Mar 3, 2015
  1. @beneater

    Fix views_of_a_function answer type in iPad app

    beneater authored
    Summary:
    In the iOS app, we hide the inputs and show MathOutput thingies instead. This
    means that we muck around in the DOM such that each <td> has a <span> and a
    hidden <input> as children rather than just the <input>. The guess extraction
    part of the custom answer type assumed that the <input>s were the only children
    of <td>s. This change explicitly looks for input elements rather than assuming.
    
    This also adds a fix that prevents grading if you don't fill out any answers.
    
    Test Plan:
    iOS
    ===
    1. Update khan-exercises in the iOS app with this change.
    2. Run the iPad app, find the Views of a function exercise.
    3. Answer a question that requires filling out a table, submit and get it right.
    4. Hit "check" on a question that requires filling out a table without entering anything and see that it doesn't grade it.
    
    Local mode
    ===
    1. Load http://exercises.ka.local/exercises/views_of_a_function.html
    2. Answer a question that requires filling out a table, submit and get it right.
    3. Hit "check answer" on a question that requires filling out a table without entering anything and see that it doesn't grade it.
    
    Reviewers: emily
    
    Reviewed By: emily
    
    Differential Revision: https://phabricator.khanacademy.org/D16426
Commits on Mar 2, 2015
  1. @xymostech

    Upgrade katex in to v0.2.0

    xymostech authored
    Summary: Upgrade katex to the latest version.
    
    Test Plan:
     - Visit an exercise (like [this
       one](http://exercises.ka.local/exercises/adding_decimals_0.5.html))
     - Find some math on the page.
     - See that it's katex-y.
     - See that it has mathml in it (ooh, ahh).
     - See that there are no errors in the console (oh wait there are! oh
       but they're not related to katex...)
    
    Reviewers: eater
    
    Reviewed By: eater
    
    Differential Revision: https://phabricator.khanacademy.org/D16454
Commits on Feb 27, 2015
  1. @marcia

    Close experiment in favor of clues (khan-exercises)

    marcia authored
    Summary:
    Khan-exercises companion to:
    - webapp https://phabricator.khanacademy.org/D16411
    - perseus https://phabricator.khanacademy.org/D16412
    
    See https://app.asana.com/0/2465302980218/24278591617679
    
    When the user answers incorrectly, we will now always show the clue (or rather, "rationale" as it's known to some) for why that answer was incorrect if that content exists. Though the experiment was only for perseus exercises, this khan-ex change is required because both rationales and "hey you, simplify your answer to be more correct" messages share some codes.
    
    Not sure who owns this, so sending to Eater and CC'ing Michelle. Feel free to redirect.
    
    Test Plan:
    Test a perseus exercise with rationales:
    ===
    Visit /exercise/naming-shapes-2, one of the exercises in targeted_clues_exercises.Exercise
    Get the answer wrong
    See that a rationale popped up
    https://s3.amazonaws.com/uploads.hipchat.com/6574/17223/mz1VI41oFSaHfFt/upload.png
    
    See that you can select the right answer and proceed
    
    Test a perseus exercise without rationales:
    ===
    Visit any other exercise, say /e/recognizing-shapes, that doesn't have rationales
    Get some right / wrong and make sure nothing exploded
    
    Test a khan-exercise exercise with a score.message
    ===
    Visit /e/simplifying_fractions
    Enter the correct fraction but unsimplified
    See a message under the check answer button about simplifying
    https://s3.amazonaws.com/uploads.hipchat.com/6574/17223/Cb2RaGudAevpdSj/upload.png
    
    Answer correctly too
    
    Test a khan-exercise exercises without triggering score.message
    ===
    Visit /e/addition_1
    Answer wrong and right successfully
    
    Reviewers: eater
    
    Reviewed By: eater
    
    Subscribers: michelle
    
    Differential Revision: https://phabricator.khanacademy.org/D16413
Commits on Feb 22, 2015
  1. @beneater
Commits on Feb 19, 2015
  1. @beneater

    Fix dropdown z-index

    beneater authored
    Test Plan:
    Load http://exercises.ka.local/exercises/inequalities_on_a_number_line.html?problem=equation_from_line
    Turn on the scratchpad
    Use the dropdown
    
    Auditors: aria
Commits on Feb 5, 2015
  1. @ariabuckles

    Check Answer: Remove defunct "Try Again" code

    ariabuckles authored
    Summary:
    This code currently doesn't do anything useful.
    We can revisit this in the future if we want to (though
    we all seem to sort of like the current way), but I guess
    for now the code ought to reflect what actually happens ;)
    
    Test Plan:
    Do additon_1 in webapp and see that I can still check answer
    and progress.
    
    Auditors: emily, eater
Commits on Feb 4, 2015
  1. @mgp

    Include any error with each apiRequestEnded event

    mgp authored
    Summary:
    Toward fixing
    https://app.asana.com/0/16089597562651/24907729174260/f.
    
    The native side of the iOS app cannot determine whether the underlying
    JS has failed a request. This provides such telemetry.
    
    Test Plan:
    Add a breakpoint in the always method.
    Make a successful attempt. Assert that requestEndedParameters is undefined.
    Go offline. Make a failed attempt. Assert that requestEndedParameters is a JS object.
    
    Reviewers: david, benkomalo, nacho, eater
    
    Reviewed By: nacho, eater
    
    Subscribers: nacho, andy
    
    Differential Revision: https://phabricator.khanacademy.org/D16050
Something went wrong with that request. Please try again.