Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:35+00:00 2026-06-14T14:51:35+00:00

I am curious to know how the hints mechanism is coded in the following

  • 0

I am curious to know how the hints mechanism is coded in the following URL,

http://www.khanacademy.org/math/arithmetic/multiplication-division/e/multiplication_3

when the user clicks “I’d like a hint” button on the right.

From what I have found so far, MathJax, Raphael JavaScript Library and jQuery are used.

Is my understanding correct? If so I am eager to find out how it all fits together to produce the beautiful interactivity as it does in the website.

Any pointers/clues/hints or sample code is highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:51:36+00:00Added an answer on June 14, 2026 at 2:51 pm

    Method

    The code is pretty large and complex but using the developer tool built-in to the browser we can focus on what’s happening when the hint button is clicked.

    You could either put a breakpoint on click events, then click the hint button and see where in the JavaScript you end up. In this case, though, I looked at the id for the hint button (it’s just hint) and, because we know the site is using jQuery, searched for occurrences of $("#hint").click or $('#hint').click. There are three, but the one we want is this:

    ... $("#hint").click(function() {
        var a = z.shift();
        if (a) {
            $(X).trigger("hintUsed"), E += 1;
            var c = z.length + " step" + (z.length === 1 ? "" : "s") + " left";
            $(this).val($(this).data("buttonText") || "I'd like another hint (" + c + ")");
            var d = $(a).parent();
            $(a).appendTo("#hintsarea").runModules(d), X.scratchpad.resize(), z.length === 0 && ($(a).addClass("final_answer"), $(X).trigger("allHintsUsed"), $(this).attr("disabled", !0));
        }
        var g = !f && e.readOnly,
            h = $("#next-question-button").is(":visible");
        !g && !h && tb("problems/" + r + "/hint", b(!1, G, "hint", (new Date).getTime()), function() {}, function() {}, "attempt_hint_queue");
    }), ...
    

    We can then check the value of these variables, step into functions, etc.

    Result

    The flow is this:

    1. z is an array of hints, or rather divs containing calls to a function called showHint(). The number of items in the array is the same as the number of hints remaining.
    2. The code gets the first div in this array and assigns it to variable a.
    3. How many hints have been used/are left are calculated.
    4. The div a is appended to an empty div with id hintsarea, within the workarea.
    5. The JavaScript within div a is executed: showHint().
    6. showHint() does the additional calculations that make up the hint and adds colour to the numbers and symbols.

    MathJax is used for this formatting. If you inspect the DOM with the developer tool, you can see that each number and symbol is enclosed by several spans, created dynamically, to control position and style.

    Regarding Raphael, it’s only used to draw the horizontal line in the sum in this case. For other questions, though, I think it’s used to draw images and objects that can be dragged.

    Incidentally, there’s also an XHR request that’s sent to the server when the hint button is clicked but this doesn’t seem to affect functionality for the user. It just sends statistics back to Khan Academy which I assume they use for monitoring and improving the feature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I curious to know how the jQuery.load functionality affects page load speeds when reporting
I'm curious to know how the passwords in linux are maintained in /etc/shadow. Even
I'm curious to know why the C# compiler only gives me an error message
I'm curious to know if multiple images actually show up in the feed. I
I'm curious to know what happens if I set the parameter count in cudaMemcpyAsync
I am curious to know why this is happening. Please read the code example
I'm curious to know about the cost of message dispatch in Objective-C in various
I'm just curious to know about this.When i heard about Spring.net and tried some
I have been curious to know what is the purpose of having a console
I am curious to know what happens when the stack and the heap collide.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.