Commit bcbf65e2 by Vik Paruchuri

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

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