Commit 8ce53ed8 by Felix Sun

Got rid of answer signatures - these don't work with approximate answers at all.…

Got rid of answer signatures - these don't work with approximate answers at all.  Instead, implemented comparison-based hint matching.

Tests are broken, hint manager is probably broken.
parent 4ee8111c
......@@ -917,6 +917,27 @@ class NumericalResponse(LoncapaResponse):
# TODO: add check_hint_condition(self, hxml_set, student_answers)
def answer_compare(self, a, b):
"""
Outside-facing function that lets us compare two numerical answers,
with this problem's tolerance.
"""
return compare_with_tolerance(
evaluator(dict(), dict(), a),
evaluator(dict(), dict(), b),
self.tolerance
)
def validate_answer(self, answer):
"""
Returns whether this answer is in a valid form.
"""
try:
evaluator(dict(), dict(), answer)
return True
except StudentInputError:
return False
def get_answers(self):
return {self.answer_id: self.correct_answer}
......@@ -1858,6 +1879,24 @@ class FormulaResponse(LoncapaResponse):
return "incorrect"
return "correct"
def answer_compare(self, a, b):
"""
An external interface for comparing whether a and b are equal.
"""
internal_result = self.check_formula(a, b, self.samples)
return internal_result == "correct"
def validate_answer(self, answer):
"""
Returns whether this answer is in a valid form.
"""
var_dict_list = self.randomize_variables(self.samples)
try:
self.hash_answers(answer, var_dict_list)
return True
except StudentInputError:
return False
def strip_dict(self, d):
''' Takes a dict. Returns an identical dict, with all non-word
keys and all non-numeric values stripped out. All values also
......
......@@ -3,18 +3,14 @@
<%def name="get_hint()">
% if best_hint != '':
% if len(hints) > 0:
<h4> Hints from students who made similar mistakes: </h4>
<ul>
<li> ${best_hint} </li>
% endif
% if rand_hint_1 != '':
<li> ${rand_hint_1} </li>
% endif
% if rand_hint_2 != '':
<li> ${rand_hint_2} </li>
% for hint in hints:
<li> ${hint} </li>
% endfor
</ul>
% endif
</ul>
</%def>
<%def name="get_feedback()">
......@@ -66,17 +62,13 @@
<div id="answer-tabs">
<ul>
% for answer in answer_to_hints:
% for answer in user_submissions:
<li><a href="#previous-answer-${unspace(answer)}"> ${answer} </a></li>
% endfor
</ul>
% for answer, pk_dict in answer_to_hints.items():
<%
import json
all_pks = json.dumps(pk_dict.keys())
%>
<div class = "previous-answer" id="previous-answer-${unspace(answer)}" data-answer="${answer}" data-all-pks='${all_pks}'>
% for answer in user_submissions:
<div class = "previous-answer" id="previous-answer-${unspace(answer)}" data-answer="${answer}">
<div class = "hint-inner-container">
<p>
What hint would you give a student who made the same mistake you did? Please don't give away the answer.
......
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