示例#1
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        log.debug("renderPreview")
        #resources = "http://127.0.0.1:%s/%s/resources" % (self.config.port, self.package.name)
        resources = "/%s/resources" % (self.package.name)
        appletcode = self.idevice.appletCode
        appletcode = appletcode.replace('>', '>')
        appletcode = appletcode.replace('&lt;', '<')
        appletcode = appletcode.replace('&quot;', '"')
        appletcode = appletcode.replace('\xC2\x82','&#130')
        appletcode = appletcode.replace('<applet','<applet codebase="%s"' % resources)
        appletcode = appletcode.replace('<APPLET','<applet codebase="%s"' % resources)

        if self.idevice.type == "jclic":
            appletcode = appletcode.replace('activitypack" value="', 'activitypack" value="%s/' % resources)

        if self.idevice.type == "geogebra":
            # according to self.port (config.py)
            appletcode = appletcode.replace('filename" value="', 'filename" value="%s/' % resources)

        lb = "\n" #Line breaks
        html = common.ideviceHeader(self, style, "preview")
        html += '<div class="iDevice_content">'+lb
        html += appletcode+lb
        html += '</div>'+lb
        html += common.ideviceFooter(self, style, "preview")

        return html
示例#2
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        lb = "\n"  #Line breaks
        html = common.ideviceHeader(self, style, "preview")

        html += u'<input type="hidden" name="passrate" id="passrate-' + self.idevice.id + '" value="' + self.idevice.passRate + '" />'

        for element in self.questionElements:
            html += element.renderPreview()

        html += '<div class="block iDevice_buttons">' + lb
        html += '<p><input type="submit" name="submitScore" value="' + c_(
            "SUBMIT ANSWERS") + '" /></p>'
        html += '</div>' + lb

        if not self.idevice.score == -1:
            message = c_("Your score is %d%%") % self.idevice.score
            html += '<script type="text/javascript">alert("' + message + '")</script>'

        self.idevice.score = -1

        html += common.ideviceFooter(self, style, "preview")

        return html
示例#3
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """     

        lb = "\n" #Line breaks
        html = common.ideviceHeader(self, style, "view")
        
        html += '<div class="iDevice_content">'+lb
        html += '<div class="image_text" style="width:'+str(self.idevice.imageMagnifier.width)+'px;float:'+self.idevice.float+';'
        if self.idevice.float == 'left':
            html += 'margin:0 20px 20px 0'
        if self.idevice.float == 'right':
            html += 'margin:0 0 20px 20px'
        html += '">'  
        html += lb
        html += self.imageMagnifierElement.renderView()
        if self.idevice.caption != '':
            html = html.replace(' alt="" ',' alt="'+self.idevice.caption.replace('"','&quot;')+'" ', 1)
            html += '<strong>'+self.idevice.caption+'</strong>'
        html += '</div>'+lb 
        text = self.textElement.renderView()
        if text:
            text = text.replace('"block iDevice_content"', '"iDevice_text"', 1)
            html += text
        else:
            html += '&nbsp;'
        html += '</div>'+lb # /.iDevice_content
        
        html += common.ideviceFooter(self, style, "view")

        return html
示例#4
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        log.debug("renderPreview")
        resources = "%s/%s/resources" % (G.application.exeAppUri,
                                         self.package.name)
        appletcode = self.idevice.appletCode
        appletcode = appletcode.replace('&gt;', '>')
        appletcode = appletcode.replace('&lt;', '<')
        appletcode = appletcode.replace('&quot;', '"')
        appletcode = appletcode.replace('\xC2\x82', '&#130')
        appletcode = appletcode.replace('<applet',
                                        '<applet codebase="%s"' % resources)
        appletcode = appletcode.replace('<APPLET',
                                        '<applet codebase="%s"' % resources)

        if self.idevice.type == "jclic":
            appletcode = appletcode.replace(
                'activitypack" value="',
                'activitypack" value="%s/' % resources)

        if self.idevice.type == "geogebra":
            # according to self.port (config.py)
            appletcode = appletcode.replace('filename" value="',
                                            'filename" value="%s/' % resources)

        lb = "\n"  #Line breaks
        html = common.ideviceHeader(self, style, "preview")
        html += '<div class="iDevice_content">' + lb
        html += appletcode + lb
        html += '</div>' + lb
        html += common.ideviceFooter(self, style, "preview")

        return html
示例#5
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        lb = "\n" #Line breaks
        html = common.ideviceHeader(self, style, "preview")
        
        html += u'<input type="hidden" name="passrate" id="passrate-'+self.idevice.id+'" value="'+self.idevice.passRate+'" />'
        
        for element in self.questionElements:
            html += element.renderPreview()
        
        html += '<div class="block iDevice_buttons">'+lb
        html += '<p><input type="submit" name="submitScore" value="' + c_("SUBMIT ANSWERS")+'" /></p>'
        html += '</div>'+lb
        
        if not self.idevice.score == -1:
            message = c_("Your score is ") + unicode(self.idevice.score) + "%"
            html += '<script type="text/javascript">alert("'+ message+ '")</script>'

        self.idevice.score = -1   
        
        html += common.ideviceFooter(self, style, "preview")
        
        return html
示例#6
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        html = common.ideviceHeader(self, style, "view")
# JRJ: Si hay instrucciones añadimos un &nbsp;
# (if there are instructions let's add a &nbsp;)
        aux =self.instructionElement.renderView()
        
        if re.search(">[\n|\r|\t]*</div>", aux):
            html += aux
        else:
            html += aux + "&nbsp;"

#       html += self.instructionElement.renderPreview()
# JRJ: si es la última pregunta no añadimos br
# (if it's the last question we won't add br)        
        for element in self.questionElements:
            html += "<div class=\"question\">\n"
            html += element.renderQuestion(False)
        html += element.renderFeedbackView(False)
        html += element.renderNoscript(False)
        if element == self.questionElements[len(self.questionElements) - 1]:
            html += "</div>\n"
        else:
            html += "</div><div>&nbsp;</div>\n"
            
        html += common.ideviceFooter(self, style, "view")

        return html
示例#7
0
    def renderView(self, style, preview=False):
        """
        Returns an XHTML string for viewing this block
        """
        lb = "\n"  #Line breaks
        html = common.ideviceHeader(self, style, "view")
        html += '<form name="quizForm%s" id="quizForm%s" action="#" class="quiz-test-form">' % (
            self.idevice.id, self.idevice.id)
        html += lb
        html += u'<input type="hidden" name="passrate" id="passrate-' + self.idevice.id + '" value="' + self.idevice.passRate + '" />' + lb
        for element in self.questionElements:
            if preview:
                html += element.renderPreview()
            else:
                html += element.renderView()
        html += '<div class="block iDevice_buttons">' + lb
        html += '<p><input type="submit" name="submitB" value="' + c_(
            "SUBMIT ANSWERS") + '" /> ' + common.javaScriptIsRequired(
            ) + '</p>' + lb
        html += '</div>' + lb
        html += '<div id="quizFormScore' + self.id + '"></div>' + lb
        html += '</form>' + lb
        html += common.ideviceFooter(self, style, "view")

        return html
示例#8
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block during editing
     """
     html = common.ideviceHeader(self, style, "preview")
     html += self.renderViewContent()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#9
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block during editing
     """
     html = common.ideviceHeader(self, style, "preview")
     html += self.renderViewContent()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#10
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block, 
     i.e. when exported as a webpage or SCORM package
     """
     html = common.ideviceHeader(self, style, "view")
     html += self.renderViewContent()
     html += common.ideviceFooter(self, style, "view")
     return html
示例#11
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block during editing
     """
     html = common.ideviceHeader(self, style, "preview")
     for element in self.elements:
         html += element.renderPreview()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#12
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     log.debug("renderPreview")
     html = common.ideviceHeader(self, style, "preview")
     html += self.articleElement.renderPreview()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#13
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block, 
     i.e. when exported as a webpage or SCORM package
     """
     html = common.ideviceHeader(self, style, "view")
     html += self.renderViewContent()
     html += common.ideviceFooter(self, style, "view")
     return html
示例#14
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     html = common.ideviceHeader(self, style, "view")
     for element in self.questionElements:
         html += element.renderView()
     html += common.ideviceFooter(self, style, "view")
     return html    
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     html = common.ideviceHeader(self, style, "view")
     for element in self.questionElements:
         html += element.renderView()
     html += common.ideviceFooter(self, style, "view")
     return html    
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     log.debug("renderPreview")    
     html = common.ideviceHeader(self, style, "preview")
     html += self.articleElement.renderPreview() 
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#17
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block during editing
     """
     html = common.ideviceHeader(self, style, "preview")
     for element in self.elements:
         html += element.renderPreview()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#18
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     if hasattr(self.idevice, 'parent') and self.idevice.parent and not self.idevice.parent.edit:
         return u""
     html = common.ideviceHeader(self, style, "preview")
     html += self.contentElement.renderPreview()
     html += common.ideviceFooter(self, style, "preview")                
     return html
示例#19
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     #html  = u"<div class=\"iDevice "
     #html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n"
     html = common.ideviceHeader(self, style, "view")
     html += self._renderGame(False)
     html += common.ideviceFooter(self, style, "view")
     return html
示例#20
0
文件: sortblock.py 项目: RichDijk/eXe
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     # html  = u"<div class=\"iDevice "
     # html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n"
     html = common.ideviceHeader(self, style, "view")
     html += self._renderGame(False)
     html += common.ideviceFooter(self, style, "view")
     return html
示例#21
0
文件: rssblock.py 项目: Rafav/iteexe
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """        
     log.debug("renderView")
     content = self.rssElement.renderView()
     content = re.sub(r'src="/.*?/resources/', 'src="', content)
     html = common.ideviceHeader(self, style, "view")
     html += content
     html += common.ideviceFooter(self, style, "view")
     return html
示例#22
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     if hasattr(self.idevice, 'parent'
                ) and self.idevice.parent and not self.idevice.parent.edit:
         return u""
     html = common.ideviceHeader(self, style, "preview")
     html += self.contentElement.renderPreview()
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#23
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """        
     log.debug("renderView")
     html = common.ideviceHeader(self, style, "view")
     html += u"<div class=\"media\">"
     html += self.mediaElement.renderView()
     html += "</div>"
     html += self.textElement.renderView()
     html += common.ideviceFooter(self, style, "view")
     return html
示例#24
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     log.debug("renderView")
     html = common.ideviceHeader(self, style, "view")
     html += u"<div class=\"media\">"
     html += self.mediaElement.renderView()
     html += "</div>"
     html += self.textElement.renderView()
     html += common.ideviceFooter(self, style, "view")
     return html
示例#25
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        html = common.ideviceHeader(self, style, "preview")

        for element in self.questionElements:
            html += element.renderPreview("/images/panel-amusements.png","/images/stock-stop.png") 
            
        html += common.ideviceFooter(self, style, "preview")

        return html
示例#26
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        html = common.ideviceHeader(self, style, "preview")

        for element in self.questionElements:
            html += element.renderPreview("/images/panel-amusements.png",
                                          "/images/stock-stop.png")

        html += common.ideviceFooter(self, style, "preview")

        return html
示例#27
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     #html  = u"<div class=\"iDevice "
     #html += u"emphasis"+unicode(self.idevice.emphasis)+"\" "
     #html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n"
     html = common.ideviceHeader(self, style, "preview")
     html += self._renderGame(True)
     #html += self.renderViewButtons()
     #html += "</div>\n"
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#28
0
文件: sortblock.py 项目: RichDijk/eXe
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     # html  = u"<div class=\"iDevice "
     # html += u"emphasis"+unicode(self.idevice.emphasis)+"\" "
     # html += u"ondblclick=\"submitLink('edit',"+self.id+", 0);\">\n"
     html = common.ideviceHeader(self, style, "preview")
     html += self._renderGame(True)
     # html += self.renderViewButtons()
     # html += "</div>\n"
     html += common.ideviceFooter(self, style, "preview")
     return html
示例#29
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """
        html = common.ideviceHeader(self, style, "preview")
        html += self.instructionElement.renderPreview()

        for element in self.questionElements:
            html += element.renderQuestionPreview()
            html += element.renderFeedbackPreview()

        html += common.ideviceFooter(self, style, "preview")

        return html
示例#30
0
 def renderPreview(self, style):
     """
     Returns an XHTML string for previewing this block
     """
     html = common.ideviceHeader(self, style, "preview")
     
     aux = self.questionElements[len(self.questionElements) - 1]
     for element in self.questionElements:
         if element == aux:
             html += element.renderPreview()
         else:
             html += element.renderPreview() + "<br/>"
     
     html += common.ideviceFooter(self, style, "preview")
     return html
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """        
     log.debug("renderView")
     content = self.articleElement.renderView()
     # content = re.sub(r'src="resources/', 'src="', content)
     content = re.sub(r'src="http://127.0.0.1:\d+/newPackage.*/resources/', 'src="', content)
     content = re.sub(r'src="/newPackage.*/resources/', 'src="', content)
     content = re.sub(r'src=\'/newPackage.*/resources/', 'src="', content)
     content = re.sub(r'src=\"/newPackage.*/resources/', 'src="', content)
     html = common.ideviceHeader(self, style, "view")
     html += content        
     html += common.ideviceFooter(self, style, "view")
     return html
示例#32
0
 def renderView(self, style):
     """
     Returns an XHTML string for viewing this block
     """
     log.debug("renderView")
     content = self.articleElement.renderView()
     # content = re.sub(r'src="resources/', 'src="', content)
     content = re.sub(r'src="http://127.0.0.1:\d+/newPackage.*/resources/',
                      'src="', content)
     content = re.sub(r'src="/newPackage.*/resources/', 'src="', content)
     content = re.sub(r'src=\'/newPackage.*/resources/', 'src="', content)
     content = re.sub(r'src=\"/newPackage.*/resources/', 'src="', content)
     html = common.ideviceHeader(self, style, "view")
     html += content
     html += common.ideviceFooter(self, style, "view")
     return html
示例#33
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        html = common.ideviceHeader(self, style, "view")
        html += self.instructionElement.renderView()

        for element in self.questionElements:
            html += '<div class="question">\n'
            html += element.renderQuestionView()
            html += element.renderFeedbackView()
            html += "</div>\n"

        html += common.ideviceFooter(self, style, "view")

        return html
示例#34
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        
        html = common.ideviceHeader(self, style, "view")
        
        aux = self.questionElements[len(self.questionElements) - 1]
        for element in self.questionElements:
            if element == aux:
                html += element.renderView("panel-amusements.png","stock-stop.png")
            else:
                html += element.renderView("panel-amusements.png","stock-stop.png")  + "<br/>"        
            
        html += common.ideviceFooter(self, style, "view")

        return html
示例#35
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """

        lb = "\n"  #Line breaks
        dT = common.getExportDocType()
        figureTag = "div"
        if dT == "HTML5":
            figureTag = "figure"

        html = common.ideviceHeader(self, style, "view")

        html += '<div class="iDevice_content">' + lb
        html += '<' + figureTag + ' class="image_text" style="width:' + str(
            self.idevice.imageMagnifier.width
        ) + 'px;float:' + self.idevice.float + ';'
        if self.idevice.float == 'left':
            html += 'margin:0 20px 20px 0'
        if self.idevice.float == 'right':
            html += 'margin:0 0 20px 20px'
        html += '">'
        html += lb
        html += self.imageMagnifierElement.renderView()
        if self.idevice.caption != '':
            html = html.replace(
                ' alt="" ',
                ' alt="' + self.idevice.caption.replace('"', '&quot;') + '" ',
                1)
            if dT == "HTML5":
                html += '<figcaption style="font-weight:bold">' + self.idevice.caption + '</figcaption>' + lb
            else:
                html += '<strong>' + self.idevice.caption + '</strong>' + lb
        html += '</' + figureTag + '>' + lb
        text = self.textElement.renderView()
        if text:
            text = text.replace('"block iDevice_content"', '"iDevice_text"', 1)
            html += text
        else:
            html += '&nbsp;'
        html += '</div>' + lb  # /.iDevice_content

        html += common.ideviceFooter(self, style, "view")

        return html
示例#36
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """

        html = common.ideviceHeader(self, style, "view")

        aux = self.questionElements[len(self.questionElements) - 1]
        for element in self.questionElements:
            if element == aux:
                html += element.renderView("panel-amusements.png",
                                           "stock-stop.png")
            else:
                html += element.renderView("panel-amusements.png",
                                           "stock-stop.png") + "<br/>"

        html += common.ideviceFooter(self, style, "view")

        return html
示例#37
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        log.debug("renderView")
        appletcode = self.idevice.appletCode
        appletcode = appletcode.replace('&gt;', '>')
        appletcode = appletcode.replace('&lt;', '<')
        appletcode = appletcode.replace('&quot;', '"')
        appletcode = appletcode.replace('&nbsp;', '')
        appletcode = appletcode.replace('\xC2\x82', '&#130')

        lb = "\n"  #Line breaks
        html = common.ideviceHeader(self, style, "view")
        html += '<div class="iDevice_content">' + lb
        html += appletcode + lb
        html += '</div>' + lb
        html += common.ideviceFooter(self, style, "view")

        return html
示例#38
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """        
        log.debug("renderView")
        appletcode = self.idevice.appletCode
        appletcode = appletcode.replace('&gt;', '>')
        appletcode = appletcode.replace('&lt;', '<')
        appletcode = appletcode.replace('&quot;', '"')
        appletcode = appletcode.replace('&nbsp;', '')
        appletcode = appletcode.replace('\xC2\x82','&#130')
        
        lb = "\n" #Line breaks
        html = common.ideviceHeader(self, style, "view")
        html += '<div class="iDevice_content">'+lb
        html += appletcode+lb
        html += '</div>'+lb
        html += common.ideviceFooter(self, style, "view")

        return html
示例#39
0
    def renderView(self, style, preview=False):
        """
        Returns an XHTML string for viewing this block
        """
        lb = "\n" #Line breaks
        html = common.ideviceHeader(self, style, "view")
        html += '<form name="quizForm%s" id="quizForm%s" action="javascript:calcScore2();">' % (self.idevice.id, self.idevice.id)
        html += lb
        html += u'<input type="hidden" name="passrate" id="passrate-'+self.idevice.id+'" value="'+self.idevice.passRate+'" />'+lb
        for element in self.questionElements:
            if preview: 
                html += element.renderPreview()
            else:
                html += element.renderView()
        html += '<div class="block iDevice_buttons">'+lb
        html += '<p><input type="submit" name="submitB" value="' + c_("SUBMIT ANSWERS")+'" /> '+common.javaScriptIsRequired()+'</p>'+lb
        html += '</div>'+lb                
        html += '</form>'+lb
        html += common.ideviceFooter(self, style, "view")

        return html
示例#40
0
    def renderPreview(self, style):
        """
        Returns an XHTML string for previewing this block
        """

        lb = "\n" #Line breaks
        dT = common.getExportDocType()
        figureTag = "div"
        if dT == "HTML5":
            figureTag = "figure"         
        
        html = common.ideviceHeader(self, style, "preview")
        
        html += '<div class="iDevice_content">'+lb
        html += '<'+figureTag+' class="image_text" style="width:'+str(self.idevice.imageMagnifier.width)+'px;float:'+self.idevice.float+';'
        if self.idevice.float == 'left':
            html += 'margin:0 20px 20px 0'
        if self.idevice.float == 'right':
            html += 'margin:0 0 20px 20px'
        html += '">'+lb
        html += self.imageMagnifierElement.renderPreview()
        if self.idevice.caption != '':
            html = html.replace(' alt="" ',' alt="'+self.idevice.caption.replace('"','&quot;')+'" ', 1)
            if dT == "HTML5":
                html += '<figcaption style="font-weight:bold">'+self.idevice.caption+'</figcaption>'+lb
            else:
                html += '<strong>'+self.idevice.caption+'</strong>'+lb
        html += '</'+figureTag+'>'+lb 
        text = self.textElement.renderPreview()
        if text:
            text = text.replace('"block iDevice_content"', '"iDevice_text"', 1)
            html += text
        else:
            html += '&nbsp;'
        html += '</div>'+lb # /.iDevice_content
        
        html += common.ideviceFooter(self, style, "preview")

        return html
示例#41
0
    def renderView(self, style):
        """
        Returns an XHTML string for viewing this block
        """
        lb = "\n" #Line breaks
        dT = common.getExportDocType()
        sectionTag = "div"
        if dT == "HTML5":
            sectionTag = "section"
            
        html = common.ideviceHeader(self, style, "view")
        html += self.instructionElement.renderView()
        
        for element in self.questionElements:
            html += "<"+sectionTag+" class=\"question\">"+lb
            html += element.renderQuestionView()
            html += element.renderFeedbackView()
            html += "</"+sectionTag+">"+lb
            
        html += common.ideviceFooter(self, style, "view")

        return html
示例#42
0
    def _renderGame(self, style, mode="view"):
        previewMode = False
        resourcePath = ""
        if mode == "preview":
            previewMode = True
            resourcePath = "resources/"

        html = common.ideviceHeader(self, style, mode)

        html += \
        """
        <script src="%(resourcePath)sjquery-ui-1.10.3.custom.min.js" type="text/javascript"> </script>
        <script src="%(resourcePath)sclickinorder.js" type="text/javascript"> </script>

        <script type="text/javascript">
        var clickInOrderGame%(gameId)s = new ClickInOrder('%(gameId)s');
        """ % { 'gameId' : str(self.id), 'resourcePath': resourcePath }

        if self.questionOrderChoiceElement.renderView() == "1":
            html += "clickInOrderGame%(gameId)s.randomizeQuestions = true;\n" % {
                'gameId': str(self.id)
            }

        if self.timerChoiceElement.renderView() == "1":
            html += "clickInOrderGame%(gameId)s.timerMode = %(timerMode)s;\n" % \
                {"gameId" : str(self.id), "timerMode" : self.timerChoiceElement.renderView() }

        for clickableAreaElement in self.clickableAreaElements:
            hideDelayStr = clickableAreaElement.textElements[
                'hideDelay'].renderView()
            if len(hideDelayStr) < 1:
                hideDelayStr = "0"

            html += "clickInOrderGame%(gameId)s.addClickableArea(\"%(clickableId)s\", %(hideDelay)s, %(bounds)s);\n" \
              % {'gameId' : str(self.id), 'clickableId' : str(clickableAreaElement.id), \
              'hideDelay' : int(hideDelayStr),\
              'bounds' : "new Array(" + clickableAreaElement.textElements['left'].renderView() + "," \
                + clickableAreaElement.textElements['top'].renderView() + ","
                + clickableAreaElement.textElements['width'].renderView() + ","
                + clickableAreaElement.textElements['height'].renderView() +")"}

        html += "</script>\n"

        if previewMode == True:
            html += self.mainTextAreaElements['Instructions'].renderPreview()
        else:
            html += self.mainTextAreaElements['Instructions'].renderView()

        html += '<div id="clickableAreaGameCompleteFeedback' + self.id + '" style="position: absolute; z-index: 3">'

        if previewMode == True:
            html += self.mainTextAreaElements[
                'CompleteFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['CompleteFeedback'].renderView()
        html += "</div>"

        html += '<div id="clickableAreaPositiveFeedback' + self.id + '" style="position: absolute; z-index: 1">'

        if previewMode == True:
            html += self.mainTextAreaElements[
                'PositiveFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['PositiveFeedback'].renderView()
        html += "</div>"

        html += '<div id="clickableAreaNegativeFeedback' + self.id + '" style="position: absolute; z-index: 2">'

        if previewMode == True:
            html += self.mainTextAreaElements[
                'NegativeFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['NegativeFeedback'].renderView()

        html += "</div>"

        if self.timerChoiceElement.renderView() == "1":
            html += '<input id="clickinordertimer' + self.id + '" style="' + \
                self.mainTextElements['timerStyle'].renderView() + ' "/>\n'

        for clickableAreaElement in self.clickableAreaElements:
            posStyleTopLeft = "position: absolute; margin-left: %(left)spx; margin-top: %(top)spx; z-index: 2; " \
                % { 'left' : clickableAreaElement.textElements['left'].renderView(), \
                'top' : clickableAreaElement.textElements['top'].renderView() }

            posStyleWidthHeight = "height: %(height)spx; width: %(width)spx; " % \
                { 'width' : clickableAreaElement.textElements['width'].renderView(), \
                  'height' : clickableAreaElement.textElements['height'].renderView() }

            divDictArgs = { 'gameId' : str(self.id), \
                        'clickableAreaId' : str(clickableAreaElement.id), \
                        'posStyle' : posStyleTopLeft, \
                        'posStyleWH' : posStyleWidthHeight }
            html += """<div id="clickableArea_%(gameId)s_%(clickableAreaId)s" style="%(posStyle)s %(posStyleWH)s "  
                    onclick="clickInOrderGame%(gameId)s.checkClick(\'%(clickableAreaId)s\')"> </div>""" \
                        % divDictArgs
            html += '<div id="clickableAreaShowMe_%(gameId)s_%(clickableAreaId)s" style="%(posStyle)s">' \
                        % divDictArgs
            if previewMode == True:
                html += clickableAreaElement.textAreaElements[
                    'ShowMe'].renderPreview()
            else:
                html += clickableAreaElement.textAreaElements[
                    'ShowMe'].renderView()
            html += '</div>'

        #the click to start area
        gameSizeArgs = { 'gameId' : str(self.id), \
                'width' : self.mainTextElements['width'].renderView() ,\
                'height' : self.mainTextElements['height'].renderView()}

        html += """<div id=\"clickinordercontainer%(gameId)s\" style=\"width: %(width)spx; height: %(height)spx; overflow: hidden;\" 
                 >""" \
                % gameSizeArgs
        html += """<div id="clickinorderstartarea%(gameId)s\" onclick="clickInOrderGame%(gameId)s.startGame()"  
                style=\"width: %(width)spx; height: %(height)spx; position: absolute;\">""" \
                % gameSizeArgs
        if previewMode == True:
            html += self.mainTextAreaElements[
                'ClickToStartArea'].renderPreview()
        else:
            html += self.mainTextAreaElements['ClickToStartArea'].renderView()
        html += "</div>"

        #the main area
        html += """<div id="clickinordermainarea%(gameId)s" onclick="clickInOrderGame%(gameId)s.validateClick" 
                style=\"width: %(width)spx; height: %(height)spx; position: absolute;\">""" \
                % gameSizeArgs

        if previewMode == True:
            html += self.mainTextAreaElements['MainArea'].renderPreview()
        else:
            html += self.mainTextAreaElements['MainArea'].renderView()

        html += "</div>"

        html += "</div>"
        #the hints
        html += "<div id=\"clickInOrderHints" + self.id + "\" style=\"" \
                + "width: " + self.mainTextElements['hintWidth'].renderView() + "px; " \
                + "height: " + self.mainTextElements['hintHeight'].renderView() + "px; " \
                + self.mainTextElements['hintAreaStyle'].renderView() + "\">\n"

        for clickableAreaElement in self.clickableAreaElements:
            html += "<div id=\"clickableAreaInstruction_%(gameId)s_%(clickableAreaId)s\" style=\"position: absolute\">" \
                        % { 'gameId' : str(self.id), 'clickableAreaId' : str(clickableAreaElement.id) }
            if previewMode == True:
                html += clickableAreaElement.textAreaElements[
                    'Hint'].renderPreview()
            else:
                html += clickableAreaElement.textAreaElements[
                    'Hint'].renderView()

            html += "</div>\n"

        html += "</div>"

        html += '<input id="clickinordercounter' + self.id + '" style="' + \
                self.mainTextElements['elementCounterStyle'].renderView() +' " value="1"/>\n'

        html += "<script type=\"text/javascript\">clickInOrderGame%(gameId)s.init();</script>\n" % {
            'gameId': str(self.id)
        }

        html += common.ideviceFooter(self, style, mode)

        return html
 def renderView(self, style):
     html = common.ideviceHeader(self, style, "view")
     html += self.renderHTML()
     html += common.ideviceFooter(self, style, "view")
     return html
 def renderPreview(self, style):
     html = common.ideviceHeader(self, style, "preview")
     html += self.renderHTML(preview_mode = True)
     html += common.ideviceFooter(self, style, "preview")
     return html
 def renderView(self, style):
     html = common.ideviceHeader(self, style, "view")
     html += self.content_element.renderPreview()
     html += common.ideviceFooter(self, style, "view")
     
     return html
示例#46
0
    def _renderForGame(self, style, previewMode = False):
        """
        Renders the block as the script and XHTML elements that will be needed in order
        to make this run as a game
        """
        viewModeStr = "view"
        scriptPrefix = ""
        if previewMode == True:
            scriptPrefix = "resources/"
            viewModeStr = "preview"

        html = "<script src='%sjquery-ui-1.10.3.custom.min.js' type='text/javascript'></script>\n" % scriptPrefix
        html += "<script src='%splacetheobjects.js' type='text/javascript'></script>\n" % scriptPrefix
        
        html += common.ideviceHeader(self, style, viewModeStr)
        
        #this shows the instructions
        html += self.contentElement.renderView()

        """
        Here we make the droppable target divs
        """
        for placeableObjectElement in self.placableObjectElements:
            borderStr = ""
            if previewMode == True:
                borderStr = "border: 1px solid red;"
            tolerance = int(placeableObjectElement.toleranceElement.renderView())

            html += """<div id='%(droppableid)s' class='placeTheObjectTargetClass%(gameId)s' style='position: absolute; 
                        margin-left: %(marginleft)dpx; margin-top: %(margintop)dpx;
                        width: %(width)dpx; height: %(height)dpx; %(borderstr)s '>
                        </div>
                """ % { "droppableid" : self._makeObjectDivId("droppable", placeableObjectElement), \
                        "marginleft" : int(placeableObjectElement.targetXElement.renderView()) - tolerance, \
                        "margintop" : int(placeableObjectElement.targetYElement.renderView()) - tolerance, \
                        "width": int(placeableObjectElement.widthElement.renderView()) + (tolerance * 2), \
                        "height": int(placeableObjectElement.heightElement.renderView()) + (tolerance * 2), \
                        "borderstr": borderStr, "gameId" : str(self.id) }

        """+ve/-ve feedback areas"""
        html += "<div id='placetheobjects_" + self.id +"_positivefeedback'" \
                +" style='position: absolute; z-index: 1; '>"
        if previewMode == True:
            html += self.positiveResponseElement.renderPreview()
        else:
            html += self.positiveResponseElement.renderView()
        html += "</div>"

        
        html += "<div id='placetheobjects_" + self.id + "_negativefeedback' " \
                + "style='position: absolute; z-index: 1;'>" 
        if previewMode == True:
            html += self.negativeResponseElement.renderPreview()
        else:
            html += self.negativeResponseElement.renderView()
        html += "</div>"

        """What to click to start the game"""
        html += "<div id='placetheobjects_" + self.id + "_clicktostart' style='position: " \
                + "absolute; cursor: pointer; z-index: 3' onclick='startPlaceGame(\"" + self.id + "\")'>"
        if previewMode == True:
            html += self.clickToStartElement.renderPreview()
        else:
            html += self.clickToStartElement.renderView()
        html += "</div>"



        """
        This is the main area background where the elements are going to be dropped...
        """
        html += "<div style='z-index: -4;' id='placetheobjects_" + self.id + "_main'>"
        if previewMode == True:
            html += self.mainAreaElement.renderPreview()
        else:
            html += self.mainAreaElement.renderView()

        html += "</div>"
        """
        Here we make the part bin that will contain the elements that will be dragged 
        and dropped in place
        """

        html += "<div id='placetheobjects" + self.id + "_partbin'>\n"
        html += "<table cellpadding='2' cellspacing='2'>"
        numCols = int(self.partbinNumCols.renderView())
        html += "<!-- num cols = " + str(numCols) + "-->"
        colCount = 0
        elementCount = 0

        for placeableObjectElement in self.placableObjectElements:
            if elementCount % numCols == 0:
                #we need to make a new row...
                if elementCount > 0:
                    html += "</tr>"
                html += "<tr>"
                
            idname = self._makeObjectDivId("draggable", placeableObjectElement)
            elementDimensions = {"width" : int(placeableObjectElement.widthElement.renderView()), \
                "height" : int(placeableObjectElement.heightElement.renderView()) }
            html += "<td style='width: %(width)dpx; height: $(height)spx;'>"
            html += "<div id='" + idname + "' onclick=\"objectPlacePickupElement('%(gameid)s', '%(draggableid)s')\" style='cursor: pointer;  " \
                % {"gameid" : str(self.id), "draggableid" : idname}
            html += "width: %(width)dpx; height: %(height)dpx; overflow: hidden; z-index: 1;'>\n" \
                % elementDimensions
            html += placeableObjectElement.mainContentElement.renderView()
            html += "</div>\n"
            html += "</td>"
            elementCount += 1

        html += "</tr></table>"        
        html += "</div>\n"

        html += "<!-- Javascript Code Generated by placetheobjectsblock.py - DO NOT MODIFY -->\n"
        html += "<script type='text/javascript'>\n"
        html +="initPlaceTheObjectsGameData('" + self.id + "');\n"
        html += "placeTheObjectsGameData['" + self.id + "']['showtimer'] = '" + str(self.gameTimerShown.field.content) + "';\n"
        html += "placeTheObjectsGameData['" + self.id + "']['timelimit'] = '" + str(self.gameTimeLimit.field.content) + "';\n"

        for placeableObjectElement in self.placableObjectElements:
            draggable_id = self._makeObjectDivId("draggable", placeableObjectElement)
            droppable_id = self._makeObjectDivId("droppable", placeableObjectElement)

            perItemCode = """
                if(exe_isTouchScreenDev == false) {
                    $(function() {
                    $("#%(draggableid)s").draggable({ 
                            revert : 'invalid',
                            start: function(event, ui) {
                                    placeObjectReadyTarget("%(droppableid)s");
                            },
                            stop: function (event, ui) {
                                    placeObjectHideTarget("%(droppableid)s");
                                    setTimeout('checkObjectPlaceOK("%(gameId)s", "%(draggableid)s")', 300);
                            }
                            }
                    );
                    $("#%(droppableid)s").droppable({
                    accept: "#%(draggableid)s",
                    activeClass: "ui-state-hover",
                    hoverClass: "ui-state-active",
                            drop: function(event, ui) {
                                    $("#%(draggableid)s").effect("pulsate", {}, "fast");
                                    objectPlaceOK("%(gameId)s", "%(draggableid)s");
                            }
                            });
                    });
                    document.getElementById("%(draggableid)s").onclick = null;   
                }
                
                placeTheObjectsGameData['%(gameId)s']['elements']['%(draggableid)s'] = new Array();
                placeTheObjectsGameData['%(gameId)s']['elements']['%(draggableid)s']['status'] = 'notplaced';
                placeTheObjectsGameData['%(gameId)s']['elements']['%(draggableid)s']['bounds'] = new Array(%(targetx)s, %(targety)s, %(width)s, %(height)s ); 
                               
                """ % { "draggableid" : draggable_id, "droppableid" : droppable_id, "gameId" : str(self.id), \
                "targetx": placeableObjectElement.targetXElement.renderView() , "targety" : placeableObjectElement.targetYElement.renderView(),\
                "width" : placeableObjectElement.widthElement.renderView(),  "height" : placeableObjectElement.heightElement.renderView() }
            html += perItemCode

        html += "</script>\n"
        html += common.ideviceFooter(self, style, viewModeStr)
        return html
示例#47
0
    def _renderGame(self, style, mode="view"):
        previewMode = False
        resourcePath = ""
        if mode == "preview":
            previewMode = True
            resourcePath = "resources/"

        html = common.ideviceHeader(self, style, mode)
        
        html += \
        """
        <script src="%(resourcePath)sjquery-ui-1.10.3.custom.min.js" type="text/javascript"> </script>
        <script src="%(resourcePath)sclickinorder.js" type="text/javascript"> </script>

        <script type="text/javascript">
        var clickInOrderGame%(gameId)s = new ClickInOrder('%(gameId)s');
        """ % { 'gameId' : str(self.id), 'resourcePath': resourcePath }
        
        if self.questionOrderChoiceElement.renderView() == "1":
            html += "clickInOrderGame%(gameId)s.randomizeQuestions = true;\n" % { 'gameId' : str(self.id) }
        
        if self.timerChoiceElement.renderView() == "1":
            html += "clickInOrderGame%(gameId)s.timerMode = %(timerMode)s;\n" % \
                {"gameId" : str(self.id), "timerMode" : self.timerChoiceElement.renderView() }

        for clickableAreaElement in self.clickableAreaElements:
            hideDelayStr = clickableAreaElement.textElements['hideDelay'].renderView()
            if len(hideDelayStr) < 1:
                hideDelayStr = "0"
                
            html += "clickInOrderGame%(gameId)s.addClickableArea(\"%(clickableId)s\", %(hideDelay)s, %(bounds)s);\n" \
              % {'gameId' : str(self.id), 'clickableId' : str(clickableAreaElement.id), \
              'hideDelay' : int(hideDelayStr),\
              'bounds' : "new Array(" + clickableAreaElement.textElements['left'].renderView() + "," \
                + clickableAreaElement.textElements['top'].renderView() + ","
                + clickableAreaElement.textElements['width'].renderView() + ","
                + clickableAreaElement.textElements['height'].renderView() +")"}
                
        
        html += "</script>\n"
        

        if previewMode == True:
            html += self.mainTextAreaElements['Instructions'].renderPreview()
        else:
            html += self.mainTextAreaElements['Instructions'].renderView()

        html += '<div id="clickableAreaGameCompleteFeedback' + self.id + '" style="position: absolute; z-index: 3">'
        
        if previewMode == True:
            html +=self.mainTextAreaElements['CompleteFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['CompleteFeedback'].renderView()
        html += "</div>"

        html += '<div id="clickableAreaPositiveFeedback' + self.id +'" style="position: absolute; z-index: 1">'
        
        if previewMode == True:
            html += self.mainTextAreaElements['PositiveFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['PositiveFeedback'].renderView()
        html += "</div>"

        html += '<div id="clickableAreaNegativeFeedback' + self.id +'" style="position: absolute; z-index: 2">'
        
        if previewMode == True:
            html += self.mainTextAreaElements['NegativeFeedback'].renderPreview()
        else:
            html += self.mainTextAreaElements['NegativeFeedback'].renderView()
        
        html += "</div>"


        
        if self.timerChoiceElement.renderView() == "1":        
            html += '<input id="clickinordertimer' + self.id + '" style="' + \
                self.mainTextElements['timerStyle'].renderView() + ' "/>\n'

        for clickableAreaElement in self.clickableAreaElements:
            posStyleTopLeft = "position: absolute; margin-left: %(left)spx; margin-top: %(top)spx; z-index: 2; " \
                % { 'left' : clickableAreaElement.textElements['left'].renderView(), \
                'top' : clickableAreaElement.textElements['top'].renderView() }

            posStyleWidthHeight = "height: %(height)spx; width: %(width)spx; " % \
                { 'width' : clickableAreaElement.textElements['width'].renderView(), \
                  'height' : clickableAreaElement.textElements['height'].renderView() }
                
            divDictArgs = { 'gameId' : str(self.id), \
                        'clickableAreaId' : str(clickableAreaElement.id), \
                        'posStyle' : posStyleTopLeft, \
                        'posStyleWH' : posStyleWidthHeight }
            html += """<div id="clickableArea_%(gameId)s_%(clickableAreaId)s" style="%(posStyle)s %(posStyleWH)s "  
                    onclick="clickInOrderGame%(gameId)s.checkClick(\'%(clickableAreaId)s\')"> </div>""" \
                        % divDictArgs
            html += '<div id="clickableAreaShowMe_%(gameId)s_%(clickableAreaId)s" style="%(posStyle)s">' \
                        % divDictArgs
            if previewMode == True:
                html += clickableAreaElement.textAreaElements['ShowMe'].renderPreview()
            else:
                html += clickableAreaElement.textAreaElements['ShowMe'].renderView()
            html += '</div>'
            

        #the click to start area
        gameSizeArgs = { 'gameId' : str(self.id), \
                'width' : self.mainTextElements['width'].renderView() ,\
                'height' : self.mainTextElements['height'].renderView()}

        html += """<div id=\"clickinordercontainer%(gameId)s\" style=\"width: %(width)spx; height: %(height)spx; overflow: hidden;\" 
                 >""" \
                % gameSizeArgs
        html += """<div id="clickinorderstartarea%(gameId)s\" onclick="clickInOrderGame%(gameId)s.startGame()"  
                style=\"width: %(width)spx; height: %(height)spx; position: absolute;\">""" \
                % gameSizeArgs
        if previewMode == True:
            html += self.mainTextAreaElements['ClickToStartArea'].renderPreview()
        else:
            html += self.mainTextAreaElements['ClickToStartArea'].renderView()
        html += "</div>"
        
        #the main area
        html += """<div id="clickinordermainarea%(gameId)s" onclick="clickInOrderGame%(gameId)s.validateClick" 
                style=\"width: %(width)spx; height: %(height)spx; position: absolute;\">""" \
                % gameSizeArgs

        if previewMode == True:
            html += self.mainTextAreaElements['MainArea'].renderPreview()
        else:
            html += self.mainTextAreaElements['MainArea'].renderView()
            
        html += "</div>"

        html += "</div>"
        #the hints
        html += "<div id=\"clickInOrderHints" + self.id + "\" style=\"" \
                + "width: " + self.mainTextElements['hintWidth'].renderView() + "px; " \
                + "height: " + self.mainTextElements['hintHeight'].renderView() + "px; " \
                + self.mainTextElements['hintAreaStyle'].renderView() + "\">\n"
        
        for clickableAreaElement in self.clickableAreaElements:
            html += "<div id=\"clickableAreaInstruction_%(gameId)s_%(clickableAreaId)s\" style=\"position: absolute\">" \
                        % { 'gameId' : str(self.id), 'clickableAreaId' : str(clickableAreaElement.id) }
            if previewMode == True:
                html += clickableAreaElement.textAreaElements['Hint'].renderPreview()
            else:
                html += clickableAreaElement.textAreaElements['Hint'].renderView()
                
            html += "</div>\n"

        html += "</div>"
        
        html += '<input id="clickinordercounter' + self.id + '" style="' + \
                self.mainTextElements['elementCounterStyle'].renderView() +' " value="1"/>\n'
        
        html += "<script type=\"text/javascript\">clickInOrderGame%(gameId)s.init();</script>\n" % { 'gameId': str(self.id) }
        
        html += common.ideviceFooter(self, style, mode)
        
        return html