Commit 0f5e8c5f by Will Daly

pep8 fixes

parent 5bc44e50
...@@ -2085,7 +2085,7 @@ class AnnotationResponse(LoncapaResponse): ...@@ -2085,7 +2085,7 @@ class AnnotationResponse(LoncapaResponse):
option_scoring = dict([(option['id'], { option_scoring = dict([(option['id'], {
'correctness': choices.get(option['choice']), 'correctness': choices.get(option['choice']),
'points': scoring.get(option['choice']) 'points': scoring.get(option['choice'])
}) for option in self._find_options(inputfield) ]) }) for option in self._find_options(inputfield)])
scoring_map[inputfield.get('id')] = option_scoring scoring_map[inputfield.get('id')] = option_scoring
......
...@@ -740,7 +740,7 @@ class CapaModule(CapaFields, XModule): ...@@ -740,7 +740,7 @@ class CapaModule(CapaFields, XModule):
else: else:
msg = "Error: %s" % str(inst.message) msg = "Error: %s" % str(inst.message)
return {'success': msg } return {'success': msg}
except Exception, err: except Exception, err:
if self.system.DEBUG: if self.system.DEBUG:
...@@ -792,7 +792,7 @@ class CapaModule(CapaFields, XModule): ...@@ -792,7 +792,7 @@ class CapaModule(CapaFields, XModule):
event_info['answers'] = answers event_info['answers'] = answers
# Too late. Cannot submit # Too late. Cannot submit
if self.closed() and not self.max_attempts ==0: if self.closed() and not self.max_attempts == 0:
event_info['failure'] = 'closed' event_info['failure'] = 'closed'
self.system.track_function('save_problem_fail', event_info) self.system.track_function('save_problem_fail', event_info)
return {'success': False, return {'success': False,
...@@ -812,7 +812,7 @@ class CapaModule(CapaFields, XModule): ...@@ -812,7 +812,7 @@ class CapaModule(CapaFields, XModule):
self.system.track_function('save_problem_success', event_info) self.system.track_function('save_problem_success', event_info)
msg = "Your answers have been saved" msg = "Your answers have been saved"
if not self.max_attempts ==0: if not self.max_attempts == 0:
msg += " but not graded. Hit 'Check' to grade them." msg += " but not graded. Hit 'Check' to grade them."
return {'success': True, return {'success': True,
'msg': msg} 'msg': msg}
......
...@@ -407,7 +407,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -407,7 +407,7 @@ class CapaModuleTest(unittest.TestCase):
mock_html.return_value = "Test HTML" mock_html.return_value = "Test HTML"
# Check the problem # Check the problem
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect that the problem is marked correct # Expect that the problem is marked correct
...@@ -428,7 +428,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -428,7 +428,7 @@ class CapaModuleTest(unittest.TestCase):
mock_is_correct.return_value = False mock_is_correct.return_value = False
# Check the problem # Check the problem
get_request_dict = { CapaFactory.input_key(): '0'} get_request_dict = {CapaFactory.input_key(): '0'}
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect that the problem is marked correct # Expect that the problem is marked correct
...@@ -446,7 +446,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -446,7 +446,7 @@ class CapaModuleTest(unittest.TestCase):
with patch('xmodule.capa_module.CapaModule.closed') as mock_closed: with patch('xmodule.capa_module.CapaModule.closed') as mock_closed:
mock_closed.return_value = True mock_closed.return_value = True
with self.assertRaises(xmodule.exceptions.NotFoundError): with self.assertRaises(xmodule.exceptions.NotFoundError):
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
module.check_problem(get_request_dict) module.check_problem(get_request_dict)
# Expect that number of attempts NOT incremented # Expect that number of attempts NOT incremented
...@@ -492,7 +492,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -492,7 +492,7 @@ class CapaModuleTest(unittest.TestCase):
mock_is_queued.return_value = True mock_is_queued.return_value = True
mock_get_queuetime.return_value = datetime.datetime.now() mock_get_queuetime.return_value = datetime.datetime.now()
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
...@@ -512,7 +512,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -512,7 +512,7 @@ class CapaModuleTest(unittest.TestCase):
with patch('capa.capa_problem.LoncapaProblem.grade_answers') as mock_grade: with patch('capa.capa_problem.LoncapaProblem.grade_answers') as mock_grade:
mock_grade.side_effect = capa.responsetypes.StudentInputError('test error') mock_grade.side_effect = capa.responsetypes.StudentInputError('test error')
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
...@@ -532,7 +532,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -532,7 +532,7 @@ class CapaModuleTest(unittest.TestCase):
with patch('capa.capa_problem.LoncapaProblem.grade_answers') as mock_grade: with patch('capa.capa_problem.LoncapaProblem.grade_answers') as mock_grade:
mock_grade.side_effect = capa.responsetypes.StudentInputError('test error') mock_grade.side_effect = capa.responsetypes.StudentInputError('test error')
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.check_problem(get_request_dict) result = module.check_problem(get_request_dict)
# Expect an AJAX alert message in 'success' # Expect an AJAX alert message in 'success'
...@@ -595,11 +595,11 @@ class CapaModuleTest(unittest.TestCase): ...@@ -595,11 +595,11 @@ class CapaModuleTest(unittest.TestCase):
module = CapaFactory.create(done=False) module = CapaFactory.create(done=False)
# Save the problem # Save the problem
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.save_problem(get_request_dict) result = module.save_problem(get_request_dict)
# Expect that answers are saved to the problem # Expect that answers are saved to the problem
expected_answers = { CapaFactory.answer_key(): '3.14'} expected_answers = {CapaFactory.answer_key(): '3.14'}
self.assertEqual(module.lcp.student_answers, expected_answers) self.assertEqual(module.lcp.student_answers, expected_answers)
# Expect that the result is success # Expect that the result is success
...@@ -614,7 +614,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -614,7 +614,7 @@ class CapaModuleTest(unittest.TestCase):
mock_closed.return_value = True mock_closed.return_value = True
# Try to save the problem # Try to save the problem
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.save_problem(get_request_dict) result = module.save_problem(get_request_dict)
# Expect that the result is failure # Expect that the result is failure
...@@ -625,7 +625,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -625,7 +625,7 @@ class CapaModuleTest(unittest.TestCase):
module = CapaFactory.create(rerandomize='always', done=True) module = CapaFactory.create(rerandomize='always', done=True)
# Try to save # Try to save
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.save_problem(get_request_dict) result = module.save_problem(get_request_dict)
# Expect that we cannot save # Expect that we cannot save
...@@ -636,7 +636,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -636,7 +636,7 @@ class CapaModuleTest(unittest.TestCase):
module = CapaFactory.create(rerandomize='never', done=True) module = CapaFactory.create(rerandomize='never', done=True)
# Try to save # Try to save
get_request_dict = { CapaFactory.input_key(): '3.14'} get_request_dict = {CapaFactory.input_key(): '3.14'}
result = module.save_problem(get_request_dict) result = module.save_problem(get_request_dict)
# Expect that we succeed # Expect that we succeed
...@@ -648,7 +648,7 @@ class CapaModuleTest(unittest.TestCase): ...@@ -648,7 +648,7 @@ class CapaModuleTest(unittest.TestCase):
# Just in case, we also check what happens if we have # Just in case, we also check what happens if we have
# more attempts than allowed. # more attempts than allowed.
attempts = random.randint(1, 10) attempts = random.randint(1, 10)
module = CapaFactory.create(attempts=attempts -1, max_attempts=attempts) module = CapaFactory.create(attempts=attempts - 1, max_attempts=attempts)
self.assertEqual(module.check_button_name(), "Final Check") self.assertEqual(module.check_button_name(), "Final Check")
module = CapaFactory.create(attempts=attempts, max_attempts=attempts) module = CapaFactory.create(attempts=attempts, max_attempts=attempts)
...@@ -658,14 +658,14 @@ class CapaModuleTest(unittest.TestCase): ...@@ -658,14 +658,14 @@ class CapaModuleTest(unittest.TestCase):
self.assertEqual(module.check_button_name(), "Final Check") self.assertEqual(module.check_button_name(), "Final Check")
# Otherwise, button name is "Check" # Otherwise, button name is "Check"
module = CapaFactory.create(attempts=attempts -2, max_attempts=attempts) module = CapaFactory.create(attempts=attempts - 2, max_attempts=attempts)
self.assertEqual(module.check_button_name(), "Check") self.assertEqual(module.check_button_name(), "Check")
module = CapaFactory.create(attempts=attempts -3, max_attempts=attempts) module = CapaFactory.create(attempts=attempts - 3, max_attempts=attempts)
self.assertEqual(module.check_button_name(), "Check") self.assertEqual(module.check_button_name(), "Check")
# If no limit on attempts, then always show "Check" # If no limit on attempts, then always show "Check"
module = CapaFactory.create(attempts=attempts -3) module = CapaFactory.create(attempts=attempts - 3)
self.assertEqual(module.check_button_name(), "Check") self.assertEqual(module.check_button_name(), "Check")
module = CapaFactory.create(attempts=0) module = CapaFactory.create(attempts=0)
......
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