Commit 4a2875cc by Vik Paruchuri

Document open ended child

parent f858dce7
...@@ -72,7 +72,6 @@ class OpenEndedChild(): ...@@ -72,7 +72,6 @@ class OpenEndedChild():
def __init__(self, system, location, definition, descriptor, static_data, def __init__(self, system, location, definition, descriptor, static_data,
instance_state=None, shared_state=None, **kwargs): instance_state=None, shared_state=None, **kwargs):
# Load instance state # Load instance state
if instance_state is not None: if instance_state is not None:
instance_state = json.loads(instance_state) instance_state = json.loads(instance_state)
...@@ -102,6 +101,14 @@ class OpenEndedChild(): ...@@ -102,6 +101,14 @@ class OpenEndedChild():
self.setup_response(system, location, definition, descriptor) self.setup_response(system, location, definition, descriptor)
def setup_response(self, system, location, definition, descriptor): def setup_response(self, system, location, definition, descriptor):
"""
Needs to be implemented by the inheritors of this module. Sets up additional fields used by the child modules.
@param system: Modulesystem
@param location: Module location
@param definition: XML definition
@param descriptor: Descriptor of the module
@return: None
"""
pass pass
def latest_answer(self): def latest_answer(self):
...@@ -123,6 +130,11 @@ class OpenEndedChild(): ...@@ -123,6 +130,11 @@ class OpenEndedChild():
return self.history[-1].get('post_assessment', "") return self.history[-1].get('post_assessment', "")
def new_history_entry(self, answer): def new_history_entry(self, answer):
"""
Adds a new entry to the history dictionary
@param answer: The student supplied answer
@return: None
"""
self.history.append({'answer': answer}) self.history.append({'answer': answer})
def record_latest_score(self, score): def record_latest_score(self, score):
...@@ -213,12 +225,25 @@ class OpenEndedChild(): ...@@ -213,12 +225,25 @@ class OpenEndedChild():
'error': 'The problem state got out-of-sync'} 'error': 'The problem state got out-of-sync'}
def get_html(self): def get_html(self):
"""
Needs to be implemented by inheritors. Renders the HTML that students see.
@return:
"""
pass pass
def handle_ajax(self): def handle_ajax(self):
"""
Needs to be implemented by child modules. Handles AJAX events.
@return:
"""
pass pass
def is_submission_correct(self, score): def is_submission_correct(self, score):
"""
Checks to see if a given score makes the answer correct. Very naive right now (>66% is correct)
@param score: Numeric score.
@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())
...@@ -226,6 +251,10 @@ class OpenEndedChild(): ...@@ -226,6 +251,10 @@ class OpenEndedChild():
return correct return correct
def is_last_response_correct(self): def is_last_response_correct(self):
"""
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' correctness = 'correct' if self.is_submission_correct(score) else 'incorrect'
return correctness return correctness
......
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