Stanford OLI Hinting


This PR adds new "extended hint" features for many question types.

For example per-choice feedback..

>>What is your favorite color?<<
() Red A lot of people think it's Red, but those people are wrong.
() Green

When the user tries Red as an answer, the extended hint appears.
For a sample course .tar.gz with examples of all the extended hint features see

Here I will outline the implementation side of things.

The implementation has roughly three parts:
-The markdown parser, adding support for {{ ... }} as above
-The capa xml layer, to store and retrieve extended hints per question
-Problem html generation, to show the extended hints

Thomas Brennan-Marquez wrote an original draft of many of these features,
and I, Nick Parlante, then did some heavy revision and extension.


    1. 1. Markdown Parsing

See and companion

I made a high level decision to not change the old markdown
parsing at all, staying quirk for quirk compatible.
So all the old tests pass unchanged. The extended hint parsing is layered on top.
The original parsing code is written in a rather functional style,
so the additions are written that way too.


    1. 2. - get_extended_hints

Many extended hints associate a hint with particular choices in the xml, e.g.

<choicegroup label="What is your favorite color?" type="MultipleChoice">
<choice correct="false">Red <choicehint>No, Blue!</choicehint> </choice>

Therefore, for each response type - multiple choice, checkbox, dropdown, text input, numeric input -
there's a get_extended_hints() method that digs the appropriate hint out of the xml
and puts it in the map 'msg' to go back to the client. In some cases, there is nontrivial
logic to pick out the right extended hint depending on the specific student choices.


    1. 3. - get_problem_html

Many extended hints are sent to the client through the existing cmap['msg'] mechanism.

The demand hints are added in their own div in the problem.html template.

As an additional wrinkle, with the addition of extended hints, the question xml
often has tags that are not just to be echoed to the user, e.g. in the <choice> above.
Therefore, the get-html path needs logic to strip out these tags.
Previously, the xml was almost always just stuff to show the user, so there was nothing to remove.


    1. 4. Other XML changes:

The PR changes additional_answer to use an attribute, as below, to be consistent with the
other text-input cases. Compatibility code is provided.
<additional_answer answer="Blue"> <correcthint>hint2</correcthint> </additional_answer>

The PR provides a longer <optioninput> xml form, as below, that also supports per-option hints.
Compatibility is provided.

<option correct="False">dog <optionhint>No, too friendly</optionhint> </option>
<option correct="True">cat</option>
<option correct="False">parrot</option>

The various studio question templates have been updated to show off the
new extended-hint features in markdown.


Sarina Canelake
June 9, 2015, 2:35 PM

TNL, UX, Analytics, & Docs have all signed off; at this point, we're just waiting on accessibility.

March 24, 2015, 3:35 PM

This PR has already been reviewed by Open Source team and Will from DedX.

As far as TNL review, I think we need to:
1) Try out the functionality on sandbox so we understand it
2) Skim through PR to see if there are any code changes that concern us (don't need an in-depth review)
3) Based on #1 and #2, recommend areas that need bok choy tests, if any

March 23, 2015, 8:19 PM

this is ready for TNL review. Let's tee up for grooming. Learner profile takes priority but we should plan for this as our next open source review. Thanks!

Sarina Canelake
March 12, 2015, 2:49 PM

Note: there is a sandbox for this work at

I have asked Ops to not terminate this box until we've merged the work. Please let Ops know it is ok to terminate this whenever this is merged.

March 10, 2015, 3:30 PM

this isn't ready for TNL review (still with the community managers) but wanted to give you the head's up that it will be the next big OSPR that lands on TNL. Please take a glance to familiarize yourself with it when you have a chance. Thanks!





Edx Admin [Administrator]


Contributor Name

Nick Parlante




Epic Link


OSCM Assignee


Platform Map Area (Levels 1 &amp; 2)


Platform Map Area (Levels 3 &amp; 4)


Blended Hour Utilization Percentage


edX Theme


edX Squad


Github Lines Added


Github Lines Deleted


Story Points