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"
def genItemResStr(self, page): """ Returning xml string for items and resources """ itemId = "ITEM-"+unicode(self.idGenerator.generate()) resId = "RES-"+unicode(self.idGenerator.generate()) filename = page.name+".html" self.itemStr += '<item identifier="'+itemId+'" ' if self.scormType != "commoncartridge": self.itemStr += 'isvisible="true" ' self.itemStr += 'identifierref="'+resId+'">\n' self.itemStr += " <title>" if self.scormType == "scorm2004" and page.node.children: self.itemStr += escape('<-') else: 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.js"/>""" % (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()] for resource in resources: fileStr += " <file href=\""+escape(resource)+"\"/>\n" self.dependencies[resource] = True self.resStr += fileStr # 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"
def render(self): """ Returns an XHTML string rendering this page. """ dT = common.getExportDocType() lb = "\n" #Line breaks sectionTag = "div" articleTag = "div" headerTag = "div" if dT == "HTML5": sectionTag = "section" articleTag = "article" headerTag = "header" html = common.docType() lenguaje = G.application.config.locale style = G.application.config.styleStore.getStyle(self.node.package.style) if self.node.package.dublinCore.language!="": lenguaje = self.node.package.dublinCore.language html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb html += u"<head>"+lb html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb html += u"<title>" if self.node.id=='0': if self.node.package.title!='': html += escape(self.node.package.title) else: html += escape(self.node.titleLong) else: if self.node.package.title!='': html += escape(self.node.titleLong)+" | "+escape(self.node.package.title) else: html += escape(self.node.titleLong) html += u" </title>"+lb if dT != "HTML5" and self.node.package.dublinCore.language!="": html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb if self.node.package.author!="": html += '<meta name="author" content="'+self.node.package.author+'" />'+lb html += common.getLicenseMetadata(self.node.package.license) html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb if self.node.id=='0': if self.node.package.description!="": desc = self.node.package.description desc = desc.replace('"', '"') html += '<meta name="description" content="'+desc+'" />'+lb html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb if common.hasWikipediaIdevice(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb if common.hasGalleryIdevice(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb if common.hasFX(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />"+lb if common.hasSH(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_highlighter.css\" />"+lb if common.hasGames(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />"+lb if common.hasABCMusic(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_abcmusic.css\" />"+lb html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb if dT == "HTML5" or common.nodeHasMediaelement(self.node): html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb # jQuery if style.hasValidConfig: if style.get_jquery() == True: html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb else: html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb else: html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb if common.hasGalleryIdevice(self.node): html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb if common.hasFX(self.node): html += u'<script type="text/javascript" src="exe_effects.js"></script>'+lb if common.hasSH(self.node): html += u'<script type="text/javascript" src="exe_highlighter.js"></script>'+lb html += common.getJavaScriptStrings()+lb if common.hasGames(self.node): # The games require additional strings html += common.getGamesJavaScriptStrings() + lb html += u'<script type="text/javascript" src="exe_games.js"></script>'+lb if common.hasABCMusic(self.node): html += u'<script type="text/javascript" src="exe_abcmusic.js"></script>'+lb html += u'<script type="text/javascript" src="common.js"></script>'+lb if common.hasMagnifier(self.node): html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb if self.scormType == 'commoncartridge': if style.hasValidConfig: html += style.get_extra_head() html += u"</head>"+lb html += u"<body id=\""+self.node.id+"\" class=\"exe-scorm\" " else: html += u"<script type=\"text/javascript\" src=\"SCORM_API_wrapper.js\"></script>"+lb html += u"<script type=\"text/javascript\" src=\"SCOFunctions.js\"></script>"+lb if style.hasValidConfig: html += style.get_extra_head() html += u"</head>"+lb html += u'<body id="exe-node-'+self.node.id+'" class=\"exe-scorm\" ' if common.hasQuizTest(self.node): html += u'onunload="unloadPage(true)">' else: html += u'onunload="unloadPage()">' html += u'<script type="text/javascript">document.body.className+=" js";jQuery(function(){loadPage()})</script>'+lb html += u"<div id=\"outer\">"+lb html += u"<"+sectionTag+" id=\"main\">"+lb html += u"<"+headerTag+" id=\"nodeDecoration\">" html += u"<div id=\"headerContent\">" html += u"<h1 id=\"nodeTitle\">" html += escape(self.node.titleLong) html += u'</h1>' html += u'</div>' html += u'</'+headerTag+'>'+lb self.node.exportType = 'scorm' for idevice in self.node.idevices: if idevice.klass != 'NotaIdevice': e=" em_iDevice" if unicode(idevice.emphasis)=='0': e="" html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb) block = g_blockFactory.createBlock(None, idevice) if not block: log.critical("Unable to render iDevice.") raise Error("Unable to render iDevice.") if hasattr(idevice, "isQuiz"): html += block.renderJavascriptForScorm() html += self.processInternalLinks( block.renderView(self.node.package.style)) html += u'</'+articleTag+'>'+lb # iDevice div html += u"</"+sectionTag+">"+lb # /#main themeHasXML = common.themeHasConfigXML(self.node.package.style) if themeHasXML: #if style.hasValidConfig: html += self.renderLicense() html += self.renderFooter() html += u"</div>"+lb # /#outer if self.node.package.scolinks: html += u'<'+sectionTag+' class="previousnext">'+lb html += u'<a class="previouslink" ' html += u'href="javascript:goBack();">%s</a> | <a class="nextlink" ' % c_('Previous') html += u'href="javascript:goForward();">%s</a>' % c_('Next') html += u'</'+sectionTag+'>'+lb if not themeHasXML: #if not style.hasValidConfig: html += self.renderLicense() html += self.renderFooter() else: html += style.get_extra_body() html += u'</body></html>' html = html.encode('utf8') # JR: Eliminamos los atributos de las ecuaciones aux = re.compile("exe_math_latex=\"[^\"]*\"") html = aux.sub("", html) aux = re.compile("exe_math_size=\"[^\"]*\"") html = aux.sub("", html) #JR: Cambio el & en los enlaces del glosario html = html.replace("&concept", "&concept") # Remove "resources/" from data="resources/ and the url param html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"") html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"") html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"") html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"") return html
def render(self): """ Returns an XHTML string rendering this page. """ dT = common.getExportDocType() lb = "\n" #Line breaks sectionTag = "div" articleTag = "div" headerTag = "div" if dT == "HTML5": sectionTag = "section" articleTag = "article" headerTag = "header" html = common.docType() lenguaje = G.application.config.locale style = G.application.config.styleStore.getStyle(self.node.package.style) if self.node.package.dublinCore.language!="": lenguaje = self.node.package.dublinCore.language html += u"<html lang=\"" + lenguaje + "\" xml:lang=\"" + lenguaje + "\" xmlns=\"http://www.w3.org/1999/xhtml\">"+lb html += u"<head>"+lb html += u"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"+lb html += u"<title>" if self.node.id=='0': if self.node.package.title!='': html += escape(self.node.package.title) else: html += escape(self.node.titleLong) else: if self.node.package.title!='': html += escape(self.node.titleLong)+" | "+escape(self.node.package.title) else: html += escape(self.node.titleLong) html += u" </title>"+lb if dT != "HTML5" and self.node.package.dublinCore.language!="": html += '<meta http-equiv="content-language" content="'+lenguaje+'" />'+lb if self.node.package.author!="": html += '<meta name="author" content="'+self.node.package.author+'" />'+lb html += common.getLicenseMetadata(self.node.package.license) html += '<meta name="generator" content="eXeLearning '+release+' - exelearning.net" />'+lb if self.node.id=='0': if self.node.package.description!="": desc = self.node.package.description desc = desc.replace('"', '"') html += '<meta name="description" content="'+desc+'" />'+lb html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"+lb if common.hasWikipediaIdevice(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_wikipedia.css\" />"+lb if common.hasGalleryIdevice(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_lightbox.css\" />"+lb if common.hasFX(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_effects.css\" />"+lb if common.hasGames(self.node): html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"exe_games.css\" />"+lb html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"content.css\" />"+lb if dT == "HTML5" or common.nodeHasMediaelement(self.node): html += u'<!--[if lt IE 9]><script type="text/javascript" src="exe_html5.js"></script><![endif]-->'+lb # jQuery if style.hasValidConfig: if style.get_jquery() == True: html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb else: html += u'<script type="text/javascript" src="'+style.get_jquery()+'"></script>'+lb else: html += u'<script type="text/javascript" src="exe_jquery.js"></script>'+lb if common.hasGalleryIdevice(self.node): html += u'<script type="text/javascript" src="exe_lightbox.js"></script>'+lb if common.hasFX(self.node): html += u'<script type="text/javascript" src="exe_effects.js"></script>'+lb html += common.getJavaScriptStrings()+lb if common.hasGames(self.node): # The games require additional strings html += common.getGamesJavaScriptStrings() + lb html += u'<script type="text/javascript" src="exe_games.js"></script>'+lb html += u'<script type="text/javascript" src="common.js"></script>'+lb if common.hasMagnifier(self.node): html += u'<script type="text/javascript" src="mojomagnify.js"></script>'+lb if self.scormType == 'commoncartridge': if style.hasValidConfig: html += style.get_extra_head() html += u"</head>"+lb html += u"<body class=\"exe-scorm\">" else: html += u"<script type=\"text/javascript\" src=\"SCORM_API_wrapper.js\"></script>"+lb html += u"<script type=\"text/javascript\" src=\"SCOFunctions.js\"></script>"+lb if style.hasValidConfig: html += style.get_extra_head() html += u"</head>"+lb html += u'<body class=\"exe-scorm\" onload="loadPage()" ' if common.hasQuizTest(self.node): html += u'onunload="unloadPage(true)">' else: html += u'onunload="unloadPage()">' html += u'<script type="text/javascript">document.body.className+=" js"</script>'+lb html += u"<div id=\"outer\">"+lb html += u"<"+sectionTag+" id=\"main\">"+lb html += u"<"+headerTag+" id=\"nodeDecoration\">" html += u"<div id=\"headerContent\">" html += u"<h1 id=\"nodeTitle\">" html += escape(self.node.titleLong) html += u'</h1>' html += u'</div>' html += u'</'+headerTag+'>'+lb for idevice in self.node.idevices: if idevice.klass != 'NotaIdevice': e=" em_iDevice" if unicode(idevice.emphasis)=='0': e="" html += u'<'+articleTag+' class="iDevice_wrapper %s%s" id="id%s">%s' % (idevice.klass, e, idevice.id, lb) block = g_blockFactory.createBlock(None, idevice) if not block: log.critical("Unable to render iDevice.") raise Error("Unable to render iDevice.") if hasattr(idevice, "isQuiz"): html += block.renderJavascriptForScorm() html += self.processInternalLinks( block.renderView(self.node.package.style)) html += u'</'+articleTag+'>'+lb # iDevice div html += u"</"+sectionTag+">"+lb # /#main themeHasXML = common.themeHasConfigXML(self.node.package.style) if themeHasXML: #if style.hasValidConfig: html += self.renderLicense() html += self.renderFooter() html += u"</div>"+lb # /#outer if self.node.package.scolinks: html += u'<'+sectionTag+' class="previousnext">'+lb html += u'<a class="previouslink" ' html += u'href="javascript:goBack();">%s</a> | <a class="nextlink" ' % c_('Previous') html += u'href="javascript:goForward();">%s</a>' % c_('Next') html += u'</'+sectionTag+'>'+lb if not themeHasXML: #if not style.hasValidConfig: html += self.renderLicense() html += self.renderFooter() else: html += style.get_extra_body() html += u'</body></html>' html = html.encode('utf8') # JR: Eliminamos los atributos de las ecuaciones aux = re.compile("exe_math_latex=\"[^\"]*\"") html = aux.sub("", html) aux = re.compile("exe_math_size=\"[^\"]*\"") html = aux.sub("", html) #JR: Cambio el & en los enlaces del glosario html = html.replace("&concept", "&concept") # Remove "resources/" from data="resources/ and the url param html = html.replace("video/quicktime\" data=\"resources/", "video/quicktime\" data=\"") html = html.replace("application/x-mplayer2\" data=\"resources/", "application/x-mplayer2\" data=\"") html = html.replace("audio/x-pn-realaudio-plugin\" data=\"resources/", "audio/x-pn-realaudio-plugin\" data=\"") html = html.replace("<param name=\"url\" value=\"resources/", "<param name=\"url\" value=\"") return html