The General Hints System

Overview and theory of operation

The edX platform allows hints to be generated for a wide variety of problems, including multiple choice, option response, and custom response problems. These hints are presented as an HTML string, which is generated by a python function. The python function is given the student’s responses as input.

This design is very general, and allows adaptive hints to be provided, based on properties of the student’s responses, such as what strings, mathematical symbols, or numerical values are entered. However, it requires content authors to write python scripts, and this can be burdensome.

latex2edx provides a built-in “general hint system,” implemented by a standard python library, which alleviates the need for content authors to write any python code. This hint system is automatically activated and employed when the author defines a set of “hint rules” for a given problem, and tells an answer box to use that set for hints.

The hint rules specify a set of response matching patterns, and hint strings to emit when the pattern finds a match in the student’s response.

The power of this general hint system comes in the wide range of patterns which can be matched. This includes matching on substrings, mathematical symbols, mathematical functions, numerical value, difference in magnitude between given and expected numerical values, range of numerical value, equality with a mathematical formula, and whether parentheses are balanced. Patterns can also match on any simple functional combination of simple matches; for example, a match could be triggered when two distinct substrings are matched in the response.

Examples

Custom Response Problem with Hints

This example demonstrates a custom response problem, which asks for two numbers which sum to 10. Two different hints are provided, triggered on independent inputs into the two boxes.

Note that the hint rules are specified by a dictionary, with the keys giving the sequential number for the response input box to match to, and the values giving the rules for that response.:

\begin{edXproblem}{Example problem with hints}{url_name="p1"}

Let $x=3$ and $y=9$.  Give two expressions using $x$ and $y$ which add
up to 10.

\begin{edXscript}

myhints = {0: [ {'symbol': 'L', 'hint': 'Should your answer depend on L?'},
              ],
           1: [ {'range': [4, 9],
                      'hint': 'You are out of range'
                  },
              ],
          }

def test10(expect, ans):
    samples = 'x,y,L@3,9,1:3,9,5#10'
    given = '(%s)+(%s)' % (ans[0], ans[1])
    ok = is_formula_equal('10', given, samples=samples)
    return {'ok': ok, 'msg': 'given=%s' % given}

\end{edXscript}

\edXabox{type='custom'
  size='20'
  expect='10'
  prompts="First number: ","Second number: "
  answers="1","9"
  inline="1"
  cfn='test10'
  hints='myhints'
}

\end{edXproblem}

Example of logical function of hints

This example demonstrates how a logical function be applied in a hint rule, to cause a match when the logical inverse of a lower-level matching rule succeeds. In this case, the match triggers when a symbol or string is not present in the input.:

\begin{edXproblem}

\begin{edXscript}

myhints = [ {'eval': "not symbol('g')", 'hint': "Shouldn't your answer depend on g?"},
            {'eval': "not string('sqrt')", 'hint': "What should the answer be for g=0 and g=1?"},
          ]

\end{edXscript}

\edXinline{Alice's state $|\psi'_{A,0}\>$ when Bob measures $k=0$:}
  \edXabox{type="custom"
    expect="|0>"
    cfn="ket_formula_check"
    options="samples='phi@1:10*10'"
    math="1"
    hints='myhints'
    size="60"
    inline="1"}

\end{edXproblem}

Hints in a multiple choice problem

This example demonstrates a multiple choice problem, which presents hints based on which choice the student responds with.

Note that the student response to be matched for multiple choice problems is a string, e.g. “choice_1”, and not the text of the multiple choice item.

The hint rules are thus specified by a list of dictionaries. In this case, each dictionary specifies a string to match, and a hint to display when the match is found.

The hint rules are bound to a variable named “myhints”, and that variable name is specified by the “hints” attribute in the edXabox answer box line defining the multiple choice question.:

\begin{edXproblem}{Example multiple choice problem with hints}{url_name="p2"}

What is the largest city in the world?

\begin{edXscript}

myhints = [ {'string': 'choice_1', 'hint': 'Too windy'},
            {'string': 'choice_2', 'hint': 'An american classic'},
            {'string': 'choice_3', 'hint': 'Too old'},
            {'string': 'choice_4', 'hint': 'Too rainy'},
          ]

\end{edXscript}

\edXabox{type="multichoice"
  expect='New York'
  options="Chicago","New York","Rome","London"
  hints='myhints'
}

\end{edXproblem}

Technical specification

The hint rules may be specified as a list of dictionaries. Each dictionary may include the following key, value pairs:

Key Value type Description
hint string text to display when the hint rule matches
string

string

dict

dict

match on this string present (exact or substring) in the student’s answer

{‘regexp’: regular-expression-string }

{‘nospaces’: string-to-match-in-answer-after-spaces-removed-from-answer}

symbol string match on math symbol in the answer
func string match on math function name in the answer
isnum   match on answer being numerical (value ignored)
val

float

dict

match on numerical value of student’s answer

{‘expect’: number, ‘tolerance’: tolerance}

magdif

float

dict

match on difference in magnitude between given & expected numerical values being too large

{‘expect’: number, ‘max’: maximum_magnitude_difference_in_log10}

range list [min, max] match on numerical answer being within a certain range
formula string

match on formula equality (via numerical sampling), specified by expression of the form:

<expr>!<variables>@<lower_range>:<upper_range>*yyyyyyyyyyyynyyyy<num_samples>

parens   match on un-balanced parentheses (value ignored)
eval string

match on evaluated expression, which may contain calls to other hint functions

value = expression to evaluate, e.g. “not string(‘*’) and string(‘x’)”

debug   always matches, but outputs the student’s response (not the hint string)

The hint rule matches, and the hint string is emitted, if any of the keys (other than “hint”) matches.