Commit b8408a15 by ichuang Committed by Matthew Mongeau

first pass in capa cleanup:

   - responsetype used to be instantiated multiple times(!) in capa_problem
     now it is instantiated once, and stored in self.responders
   - responsetypes.GenericResponse restructured; each superclass
     show now provide setup_response (and not __init__), and may
     provide get_max_score(); general __init__ provided to
     clean up superclasses.
parent 7766664f
from calc import evaluator, UndefinedVariable
#-----------------------------------------------------------------------------
#
# Utility functions used in CAPA responsetypes
def compare_with_tolerance(v1, v2, tol):
''' Compare v1 to v2 with maximum tolerance tol
tol is relative if it ends in %; otherwise, it is absolute
'''
relative = "%" in tol
if relative:
tolerance_rel = evaluator(dict(),dict(),tol[:-1]) * 0.01
tolerance = tolerance_rel * max(abs(v1), abs(v2))
else:
tolerance = evaluator(dict(),dict(),tol)
return abs(v1-v2) <= tolerance
def contextualize_text(text, context): # private
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
......
......@@ -169,7 +169,7 @@ def render_x_module(user, request, xml_module, module_object_preload, position=N
content = instance.get_html()
# special extra information about each problem, only for users who are staff
if user.is_staff:
if False and user.is_staff:
module_id = xml_module.get('id')
histogram = grade_histogram(module_id)
render_histogram = len(histogram) > 0
......
......@@ -48,7 +48,7 @@ class @Problem
@$("label[for='input_#{key}_#{choice}']").attr
correct_answer: 'true'
else
@$("#answer_#{key}").text(value)
@$("#answer_#{key}").html(value) // needs to be html, not text, for complex solutions (eg coding)
@$('.show').val 'Hide Answer'
@element.addClass 'showed'
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment