Beispiel #1
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId = "ITEM-" + unicode(self.idGenerator.generate())
        resId = "RES-" + unicode(self.idGenerator.generate())
        ext = 'html'
        if G.application.config.cutFileName == "1":
            ext = 'htm'

        filename = page.name + '.' + ext

        self.itemStr += '<item identifier="' + itemId + '" '
        if self.scormType != "commoncartridge":
            self.itemStr += 'isvisible="true" '
        self.itemStr += 'identifierref="' + resId + '">\n'
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        ## SCORM 12 specific metadata: Mastery Score is an ADL extension to the IMS Content Packaging Information Model
        ## Added for FR [#2501] Add masteryscore to manifest in evaluable nodes
        if self.scormType == "scorm1.2" and common.hasQuizTest(page.node):
            self.itemStr += "    <adlcp:masteryscore>%s</adlcp:masteryscore>\n" % common.getQuizTestPassRate(
                page.node)

        ## RESOURCES

        self.resStr += "  <resource identifier=\"" + resId + "\" "
        self.resStr += "type=\"webcontent\" "

        # FIXME force dependency on popup_bg.gif on every page
        # because it isn't a "resource" so we can't tell which
        # pages will use it from content.css
        if self.scormType == "commoncartridge":
            fileStr = ""
            self.resStr += """href="%s">
    <file href="%s"/>
    <file href="base.css"/>
    <file href="popup_bg.gif"/>
    <file href="exe_jquery.js"/>
    <file href="common_i18n.js"/>
    <file href="common.js"/>\n""" % (filename, filename)
            my_style = G.application.config.styleStore.getStyle(
                page.node.package.style)
            for x in my_style.get_style_dir().files('*.*'):
                fileStr += """    <file href="%s"/>\n""" % x.basename()
                self.dependencies[x.basename()] = True
            # CC export require content.* any place inside the manifest:
            if page.node.package.exportSource and page.depth == 1:
                self.resStr += '    <file href="content.xsd"/>\n'
                self.resStr += '    <file href="content.data"/>\n'
                self.resStr += '    <file href="contentv3.xml"/>\n'
            if page.node.package.backgroundImg:
                self.resStr += '\n    <file href="%s"/>' % \
                        page.node.package.backgroundImg.basename()
            self.dependencies["base.css"] = True
            self.dependencies["content.css"] = True
            self.dependencies["popup_bg.gif"] = True
        else:
            if self.scormType == "scorm2004":
                self.resStr += "adlcp:scormType=\"sco\" "
                self.resStr += "href=\"" + filename + "\"> \n"
                self.resStr += "    <file href=\"" + filename + "\"/> \n"
                fileStr = ""
            if self.scormType == "scorm1.2":
                self.resStr += "adlcp:scormtype=\"sco\" "
                self.resStr += "href=\"" + filename + "\"> \n"
                self.resStr += "    <file href=\"" + filename + "\"/> \n"
                fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()

        if common.nodeHasMediaelement(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'mediaelement').files()
            ]
            if dT != "HTML5":
                self.scriptsDir = self.config.webDir / "scripts"
                jsFile = (self.scriptsDir / 'exe_html5.js')
                jsFile.copyfile(self.outputDir / 'exe_html5.js')

        if common.nodeHasTooltips(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_tooltips').files()
            ]

        if common.hasGalleryIdevice(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_lightbox').files()
            ]

        if common.hasFX(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_effects').files()
            ]

        if common.hasSH(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_highlighter').files()
            ]

        if common.hasGames(page.node):
            resources = resources + [
                f.basename() for f in (self.config.webDir / "scripts" /
                                       'exe_games').files()
            ]

        if common.hasABCMusic(page.node):
            resources = resources + [
                f.basename()
                for f in (self.config.webDir / "scripts" / 'tinymce_4' / 'js' /
                          'tinymce' / 'plugins' / 'abcmusic' /
                          'export').files()
            ]

        for resource in resources:
            fileStr += "    <file href=\"" + escape(resource) + "\"/>\n"
            self.dependencies[resource] = True

        if common.hasElpLink(page.node):
            fileStr += "    <file href=\"" + page.node.package.name + ".elp\"/>\n"

        self.resStr += fileStr

        self.resStr += common.getJavascriptIdevicesResources(page,
                                                             xmlOutput=True)

        # adding the dependency with the common files collected:
        if self.scormType != "commoncartridge":
            self.resStr += """    <dependency identifierref="COMMON_FILES"/>"""

        # and no more:
        self.resStr += '\n'
        self.resStr += "  </resource>\n"
Beispiel #2
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        # If ISO9660 compatible mode is active, we want '.htm' as the extension
        ext = 'html'
        if G.application.config.cutFileName == '1':
            ext = 'htm'

        filename = page.name + '.' + ext


        self.itemStr += "<item identifier=\""+itemId+"\" isvisible=\"true\" "
        self.itemStr += "identifierref=\""+resId+"\">\n"
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        self.resStr += "<resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        self.resStr += "href=\""+filename+"\"> \n"
        self.resStr += """\
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>""" % filename
        self.resStr += "\n"
        fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]
        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]
        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]
        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]
        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]
        if common.hasABCMusic(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'tinymce_4'/'js'/'tinymce'/'plugins'/'abcmusic'/'export').files()]
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                self.resStr += '    <file href="exe_jquery.js"/>\n'
        else:
            self.resStr += '    <file href="exe_jquery.js"/>\n'

        for resource in resources:
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"

        if common.hasElpLink(page.node):
            fileStr += "    <file href=\""+page.node.package.name+".elp\"/>\n"

        # Get all JS iDevices resources
        fileStr += common.getJavascriptIdevicesResources(page, xmlOutput = True)

        self.resStr += fileStr
        self.resStr += "</resource>\n"
Beispiel #3
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        # If ISO9660 compatible mode is active, we want '.htm' as the extension
        ext = 'html'
        if G.application.config.cutFileName == '1':
            ext = 'htm'

        filename = page.name + '.' + ext


        self.itemStr += "<item identifier=\""+itemId+"\" isvisible=\"true\" "
        self.itemStr += "identifierref=\""+resId+"\">\n"
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        self.resStr += "<resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        self.resStr += "href=\""+filename+"\"> \n"
        self.resStr += """\
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>""" % filename
        self.resStr += "\n"
        fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]
        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]
        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]
        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]
        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]
        if common.hasABCMusic(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'tinymce_4'/'js'/'tinymce'/'plugins'/'abcmusic'/'export').files()]
        if my_style.hasValidConfig():
            if my_style.get_jquery() == True:
                self.resStr += '    <file href="exe_jquery.js"/>\n'
        else:
            self.resStr += '    <file href="exe_jquery.js"/>\n'

        for resource in resources:
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"

        if common.hasElpLink(page.node):
            fileStr += "    <file href=\""+page.node.package.name+".elp\"/>\n"

        # Get all JS iDevices resources
        fileStr += common.getJavascriptIdevicesResources(page, xmlOutput = True)

        self.resStr += fileStr
        self.resStr += "</resource>\n"
Beispiel #4
0
    def genItemResStr(self, page):
        """
        Returning xml string for items and resources
        """
        itemId   = "ITEM-"+unicode(self.idGenerator.generate())
        resId    = "RES-"+unicode(self.idGenerator.generate())
        ext = 'html'
        if G.application.config.cutFileName == "1":
                ext = 'htm'

        filename = page.name + '.' + ext


        self.itemStr += '<item identifier="'+itemId+'" '
        if self.scormType != "commoncartridge":
            self.itemStr += 'isvisible="true" '
        self.itemStr += 'identifierref="'+resId+'">\n'
        self.itemStr += "    <title>"
        self.itemStr += escape(page.node.titleShort)
        self.itemStr += "</title>\n"

        ## SCORM 12 specific metadata: Mastery Score is an ADL extension to the IMS Content Packaging Information Model
        ## Added for FR [#2501] Add masteryscore to manifest in evaluable nodes
        if self.scormType == "scorm1.2" and common.hasQuizTest(page.node):
            self.itemStr += "    <adlcp:masteryscore>%s</adlcp:masteryscore>\n" % common.getQuizTestPassRate(page.node)

        ## RESOURCES

        self.resStr += "  <resource identifier=\""+resId+"\" "
        self.resStr += "type=\"webcontent\" "

        # FIXME force dependency on popup_bg.gif on every page
        # because it isn't a "resource" so we can't tell which
        # pages will use it from content.css
        if self.scormType == "commoncartridge":
            fileStr = ""
            self.resStr += """href="%s">
    <file href="%s"/>
    <file href="base.css"/>
    <file href="content.css"/>
    <file href="popup_bg.gif"/>
    <file href="exe_jquery.js"/>
    <file href="common_i18n.js"/>
    <file href="common.js"/>\n""" % (filename, filename)
            # CC export require content.* any place inside the manifest:
            if page.node.package.exportSource and page.depth == 1:
                self.resStr += '    <file href="content.xsd"/>\n'
                self.resStr += '    <file href="content.data"/>\n'
                self.resStr += '    <file href="contentv3.xml"/>\n'
            if page.node.package.backgroundImg:
                self.resStr += '\n    <file href="%s"/>' % \
                        page.node.package.backgroundImg.basename()
            self.dependencies["base.css"] = True
            self.dependencies["content.css"] = True
            self.dependencies["popup_bg.gif"] = True
        else:
            if self.scormType == "scorm2004":
                self.resStr += "adlcp:scormType=\"sco\" "
                self.resStr += "href=\""+filename+"\"> \n"
                self.resStr += "    <file href=\""+filename+"\"/> \n"
                fileStr = ""
            if self.scormType == "scorm1.2":
                self.resStr += "adlcp:scormtype=\"sco\" "
                self.resStr += "href=\""+filename+"\"> \n"
                self.resStr += "    <file href=\""+filename+"\"/> \n"
                fileStr = ""

        dT = common.getExportDocType()
        if dT == "HTML5" or common.nodeHasMediaelement(page.node):
            self.resStr += '    <file href="exe_html5.js"/>\n'

        resources = page.node.getResources()

        if common.nodeHasMediaelement(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'mediaelement').files()]
            if dT != "HTML5":
                self.scriptsDir = self.config.webDir/"scripts"
                jsFile = (self.scriptsDir/'exe_html5.js')
                jsFile.copyfile(self.outputDir/'exe_html5.js')

        if common.nodeHasTooltips(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_tooltips').files()]

        if common.hasGalleryIdevice(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_lightbox').files()]

        if common.hasFX(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_effects').files()]

        if common.hasSH(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_highlighter').files()]

        if common.hasGames(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'exe_games').files()]

        if common.hasABCMusic(page.node):
            resources = resources + [f.basename() for f in (self.config.webDir/"scripts"/'tinymce_4'/'js'/'tinymce'/'plugins'/'abcmusic'/'export').files()]

        for resource in resources:
            fileStr += "    <file href=\""+escape(resource)+"\"/>\n"
            self.dependencies[resource] = True

        if common.hasElpLink(page.node):
            fileStr += "    <file href=\""+page.node.package.name+".elp\"/>\n"

        self.resStr += fileStr

        self.resStr += common.getJavascriptIdevicesResources(page, xmlOutput = True)

        # adding the dependency with the common files collected:
        if self.scormType != "commoncartridge":
            self.resStr += """    <dependency identifierref="COMMON_FILES"/>"""

        # and no more:
        self.resStr += '\n'
        self.resStr += "  </resource>\n"