Commit bcbf65e2 by Vik Paruchuri

Code reformat, line length fix, change text names to variables

parent 8dbbb021
......@@ -63,11 +63,11 @@ class OpenEndedChild():
DONE = 'done'
#This is used to tell students where they are at in the module
HUMAN_NAMES={
'initial' : 'Started',
'assessing' : 'Being scored',
'post_assessment' : 'Scoring finished',
'done' : 'Problem complete',
HUMAN_NAMES = {
'initial': 'Started',
'assessing': 'Being scored',
'post_assessment': 'Scoring finished',
'done': 'Problem complete',
}
def __init__(self, system, location, definition, descriptor, static_data,
......@@ -84,7 +84,7 @@ class OpenEndedChild():
# Scores are on scale from 0 to max_score
self.history = instance_state.get('history', [])
self.state = instance_state.get('state', 'initial')
self.state = instance_state.get('state', self.INITIAL)
self.created = instance_state.get('created', "False")
......@@ -171,8 +171,8 @@ class OpenEndedChild():
'state': self.state,
'max_score': self._max_score,
'attempts': self.attempts,
'created' : "False",
}
'created': "False",
}
return json.dumps(state)
def _allow_reset(self):
......@@ -244,8 +244,8 @@ class OpenEndedChild():
@param score: Numeric score.
@return: Boolean correct.
"""
correct=False
if(isinstance(score,(int, long, float, complex))):
correct = False
if(isinstance(score, (int, long, float, complex))):
score_ratio = int(score) / float(self.max_score())
correct = (score_ratio >= 0.66)
return correct
......@@ -255,7 +255,7 @@ class OpenEndedChild():
Checks to see if the last response in the module is correct.
@return: 'correct' if correct, otherwise 'incorrect'
"""
score=self.get_score()['score']
score = self.get_score()['score']
correctness = 'correct' if self.is_submission_correct(score) else 'incorrect'
return correctness
......
......@@ -40,6 +40,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
</submitmessage>
</selfassessment>
"""
def setup_response(self, system, location, definition, descriptor):
"""
Sets up the module
......@@ -76,7 +77,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
'initial_message': self.get_message_html(),
'state': self.state,
'allow_reset': self._allow_reset(),
'child_type' : 'selfassessment',
'child_type': 'selfassessment',
}
html = system.render_template('self_assessment_prompt.html', context)
......@@ -112,7 +113,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
})
return json.dumps(d, cls=ComplexEncoder)
def get_rubric_html(self,system):
def get_rubric_html(self, system):
"""
Return the appropriate version of the rubric, based on the state.
"""
......@@ -121,8 +122,8 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
# we'll render it
context = {'rubric': self.rubric,
'max_score' : self._max_score,
}
'max_score': self._max_score,
}
if self.state == self.ASSESSING:
context['read_only'] = False
......@@ -133,7 +134,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
return system.render_template('self_assessment_rubric.html', context)
def get_hint_html(self,system):
def get_hint_html(self, system):
"""
Return the appropriate version of the hint view, based on state.
"""
......@@ -201,7 +202,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
return {
'success': True,
'rubric_html': self.get_rubric_html(system)
}
}
def save_assessment(self, get, system):
"""
......@@ -228,7 +229,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
self.record_latest_score(score)
d = {'success': True,}
d = {'success': True, }
if score == self.max_score():
self.change_state(self.DONE)
......@@ -264,7 +265,6 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
'allow_reset': self._allow_reset()}
class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
"""
Module for adding self assessment questions to courses
......@@ -302,7 +302,7 @@ class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
return {'submitmessage': parse('submitmessage'),
'hintprompt': parse('hintprompt'),
}
}
def definition_to_xml(self, resource_fs):
'''Return an xml element representing this definition.'''
......
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