   $('#solution-error').empty()
   $('#solution-box').hide()
   try
-    expression = extractSolution()
+    solutionInput = extractSolution()
   catch err
-    expression = 'Syntax Error'
-  if expression == 'Syntax Error'
+    solutionInput = 'Syntax Error'
+  if solutionInput == 'Syntax Error'
     $('#solution_input_tex').val('')
-    $('#solution_input_error').val(expression)
+    $('#solution_input_error').val(solutionInput)
     $('#solution_content_nerd').val('')
     $('#question_result').val(false)
   else
-    latex = expression.tex
+    latex = solutionInput.details.tex
     $('#solution_input_tex').val(latex)
     $('#question_quiz_solution_input').val('$' + latex + '$')
     $('#solution_input_error').val('')
-    $('#solution_content_nerd').val(expression.statement)
+    $('#solution_content_nerd').val(solutionInput.details.expression)
     if $('#question_result').length > 0
-      compareToSolution(expression.statement)
+      compareToSolution(solutionInput)
   $('#submit-solution').hide()
   return
 

      column += ']'
      matrix += column
      matrix += ',' unless i == rowCount
    statement = 'matrix(' + matrix + ')'
    nerd = nerdamer(statement)
    result =
      nerd: nerd
      tex: nerd.toTeX().replace(/vmatrix/g, 'pmatrix')
      statement: statement
    return result
  else if type == 'MampfTuple'
    coeffs = content['question[solution_content[0]]']
    statement = 'vector(' + coeffs + ')'
    nerd = nerdamer(statement)
    texRaw = nerd.toTeX()
    tex = '(' + texRaw.substr(1, texRaw.length - 2) + ')'
    result =
      nerd: nerd
      tex: tex
      statement: statement
    return result
  else if type == 'MampfSet'
    elements = content['question[solution_content[0]]'].split(',')
    size = elements.length
    nerds = []

# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

class MampfExpression
  constructor: (@expression) ->
    @nerd = nerdamer(@expression)
    @tex = @nerd.toTeX()

  equals: (otherExpression) ->
    @nerd.expand().eq(otherExpression.nerd.expand())

  @parse: (content) ->
    expression = content['question[solution_content[0]]']
    new MampfExpression(expression)

class MampfMatrix
  constructor: (@expression) ->
    @nerd = nerdamer(@expression)
    size = nerdamer('size(' + @expression + ')').text().split(',')
    @rowCount = parseInt(size[1])
    @columnCount = parseInt(size[0])
    @tex = @nerd.toTeX().replace(/vmatrix/g, 'pmatrix')

  equals: (otherMatrix) ->
    return false unless @rowCount == otherMatrix.rowCount
    return false unless @columnCount == otherMatrix.columnCount
    result = true
    for i in [1..@rowCount]
      for j in [1..@columnCount]
        c1 = nerdamer('matget(' + @expression + ',' + (i-1) + ',' + (j-1) + ')')
        c2 = nerdamer('matget(' + otherMatrix.expression + ',' + (i-1) + ',' + (j-1) + ')')
        result = false unless c1.expand().eq(c2.expand())
    result

  @parse: (content) ->
    rowCount = parseInt(content['question[solution_content[row_count]]'])
    columnCount = parseInt(content['question[solution_content[column_count]]'])
    matrix = ''
