parameters: (self)
docstring: Add the necessary files for the SCORM protocol to the package
docstring_summary: Add the necessary files for the SCORM protocol to the package
docstring_tokens: Add the necessary files for the SCORM protocol to the package
function: def add_scorm(self):
          """
              Add the necessary files for the SCORM protocol to the package
          """
  
          self.files.update(self.collect_files([('scormfiles', '.')]))
  
          IMSprefix = '{http://www.imsglobal.org/xsd/imscp_v1p1}'
          with open(Path(self.options.path) / 'scormfiles' / 'imsmanifest.xml') as f:
              manifest = etree.fromstring(f.read())
          manifest.attrib['identifier'] = 'Numbas: %s' % self.exam.name
          manifest.find('%sorganizations/%sorganization/%stitle' % (IMSprefix, IMSprefix, IMSprefix)).text = self.exam.name
          resource_files = [str(x) for x in self.files.keys()]
  
          resource_element = manifest.find('%sresources/%sresource' % (IMSprefix, IMSprefix))
          for filename in resource_files:
              file_element = etree.Element('file')
              file_element.attrib = {'href': filename}
              resource_element.append(file_element)
  
          manifest_string = etree.tostring(manifest)
          try:
              manifest_string = manifest_string.decode('utf-8')
          except AttributeError:
              pass
  
          self.files[PurePath('.') / 'imsmanifest.xml'] = io.StringIO(manifest_string)
function_tokens: def add_scorm ( self ) : self . files . update ( self . collect_files ( [ ( 'scormfiles' , '.' ) ] ) ) IMSprefix = '{http://www.imsglobal.org/xsd/imscp_v1p1}' with open ( Path ( self . options . path ) / 'scormfiles' / 'imsmanifest.xml' ) as f : manifest = etree . fromstring ( f . read ( ) ) manifest . attrib [ 'identifier' ] = 'Numbas: %s' % self . exam . name manifest . find ( '%sorganizations/%sorganization/%stitle' % ( IMSprefix , IMSprefix , IMSprefix ) ) . text = self . exam . name resource_files = [ str ( x ) for x in self . files . keys ( ) ] resource_element = manifest . find ( '%sresources/%sresource' % ( IMSprefix , IMSprefix ) ) for filename in resource_files : file_element = etree . Element ( 'file' ) file_element . attrib = { 'href' : filename } resource_element . append ( file_element ) manifest_string = etree . tostring ( manifest ) try : manifest_string = manifest_string . decode ( 'utf-8' ) except AttributeError : pass self . files [ PurePath ( '.' ) / 'imsmanifest.xml' ] = io . StringIO ( manifest_string )