Commit 1d5f32d0 by Ned Batchelder

Give all response types an id attribute. CustomResponse had one, with a silly…

Give all response types an id attribute.  CustomResponse had one, with a silly name.  Use it for all ResponseTypes.
parent fa6bbfb9
...@@ -140,6 +140,8 @@ class LoncapaResponse(object): ...@@ -140,6 +140,8 @@ class LoncapaResponse(object):
self.context = context self.context = context
self.system = system self.system = system
self.id = xml.get('id')
for abox in inputfields: for abox in inputfields:
if abox.tag not in self.allowed_inputfields: if abox.tag not in self.allowed_inputfields:
msg = "%s: cannot have input field %s" % ( msg = "%s: cannot have input field %s" % (
...@@ -935,7 +937,6 @@ class CustomResponse(LoncapaResponse): ...@@ -935,7 +937,6 @@ class CustomResponse(LoncapaResponse):
# if <customresponse> has an "expect" (or "answer") attribute then save # if <customresponse> has an "expect" (or "answer") attribute then save
# that # that
self.expect = xml.get('expect') or xml.get('answer') self.expect = xml.get('expect') or xml.get('answer')
self.myid = xml.get('id')
log.debug('answer_ids=%s' % self.answer_ids) log.debug('answer_ids=%s' % self.answer_ids)
...@@ -981,7 +982,7 @@ class CustomResponse(LoncapaResponse): ...@@ -981,7 +982,7 @@ class CustomResponse(LoncapaResponse):
if not self.code: if not self.code:
if answer is None: if answer is None:
log.error("[courseware.capa.responsetypes.customresponse] missing" log.error("[courseware.capa.responsetypes.customresponse] missing"
" code checking script! id=%s" % self.myid) " code checking script! id=%s" % self.id)
self.code = '' self.code = ''
else: else:
answer_src = answer.get('src') answer_src = answer.get('src')
...@@ -1034,7 +1035,7 @@ class CustomResponse(LoncapaResponse): ...@@ -1034,7 +1035,7 @@ class CustomResponse(LoncapaResponse):
# note that this doesn't help the "cfn" version - only the exec version # note that this doesn't help the "cfn" version - only the exec version
self.context.update({ self.context.update({
# my ID # my ID
'response_id': self.myid, 'response_id': self.id,
# expected answer (if given as attribute) # expected answer (if given as attribute)
'expect': self.expect, 'expect': self.expect,
......
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