Commit ef27788c by Vik Paruchuri

Initial display for open ended problem

parent a5eec6d6
......@@ -573,25 +573,26 @@ class OpenEndedModule():
Implement special logic: handle queueing state, and default input.
"""
# if no student input yet, then use the default input given by the problem
if not self.value:
self.value = self.xml.text
latest_answer=self.latest_answer()
if latest_answer is None:
value = self.initial_display
# Check if problem has been queued
self.queue_len = 0
# Flag indicating that the problem has been queued, 'msg' is length of queue
if self.status == 'incomplete':
self.status = 'queued'
self.queue_len = self.msg
self.msg = self.submitted_msg
if self.state == self.ASSESSING:
#self.queue_len = self.msg
#self.msg = self.submitted_msg
pass
context={'rows' : 30,
'cols' : 80,
'hidden' : '',
'id' : 'open_ended',
'msg' : self.msg,
'status' : self.status,
'msg' : "This is a message",
'state' : self.state,
'queue_len' : self.queue_len,
'value' : self.value,
'value' : value,
}
html=system.render_template("open_ended.html", context)
......@@ -624,6 +625,37 @@ class OpenEndedModule():
}
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):
"""
......
<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}"
% if hidden:
style="display:none;"
......@@ -6,13 +6,13 @@
>${value|h}</textarea>
<div class="grader-status">
% if status == 'unsubmitted':
% if state == 'initial':
<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>
% elif status == 'incorrect':
% elif state == 'incorrect':
<span class="incorrect" id="status_${id}">Incorrect</span>
% elif status == 'queued':
% elif state == 'assessing':
<span class="grading" id="status_${id}">Submitted for grading</span>
% 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