Commit 4bf9d5bf by ichuang

Merge pull request #445 from MITx/kimth/sjsu

Fix CustomResponse for 6.002x
changes affect 6.002 model of customresponse, making it slightly more robust when improperly used.
parents 0214afa7 bba568f9
...@@ -873,6 +873,7 @@ def sympy_check2(): ...@@ -873,6 +873,7 @@ def sympy_check2():
msg = '<font color="red">No answer entered!</font>' if self.xml.get('empty_answer_err') else '' msg = '<font color="red">No answer entered!</font>' if self.xml.get('empty_answer_err') else ''
return CorrectMap(idset[0], 'incorrect', msg=msg) return CorrectMap(idset[0], 'incorrect', msg=msg)
# NOTE: correct = 'unknown' could be dangerous. Inputtypes such as textline are not expecting 'unknown's
correct = ['unknown'] * len(idset) correct = ['unknown'] * len(idset)
messages = [''] * len(idset) messages = [''] * len(idset)
...@@ -898,6 +899,7 @@ def sympy_check2(): ...@@ -898,6 +899,7 @@ def sympy_check2():
if type(self.code) == str: if type(self.code) == str:
try: try:
exec self.code in self.context['global_context'], self.context exec self.code in self.context['global_context'], self.context
correct = self.context['correct']
except Exception as err: except Exception as err:
print "oops in customresponse (code) error %s" % err print "oops in customresponse (code) error %s" % err
print "context = ", self.context print "context = ", self.context
......
...@@ -38,5 +38,7 @@ ...@@ -38,5 +38,7 @@
% if msg: % if msg:
<span class="message">${msg|n}</span> <span class="message">${msg|n}</span>
% endif % endif
% if state in ['unsubmitted', 'correct', 'incorrect', 'incomplete'] or hidden:
</div> </div>
% endif
</section> </section>
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