def process(self, request): """ Handles a post from the webui and changes our state accordingly """ log.debug("process " + repr(request.args)) is_cancel = common.requestHasCancel(request) obj = request.args.get('object', [''])[0] if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] if obj != self.id: self.idevice.recreateResources() self.processCaptions(request) if obj != self.id: Block.process(self, request) return action = request.args.get('action', [''])[0] if action.startswith('gallery.'): self.processGallery(action) if self.mode == Block.Edit \ and not is_cancel: self.processCaptions(request) if action == 'done': self.idevice.recreateResources() if hasattr(self.idevice,'undo'): del self.idevice.undo Block.process(self, request)
def __init__(self, parent, idevice): """ 'parent' is our parent 'Renderable' instance """ Block.__init__(self, parent, idevice) if not hasattr(self.idevice,'undo'): self.idevice.undo = True
def process(self, request): """ Process the request arguments from the web server """ is_cancel = common.requestHasCancel(request) Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): for element in self.elements: element.process(request) if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] if "iconiDevice"+self.id in request.args \ and not is_cancel: self.idevice.icon = request.args["iconiDevice"+self.id][0] if not is_cancel: if self.idevice.title !='' or self.idevice.icon !='': self.idevice.emphasis = Idevice.SomeEmphasis else: self.idevice.emphasis = Idevice.NoEmphasis
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ self.idevice.message = "" Block.process(self, request) self.idevice.uploadNeededScripts() if field_engine_is_delete_request(request): return if "addMapArea" + unicode(self.id) in request.args: self.idevice.add_map_area() self.idevice.edit = True self.idevice.undo = False field_engine_process_all_elements(self.mainElements, request) for map_area_el in self.map_area_elements: field_engine_check_delete(map_area_el, request, self.idevice.map_areas) map_area_el.process(request) self.idevice.title = self.mainElements['title'].renderView()
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.mainElements = idevice.mainFieldSet.makeElementDict() self.memoryMatchElements = [] for memoryMatchField in idevice.matchPairFields: memoryMatchElement = MemoryMatchPairElement(memoryMatchField) self.memoryMatchElements.append(memoryMatchElement)
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) self.idevice.message = "" if ("addQuestion"+unicode(self.id)) in request.args: self.idevice.addQuestion() self.idevice.edit = True if "title"+self.id in request.args: self.idevice.title = request.args["title"+self.id][0] for element in self.questionElements: element.process(request) if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): for question in self.idevice.questions: isAnswered = False for option in question.options: if option.isCorrect: isAnswered = True break if not isAnswered: self.idevice.edit = True self.idevice.message = \ x_("Please select a correct answer for each question.") break
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) is_cancel = common.requestHasCancel(request) if ("addQuestion"+unicode(self.id)) in request.args: self.idevice.addQuestion() self.idevice.edit = True self.idevice.undo = False if "passrate" in request.args \ and not is_cancel: self.idevice.passRate = request.args["passrate"][0] for element in self.questionElements: element.process(request) if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): self.idevice.isAnswered = True if hasattr(self.idevice,'undo'): del self.idevice.undo for question in self.idevice.questions: if question.correctAns == -2: self.idevice.isAnswered = False self.idevice.edit = True break if "submitScore" in request.args \ and not is_cancel: self.idevice.score = self.__calcScore() if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0]
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ Block.process(self, request) self.idevice.uploadNeededScripts() if "addPlacableObject" + unicode(self.id) in request.args: self.idevice.addPlacableObject() self.idevice.edit = True self.idevice.undo = False if "checktimer" + unicode(self.id) in request.args: if "enabletimer" + unicode(self.id) in request.args: self.idevice.gameTimerShown.content = True else: self.idevice.gameTimerShown.content = False self.titleElement.process(request) self.idevice.title = self.titleElement.renderView() self.contentElement.process(request) self.mainAreaElement.process(request) self.positiveResponseElement.process(request) self.negativeResponseElement.process(request) self.clickToStartElement.process(request) self.gameTimeLimit.process(request) self.partbinNumCols.process(request) for placableObjectElement in self.placableObjectElements: placableObjectElement.process(request)
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) is_cancel = common.requestHasCancel(request) if ("addQuestion"+self.id) in request.args: self.idevice.addQuestion() self.idevice.edit = True # disable Undo once a question has been added: self.idevice.undo = False for element in self.questionElements: element.process(request) if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): # remove the undo flag in order to reenable it next time: if hasattr(self.idevice,'undo'): del self.idevice.undo
def __init__(self, parent, idevice): """ Initialize """ Block.__init__(self, parent, idevice) self.mediaElement = MultimediaElement(idevice.media) self.textElement = TextAreaElement(idevice.text)
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) is_cancel = common.requestHasCancel(request) if (u"action" not in request.args or (request.args[u"action"][0] != u"delete" and not is_cancel)): self.imageMagnifierElement.process(request) self.textElement.process(request) if "action" in request.args and request.args["action"][0] == "done": if hasattr(self.idevice,'undo'): del self.idevice.undo if "float"+self.id in request.args \ and not is_cancel: self.idevice.float = request.args["float"+self.id][0] if "caption"+self.id in request.args \ and not is_cancel: self.idevice.caption = request.args["caption"+self.id][0] if "glass"+self.id in request.args \ and not is_cancel: self.idevice.imageMagnifier.glassSize = \ request.args["glass"+self.id][0] if "initial"+self.id in request.args \ and not is_cancel: self.idevice.imageMagnifier.initialZSize = \ request.args["initial"+self.id][0] if "maxZoom"+self.id in request.args \ and not is_cancel: self.idevice.imageMagnifier.maxZSize = \ request.args["maxZoom"+self.id][0]
def __init__(self, parent, idevice): """ Initialize a new Block object """ Block.__init__(self, parent, idevice) self.idevice = idevice self.questionElements = [] # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.storyTextArea.idevice is None: idevice.storyTextArea.idevice = idevice self.storyElement = TextAreaElement(idevice.storyTextArea) self.questionInstruc = idevice.questionInstruc self.storyInstruc = idevice.storyInstruc self.feedbackInstruc = idevice.feedbackInstruc self.previewing = False # In view or preview render if not hasattr(self.idevice,'undo'): self.idevice.undo = True i = 0 for question in idevice.questions: self.questionElements.append(QuestionElement(i, idevice, question)) i += 1
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ is_cancel = common.requestHasCancel(request) if is_cancel: self.idevice.edit = False # but double-check for first-edits, and ensure proper attributes: if not hasattr(self.idevice.content, 'content_w_resourcePaths'): self.idevice.content.content_w_resourcePaths = "" if not hasattr(self.idevice.content, 'content_wo_resourcePaths'): self.idevice.content.content_wo_resourcePaths = "" return Block.process(self, request) if "title" + self.id in request.args and not is_cancel: self.idevice.title = request.args["title" + self.id][0] if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): content = self.contentElement.process(request) if content: self.idevice.content = content
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ self.idevice.message = "" Block.process(self, request) self.titleElement.process(request) self.questionOrderChoiceElement.process(request) self.timerChoiceElement.process(request) self.idevice.uploadNeededScripts() if "addClickableArea" + unicode(self.id) in request.args: self.idevice.addClickableField() self.idevice.edit = True self.idevice.undo = False for textAreaFieldName, textAreaElement in self.mainTextAreaElements.iteritems(): textAreaElement.process(request) for textFieldName, textElement in self.mainTextElements.iteritems(): textElement.process(request) for clickableAreaElement in self.clickableAreaElements: clickableAreaElement.process(request) #validate integer fields are actually integers field_engine_check_fields_are_ints(self.mainTextElements, \ ["width", "height", "hintWidth", "hintHeight"], thisIdevice=self.idevice)
def __init__(self, parent, idevice): """ Initialize """ Block.__init__(self, parent, idevice) self.articleElement = TextAreaElement(idevice.article) self.articleElement.height = 300
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.elements = [] for field in self.idevice: self.elements.append(g_elementFactory.createElement(field)) if not hasattr(self.idevice,'undo'): self.idevice.undo = True
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ Block.process(self, request) self.contentElement.process(request)
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): self.imageMagnifierElement.process(request) self.textElement.process(request) if "float"+self.id in request.args: self.idevice.float = request.args["float"+self.id][0] if "caption"+self.id in request.args: self.idevice.caption = request.args["caption"+self.id][0] if "glass"+self.id in request.args: self.idevice.imageMagnifier.glassSize = \ request.args["glass"+self.id][0] if "initial"+self.id in request.args: if request.args["initial"+self.id][0] == "yes": self.idevice.imageMagnifier.initialZSize = "120" else: self.idevice.imageMagnifier.initialZSize ="100" if "maxZoom"+self.id in request.args: self.idevice.imageMagnifier.maxZSize = \ request.args["maxZoom"+self.id][0]
def __init__(self, parent, idevice): """ Initialize """ Block.__init__(self, parent, idevice) self.flashMovieElement = FlashMovieElement(idevice.flash) self.textElement = TextAreaElement(idevice.text)
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) is_cancel = common.requestHasCancel(request) self.storyElement.process(request) if (u"addQuestion"+unicode(self.id)) in request.args: self.idevice.addQuestion() self.idevice.edit = True # disable Undo once another activity has been added: self.idevice.undo = False if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] if "action" in request.args and request.args[u"action"][0] != u"delete": for element in self.questionElements: element.process(request) if request.args[u"action"][0] == u'done': # remove the undo flag in order to reenable it next time: if hasattr(self.idevice,'undo'): del self.idevice.undo
def __init__(self, parent, idevice): """ Initialize """ Block.__init__(self, parent, idevice) self.imageMagnifierElement = MagnifierElement(idevice.imageMagnifier) self.textElement = TextAreaElement(idevice.text)
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ self.idevice.message = "" Block.process(self, request) for sortableElement in self.sortableItemElements: sortableElement.process(request) # check and see about deleting from the list field_engine_check_delete(sortableElement, request, self.idevice.itemsToSort) self.idevice.uploadNeededScripts() errorMsg = "" if "addSortableItem" + unicode(self.id) in request.args: self.idevice.addItemToSort() self.idevice.edit = True self.idevice.undo = False field_engine_process_all_elements(self.mainElements, request) self.idevice.title = self.mainElements["title"].renderView() field_engine_check_fields_are_ints(self.mainElements, ["itemwidth", "itemheight"], thisIdevice=self.idevice)
def __init__(self, parent, idevice): """ Pre-create our field ids """ Block.__init__(self, parent, idevice) # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.instructionsForLearners.idevice is None: idevice.instructionsForLearners.idevice = idevice if idevice.content.idevice is None: idevice.content.idevice = idevice if idevice.feedback.idevice is None: idevice.feedback.idevice = idevice dT = common.getExportDocType() sectionTag = "div" if dT == "HTML5": sectionTag = "section" idevice.instructionsForLearners.htmlTag = sectionTag idevice.instructionsForLearners.class_ = "block instructions" idevice.feedback.htmlTag = sectionTag self.instructionElement = TextAreaElement(idevice.instructionsForLearners) self.instructionElement.field.content_w_resourcePaths = c_(self.instructionElement.field.content_w_resourcePaths) self.listaElement = ListaElement(idevice.content) self.feedbackElement = \ TextAreaElement(idevice.feedback) self.previewing = False # In view or preview render if not hasattr(self.idevice,'undo'): self.idevice.undo = True
def __init__(self, parent, idevice): """ Initialize a new Block object """ Block.__init__(self, parent, idevice) self.idevice = idevice self.questionElements = [] self.questionInstruc = idevice.questionInstruc self.keyInstruc = idevice.keyInstruc self.feedbackInstruc = idevice.feedbackInstruc self.hintInstruc = idevice.hintInstruc # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.instructionsForLearners.idevice is None: idevice.instructionsForLearners.idevice = idevice self.instructionElement = \ TextAreaElement(idevice.instructionsForLearners) if not hasattr(self.idevice,'undo'): self.idevice.undo = True i = 0 for question in idevice.questions: self.questionElements.append(OpinionElement(i, idevice, question)) i += 1
def __init__(self, parent, idevice): """ Initialize """ Block.__init__(self, parent, idevice) if not hasattr(self.idevice,'undo'): self.idevice.undo = True
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ Block.process(self, request) is_cancel = common.requestHasCancel(request) self.showDescBlock.process(request) self.introHTMLElement.process(request) showDesc = False if self.showDescBlock.renderView() == "yes": showDesc = True if showDesc == True: self.idevice.emphasis = Idevice.SomeEmphasis else: self.idevice.emphasis = Idevice.NoEmphasis for fileElement in self.fileAttachmentElements: fileElement.process(request) if field_engine_is_delete(fileElement, request, self.idevice.fileAttachmentFields): #fileElement.field.deleteFile() field_engine_check_delete(fileElement, request, self.idevice.fileAttachmentFields) if "addFileAttachment" + unicode(self.id) in request.args: self.idevice.addFileAttachmentField() self.idevice.edit = True self.idevice.undo = False #check the title - lifted from genericblock if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0]
def process(self, request): """ Handles a post from the webui and changes our state accordingly """ log.debug("process " + repr(request.args)) # If the commit is not to do with us forget it is_cancel = common.requestHasCancel(request) obj = request.args.get('object', [''])[0] if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] if obj != self.id: self.idevice.recreateResources() self.processCaptions(request) if obj != self.id: Block.process(self, request) return # Separate out the action we want to do and the params action = request.args.get('action', [''])[0] if action.startswith('gallery.'): self.processGallery(action) if self.mode == Block.Edit \ and not is_cancel: self.processCaptions(request) if action == 'done': self.idevice.recreateResources() # remove the undo flag in order to reenable it next time: if hasattr(self.idevice,'undo'): del self.idevice.undo # Let our ancestor deal with the rest Block.process(self, request)
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) is_cancel = common.requestHasCancel(request) if 'emphasis'+self.id in request.args \ and not is_cancel: self.idevice.emphasis = int(request.args['emphasis'+self.id][0]) if 'site'+self.id in request.args \ and not is_cancel: self.idevice.site = request.args['site'+self.id][0] if 'title'+self.id in request.args \ and not is_cancel: self.idevice.title = request.args['title'+self.id][0] if "url" + self.id in request.args \ and not is_cancel: self.idevice.url = request.args['url'+ self.id][0] if 'loadRss'+self.id in request.args \ and not is_cancel: self.idevice.undo = False self.idevice.loadRss(request.args['url'+ self.id][0]) else: Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): self.rssElement.process(request) if "action" in request.args \ and request.args["action"][0] == "done": if hasattr(self.idevice,'undo'): del self.idevice.undo
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) is_cancel = common.requestHasCancel(request) if 'emphasis'+self.id in request.args \ and not is_cancel: self.idevice.emphasis = int(request.args['emphasis'+self.id][0]) self.idevice.undo = False if 'ssite'+self.id in request.args \ and not is_cancel: self.idevice.site = request.args['ssite'+self.id][0] if 'ownUrl'+self.id in request.args \ and not is_cancel: self.idevice.ownUrl = request.args['ownUrl'+self.id][0] if 'title'+self.id in request.args \ and not is_cancel: self.idevice.title = request.args['title'+self.id][0] if ("object" in request.args and request.args["object"][0] == "site" + self.id): pass elif 'loadWikipedia'+self.id in request.args: self.idevice.loadArticle(request.args['article'][0]) self.idevice.undo = False else: Block.process(self, request) if (u"action" not in request.args \ or request.args[u"action"][0] != u"delete"): self.articleElement.process(request) if "action" in request.args \ and request.args["action"][0] == "done": if hasattr(self.idevice,'undo'): del self.idevice.undo
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) if "code" + self.id in request.args: self.idevice.appletCode = request.args["code" + self.id][0] if "action" in request.args and request.args["action"][0] == self.id: self.idevice.deleteFile(request.args["object"][0]) self.idevice.edit = True if "action" in request.args and request.args["action"][0] == "changeType" + self.id: self.idevice.type = request.args["object"][0] self.idevice.copyFiles() self.idevice.edit = True if "upload" + self.id in request.args: if "path" + self.id in request.args: filePath = request.args["path"+self.id][0] if filePath: if self.idevice.type == "geogebra" and not filePath.endswith(".ggb"): self.idevice.message = _("Please upload a .ggb file.") else: self.idevice.uploadFile(filePath) self.idevice.message = "" self.idevice.edit = True
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ is_cancel = common.requestHasCancel(request) Block.process(self, request) if "url"+self.id in request.args \ and not is_cancel: self.idevice.url = request.args["url"+self.id][0] #if (self.idevice.url and # not self.idevice.url.startswith("http://") and # not self.idevice.url.startswith("https://") and # not self.idevice.url.startswith("ftp://")): # self.idevice.url = "http://" + self.idevice.url if "height"+self.id in request.args \ and not is_cancel: self.idevice.height = request.args["height"+self.id][0]
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) is_cancel = common.requestHasCancel(request) if "code" + self.id in request.args \ and not is_cancel: self.idevice.appletCode = request.args["code" + self.id][0] if "action" in request.args and request.args["action"][0] == self.id: self.idevice.deleteFile(request.args["object"][0]) self.idevice.edit = True self.idevice.undo = False if "action" in request.args and request.args["action"][0] == "changeType" + self.id: self.idevice.type = request.args["object"][0] self.idevice.copyFiles() self.idevice.edit = True self.idevice.undo = False if "action" in request.args and request.args["action"][0] == "done": # remove the undo flag in order to reenable it next time: if hasattr(self.idevice,'undo'): del self.idevice.undo if "upload" + self.id in request.args: if "path" + self.id in request.args: filePath = request.args["path"+self.id][0] if filePath: if self.idevice.type == "geogebra" and not filePath.endswith(".ggb"): self.idevice.message = _("Please upload a .ggb file.") else: self.idevice.uploadFile(filePath) self.idevice.message = "" self.idevice.edit = True self.idevice.undo = False
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) is_cancel = common.requestHasCancel(request) if 'emphasis'+self.id in request.args \ and not is_cancel: self.idevice.emphasis = int(request.args['emphasis' + self.id][0]) if 'site'+self.id in request.args \ and not is_cancel: self.idevice.site = request.args['site' + self.id][0] if 'title'+self.id in request.args \ and not is_cancel: self.idevice.title = request.args['title' + self.id][0] if "url" + self.id in request.args \ and not is_cancel: self.idevice.url = request.args['url' + self.id][0] if 'loadRss'+self.id in request.args \ and not is_cancel: # disable Undo once a question has been added: self.idevice.undo = False self.idevice.loadRss(request.args['url' + self.id][0]) else: Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): # If the text has been changed self.rssElement.process(request) if "action" in request.args \ and request.args["action"][0] == "done": # remove the undo flag in order to reenable it next time: if hasattr(self.idevice, 'undo'): del self.idevice.undo
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): self.mediaElement.process(request) self.textElement.process(request) if 'emphasis' + self.id in request.args: self.idevice.emphasis = int(request.args['emphasis' + self.id][0]) if "float" + self.id in request.args: self.idevice.float = request.args["float" + self.id][0] if "title" + self.id in request.args: self.idevice.title = request.args["title" + self.id][0]
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) is_cancel = common.requestHasCancel(request) if ("addQuestion" + unicode(self.id)) in request.args: self.idevice.addQuestion() self.idevice.edit = True # disable Undo once a question has been added: self.idevice.undo = False if "passrate" in request.args \ and not is_cancel: self.idevice.passRate = request.args["passrate"][0] for element in self.questionElements: element.process(request) if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): self.idevice.isAnswered = True # remove the undo flag in order to reenable it next time: if hasattr(self.idevice, 'undo'): del self.idevice.undo for question in self.idevice.questions: if question.correctAns == -2: self.idevice.isAnswered = False self.idevice.edit = True break if "submitScore" in request.args \ and not is_cancel: self.idevice.score = self.__calcScore() if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title" + self.id][0]
def process(self, request): """ Process the request arguments from the web server """ is_cancel = common.requestHasCancel(request) Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): for element in self.elements: element.process(request) if "address" + self.id in request.args and not is_cancel: if request.args["address" + self.id][0] == self.package.email: self.idevice.address = "" else: self.idevice.address = request.args["address" + self.id][0] if "subject" + self.id in request.args and not is_cancel: self.idevice.subject = request.args["subject" + self.id][0] if "comment" + self.id in request.args and not is_cancel: self.idevice.comment = request.args["comment" + self.id][0] if "title"+self.id in request.args: self.idevice.title = request.args["title"+self.id][0]
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.titleElement = TextElement(idevice.titleField) self.contentElement = TextAreaElement(idevice.content) self.contentElement.height = 250 self.chanceImageElements = [] #go through all image fields in the list and create an image element linked to that field for chanceImageField in idevice.chanceImageFields: newImgElement = ImageElement(chanceImageField) self.chanceImageElements.append(newImgElement) self.wordElements = [] self.hintElements = [] #go through all of the word fields and hint fields and create an for wordIndex, word in enumerate(idevice.wordTextFields): newWordElement = TextElement(word) self.wordElements.append(newWordElement) newHintElement = TextElement(idevice.hintTextFields[wordIndex]) self.hintElements.append(newHintElement) #make an element for the alphabet self.alphabetElement = TextElement(idevice.alphabet) #element for the messages that are shown to the player self.wrongGuessTextElement = TextAreaElement(self.idevice.wrongGuessMessageField) self.lostLevelTextElement = TextAreaElement(self.idevice.lostLevelMessageField) self.levelPassedTextElement = TextAreaElement(self.idevice.levelPasssedMessageField) self.gameWonTextElement = TextAreaElement(self.idevice.gameWonMessageField) self.letterButtonStyleElement = TextElement(self.idevice.letterButtonStyle) self.wrongLetterButtonStyleElement = TextElement(self.idevice.wrongLetterButtonStyle) self.rightLetterButtonStyleElement = TextElement(self.idevice.rightLetterButtonStyle) self.hintFieldStyleElement = TextElement(self.idevice.hintFieldStyle) self.wordAreaStyleElement = TextElement(self.idevice.wordAreaStyle) self.resetButtonTextElement = TextElement(self.idevice.resetButtonText) self.resetButtonStyleElement = TextElement(self.idevice.resetButtonStyle)
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()
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ Block.process(self, request) is_cancel = common.requestHasCancel(request) if "title" + self.id in request.args: self.idevice.title = request.args["title" + self.id][0] if ("addTerm" + self.id) in request.args: self.idevice.addTerm() self.idevice.edit = True self.idevice.undo = False for element in self.termElements: element.process(request) if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): # remove the undo flag in order to reenable it next time: if hasattr(self.idevice, 'undo'): del self.idevice.undo
def __init__(self, parent, idevice): """ Initialize a new Block object """ Block.__init__(self, parent, idevice) self.activityInstruc = idevice.activityInstruc self.answerInstruc = idevice.answerInstruc # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.activityTextArea.idevice is None: idevice.activityTextArea.idevice = idevice if idevice.answerTextArea.idevice is None: idevice.answerTextArea.idevice = idevice self.activityElement = TextAreaElement(idevice.activityTextArea) self.answerElement = TextAreaElement(idevice.answerTextArea) self.previewing = False # In view or preview render if not hasattr(self.idevice,'undo'): self.idevice.undo = True
def process(self, request): """ Process the request arguments from the web server """ Block.process(self, request) self.idevice.message = "" is_cancel = common.requestHasCancel(request) if ("addQuestion"+unicode(self.id)) in request.args: self.idevice.addQuestion() self.idevice.edit = True # disable Undo once a question has been added: self.idevice.undo = False if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title"+self.id][0] for element in self.questionElements: element.process(request) if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit): # remove the undo flag in order to reenable it next time: if hasattr(self.idevice,'undo'): del self.idevice.undo for question in self.idevice.questions: isAnswered = False for option in question.options: if option.isCorrect: isAnswered = True break if not isAnswered: self.idevice.edit = True self.idevice.message = \ x_("Please select a correct answer for each question.") break
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.mainTextAreaElements = {} self.mainTextElements = {} self.clickableAreaElements = [] self.questionOrderChoiceElement = ChoiceElement( idevice.questionOrderChoiceField) self.timerChoiceElement = ChoiceElement(idevice.timerChoiceField) self.titleElement = TextElement(idevice.titleField) for textAreaFieldName, textAreaFieldVals in idevice.textAreaFieldNames.iteritems( ): self.mainTextAreaElements[textAreaFieldName] = TextAreaElement( idevice.textAreaFields[textAreaFieldName]) for textFieldName, textFieldVals in idevice.textFieldNames.iteritems(): self.mainTextElements[textFieldName] = TextElement( idevice.textFields[textFieldName]) for clickableAreaField in idevice.clickableAreaFields: newClickableElement = ClickInOrderClickableAreaElement( clickableAreaField) self.clickableAreaElements.append(newClickableElement)
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ is_cancel = common.requestHasCancel(request) if is_cancel: self.idevice.edit = False # but double-check for first-edits, and ensure proper attributes: if not hasattr(self.idevice.content, 'content_w_resourcePaths'): self.idevice.content.content_w_resourcePaths = "" if not hasattr(self.idevice.content, 'content_wo_resourcePaths'): self.idevice.content.content_wo_resourcePaths = "" return Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): content = self.contentElement.process(request) if content: self.idevice.content = content
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): if u"label" + self.id in request.args: self.idevice.label = request.args[u"label" + self.id][0] self.descriptionElement.process(request) if "path" + self.id in request.args: attachmentPath = request.args["path" + self.id][0] if attachmentPath: self.idevice.setAttachment(attachmentPath) if self.idevice.label == "": self.idevice.label = os.path.basename(attachmentPath)
def __init__(self, parent, idevice): """ Pre-create our field ids """ Block.__init__(self, parent, idevice) # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.instructionsForLearners.idevice is None: idevice.instructionsForLearners.idevice = idevice if idevice.content.idevice is None: idevice.content.idevice = idevice if idevice.feedback.idevice is None: idevice.feedback.idevice = idevice self.instructionElement = \ TextAreaElement(idevice.instructionsForLearners) self.clozeElement = ClozeElement(idevice.content) self.feedbackElement = \ TextAreaElement(idevice.feedback) self.previewing = False # In view or preview render if not hasattr(self.idevice, 'undo'): self.idevice.undo = True
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ Block.process(self, request) is_cancel = common.requestHasCancel(request) self.showDescBlock.process(request) self.introHTMLElement.process(request) showDesc = False if self.showDescBlock.renderView() == "yes": showDesc = True if showDesc == True: self.idevice.emphasis = Idevice.SomeEmphasis else: self.idevice.emphasis = Idevice.NoEmphasis for fileElement in self.fileAttachmentElements: fileElement.process(request) if field_engine_is_delete(fileElement, request, self.idevice.fileAttachmentFields): #fileElement.field.deleteFile() field_engine_check_delete(fileElement, request, self.idevice.fileAttachmentFields) if "addFileAttachment" + unicode(self.id) in request.args: self.idevice.addFileAttachmentField() self.idevice.edit = True self.idevice.undo = False #check the title - lifted from genericblock if "title"+self.id in request.args \ and not is_cancel: self.idevice.title = request.args["title" + self.id][0]
def __init__(self, parent, idevice): """ Initialize a new Block object """ Block.__init__(self, parent, idevice) self.idevice = idevice self.questionElements = [] # to compensate for the strange unpickling timing when objects are # loaded from an elp, ensure that proper idevices are set: if idevice.storyTextArea.idevice is None: idevice.storyTextArea.idevice = idevice dT = common.getExportDocType() sectionTag = "div" if dT == "HTML5": sectionTag = "section" idevice.storyTextArea.htmlTag = sectionTag idevice.storyTextArea.class_ = "block story" self.storyElement = TextAreaElement(idevice.storyTextArea) self.questionInstruc = idevice.questionInstruc self.storyInstruc = idevice.storyInstruc self.feedbackInstruc = idevice.feedbackInstruc self.previewing = False # In view or preview render if not hasattr(self.idevice,'undo'): self.idevice.undo = True i = 0 for question in idevice.questions: self.questionElements.append(QuestionElement(i, idevice, question)) i += 1
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ log.debug("process " + repr(request.args)) Block.process(self, request) is_cancel = common.requestHasCancel(request) if "code" + self.id in request.args \ and not is_cancel: self.idevice.appletCode = request.args["code" + self.id][0] if "action" in request.args and request.args["action"][0] == self.id: self.idevice.deleteFile(request.args["object"][0]) self.idevice.edit = True self.idevice.undo = False if "action" in request.args and request.args["action"][ 0] == "changeType" + self.id: self.idevice.type = request.args["object"][0] self.idevice.copyFiles() self.idevice.edit = True self.idevice.undo = False if "action" in request.args and request.args["action"][0] == "done": # remove the undo flag in order to reenable it next time: if hasattr(self.idevice, 'undo'): del self.idevice.undo if "upload" + self.id in request.args: if "path" + self.id in request.args: filePath = request.args["path" + self.id][0] if filePath: if self.idevice.type == "geogebra" and not filePath.endswith( ".ggb"): self.idevice.message = _("Please upload a .ggb file.") elif self.idevice.type == "jclic" and not filePath.endswith( ".jclic.zip"): self.idevice.message = _( "Please upload a .jclic.zip file.") elif self.idevice.type == "scratch" and not filePath.endswith( ".sb") or filePath.endswith(".scratch"): self.idevice.message = _( "Please upload a .sb or .scratch file.") elif self.idevice.type == "descartes" and not ( filePath.endswith(".htm") or filePath.endswith(".html")): self.idevice.message = _( "Please type or paste a valid URL.") else: if self.idevice.type == "descartes" and filePath.find( ","): self.idevice.uploadFile(filePath) if self.idevice.uploadFile(filePath) == None: if self.idevice.appletCode == '': self.idevice.message = _( "eXe cannot access any scene inside the indicated website. " "Anyway you can access the desired scene in your regular browser, " "click with right mouse button on it and in config > codigo is its " "associated code. Copy and paste it directly into an Applet " "iDevice such as Other.") self.idevice.edit = True self.idevice.undo = False return else: self.idevice.uploadFile(filePath) # Descartes applet requires two functionalities: read html files (like above # and upload user indicated files, this is the second one: if "uploadother" + self.id in request.args: if "path" + self.id in request.args: filePath = request.args["path" + self.id][0] if filePath: if self.idevice.type == "descartes" and not ( filePath.endswith(".htm") or filePath.endswith(".html")): self.idevice.uploadFile(filePath) self.idevice.edit = True self.idevice.undo = False
def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ #Make sure that we don't do anything when it's time to die... Block.process(self, request) self.idevice.message = "" if field_engine_is_delete_request(request): return self.idevice.addGameScript() self.titleElement.process(request) self.idevice.title = self.titleElement.renderView() self.alphabetElement.process(request) self.wrongGuessTextElement.process(request) self.lostLevelTextElement.process(request) self.levelPassedTextElement.process(request) self.gameWonTextElement.process(request) self.letterButtonStyleElement.process(request) self.wrongLetterButtonStyleElement.process(request) self.rightLetterButtonStyleElement.process(request) self.hintFieldStyleElement.process(request) self.wordAreaStyleElement.process(request) self.resetButtonTextElement.process(request) self.resetButtonStyleElement.process(request) #see if we need to delete a word blankWords = False for wordIndex in range(0, len(self.wordElements)): if self.wordElements[wordIndex].renderView() == "": blankWords = True elif self.hintElements[wordIndex].renderView() == "": blankWords = True if blankWords is True: self.idevice.message = _("One or more words or hints are blank. Please do not have any blank hints or words - you can delete unused ones.") self.idevice.edit = True #see if we need to add another chance if ("addChance"+unicode(self.id)) in request.args: self.idevice.addChance() self.idevice.edit = True # disable Undo once a question has been added: self.idevice.undo = False if("addWord"+unicode(self.id)) in request.args: self.idevice.addWord() self.idevice.edit = True self.idevice.undo = False content = self.contentElement.process(request) for imgElement in self.chanceImageElements: imgElement.process(request) if "action" in request.args and request.args["action"][0] == imgElement.id: self.idevice.chanceImageFields.remove(imgElement.field) imgElement.field.idevice.undo = False imgElement.field.idevice.edit = True for wordElement in self.wordElements: wordElement.process(request) if "action" in request.args and request.args["action"][0] == wordElement.id: wordIdx = self.wordElements.index(wordElement) self.idevice.wordTextFields.remove(wordElement.field) self.idevice.hintTextFields.remove(self.hintElements[wordIdx].field) wordElement.field.idevice.undo = False wordElement.field.idevice.edit = True for hintElement in self.hintElements: hintElement.process(request) if content: self.idevice.content = content
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) if not hasattr(self.idevice, 'undo'): self.idevice.undo = True
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.elements = []
def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) self.contentElement = MathElement(idevice.content) self.contentElement.height = 250