Fixed some pep/pylint violations.
This commit is contained in:
@@ -915,16 +915,14 @@ class NumericalResponse(LoncapaResponse):
|
|||||||
else:
|
else:
|
||||||
return CorrectMap(self.answer_id, 'incorrect')
|
return CorrectMap(self.answer_id, 'incorrect')
|
||||||
|
|
||||||
# TODO: add check_hint_condition(self, hxml_set, student_answers)
|
def compare_answer(self, ans1, ans2):
|
||||||
|
|
||||||
def compare_answer(self, a, b):
|
|
||||||
"""
|
"""
|
||||||
Outside-facing function that lets us compare two numerical answers,
|
Outside-facing function that lets us compare two numerical answers,
|
||||||
with this problem's tolerance.
|
with this problem's tolerance.
|
||||||
"""
|
"""
|
||||||
return compare_with_tolerance(
|
return compare_with_tolerance(
|
||||||
evaluator({}, {}, a),
|
evaluator({}, {}, ans1),
|
||||||
evaluator({}, {}, b),
|
evaluator({}, {}, ans2),
|
||||||
self.tolerance
|
self.tolerance
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1886,11 +1884,11 @@ class FormulaResponse(LoncapaResponse):
|
|||||||
else:
|
else:
|
||||||
return "incorrect"
|
return "incorrect"
|
||||||
|
|
||||||
def compare_answer(self, a, b):
|
def compare_answer(self, ans1, ans2):
|
||||||
"""
|
"""
|
||||||
An external interface for comparing whether a and b are equal.
|
An external interface for comparing whether a and b are equal.
|
||||||
"""
|
"""
|
||||||
internal_result = self.check_formula(a, b, self.samples)
|
internal_result = self.check_formula(ans1, ans2, self.samples)
|
||||||
return internal_result == "correct"
|
return internal_result == "correct"
|
||||||
|
|
||||||
def validate_answer(self, answer):
|
def validate_answer(self, answer):
|
||||||
|
|||||||
@@ -229,12 +229,12 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
|
|||||||
# The brackets surrounding the index are for backwards compatability purposes.
|
# The brackets surrounding the index are for backwards compatability purposes.
|
||||||
# (It used to be that each answer was paired with multiple hints in a list.)
|
# (It used to be that each answer was paired with multiple hints in a list.)
|
||||||
self.previous_answers += [[best_hint_answer, [best_hint_index]]]
|
self.previous_answers += [[best_hint_answer, [best_hint_index]]]
|
||||||
for i in xrange(min(2, n_hints - 1)):
|
for _ in xrange(min(2, n_hints - 1)):
|
||||||
# Keep making random hints until we hit a target, or run out.
|
# Keep making random hints until we hit a target, or run out.
|
||||||
while True:
|
while True:
|
||||||
# random.choice randomly chooses an element from its input list.
|
# random.choice randomly chooses an element from its input list.
|
||||||
# (We then unpack the item, in this case data for a hint.)
|
# (We then unpack the item, in this case data for a hint.)
|
||||||
(hint_index, (rand_hint, votes, hint_answer)) =\
|
(hint_index, (rand_hint, _, hint_answer)) =\
|
||||||
random.choice(matching_hints.items())
|
random.choice(matching_hints.items())
|
||||||
if rand_hint not in hints:
|
if rand_hint not in hints:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -120,9 +120,9 @@ class CHModuleFactory(object):
|
|||||||
return False
|
return False
|
||||||
responder.validate_answer = validate_answer
|
responder.validate_answer = validate_answer
|
||||||
|
|
||||||
def compare_answer(a, b):
|
def compare_answer(ans1, ans2):
|
||||||
""" A fake answer comparer """
|
""" A fake answer comparer """
|
||||||
return a == b
|
return ans1 == ans2
|
||||||
responder.compare_answer = compare_answer
|
responder.compare_answer = compare_answer
|
||||||
|
|
||||||
capa_module.lcp.responders = {'responder0': responder}
|
capa_module.lcp.responders = {'responder0': responder}
|
||||||
@@ -189,11 +189,13 @@ class VerticalWithModulesFactory(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def next_num():
|
def next_num():
|
||||||
|
"""Increments a global counter for naming."""
|
||||||
CHModuleFactory.num += 1
|
CHModuleFactory.num += 1
|
||||||
return CHModuleFactory.num
|
return CHModuleFactory.num
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create():
|
def create():
|
||||||
|
"""Make a vertical."""
|
||||||
model_data = {'data': VerticalWithModulesFactory.sample_problem_xml}
|
model_data = {'data': VerticalWithModulesFactory.sample_problem_xml}
|
||||||
system = get_test_system()
|
system = get_test_system()
|
||||||
descriptor = VerticalDescriptor.from_xml(VerticalWithModulesFactory.sample_problem_xml, system)
|
descriptor = VerticalDescriptor.from_xml(VerticalWithModulesFactory.sample_problem_xml, system)
|
||||||
@@ -532,7 +534,7 @@ class CrowdsourceHinterTest(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
mock_module = CHModuleFactory.create()
|
mock_module = CHModuleFactory.create()
|
||||||
|
|
||||||
def fake_get_hint(get):
|
def fake_get_hint(_):
|
||||||
"""
|
"""
|
||||||
Creates a rendering dictionary, with which we can test
|
Creates a rendering dictionary, with which we can test
|
||||||
the templates.
|
the templates.
|
||||||
|
|||||||
Reference in New Issue
Block a user