Permalink
Browse files

pass label through to manifest node if available

some vendors use the label attribute instead of identifier
as the unique id. This allows them to be processed correctly

refs #CNVS-1346

Change-Id: I007952a7c9a99b61056816cce1feb33ac1e72277
Reviewed-on: https://gerrit.instructure.com/15818
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
  • Loading branch information...
1 parent 39e232f commit cc682d0650ec2dff593148a77b57a7f2b7fd51f6 @bracken bracken committed Dec 4, 2012
Showing with 20 additions and 7 deletions.
  1. +6 −0 lib/imscp.py
  2. +9 −3 lib/imsqti.py
  3. +5 −4 lib/imsqtiv1.py
View
@@ -148,12 +148,16 @@ def __init__ (self):
self.instructureMD=None
self.files=[]
self.entryPoint=None
+ self.label=None
def SetIdentifier (self,identifier):
self.id=identifier
self.id = CPResource.FixIdentifier(self.id)
return self.id
+ def SetLabel (self,value):
+ self.label = value
+
@staticmethod
def FixIdentifier (id):
# Must match correct syntax
@@ -219,6 +223,8 @@ def DumpToDirectory (self,path,create_error_files=None):
def WriteManifestXML (self,f):
f.write('\n\t<resource identifier="'+self.id+'"')
+ if self.label:
+ f.write(' label="'+self.label+'"')
if self.type:
f.write(' type="'+self.type+'"')
if self.entryPoint:
View
@@ -371,8 +371,8 @@ def SetTimeLimit (self,timeLimit):
def AddSection(self, section):
self.items.append(section)
- def AddItemReference(self, reference, fName, weight=None):
- ref = AssessmentItemRef(reference, fName, weight)
+ def AddItemReference(self, reference, fName, weight=None, label=None):
+ ref = AssessmentItemRef(reference, fName, weight, label)
self.items.append(ref)
self.references[reference] = ref
@@ -433,16 +433,20 @@ def WriteXML (self,f):
f.write('\n</assessmentSection>')
class AssessmentItemRef:
- def __init__(self, iden, href, weight=None):
+ def __init__(self, iden, href, weight=None, label=None):
self.identifier=iden
self.weight=weight
self.href=href
+ self.label=label
def SetIdentifier(self, value):
self.identifier=value
def SetWeight(self, weight):
self.weight=weight
+
+ def SetLabel(self, label):
+ self.label=label
def SetHREF(self, href):
self.href = href
@@ -452,6 +456,8 @@ def WriteXML(self,f):
f.write('\n<assessmentItemRef')
f.write(' identifier="%s"' % XMLString(self.identifier))
f.write(' href="../%s"' % XMLString(self.href))
+ if self.label:
+ f.write(' label="%s"' % XMLString(self.label))
if self.weight:
f.write(">")
f.write('\n<weight identifier="%s" value="%s"/>' % (0, self.weight))
View
@@ -1497,8 +1497,8 @@ def SetSequenceType(self, value):
def SetOutcomeWeights(self, weights):
self.section.SetOutcomeWeights(weights)
- def AddItemReference(self, ref, fName, weight=None):
- self.section.AddItemReference(ref, fName, weight)
+ def AddItemReference(self, ref, fName, weight=None, label=None):
+ self.section.AddItemReference(ref, fName, weight, label)
def GetBankId(self):
if isinstance(self.parent, QTIObjectBank):
@@ -1962,7 +1962,8 @@ def SetAttribute_maxattempts (self,value):
def SetAttribute_label (self,value):
self.item.SetLabel(value)
-
+ self.resource.SetLabel(value)
+
def SetAttribute_ident (self,value):
if self.item.identifier: return
if ':' in value:
@@ -2212,7 +2213,7 @@ def AddCPFile (self,uri, prepend_path=None):
def CloseObject (self):
#Add reference to parent if it's a section
if isinstance(self.parent,QTISection):
- self.parent.AddItemReference(self.resource.id, self.fName)
+ self.parent.AddItemReference(self.resource.id, self.fName, None, self.resource.label)
# Check devvar min/max constraints
rp=self.item.GetResponseProcessing()

0 comments on commit cc682d0

Please sign in to comment.