def __calcScore(self): """ Return a score for preview mode. """ rawScore = 0 numQuestion = len(self.questionElements) score = 0 for question in self.idevice.questions: if (question.userAns == question.correctAns): log.info("userAns " + unicode(question.userAns) + ": " + "correctans " + unicode(question.correctAns)) rawScore += 1 if numQuestion > 0: score = rawScore * 100 / numQuestion for question in self.idevice.questions: question.userAns = -1 return score # =========================================================================== """Register this block with the BlockFactory""" from exe.engine.quiztestidevice import QuizTestIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(QuizTestBlock, QuizTestIdevice) # ===========================================================================
return html def renderView(self, style): """ Returns an XHTML string for viewing this block, i.e. when exported as a webpage or SCORM package """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" if self.idevice.icon: html += u'<img alt="%s" ' % _(u'IDevice Icon') html += u' class="iDevice_icon" ' html += u"src=\"icon_"+self.idevice.icon+".gif\"/>\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title html += u"</span>\n" html += u"<div class=\"iDevice_inner\">\n" for element in self.elements: html += element.renderView() html += u"<br/>\n" html += u"</div>\n" html += u"</div>\n" return html from exe.engine.genericidevice import GenericIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(GenericBlock, GenericIdevice) # ===========================================================================
html += ' value="%s"/> ' % _("Submit Answer") if not self.idevice.score == -1: message = "Your score is " + unicode(self.idevice.score) + "%" html += "<b>"+ message+ "</b><br/>" self.idevice.score = -1 html += u"</div>\n" html += self.renderViewButtons() html += u"</div>\n" return html def __calcScore(self): """ Return a score for preview mode. """ rawScore = 0 numQuestion = len(self.questionElements) score = 0 for question in self.idevice.questions: if (question.userAns == question.correctAns): log.info("userAns " +unicode(question.userAns) + ": " + "correctans " +unicode(question.correctAns)) rawScore += 1 if numQuestion > 0: score = rawScore * 100 / numQuestion for question in self.idevice.questions: question.userAns = -1 return score """Register this block with the BlockFactory""" from exe.engine.quiztestidevice import QuizTestIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(QuizTestBlock, QuizTestIdevice)
return html def renderPreview(self, style): """ Returns an XHTML string for previewing this block """ html = common.ideviceHeader(self, style, "preview") for element in self.questionElements: html += element.renderPreview() html += common.ideviceFooter(self, style, "preview") return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = common.ideviceHeader(self, style, "view") for element in self.questionElements: html += element.renderView() html += common.ideviceFooter(self, style, "view") return html from exe.engine.multiselectidevice import MultiSelectIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MultiSelectBlock, MultiSelectIdevice) # ===========================================================================
content = self.articleElement.renderView() content = re.sub(r'src="/.*?/resources/', 'src="', content) html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" if self.idevice.emphasis != Idevice.NoEmphasis: if self.idevice.icon: html += u'<img alt="iDevice icon" class="iDevice_icon" ' html += u" src=\"icon_"+self.idevice.icon+".gif\"/>\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title html += u"</span>\n" html += u"<div class=\"iDevice_inner\">\n" html += content html += u"<br/>\n" html += _(u"This article is licensed under the ") html += u"<a " html += u"href=\"javascript:window.open('fdl.html')\">" html += u"%s</a>. " % _(u"GNU Free Documentation License") html += _(u"It uses material from the ") html += u"<a href=\""+self.idevice.site+u"wiki/" html += self.idevice.articleName+u"\">" html += _(u"article ") + u"\""+self.idevice.articleName+u"\"</a>.<br/>\n" if self.idevice.emphasis != Idevice.NoEmphasis: html += u"</div></div>\n" else: html += u"</div>\n" return html from exe.engine.wikipediaidevice import WikipediaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(WikipediaBlock, WikipediaIdevice)
from exe.engine.idevice import Idevice from exe.webui.blockfactory import g_blockFactory # =========================================================================== class DummyBlock(Block): def __init__(self, parent, idevice): pass class DummyIdevice(Idevice): def __init__(self): pass g_blockFactory.registerBlockType(DummyBlock, DummyIdevice) # =========================================================================== class TestBlockFactory(unittest.TestCase): def setUp(self): pass def testBlockFactory(self): myidevice = DummyIdevice() myblock = g_blockFactory.createBlock(None, myidevice) self.assertEquals(type(myblock), DummyBlock) if __name__ == "__main__": unittest.main()
""" Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ # html = u'<script type="text/javascript" src="common.js"></script>\n' # html += u'<div class="iDevice_inner">\n' html = u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += "</div>\n" return html from exe.engine.orientacionesalumnadofpdidevice import OrientacionesalumnadofpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(OrientacionesalumnadofpdBlock, OrientacionesalumnadofpdIdevice) # ===========================================================================
def __init__(self, field): Element.__init__(self, field) self.elements = field.mainFields.makeElementDict() def process(self, request): field_engine_process_all_elements(self.elements, request) def renderEdit(self): html = "" #to make sure people see what is a pair.. html += "<div style='border: 2px solid green; margin: 5px; padding: 5px'>\n" html += self.field.mainFields.renderEditInOrder(self.elements) html += "</div>" return html #makes the line of Javascript for adding this to the game def makeJSLine(self): html = "" html += "memMatchGame%(ideviceid)s.addPairToMatch('%(pair1id)s', '%(pair2id)s');\n" \ % { 'ideviceid' : str(self.field.idevice.id), 'pair1id' : self.elements['match1'].id, \ 'pair2id' : self.elements['match2'].id} return html # =========================================================================== """Register this block with the BlockFactory""" from exe.engine.memorymatchidevice import MemoryMatchIdeviceInc from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MemoryMatchBlockInc, MemoryMatchIdeviceInc) # ===========================================================================
if self.previewing: html = self.activityElement.renderPreview() else: html = self.activityElement.renderView() # html += '<div id="view%s" style="display:block;">' % self.id # html += common.feedbackButton("btnshow"+self.id, _(u"Click here"), # onclick="showAnswer('%s',1)" % self.id) # html += '</div>\n' # html += '<div id="hide%s" style="display:none;">' % self.id # html += common.feedbackButton("btnshow"+self.id, _(u"Hide"), # onclick="showAnswer('%s',0)" % self.id) # html += '</div>\n' # html += '<div id="s%s" class="feedback" style=" ' % self.id # html += 'display: none;">' # if self.previewing: # html += self.answerElement.renderPreview() # else: # html += self.answerElement.renderView() # html += "</div>\n" return html from exe.engine.reflectionfpdmodifidevice import ReflectionfpdmodifIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ReflectionfpdmodifBlock, ReflectionfpdmodifIdevice) # ===========================================================================
def renderText(self): """ Returns an XHTML string for text file export. """ if self.previewing: html = '<p>' + self.instructionElement.renderPreview() +'</p>' else: html = '<p>' + self.instructionElement.renderView() +'</p>' html += '<p>' + self.listaElement.renderText() + '</p>' if self.feedbackElement.field.content: html += '<p>%s:</P>' % c_(u"Feedback") if self.previewing: html += '<p>' +self.feedbackElement.renderPreview(False, class_="feedback") html += '</p>' else: html += '<p>' +self.feedbackElement.renderView(False, class_="feedback") html += '</p>' html += self.listaElement.renderAnswers() return html #======================================================= from exe.engine.listaidevice import ListaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ListaBlock, ListaIdevice)
Returns an XHTML string for previewing this block """ html = u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\" " html += u"ondblclick=\"submitLink('edit'," + self.id + ", 0);\">\n" html += u'<img alt="%s" ' % _(u'IDevice Icon') html += u' class="iDevice_icon" ' html += u"src=\"/style/" + style + "/icon_" + self.idevice.icon + ".gif\" />\n" html += u"<span class=\"iDeviceTitle\">" # html += self.idevice.title+"</strong></span>\n" html += self.idevice.alt_title + "</span><br/>\n" #changed kthamm 111221 html += "<div class=\"iDevice_inner\">\n" for element in self.questionElements: html += element.renderPreview("/images/panel-amusements.png", "/images/stock-stop.png") html += "<br/>" html += "</div>\n" html += self.renderViewButtons() html += "</div>\n" return html from exe.engine.multichoiceidevice import MultichoiceIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MultichoiceBlock, MultichoiceIdevice) # ===========================================================================
Returns an XHTML string for viewing this block, i.e. when exported as a webpage or SCORM package """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += self.renderViewContent() html += u"</div>\n" return html def renderViewContent(self, resource=""): html = "<div class=\"iDevice_inner\">\n" if self.idevice.file == None: html += "<strong>%s : %s</strong>" \ % (_("File not found"), self.idevice.path) else: html += u'<embed height="%s"' %\ self.idevice.height html += ' width="100%"' html += u"src=\"%s\"></embed>\n" \ % (resource + self.idevice.file.storageName) html += u'</div>\n' return html from exe.engine.pdfidevice import PdfIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(PdfBlock, PdfIdevice) # ===========================================================================
def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"<!-- attachment iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" if self.idevice.userResources: html += u"<img src='stock-attach.png'> " html += u"<a href=\"#\" onclick=\"window.open('" html += self.idevice.userResources[0].storageName html += u"', '_blank');\" >" html += self.idevice.label html += u"</a> \n" html += u'<div class="block">\n' html += self.descriptionElement.renderView() html += u"</div>" html += u"</div>\n" return html from exe.engine.attachmentidevice import AttachmentIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(AttachmentBlock, AttachmentIdevice) # ===========================================================================
html += '<div class="notetitle">' html += '%s</div>' % self.idevice.title if self.commentElement.field.content: html += '<div id="fb%s" class="notearea">' % self.id if self.previewing: html += self.commentElement.renderPreview() else: html += self.commentElement.renderView() html += "</div>\n" if self.previewing: html += Block.renderViewButtons(self) html += "<a title=\"" + _( u"Delete all notes" ) + "\" href=\"#\" onclick=\"confirmThenSubmitLink('" + _( u"Would you delete all notes?" ) + "', '" + u'deleteallnotes' + "', '" + self.id + "', 1);\" style=\"float:right;margin-top:-20px;\"><img alt=\"" + _( u"Delete all notes" ) + "\" width=\"16\" height=\"16\" class=\"submit\" src=\"/images/stock-delete.png\"></a>" html += "</div>\n" return html from exe.engine.notaidevice import NotaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(NotaBlock, NotaIdevice) # ===========================================================================
""" log.debug("renderPreview") html = common.ideviceHeader(self, style, "preview") html += self.articleElement.renderPreview() html += common.ideviceFooter(self, style, "preview") return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") content = self.articleElement.renderView() # content = re.sub(r'src="resources/', 'src="', content) content = re.sub(r'src="http://127.0.0.1:\d+/newPackage.*/resources/', 'src="', content) content = re.sub(r'src="/newPackage.*/resources/', 'src="', content) content = re.sub(r'src=\'/newPackage.*/resources/', 'src="', content) content = re.sub(r'src=\"/newPackage.*/resources/', 'src="', content) html = common.ideviceHeader(self, style, "view") html += content html += common.ideviceFooter(self, style, "view") return html from exe.engine.wikipediaidevice import WikipediaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(WikipediaBlock, WikipediaIdevice) # ===========================================================================
""" html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<script type="text/javascript" src="libot_drag.js"></script>' html += u"\n<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += u'<img alt="" class="iDevice_icon" ' html += u"src=\"icon_"+self.idevice.icon+".gif\" />\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title+"</span><br/>\n" html += u"<div class=\"iDevice_inner\">\n" html += self.instructionElement.renderView() for element in self.questionElements: html += "<div class=\"question\">\n" html += element.renderQuestionView() html += element.renderFeedbackView() html += "</div>\n" html += u"</div>\n" html += u"</div>\n" return html from exe.engine.opinionidevice import OpinionIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(OpinionBlock, OpinionIdevice) # ===========================================================================
""" Returns an XHTML string for previewing this block """ if hasattr(self.idevice, 'parent') and self.idevice.parent and not self.idevice.parent.edit: return u"" html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\" " html += u"style=\"position: relative\" " html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n" html += self.contentElement.renderPreview() html += self.renderViewButtons() html += "</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += self.contentElement.renderView() html += u"</div>\n" return html from exe.engine.freetextidevice import FreeTextIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(FreeTextBlock, FreeTextIdevice) # ===========================================================================
appletcode = appletcode.replace('<APPLET','<applet CODEBASE="resources"') html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\" " html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n" html += appletcode html += u"<br/>" html += self.renderViewButtons() html += u"</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"<!-- applet iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" appletcode = self.idevice.appletCode appletcode = appletcode.replace('>', '>') appletcode = appletcode.replace('<', '<') appletcode = appletcode.replace('"', '"') appletcode = appletcode.replace(' ', '') html += appletcode html += u"<br/>" html += u"</div>\n" return html """Register this block with the BlockFactory""" from exe.engine.appletidevice import AppletIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(AppletBlock, AppletIdevice)
html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Click here"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Hide"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() html += "</div>\n" html += "</div>\n" return html from exe.engine.reflectionidevice import ReflectionIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ReflectionBlock, ReflectionIdevice) # ===========================================================================
html += u'<div class="iDevice_inner">\n' for letter in sortedLetters: html += '<a href="#anchor%s">' % letter html += '<span style="font-size: 26px">%s</span></a>\n' % letter html += '<br/>\n' html += '<br/>\n' for letter in sortedLetters: html += '<a id="anchor%s">' % letter html += '<span style="font-size: 26px">%s</span></a>\n' % letter html += '<br/>\n' html += '<br/>\n' html += lettersDict[letter] html += '<br/>\n' html += '<a href="#glossary_start">%s</a>\n' % _('Top') html += '<br/>\n' html += '<br/>\n' html += '<br/>\n' html += "</div></div>\n" return html from exe.engine.glossaryidevice import GlossaryIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(GlossaryBlock, GlossaryIdevice) # ===========================================================================
Returns an XHTML string for viewing this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<script type="text/javascript" src="libot_drag.js"></script>' html += u"\n<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += u'<img alt="" class="iDevice_icon" ' html += u"src=\"icon_" + self.idevice.icon + ".gif\" />\n" html += u"<span class=\"iDeviceTitle\"><strong>" html += self.idevice.title + "</strong></span>\n" html += u"<div class=\"iDevice_inner\">\n" html += self.instructionElement.renderView() for element in self.questionElements: html += "<div class=\"question\">\n" html += element.renderQuestionView() html += element.renderFeedbackView() html += "</div>\n" html += u"</div>\n" html += u"</div>\n" return html from exe.engine.truefalseidevice import TrueFalseIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(TrueFalseBlock, TrueFalseIdevice) # ===========================================================================
def register(): """Register this block with the BlockFactory""" from flashmovieidevice import FlashMovieIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(FlashMovieBlock, FlashMovieIdevice)
return Block.renderPreview(self, style) def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ if self.previewing: html = self.activityElement.renderPreview() else: html = self.activityElement.renderView() return html from exe.engine.recomendacionfpdidevice import RecomendacionfpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(RecomendacionfpdBlock, RecomendacionfpdIdevice) # ===========================================================================
""" self.previewing = True return Block.renderPreview(self, style) def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ if self.previewing: html = self.activityElement.renderPreview() else: html = self.activityElement.renderView() return html from exe.engine.debesconocerfpdidevice import DebesconocerfpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(DebesconocerfpdBlock, DebesconocerfpdIdevice) # ===========================================================================
html.append(self.feedbackElement.renderView(False, class_="feedback")) html += [ u'</div>\n', ] return u'\n '.join(html) def renderText(self): """ Returns an XHTML string for text file export. """ if self.previewing: html = '<p>' + self.instructionElement.renderPreview() +'</p>' else: html = '<p>' + self.instructionElement.renderView() +'</p>' html += '<p>' + self.clozeElement.renderText() + '</p>' if self.feedbackElement.field.content: html += '<p>%s:</P>' % _(u"Feedback") if self.previewing: html += '<p>' +self.feedbackElement.renderPreview(False, class_="feedback") html += '</p>' else: html += '<p>' +self.feedbackElement.renderView(False, class_="feedback") html += '</p>' html += self.clozeElement.renderAnswers() return html from exe.engine.clozeidevice import ClozeIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ClozeBlock, ClozeIdevice)
html = self._generateTable(genCell) return u''.join(html) def renderPreview(self, style): """ Renders html for teacher preview inside of exe """ cls = self.idevice.__class__ cls.preview() return Block.renderPreview(self, style) def renderView(self, style): """ Renders the html for export """ # Temporarily change the resources Url for exporting the images nicely cls = self.idevice.__class__ cls.export() try: html = [Block.renderView(self, style)] return u'\n '.join(html) finally: # Put everything back into the default preview mode cls.preview() from exe.engine.galleryidevice import GalleryIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(GalleryBlock, GalleryIdevice) # ===========================================================================
def renderText(self): """ Returns an XHTML string for text file export. """ if self.previewing: html = '<p>' + self.instructionElement.renderPreview() + '</p>' else: html = '<p>' + self.instructionElement.renderView() + '</p>' html += '<p>' + self.clozeElement.renderText() + '</p>' if self.feedbackElement.field.content: html += '<p>%s:</P>' % _(u"Feedback") if self.previewing: html += '<p>' + self.feedbackElement.renderPreview( False, class_="feedback") html += '</p>' else: html += '<p>' + self.feedbackElement.renderView( False, class_="feedback") html += '</p>' html += self.clozeElement.renderAnswers() return html from exe.engine.clozefpdidevice import ClozefpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ClozefpdBlock, ClozefpdIdevice) # ===========================================================================
def renderPreview(self, style): """ Returns an XHTML string for previewing this block """ html = u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\" " html += u"ondblclick=\"submitLink('edit'," + self.id + ", 0);\">\n" html += self.contentElement.renderPreview() html += self.renderViewButtons() html += "</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += self.contentElement.renderView() html += u"</div>\n" return html # ========================================================================= from exe.engine.mathidevice import MathIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MathBlock, MathIdevice) # ===========================================================================
def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ # html = u'<script type="text/javascript" src="common.js"></script>\n' # html += u'<div class="iDevice_inner">\n' html = u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += "</div>\n" return html from exe.engine.parasabermasfpdidevice import ParasabermasfpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ParasabermasfpdBlock, ParasabermasfpdIdevice) # ===========================================================================
""" self.previewing = True return Block.renderPreview(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ log.debug("renderViewContent called with previewing mode = " + str(self.previewing)) html = u"" if self.previewing: html += self.storyElement.renderPreview() html + u"<br />\n" for element in self.questionElements: html += element.renderPreview() else: html += self.storyElement.renderView() html + u"<br />\n" for element in self.questionElements: html += element.renderView() return html from exe.engine.ejercicioresueltofpdidevice import EjercicioresueltofpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(EjercicioresueltofpdBlock, EjercicioresueltofpdIdevice) # ===========================================================================
""" html = u'<div class="classnote">\n' if self.commentElement.field.content: html += '<div class="notetitleex" onclick="jQuery(\'#fb%s\').toggle()" title="%s">' % (self.id , _(u"Show/Hide")) else: html += '<div class="notetitle">' html +='%s</div>' % self.idevice.title if self.commentElement.field.content: html += '<div id="fb%s" class="notearea">' % self.id if self.previewing: html += self.commentElement.renderPreview() else: html += self.commentElement.renderView() html += "</div>\n" if self.previewing: html +=Block.renderViewButtons(self) html +="<a title=\""+_(u"Delete all notes")+"\" href=\"#\" onclick=\"confirmThenSubmitLink('"+_(u"Would you delete all notes?")+"', '"+u'deleteallnotes'+"', '"+self.id+"', 1);\" style=\"float:right;margin-top:-20px;\"><img alt=\""+_(u"Delete all notes")+"\" width=\"16\" height=\"16\" class=\"submit\" src=\"/images/stock-delete.png\"></a>" html += "</div>\n" return html from exe.engine.notaidevice import NotaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(NotaBlock, NotaIdevice) # ===========================================================================
self.previewing = False return Block.renderView(self, style) def renderPreview(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = True return Block.renderPreview(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ log.debug("renderViewContent called with previewing mode = " + str(self.previewing)) html = u"<div class=\"iDevice_inner\">\n" if self.previewing: html += self.storyElement.renderPreview() html + u"<br/>\n" for element in self.questionElements: html += element.renderPreview() else: html += self.storyElement.renderView() html + u"<br/>\n" for element in self.questionElements: html += element.renderView() html += u"</div>\n" return html from exe.engine.casestudyidevice import CasestudyIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(CasestudyBlock, CasestudyIdevice)
""" Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"\n<!-- MP3 iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" if self.idevice.emphasis != Idevice.NoEmphasis: if self.idevice.icon: html += u'<img alt="idevice icon" class="iDevice_icon" ' html += u' src="icon_' + self.idevice.icon + '.gif"/>\n' html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title html += u"</span>\n" html += u"<div class=\"iDevice_inner\"> " html += u"<div class=\"media\">\n" + "</div>" html += self.mediaElement.renderView() # html += u"<br/>" + self.idevice.media.caption + "</div>" html += self.textElement.renderView() html += u"<div style=\"clear:both;\">" html += u"</div></div>\n" html += u"</div>\n" return html from exe.engine.multimediaidevice import MultimediaIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MultimediaBlock, MultimediaIdevice) # ===========================================================================
def register(): """Register this block with the BlockFactory""" from forumidevice import ForumIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ForumBlock, ForumIdevice)
def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ # html = u'<script type="text/javascript" src="common.js"></script>\n' # html += u'<div class="iDevice_inner">\n' html = u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += "</div>\n" return html from exe.engine.casopracticofpdidevice import CasopracticofpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(CasopracticofpdBlock, CasopracticofpdIdevice) # ===========================================================================
word = self.wordElements[wordIndex] if word != "": xml += "<word>\n<hint>%(hint)s</hint>\n<answer>%(answer)s</answer>\n</word>\n" \ % {"answer" : word.renderView() , "hint" : self.hintElements[wordIndex].renderView()} xml += "</words>\n" xml += "</idevice>\n" return xml def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += self.contentElement.renderView() html += self._renderGame(style, mode = "view") html += u"</div>\n" return html # =========================================================================== """Register this block with the BlockFactory""" from exe.engine.hangmanidevice import HangmanIdeviceInc from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(HangmanBlockInc, HangmanIdeviceInc) # ===========================================================================
html += u"</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") content = self.rssElement.renderView() content = re.sub(r'src="/.*?/resources/', 'src="', content) html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += u"<div class=\"rss_url\" value=\"" + self.idevice.url \ + "\"></div>" if self.idevice.emphasis != Idevice.NoEmphasis: if self.idevice.icon: html += u'<img alt="iDevice icon" class="iDevice_icon" ' html += u" src=\"icon_"+self.idevice.icon+".gif\"/>\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title html += u"</span>\n" html += u"<div class=\"iDevice_inner\">\n" html += content if self.idevice.emphasis != Idevice.NoEmphasis: html += u"</div></div>\n" else: html += u"</div>\n" return html from exe.engine.rssidevice import RssIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(RssBlock, RssIdevice)
def register(): """Register this block with the BlockFactory""" from appletidevice import AppletIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(AppletBlock, AppletIdevice)
html += u"</div> <!-- class=\"iDevice emphasisX\" -->\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"\n<!-- image with text iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += u" <div class=\"image_text\" style=\"" html += u"width:" + str(self.idevice.imageMagnifier.width) + "px; " html += u"float:%s;\">\n" % self.idevice.float html += u" <div class=\"image\">\n" html += self.imageMagnifierElement.renderView() html += u" <br/>" + self.idevice.caption html += u" </div> <!-- class=\"image\" -->\n" html += u" </div> <!-- class=\"image_text\" -->\n" text = self.textElement.renderView() if text: html += text else: html += ' ' html += u'\n<div style="clear:both;height:1px;overflow:hidden;"></div>\n' html += u'\n<div style="clear:both;"></div>\n' html += u"</div> <!-- class=\"iDevice emphasisX\" -->\n" return html from exe.engine.imagemagnifieridevice import ImageMagnifierIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ImageMagnifierBlock, ImageMagnifierIdevice)
errMsg = field_engine_check_fields_are_ints(self.textElements, \ ['top', 'left', 'width', 'height', 'hideDelay'], None, self.field.idevice, self.field) def renderEdit(self): html = "<div stlye='border: 1px solid green; padding-top: 20px;'>" html += common.fieldShowEditMessageEle(self) textElementItems = ["left", "top", "width", "height", "hideDelay"] textAreaItems = ["Hint", "ShowMe"] for textElementName in textElementItems: html += self.textElements[textElementName].renderEdit() #for textAreaElementName, textAreaElement in self.textAreaElements.iteritems(): for textAreaElementName in textAreaItems: html +=self.textAreaElements[textAreaElementName].renderEdit() html += common.submitImage(self.id, self.field.idevice.id, "/images/stock-cancel.png", _("Delete Clickable Area")) html += "</div>" return html # =========================================================================== """Register this block with the BlockFactory""" from exe.engine.clickinorderidevice import ClickInOrderIdeviceInc from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ClickInOrderBlockInc, ClickInOrderIdeviceInc) # ===========================================================================
html += u"<br/>\n" html += u"<div style=\"clear:both;\">" html += u"</div>\n" html += self.renderViewButtons() html += u"</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"\n<!-- Flash with text iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += u"<div class=\"flash_text\" style=\"" html += u"width:" + str(self.idevice.flash.width) + "px; " html += u"float:%s;\">\n" % self.idevice.float html += u"<div class=\"flash\">\n" html += self.flashMovieElement.renderView() html += u"<br/>" + self.idevice.caption + "</div>" html += u"</div>\n" html += self.textElement.renderView() html += u"<div style=\"clear:both;\">" html += u"</div>\n" html += u"</div><br/>\n" return html """Register this block with the BlockFactory""" from exe.engine.flashmovieidevice import FlashMovieIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(FlashMovieBlock, FlashMovieIdevice)
return Block.renderPreview(self, style) def renderView(self, style): """ Renders the html for export """ cls = self.idevice.__class__ cls.export() try: html = [u'<div class="iDevice emphasis%s" ' % unicode(self.idevice.emphasis), u'>', u'<img alt="%s" ' % _(u'IDevice Icon'), u' class="iDevice_icon" ', u'src="icon_'+self.idevice.icon+'.gif" />' u'<span class="iDeviceTitle">', self.idevice.title, '</span><br/>'] popup = "" if self.idevice._htmlResource is not None: popup = self.idevice.htmlSrc html += [u'<div class="gallery_popup" value="%s"></div>' \ % popup] html += [self.renderViewContent()] html += [u'</div>'] return u'\n '.join(html) finally: cls.preview() from exe.engine.galleryidevice import GalleryIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(GalleryBlock, GalleryIdevice)
html += common.ideviceFooter(self, style, "preview") return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += self.contentElement.renderView() html += u"</div>\n" return html def renderXML(self, style): xml = u"" """ If we are effectively just one large image then make just an img tag and sound tag if appropriate. If not output all the html """ xmlStr = self.contentElement.renderXML(None, "idevice", self.idevice.id) return xmlStr from exe.engine.freetextidevice import FreeTextIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(FreeTextBlock, FreeTextIdevice) # ===========================================================================
import unittest from exe.webui.block import Block from exe.engine.idevice import Idevice from exe.webui.blockfactory import g_blockFactory # =========================================================================== class DummyBlock(Block): def __init__(self, parent, idevice): pass class DummyIdevice(Idevice): def __init__(self): pass g_blockFactory.registerBlockType(DummyBlock, DummyIdevice) # =========================================================================== class TestBlockFactory(unittest.TestCase): def setUp(self): pass def testBlockFactory(self): myidevice = DummyIdevice() myblock = g_blockFactory.createBlock(None, myidevice) self.assertEquals(type(myblock), DummyBlock) if __name__ == "__main__": unittest.main()
def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ # html = u'<script type="text/javascript" src="common.js"></script>\n' # html += u'<div class="iDevice_destacadofpd">\n' html = u'<div class="iDevice_destacadofpd">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += "</div>\n" return html from exe.engine.destacadofpdidevice import DestacadofpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(DestacadofpdBlock, DestacadofpdIdevice) # ===========================================================================
""" Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"\n<!-- image with text iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += u" <div class=\"image_text\" style=\"" html += u"width:" + str(self.idevice.imageMagnifier.width) + "px; " html += u"float:%s;\">\n" % self.idevice.float html += u" <div class=\"image\">\n" html += self.imageMagnifierElement.renderView() html += u" <br/>" + self.idevice.caption html += u" </div> <!-- class=\"image\" -->\n" html += u" </div> <!-- class=\"image_text\" -->\n" text = self.textElement.renderView() if text: html += text else: html += ' ' html += u'\n<div style="clear:both;height:1px;overflow:hidden;"></div>\n' html += u"</div> <!-- class=\"iDevice emphasisX\" -->\n" return html from exe.engine.imagemagnifieridevice import ImageMagnifierIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(ImageMagnifierBlock, ImageMagnifierIdevice) # ===========================================================================
def renderView(self, style): """ Remembers if we're previewing or not, then implicitly calls self.renderViewContent (via Block.renderPreview) """ self.previewing = False return Block.renderView(self, style) def renderViewContent(self): """ Returns an XHTML string for this block """ # html = u'<script type="text/javascript" src="common.js"></script>\n' # html += u'<div class="iDevice_inner">\n' html = u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += "</div>\n" return html from exe.engine.orientacionesalumnadofpdidevice import OrientacionesalumnadofpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(OrientacionesalumnadofpdBlock, OrientacionesalumnadofpdIdevice) # ===========================================================================
html += u"</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"\n<!-- Flash with text iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += u"<div class=\"flash_text\" style=\"" html += u"width:" + str(self.idevice.flash.width) + "px; " html += u"float:%s;\">\n" % self.idevice.float html += u"<div class=\"flash\">\n" html += self.flashElement.renderView() html += u"<br/>" + self.idevice.caption + "</div>" html += u"</div>\n" html += self.textElement.renderView() html += u"<div style=\"clear:both;\">" html += u"</div>\n" html += u"</div><br/>\n" return html from exe.engine.flashwithtextidevice import FlashWithTextIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(FlashWithTextBlock, FlashWithTextIdevice) # ===========================================================================
html += element.renderFeedbackPreview() html += "</div>\n" html += self.renderViewButtons() html += "</div>\n" return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<script type="text/javascript" src="libot_drag.js"></script>' html += u"\n<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += u'<img alt="" class="iDevice_icon" ' html += u"src=\"icon_"+self.idevice.icon+".gif\" />\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title+"</span><br/>\n" html += u"<div class=\"iDevice_inner\">\n" html += self.instructionElement.renderView() for element in self.questionElements: html += "<div class=\"question\">\n" html += element.renderQuestionView() html += element.renderFeedbackView() html += "</div>\n" html += u"</div>\n" html += u"</div>\n" return html from exe.engine.truefalseidevice import TrueFalseIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(TrueFalseBlock, TrueFalseIdevice)
html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\" " html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n" html += u'<img alt="%s" ' % _(u'IDevice Icon') html += u' class="iDevice_icon" ' html += u"src=\"/style/"+style+"/icon_"+self.idevice.icon+".gif\" />\n" html += u"<span class=\"iDeviceTitle\"><strong>" html += self.idevice.title+"</strong></span>\n" html += "<div class=\"iDevice_inner\">\n" aux = self.questionElements[len(self.questionElements) - 1] for element in self.questionElements: if element == aux: html += element.renderPreview("/images/panel-amusements.png", "/images/stock-stop.png") else: html += element.renderPreview("/images/panel-amusements.png", "/images/stock-stop.png") + "<br/>" html += "</div>\n" html += self.renderViewButtons() html += "</div>\n" return html from exe.engine.eleccionmultiplefpdidevice import EleccionmultiplefpdIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(EleccionmultiplefpdBlock, EleccionmultiplefpdIdevice) # ===========================================================================
for element in self.questionElements: html += element.renderView("panel-amusements.png","stock-stop.png") html += "<br/>" html += "</div>\n" html += "</div>\n" return html def renderPreview(self, style): """ Returns an XHTML string for previewing this block """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\" " html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n" html += u'<img alt="%s" ' % _(u'IDevice Icon') html += u' class="iDevice_icon" ' html += u"src=\"/style/"+style+"/icon_"+self.idevice.icon+".gif\" />\n" html += u"<span class=\"iDeviceTitle\">" html += self.idevice.title+"</span><br/>\n" html += "<div class=\"iDevice_inner\">\n" for element in self.questionElements: html += element.renderPreview("/images/panel-amusements.png", "/images/stock-stop.png") html += "<br/>" html += "</div>\n" html += self.renderViewButtons() html += "</div>\n" return html from exe.engine.multichoiceidevice import MultichoiceIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(MultichoiceBlock, MultichoiceIdevice)
def renderView(self, style): """ Returns an XHTML string for viewing this block """ log.debug("renderView") html = u"<!-- applet iDevice -->\n" html += u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" appletcode = self.idevice.appletCode appletcode = appletcode.replace('>', '>') appletcode = appletcode.replace('<', '<') appletcode = appletcode.replace('"', '"') appletcode = appletcode.replace(' ', '') html += appletcode html += u"<br/>" html += u"</div>\n" return html # =========================================================================== """Register this block with the BlockFactory""" from exe.engine.appletidevice import AppletIdevice from exe.webui.blockfactory import g_blockFactory g_blockFactory.registerBlockType(AppletBlock, AppletIdevice) # ===========================================================================