Permalink
Browse files

flag text question responses as text

Previous to this text responses would be converted in the
same way as html responses, so a QTI importing tool wouldn't
be able to tell the difference. This now flags them as 'text'

refs #8771

Change-Id: Id217e6f5da5c80728e187ad7fc5bcb3840bc2492
Reviewed-on: https://gerrit.instructure.com/11202
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
  • Loading branch information...
1 parent e73e8fb commit f268a9eb4d24efbda364c954bf4dccd3ecbddf22 @bracken bracken committed Jun 1, 2012
Showing with 16 additions and 8 deletions.
  1. +4 −0 lib/imsqti.py
  2. +12 −8 lib/imsqtiv1.py
View
4 lib/imsqti.py
@@ -1155,6 +1155,10 @@ def WriteXML (self,f):
def ExtractText (self):
return self.text
+class just_text(xhtml_text):
+ def __init__(self, text=""):
+ xhtml_text.__init__(self, text)
+
class Interaction:
def __init__ (self):
self.response=None
View
20 lib/imsqtiv1.py
@@ -3468,30 +3468,36 @@ def AppendToParent(self, element):
else:
self.parent.AppendElement(element)
- def AppendHTMLContainer (self,content):
+ def AppendHTMLContainer (self,content, is_text=False):
container=xhtml_div()
container.escaped = True
- container.SetClass('html')
+ if is_text:
+ container.SetClass('text')
+ else:
+ container.SetClass('html')
container.AppendElement(xhtml_text(content))
self.AppendToParent(container)
def CloseObject (self):
buffer=None
+ is_text=False
for child in self.children:
if isinstance(child,HTML) and not child.escaped:
if not buffer:
buffer=StringIO.StringIO()
if isinstance(child,xhtml_text):
buffer.write(child.ExtractText())
+ if isinstance(child, just_text):
+ is_text = True
else:
child.WriteXML(buffer)
else:
if buffer:
- self.AppendHTMLContainer(buffer.getvalue())
+ self.AppendHTMLContainer(buffer.getvalue(), is_text)
buffer=None
self.AppendToParent(child)
if buffer:
- self.AppendHTMLContainer(buffer.getvalue())
+ self.AppendHTMLContainer(buffer.getvalue(), is_text)
if self.div_container:
self.parent.AppendElement(self.div_container)
@@ -3915,7 +3921,7 @@ class MatText(MatThing, handler.ContentHandler, handler.ErrorHandler):
def __init__(self,name,attrs,parent):
MatThing.__init__(self,name,attrs,parent)
if not self.type:
- self.type="text/plain"
+ self.type="text/html"
self.htmlStack=[]
self.htmlElements=[]
self.htmlElement=None
@@ -3959,9 +3965,7 @@ def CloseObject (self):
def MakeText (self):
if self.type=='text/plain':
-# if self.space.lower()!='preserve':
-# self.data=string.join(string.split(self.data.strip()),' ')
- element=xhtml_text()
+ element=just_text()
element.SetText(self.data)
if self.label or self.language:
# We need to wrap it in a span

0 comments on commit f268a9e

Please sign in to comment.