Commit 5125d8b0 by Vik Paruchuri

Reformat code

parent d82ac2b7
......@@ -461,7 +461,7 @@ class CombinedOpenEndedV1Module():
last_response_dict = {
'response': last_response,
'score': last_score,
'all_scores' : all_scores,
'all_scores': all_scores,
'post_assessment': last_post_assessment,
'type': task_type,
'max_score': max_score,
......@@ -750,7 +750,7 @@ class CombinedOpenEndedV1Module():
score = last_response.get('all_scores', None)
if score is not None:
#Convert none scores and weight scores properly
for z in xrange(0,len(score)):
for z in xrange(0, len(score)):
if score[z] is None:
score[z] = 0
score[z] *= float(self.weight)
......
......@@ -72,7 +72,8 @@ class OpenEndedChild(object):
try:
instance_state = json.loads(instance_state)
except:
log.error("Could not load instance state for open ended. Setting it to nothing.: {0}".format(instance_state))
log.error(
"Could not load instance state for open ended. Setting it to nothing.: {0}".format(instance_state))
else:
instance_state = {}
......@@ -81,8 +82,8 @@ class OpenEndedChild(object):
# element.
# Scores are on scale from 0 to max_score
self.child_history=instance_state.get('child_history',[])
self.child_state=instance_state.get('child_state', self.INITIAL)
self.child_history = instance_state.get('child_history', [])
self.child_state = instance_state.get('child_state', self.INITIAL)
self.child_created = instance_state.get('child_created', False)
self.child_attempts = instance_state.get('child_attempts', 0)
......@@ -166,7 +167,7 @@ class OpenEndedChild(object):
"""None if not available"""
if not self.child_history:
return None
return [self.child_history[i].get('score') for i in xrange(0,len(self.child_history))]
return [self.child_history[i].get('score') for i in xrange(0, len(self.child_history))]
def latest_post_assessment(self, system):
"""Empty string if not available"""
......
......@@ -291,7 +291,7 @@ class SelfAssessmentDescriptor():
template_dir_name = "selfassessment"
def __init__(self, system):
self.system =system
self.system = system
@classmethod
def definition_from_xml(cls, xml_object, system):
......
......@@ -323,7 +323,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
's3_interface': test_util_open_ended.S3_INTERFACE,
'open_ended_grading_interface': test_util_open_ended.OPEN_ENDED_GRADING_INTERFACE,
'skip_basic_checks': False,
'is_graded' : True,
'is_graded': True,
}
oeparam = etree.XML('''
......@@ -359,7 +359,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
combinedoe_container = CombinedOpenEndedModule(test_system,
location,
descriptor,
model_data={'data': full_definition, 'weight' : '1'})
model_data={'data': full_definition, 'weight': '1'})
def setUp(self):
......@@ -372,6 +372,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
static_data=self.static_data,
metadata=self.metadata,
instance_state=self.static_data)
def test_get_tag_name(self):
name = self.combinedoe.get_tag_name("<t>Tag</t>")
self.assertEqual(name, "t")
......@@ -406,11 +407,11 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def test_container_weight(self):
weight = self.combinedoe_container.weight
self.assertEqual(weight,1)
self.assertEqual(weight, 1)
def test_container_child_weight(self):
weight = self.combinedoe_container.child_module.weight
self.assertEqual(weight,1)
self.assertEqual(weight, 1)
def test_get_score(self):
score_dict = self.combinedoe.get_score()
......@@ -420,7 +421,7 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def test_alternate_orderings(self):
t1 = self.task_xml1
t2 = self.task_xml2
xml_to_test = [[t1], [t2], [t1,t1], [t1,t2], [t2,t2], [t2,t1], [t1,t2,t1]]
xml_to_test = [[t1], [t2], [t1, t1], [t1, t2], [t2, t2], [t2, t1], [t1, t2, t1]]
for xml in xml_to_test:
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(self.rubric), 'task_xml': xml}
descriptor = Mock(data=definition)
......@@ -451,7 +452,8 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
</rubric>
</rubric>
"""
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(rubric), 'task_xml': [self.task_xml1, self.task_xml2]}
definition = {'prompt': etree.XML(self.prompt), 'rubric': etree.XML(rubric),
'task_xml': [self.task_xml1, self.task_xml2]}
descriptor = Mock(data=definition)
combinedoe = CombinedOpenEndedV1Module(self.test_system,
self.location,
......
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