Commit ef27788c by Vik Paruchuri

Initial display for open ended problem

parent a5eec6d6
...@@ -573,25 +573,26 @@ class OpenEndedModule(): ...@@ -573,25 +573,26 @@ class OpenEndedModule():
Implement special logic: handle queueing state, and default input. Implement special logic: handle queueing state, and default input.
""" """
# if no student input yet, then use the default input given by the problem # if no student input yet, then use the default input given by the problem
if not self.value: latest_answer=self.latest_answer()
self.value = self.xml.text if latest_answer is None:
value = self.initial_display
# Check if problem has been queued # Check if problem has been queued
self.queue_len = 0 self.queue_len = 0
# Flag indicating that the problem has been queued, 'msg' is length of queue # Flag indicating that the problem has been queued, 'msg' is length of queue
if self.status == 'incomplete': if self.state == self.ASSESSING:
self.status = 'queued' #self.queue_len = self.msg
self.queue_len = self.msg #self.msg = self.submitted_msg
self.msg = self.submitted_msg pass
context={'rows' : 30, context={'rows' : 30,
'cols' : 80, 'cols' : 80,
'hidden' : '', 'hidden' : '',
'id' : 'open_ended', 'id' : 'open_ended',
'msg' : self.msg, 'msg' : "This is a message",
'status' : self.status, 'state' : self.state,
'queue_len' : self.queue_len, 'queue_len' : self.queue_len,
'value' : self.value, 'value' : value,
} }
html=system.render_template("open_ended.html", context) html=system.render_template("open_ended.html", context)
...@@ -624,6 +625,37 @@ class OpenEndedModule(): ...@@ -624,6 +625,37 @@ class OpenEndedModule():
} }
return json.dumps(state) return json.dumps(state)
def latest_answer(self):
"""None if not available"""
if not self.history:
return None
return self.history[-1].get('answer')
def latest_score(self):
"""None if not available"""
if not self.history:
return None
return self.history[-1].get('score')
def latest_hint(self):
"""None if not available"""
if not self.history:
return None
return self.history[-1].get('hint')
def new_history_entry(self, answer):
self.history.append({'answer': answer})
def record_latest_score(self, score):
"""Assumes that state is right, so we're adding a score to the latest
history element"""
self.history[-1]['score'] = score
def record_latest_hint(self, hint):
"""Assumes that state is right, so we're adding a score to the latest
history element"""
self.history[-1]['hint'] = hint
class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor): class OpenEndedDescriptor(XmlDescriptor, EditingDescriptor):
""" """
......
<section id="openended_${id}" class="openended"> <section id="openended_${id}" class="openended" data-state="${state}">
<textarea rows="${rows}" cols="${cols}" name="input_${id}" class="short-form-response" id="input_${id}" <textarea rows="${rows}" cols="${cols}" name="input_${id}" class="short-form-response" id="input_${id}"
% if hidden: % if hidden:
style="display:none;" style="display:none;"
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
>${value|h}</textarea> >${value|h}</textarea>
<div class="grader-status"> <div class="grader-status">
% if status == 'unsubmitted': % if state == 'initial':
<span class="unanswered" style="display:inline-block;" id="status_${id}">Unanswered</span> <span class="unanswered" style="display:inline-block;" id="status_${id}">Unanswered</span>
% elif status == 'correct': % elif state == 'done':
<span class="correct" id="status_${id}">Correct</span> <span class="correct" id="status_${id}">Correct</span>
% elif status == 'incorrect': % elif state == 'incorrect':
<span class="incorrect" id="status_${id}">Incorrect</span> <span class="incorrect" id="status_${id}">Incorrect</span>
% elif status == 'queued': % elif state == 'assessing':
<span class="grading" id="status_${id}">Submitted for grading</span> <span class="grading" id="status_${id}">Submitted for grading</span>
% endif % endif
......
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