Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pass selectionExtension properties through

refs #8159

Change-Id: I52c211bc9d0e6e64aaa63866aed9c29cb355097c
Reviewed-on: https://gerrit.instructure.com/10117
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
  • Loading branch information...
commit 805367b4b8d4f739ebdbc1d86a71f8cb5defec41 1 parent 07c7c43
@bracken bracken authored
Showing with 63 additions and 30 deletions.
  1. +10 −13 lib/imsqti.py
  2. +53 −17 lib/imsqtiv1.py
View
23 lib/imsqti.py
@@ -334,19 +334,21 @@ def __init__ (self):
self.timeLimit=None
self.randomOrdering=None
self.selectNumber=None
- self.sourceBankRef=None
- self.pointsPerItem=None
self.withReplacement=None
self.items = []
self.outcomeWeights=None
self.references={}
self.itemSessionControl=None
+ self.selection_extensions = {}
def SetItemSessionControl(self, control):
self.itemSessionControl = control
def SetIdentifier (self,identifier):
self.identifier=identifier
+
+ def AddSelectionExtension(self, key, value):
+ self.selection_extensions[key] = value
def SetTitle (self,title):
self.title=title
@@ -388,12 +390,6 @@ def SetSelectionNumber(self, value):
"""This is how many questions from a group should be selected"""
self.selectNumber = value
- def SetSourceBankRef(self, value):
- self.sourceBankRef = value
-
- def SetPointsPerItem(self, value):
- self.pointsPerItem = value
-
def SetSequenceType(self, value):
"""Possible values: repeat, normal"""
if value.lower() == "repeat":
@@ -417,15 +413,16 @@ def WriteXML (self,f):
if self.timeLimit: f.write('\n<timeLimits maxTime="%s"/>' % self.timeLimit)
if self.randomOrdering: f.write('\n<ordering shuffle="true"/>')
if self.itemSessionControl: self.itemSessionControl.WriteXML(f)
- if self.selectNumber or self.withReplacement or self.sourceBankRef or self.pointsPerItem:
+ if self.selectNumber or self.withReplacement or len(self.selection_extensions) > 0:
f.write('\n<selection')
if self.selectNumber: f.write(' select="%s"' % self.selectNumber)
if self.withReplacement: f.write(' withReplacement="%s"' % self.withReplacement)
- if self.sourceBankRef or self.pointsPerItem:
+ if len(self.selection_extensions) > 0:
f.write('>\n')
- # This isn't valid QTI 2.*
- if self.sourceBankRef: f.write('<sourcebank_ref>%s</sourcebank_ref>' % self.sourceBankRef)
- if self.pointsPerItem: f.write('<points_per_item>%s</points_per_item>' % self.pointsPerItem)
+ f.write('\n<selectionExtension>')
+ for key, val in self.selection_extensions.items():
+ f.write('\n<' + key + '>' + val + '</' + key + '>')
+ f.write('\n</selectionExtension>')
f.write('\n</selection>')
else:
f.write(' />')
View
70 lib/imsqtiv1.py
@@ -1437,11 +1437,8 @@ def SetOrderType (self,value):
def SetSelectionNumber(self, value):
self.section.SetSelectionNumber(value)
- def SetSourceBankRef(self, value):
- self.section.SetSourceBankRef(value)
-
- def SetPointsPerItem(self, value):
- self.section.SetPointsPerItem(value)
+ def AddSelectionExtension(self, key, value):
+ self.section.AddSelectionExtension(key, value)
def SetSequenceType(self, value):
self.section.SetSequenceType(value)
@@ -1502,11 +1499,8 @@ def SetOrderType (self,value):
def SetSelectionNumber(self, value):
if self.process: self.parent.SetSelectionNumber(value)
- def SetSourceBankRef(self, value):
- if self.process: self.parent.SetSourceBankRef(value)
-
- def SetPointsPerItem(self, value):
- if self.process: self.parent.SetPointsPerItem(value)
+ def AddSelectionExtension(self, key, value):
+ if self.process: self.parent.AddSelectionExtension(key, value)
def SetSequenceType(self, value):
if self.process: self.parent.SetSequenceType(value)
@@ -1557,11 +1551,8 @@ def AddData (self,data):
def SetSelectionNumber(self, value):
self.parent.SetSelectionNumber(value)
- def SetSourceBankRef(self, value):
- self.parent.SetSourceBankRef(value)
-
- def SetPointsPerItem(self, value):
- self.parent.SetPointsPerItem(value)
+ def AddSelectionExtension(self, key, value):
+ self.parent.AddSelectionExtension(key, value)
def SetAttribute_sequence_type (self,value):
self.parent.SetSequenceType(value)
@@ -1604,7 +1595,7 @@ def AddData (self,data):
def CloseObject (self):
self.data=self.data.strip()
- if self.data: self.parent.SetSourceBankRef(self.data)
+ if self.data: self.parent.AddSelectionExtension('sourcebank_ref', self.data)
# SelectionExtension
@@ -1621,6 +1612,9 @@ def __init__(self,name,attrs,parent):
def SetPointsPerItem(self, value):
self.parent.SetPointsPerItem(value)
+ def AddSelectionExtension(self, key, value):
+ self.parent.AddSelectionExtension(key, value)
+
# PointsPerItem
# --------
@@ -1639,7 +1633,47 @@ def AddData (self,data):
def CloseObject (self):
self.data=self.data.strip()
- if self.data: self.parent.SetPointsPerItem(self.data)
+ if self.data: self.parent.AddSelectionExtension('points_per_item', self.data)
+
+
+# SourceBankContext
+# --------
+#
+class SourceBankContext(QTIObjectV1):
+ """
+ <!ELEMENT points_per_item (#PCDATA)>
+ """
+ def __init__(self,name,attrs,parent):
+ self.parent=parent
+ self.data=""
+ self.CheckLocation((SelectionExtension),"<sourcebank_context>")
+
+ def AddData (self,data):
+ self.data=self.data+data
+
+ def CloseObject (self):
+ self.data=self.data.strip()
+ if self.data: self.parent.AddSelectionExtension('sourcebank_context', self.data)
+
+
+# SourceBankIsExternal
+# --------
+#
+class SourceBankIsExternal(QTIObjectV1):
+ """
+ <!ELEMENT points_per_item (#PCDATA)>
+ """
+ def __init__(self,name,attrs,parent):
+ self.parent=parent
+ self.data=""
+ self.CheckLocation((SelectionExtension),"<sourcebank_is_external>")
+
+ def AddData (self,data):
+ self.data=self.data+data
+
+ def CloseObject (self):
+ self.data=self.data.strip()
+ if self.data: self.parent.AddSelectionExtension('sourcebank_is_external', self.data)
# OutcomesProcessing
@@ -6012,6 +6046,8 @@ def CloseObject (self):
'solution':Solution,
'solutionmaterial':SolutionMaterial,
'sourcebank_ref':SourceBankRef,
+ 'sourcebank_context':SourceBankContext,
+ 'sourcebank_is_external':SourceBankIsExternal,
'step':Unsupported,
'test_variable':Unsupported,
'unanswered':Unanswered,
Please sign in to comment.
Something went wrong with that request. Please try again.