Esempio n. 1
0
    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
Esempio n. 2
0
 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)
Esempio n. 3
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 "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
Esempio n. 4
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 (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]
Esempio n. 5
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)
Esempio n. 6
0
    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
        if "export" + self.id in request.args and not is_cancel:
            self.idevice.exportType = request.args["export" + self.id][0]
Esempio n. 7
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":
         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
Esempio n. 8
0
    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
Esempio n. 9
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))
     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
Esempio n. 10
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)
Esempio n. 11
0
 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
         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):
         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
Esempio n. 12
0
    def process(self, request):
        """
        Process the request arguments from the web server
        """
        Block.process(self, request)

        is_cancel = common.requestHasCancel(request)

        self.instructionElement.process(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
Esempio n. 13
0
 def process(self, request):
     """
     Process arguments from the web server.  Return any which apply to this 
     element.
     """
     log.debug("process " + repr(request.args))
     is_cancel = common.requestHasCancel(request)
     if self.answerId in request.args \
     and not is_cancel:
         self.answerElement.process(request)
     if "c"+self.keyId in request.args \
     and not is_cancel:
         if request.args["c"+self.keyId][0] == self.id:
             self.option.isCorrect = True 
             self.question.correctAns = self.index
             log.debug("option " + repr(self.option.isCorrect))
         else:
             self.option.isCorrect = False
     if self.keyId in request.args \
     and not is_cancel:
         if request.args[self.keyId][0] == unicode(self.index):
             self.question.userAns = self.index
     if "action" in request.args and request.args["action"][0] == self.id:
         for o_field in self.option.getRichTextFields():
              o_field.ReplaceAllInternalAnchorsLinks()  
              o_field.RemoveAllInternalLinks()  
         self.question.options.remove(self.option)
         self.idevice.undo = False
Esempio n. 14
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 "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
        """
        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
Esempio n. 16
0
 def process(self, request):
     """
     Process arguments from the web server.  Return any which apply to this 
     element.
     """
     log.debug("process " + repr(request.args))
     is_cancel = common.requestHasCancel(request)
     if self.questionId in request.args \
     and not is_cancel:
         self.question_question.process(request)
     if self.hintId in request.args \
     and not is_cancel:
         self.question_hint.process(request)
     if self.keyId in request.args \
     and not is_cancel:
         if request.args[self.keyId][0] == "true":
             self.question.isCorrect = True 
             log.debug("question " + repr(self.question.isCorrect))
         else:
             self.question.isCorrect = False        
     if self.feedbackId in request.args \
     and not is_cancel:
         self.question_feedback.process(request)
     if "action" in request.args and request.args["action"][0] == self.id:
         for q_field in self.question.getRichTextFields():
              q_field.ReplaceAllInternalAnchorsLinks()  
              q_field.RemoveAllInternalLinks()  
         self.idevice.questions.remove(self.question)
         self.idevice.undo = False
Esempio n. 17
0
    def process(self, request):
        """
        Process arguments from the web server.  Return any which apply to this 
        element.
        """
        log.debug("process " + repr(request.args))

        is_cancel = common.requestHasCancel(request)

        if self.answerId in request.args \
        and not is_cancel:
            self.answerElement.process(request)

        if "c"+self.keyId in request.args \
        and not is_cancel:
            if request.args["c" + self.keyId][0] == self.id:
                self.option.isCorrect = True
                self.question.correctAns = self.index
                log.debug("option " + repr(self.option.isCorrect))
            else:
                self.option.isCorrect = False

        if self.keyId in request.args \
        and not is_cancel:
            if request.args[self.keyId][0] == unicode(self.index):
                self.question.userAns = self.index

        if "action" in request.args and request.args["action"][0] == self.id:
            # before deleting the option object, remove any internal anchors:
            for o_field in self.option.getRichTextFields():
                o_field.ReplaceAllInternalAnchorsLinks()
                o_field.RemoveAllInternalLinks()
            self.question.options.remove(self.option)
            # disable Undo once an option has been deleted:
            self.idevice.undo = False
Esempio n. 18
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
         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]
Esempio n. 19
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))
     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
Esempio n. 20
0
 def process(self, request):
     """
     Process the request arguments from the web server
     """
     Block.process(self, request)
     is_cancel = common.requestHasCancel(request)
     if not is_cancel:
         self.activityElement.process(request)
         self.answerElement.process(request)
         if "title"+self.id in request.args:
             self.idevice.title = request.args["title"+self.id][0]
Esempio n. 21
0
    def process(self, request):
        """
        Process the request arguments from the web server
        """
        Block.process(self, request)

        is_cancel = common.requestHasCancel(request)

        if not is_cancel:
            self.activityElement.process(request)
            if "title" + self.id in request.args:
                self.idevice.title = request.args["title" + self.id][0]
Esempio n. 22
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 "title"+self.id in request.args \
     and not is_cancel:
         self.idevice.title = request.args["title"+self.id][0]
Esempio n. 23
0
 def process(self, request):
     """
     Handles changes in the paragraph text from editing
     """
     is_cancel = common.requestHasCancel(request)
     if "title"+self.id in request.args \
     and not is_cancel:
         self.idevice.title = request.args["title"+self.id][0]
     object = request.args.get('object', [''])[0]
     action = request.args.get('action', [''])[0]
     self.instructionElement.process(request)
     self.clozeElement.process(request)
     self.feedbackElement.process(request)
     Block.process(self, request)
    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]
Esempio n. 25
0
    def process(self, request):
        """
        Handles changes in the paragraph text from editing
        """
        is_cancel = common.requestHasCancel(request)

        if "title"+self.id in request.args \
        and not is_cancel:
            self.idevice.title = request.args["title" + self.id][0]
        object = request.args.get('object', [''])[0]
        action = request.args.get('action', [''])[0]
        self.instructionElement.process(request)
        self.clozeElement.process(request)
        self.feedbackElement.process(request)
        Block.process(self, request)
Esempio n. 26
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))

        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])
            # disable Undo once an emphasis has changed:
            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:
            # If they've hit "load" instead of "the tick"
            self.idevice.loadArticle(request.args['article'][0])
            # disable Undo once an article has been loaded:
            self.idevice.undo = False
        else:
            # If they hit "the tick" instead of "load"
            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.articleElement.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
Esempio n. 27
0
    def process(self, request):
        """
        Process the request arguments from the web server
        """
        is_cancel = common.requestHasCancel(request)

        Block.process(self, request)
        if "pages" + self.id in request.args and not is_cancel :
            self.idevice.pages = request.args["pages" + self.id][0]
        if "path" + self.id in request.args \
        and not is_cancel:
            pdfPath = request.args["path"+self.id][0]
            self.idevice.path = pdfPath
            try:
                self.idevice.uploadFile()
            except IOError, e:
                log.error("Unable to add file %s" % pdfPath)
    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])
            # disable Undo once an emphasis has changed: 
            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:
            # If they've hit "load" instead of "the tick"
            self.idevice.loadArticle(request.args['article'][0])
            # disable Undo once an article has been loaded: 
            self.idevice.undo = False
        else:
            # If they hit "the tick" instead of "load"
            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.articleElement.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
Esempio n. 29
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))

        is_cancel = common.requestHasCancel(request)
        
        # If they hit "the tick" instead of "load"
        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.articleElement.process(request)
        if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit):
            if hasattr(self.idevice, 'undo'):
                del self.idevice.undo
Esempio n. 30
0
    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]
Esempio n. 31
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))

        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])
            # disable Undo once an emphasis has changed:
            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 'kpse' + self.id in request.args and not is_cancel:
            path = \
                request.args['kpse' + self.id][0]
            if not os.path.isdir(path):
                path = os.path.dirname(path)
            self.idevice.latexpath = path
            self.idevice.set_env()

        if 'loadSource' + self.id in request.args:
            # If they've hit "load" instead of "the tick"
            self.idevice.source = request.args['path' + self.id][0]
            self.idevice.loadSource()
            # disable Undo once an article has been loaded:
            self.idevice.undo = False
        else:
            # If they hit "the tick" instead of "load"
            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.articleElement.process(request)
        if ("action" in request.args and request.args["action"][0] == "done"
                or not self.idevice.edit):
            if hasattr(self.idevice, 'undo'):
                del self.idevice.undo
Esempio n. 32
0
 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
         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):
         if hasattr(self.idevice,'undo'): 
             del self.idevice.undo
Esempio n. 33
0
    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]
Esempio n. 34
0
 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
         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
Esempio n. 35
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 (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":
            # remove the undo flag in order to reenable it next time:
            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]
Esempio n. 36
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]
Esempio n. 37
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))

        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])
            # disable Undo once an emphasis has changed: 
            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 'kpse' + self.id in request.args and not is_cancel:
            path = \
                request.args['kpse' + self.id][0]
            if not os.path.isdir(path):
                path = os.path.dirname(path)
            self.idevice.latexpath = path
            self.idevice.set_env()
            
        if 'loadSource'+self.id in request.args:
            # If they've hit "load" instead of "the tick"
            self.idevice.source = request.args['path' + self.id][0]
            self.idevice.loadSource()
            # disable Undo once an article has been loaded: 
            self.idevice.undo = False
        else:
            # If they hit "the tick" instead of "load"
            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.articleElement.process(request)
        if ("action" in request.args and request.args["action"][0] == "done" or not self.idevice.edit):
            if hasattr(self.idevice, 'undo'):
                del self.idevice.undo
Esempio n. 38
0
 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
         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':
             if hasattr(self.idevice,'undo'): 
                 del self.idevice.undo
Esempio n. 39
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))

        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):
        """
        Sets the encodedContent of our field
        """
       
        
        is_cancel = common.requestHasCancel(request)

        if is_cancel:
            self.field.idevice.edit = False
            # but double-check for first-edits, and ensure proper attributes:
            if not hasattr(self.field, 'content_w_resourcePaths'):
                self.field.content_w_resourcePaths = ""
                self.field.idevice.edit = True
            if not hasattr(self.field, 'content_wo_resourcePaths'):
                self.field.content_wo_resourcePaths = ""
                self.field.idevice.edit = True
            return
       
        
        if self.editorId in request.args:
            # process any new images and other resources courtesy of tinyMCE:

            self.field.content_w_resourcePaths = \
                self.field.ProcessPreviewed(request.args[self.editorId][0])
            # likewise determining the paths for exports, etc.:
            self.field.content_wo_resourcePaths = \
                  self.field.MassageContentForRenderView(\
                         self.field.content_w_resourcePaths)
            # and begin by choosing the content for preview mode, WITH paths:
            self.field.encodedContent = self.field.content_w_resourcePaths
            
            if "clOtras"+self.id in request.args :
                totras=request.args["clOtras"+self.id][0]
                self.field.otras = totras
        else:
            if "clozeOtras"+self.id in request.args :
                totras=request.args["clozeOtras"+self.id][0]
                self.field.otras = self.dcrypt(totras)
            
            """
    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
Esempio n. 42
0
    def process(self, request):
        """
        Sets the encodedContent of our field
        """
       
        
        is_cancel = common.requestHasCancel(request)

        if is_cancel:
            self.field.idevice.edit = False
            # but double-check for first-edits, and ensure proper attributes:
            if not hasattr(self.field, 'content_w_resourcePaths'):
                self.field.content_w_resourcePaths = ""
                self.field.idevice.edit = True
            if not hasattr(self.field, 'content_wo_resourcePaths'):
                self.field.content_wo_resourcePaths = ""
                self.field.idevice.edit = True
            return
       
        
        if self.editorId in request.args:
            # process any new images and other resources courtesy of tinyMCE:

            self.field.content_w_resourcePaths = \
                self.field.ProcessPreviewed(request.args[self.editorId][0])
            # likewise determining the paths for exports, etc.:
            self.field.content_wo_resourcePaths = \
                  self.field.MassageContentForRenderView(\
                         self.field.content_w_resourcePaths)
            # and begin by choosing the content for preview mode, WITH paths:
            self.field.encodedContent = self.field.content_w_resourcePaths
            
            if "clOtras"+self.id in request.args :
                totras=request.args["clOtras"+self.id][0]
                self.field.otras = totras
        else:
            if "clozeOtras"+self.id in request.args :
                totras=request.args["clozeOtras"+self.id][0]
                self.field.otras = self.dcrypt(totras)
            
            """
Esempio n. 43
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))

        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
Esempio n. 44
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)

        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
Esempio n. 45
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)

        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
Esempio n. 46
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 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
Esempio n. 48
0
    def process(self, request):
        """
        Process arguments from the web server.  Return any which apply to this 
        element.
        """
        log.debug("process " + repr(request.args))

        is_cancel = common.requestHasCancel(request)

        if self.questionId in request.args \
        and not is_cancel:
            self.question_question.process(request)

        if self.hintId in request.args \
        and not is_cancel:
            self.question_hint.process(request)

        if self.keyId in request.args \
        and not is_cancel:
            if request.args[self.keyId][0] == "true":
                self.question.isCorrect = True
                log.debug("question " + repr(self.question.isCorrect))
            else:
                self.question.isCorrect = False

        if self.feedbackId in request.args \
        and not is_cancel:
            self.question_feedback.process(request)

        if "action" in request.args and request.args["action"][0] == self.id:
            # before deleting the question object, remove any internal anchors:
            for q_field in self.question.getRichTextFields():
                q_field.ReplaceAllInternalAnchorsLinks()
                q_field.RemoveAllInternalLinks()
            self.idevice.questions.remove(self.question)
            # disable Undo once a question has been deleted:
            self.idevice.undo = False
Esempio n. 49
0
 def process(self, request):
     is_cancel = common.requestHasCancel(request)
     if self.id in request.args and not is_cancel:
         self.field.content = request.args[self.id][0]
Esempio n. 50
0
 def process(self, request):
     is_cancel = common.requestHasCancel(request)
     if self.id in request.args and not is_cancel:
         self.field.content = request.args[self.id][0]
Esempio n. 51
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.")
                    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