def renderViewContent(self): """ Returns an XHTML string for this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Click here"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Hide"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() html += "</div>\n" html += "</div>\n" return html
def doRender(self, preview=False): """ Returns an XHTML string for viewing and previewing this question element depending on the value of 'preview'. """ log.debug("renderView called") if preview: html = self.question_question.renderPreview() else: html = self.question_question.renderView() if self.question_feedback.field.content != "" : html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton('btnshow' + self.id, _(u"Show Feedback"), onclick = "showAnswer('%s',1)" % self.id) html += '</div>' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton('btnhide' + self.id, _(u"Hide Feedback"), onclick = "showAnswer('%s',0)" % self.id) html += '<p>' html += '</p>' html += '</div>' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if preview: html += self.question_feedback.renderPreview() else: html += self.question_feedback.renderView() html += "</div><br/>\n" else: html += "<br/>\n" return html
def doRender(self, preview=False): """ Returns an XHTML string for viewing and previewing this question element depending on the value of 'preview'. """ log.debug("renderView called") if preview: html = self.question_question.renderPreview() else: html = self.question_question.renderView() if self.question_feedback.field.content.strip() != "" : html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton('btnshow' + self.id, _(u"Show Feedback"), onclick = "showAnswer('%s',1)" % self.id) html += '</div>' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton('btnhide' + self.id, _(u"Hide Feedback"), onclick = "showAnswer('%s',0)" % self.id) html += '<p>' html += '</p>' html += '</div>' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if preview: html += self.question_feedback.renderPreview() else: html += self.question_feedback.renderView() html += "</div>\n" # JR: Generamos el contenido que ira dentro de la etiqueta noscript html += '<noscript><div class="feedback">\n' html += "<p><strong>" + _("Solucion") + ": </strong></p>\n" if preview: html += self.question_feedback.field.content_w_resourcePaths else: html += self.question_feedback.field.content_wo_resourcePaths html += "</div></noscript>\n" else: html += "\n" return html
def renderViewContent(self): """ Returns an XHTML string for this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow" + self.id, _(u"Click here"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow" + self.id, _(u"Hide"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() html += "</div>\n" # JR: Generamos el contenido que ira dentro de la etiqueta noscript html += '<noscript><br/><div class="feedback">\n' html += "<p><strong>" + _("Retroalimentacion") + ": </strong></p>\n" if self.previewing: html += self.answerElement.field.content_w_resourcePaths else: html += self.answerElement.field.content_wo_resourcePaths html += "</div></noscript>\n" html += "</div>\n" return html
def doRender(self, preview=False): """ Returns an XHTML string for viewing and previewing this question element depending on the value of 'preview'. """ log.debug("renderView called") if preview: html = self.question_question.renderPreview() else: html = self.question_question.renderView() if self.question_feedback.field.content.strip() != "": html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton('btnshow' + self.id, _(u"Show Feedback"), onclick="showAnswer('%s',1)" % self.id) html += '</div>' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton('btnhide' + self.id, _(u"Hide Feedback"), onclick="showAnswer('%s',0)" % self.id) html += '<p>' html += '</p>' html += '</div>' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if preview: html += self.question_feedback.renderPreview() else: html += self.question_feedback.renderView() html += "</div><br/>\n" else: html += "<br/>\n" return html
def renderViewContent(self): """ Returns an XHTML string for this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow" + self.id, _(u"Show Feedback"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow" + self.id, _(u"Hide Feedback"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() #added lernmodule.net htmplus = '<div class="Reflection" id="Reflection%s">' % (self.id) htmplus += '<textarea id="ReflectionText%s" class="ReflectionText" name="ReflectionText%s"' % ( self.id, self.id) htmplus += ' rows=5 style="width:99%"></textarea></div><div id="view' html = html.replace("<div id=\"view", htmplus, 1) html += "</div>\n" html += "</div>\n" return html
def renderViewContent(self): """ Returns an XHTML string for this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Click here"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Hide"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() html += "</div>\n" # JR: Generamos el contenido que ira dentro de la etiqueta noscript html += '<noscript><br/><div class="feedback">\n' html += "<p><strong>" + _("Retroalimentacion") + ": </strong></p>\n" if self.previewing: html += self.answerElement.field.content_w_resourcePaths else: html += self.answerElement.field.content_wo_resourcePaths html += "</div></noscript>\n" html += "</div>\n" return html
def renderView(self): """ Returns an XHTML string for viewing and previewing this question element """ log.debug("renderView called") html = self.question.question if self.question.feedback <> "": html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton('btnshow' + self.id, _(u"Click Here"), onclick = "showAnswer('%s',1)" % self.id) html += '</div>' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton('btnhide' + self.id, _(u"Hide"), onclick = "showAnswer('%s',0)" % self.id) html += '</div>' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' html += self.question.feedback html += "</div><br/>\n" return html
def renderViewContent(self): """ Returns an XHTML string for this block """ html = u'<script type="text/javascript" src="common.js"></script>\n' html += u'<div class="iDevice_inner">\n' if self.previewing: html += self.activityElement.renderPreview() else: html += self.activityElement.renderView() html += '<div id="view%s" style="display:block;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Show Feedback"), onclick="showAnswer('%s',1)" % self.id) html += '</div>\n' html += '<div id="hide%s" style="display:none;">' % self.id html += common.feedbackButton("btnshow"+self.id, _(u"Hide Feedback"), onclick="showAnswer('%s',0)" % self.id) html += '</div>\n' html += '<div id="s%s" class="feedback" style=" ' % self.id html += 'display: none;">' if self.previewing: html += self.answerElement.renderPreview() else: html += self.answerElement.renderView() #added lernmodule.net htmplus = '<div class="Reflection" id="Reflection%s">' % (self.id) htmplus += '<textarea id="ReflectionText%s" class="ReflectionText" name="ReflectionText%s"' % (self.id, self.id) htmplus += ' rows=5 style="width:99%"></textarea></div><div id="view' html = html.replace("<div id=\"view",htmplus,1) html += "</div>\n" html += "</div>\n" return html
def renderView(self): """ Returns an XHTML string for viewing or previewing this element """ html = "" if self.field.feedback != "": html += '<div class="block">\n ' html += common.feedbackButton('btn' + self.id, self.field.buttonCaption, onclick="toggleFeedback('%s')" % self.id) html += '</div>\n ' html += '<div id="fb%s" class="feedback" style="display: none;"> ' % self.id html += self.field.feedback html += "</div>\n" return html
def renderView(self, feedbackId=None): """ Shows the text with inputs for the missing parts """ html = ['<div id="cloze%s">' % self.id] def storeValue(name): value = str(bool(getattr(self.field, name))).lower() return common.hiddenField('clozeFlag%s.%s' % (self.id, name), value) html.append(storeValue('strictMarking')) html.append(storeValue('checkCaps')) html.append(storeValue('instantMarking')) if feedbackId: html.append(common.hiddenField('clozeVar%s.feedbackId' % self.id, 'ta'+feedbackId)) words = "" def encrypt(word): """ Simple XOR encryptions """ result = '' key = 'X' for letter in word: result += unichr(ord(key) ^ ord(letter)) key = letter output = '' for char in result: output += '%%u%04x' % ord(char[0]) return output.encode('base64') for i, (text, missingWord) in enumerate(self.field.parts): if text: html.append(text) if missingWord: words += "'" + missingWord + "'," inputHtml = [ ' <input type="text" value="" ', ' id="clozeBlank%s.%s"' % (self.id, i), ' autocomplete="off"', ' style="width:%sem"/>\n' % len(missingWord)] if self.field.instantMarking: inputHtml.insert(2, ' onKeyUp="onClozeChange(this)"') html += inputHtml html += [ '<span style="display: none;" ', 'id="clozeAnswer%s.%s">%s</span>' % ( self.id, i, encrypt(missingWord))] html += ['<p id="clozeScore%s"></p>' % self.id] html += ['<div class="block">\n'] if self.field.instantMarking: html += ['<input type="button" ', 'value="%s"' % _(u"Get score"), 'id="getScore%s"' % self.id, 'onclick="showClozeScore(\'%s\')"/>\n' % (self.id)] if feedbackId is not None: html += [common.feedbackButton('feedback'+self.id, _(u"Show/Hide Feedback"), style="margin: 0;", onclick="toggleClozeFeedback('%s')" % self.id)] style = 'display: inline;' value = _(u"Show/Clear Answers") onclick = "toggleClozeAnswers('%s')" % self.id else: html += [common.button('submit%s' % self.id, _(u"Submit"), id='submit%s' % self.id, onclick="clozeSubmit('%s')" % self.id), common.button( 'restart%s' % self.id, _(u"Restart"), id='restart%s' % self.id, style="display: none;", onclick="clozeRestart('%s')" % self.id), ] style = 'display: none;' value = _(u"Show Answers") onclick = "fillClozeInputs('%s')" % self.id html += [' ', common.button( '%sshowAnswersButton' % self.id, value, id='showAnswersButton%s' % self.id, style=style, onclick=onclick), ] html += ['</div>\n'] return '\n'.join(html) + '</div>'
def renderView(self, feedbackId=None, preview=False): # Shows the text with inputs for the missing parts dT = common.getExportDocType() sectionTag = "div" if dT == "HTML5": sectionTag = "section" html = ['<%s class="activity" id="activity-%s">' % (sectionTag,self.id)] if preview: # to render, use the content with the preview-able resource paths: self.field.encodedContent = self.field.content_w_resourcePaths html += ['<div class="activity-form">'] else: # to render, use the flattened content, withOUT resource paths: self.field.encodedContent = self.field.content_wo_resourcePaths html += ['<form name="cloze-form-'+self.id+'" action="#" onsubmit="showClozeScore(\''+self.id+'\',1);return false" class="activity-form">'] html += ['<div id="cloze%s">' % self.id] html += ['<script type="text/javascript">var YOUR_SCORE_IS="%s"</script>' % c_('Your score is ')] # Store our args in some hidden fields def storeValue(name): value = str(bool(getattr(self.field, name))).lower() return common.hiddenField('clozeFlag%s.%s' % (self.id, name), value) #html.append(storeValue('showScore')) if feedbackId: html.append(common.hiddenField('clozeVar%s.feedbackId' % self.id,'ta'+feedbackId)) # Mix the parts together words = "" wordslista='<option selected="selected"> </option>' wordsarray=[] listaotras=[] listaotras2=[] wordsarraylimpo=[] for i, (text, missingWord) in enumerate(self.field.parts): if missingWord: wordsarray.append([missingWord]) listaotras=re.compile(",|\|").split(self.field.otras) for i, (missingWord) in enumerate(listaotras): if missingWord: listaotras2.append([missingWord]) wordsarray=wordsarray + listaotras2 wordsarraylimpo= [wordsarray[i] for i in range(len(wordsarray)) if wordsarray[i] not in wordsarray[:i]] random.shuffle(wordsarraylimpo) for wdlista in wordsarraylimpo: wordslista +='<option value="%s">%s</option>' % (escape(wdlista[0], True), wdlista[0]) for i, (text, missingWord) in enumerate(self.field.parts): if text: html.append(text) if missingWord: words += "'" + missingWord + "'," # The edit box for the user to type into inputHtml = ['<label for="clozeBlank%s.%s" class="sr-av">%s (%s):</label>' % (self.id, i, c_("Cloze"), (i+1))] inputHtml += ['<select id="clozeBlank%s.%s">' % (self.id, i),wordslista,'</select>'] html += inputHtml # Hidden span with correct answer html += ['<span style="display:none" id="clozeAnswer%s.%s">%s</span>' % (self.id, i, self.ecrypt(missingWord))] # Score string html += ['<div class="block iDevice_buttons">'] html += ['<p>'] if preview: html += [common.button('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id, onclick="showClozeScore('%s',1)" % self.id)] else: html += [common.submitButton('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id)] if feedbackId: html += [common.feedbackButton('feedback%s' % self.id, c_(u"Show Feedback"), onclick = "toggleClozeFeedback('%s',this)" % self.id)] codotras=self.ecrypt(self.field.otras) html += [common.hiddenField('clozeOtras%s' % self.id,codotras)] html += ['<input type="hidden" name="clozeFlag%s.strictMarking" id="clozeFlag%s.strictMarking" value="false" />' % (self.id,self.id)] html += ['<input type="hidden" name="clozeFlag%s.checkCaps" id="clozeFlag%s.checkCaps" value="false" />' % (self.id,self.id)] html += ['<input type="hidden" name="clozeFlag%s.instantMarking" id="clozeFlag%s.instantMarking" value="false" />' % (self.id,self.id)] html += [common.javaScriptIsRequired()] html += ['</p>'] html += ['</div>'] html += ['<div class="score js-feedback" id="clozeScore%s"></div>' % self.id] html += ['</div>'] if preview: html += ['</div>'] else: html += ['</form>'] html += ['</%s>' % sectionTag] return '\n'.join(html)
def renderView(self, feedbackId=None, preview=False): # Shows the text with inputs for the missing parts dT = common.getExportDocType() sectionTag = "div" if dT == "HTML5": sectionTag = "section" html = ['<%s class="activity" id="activity-%s">' % (sectionTag,self.id)] if preview: # to render, use the content with the preview-able resource paths: self.field.encodedContent = self.field.content_w_resourcePaths html += ['<div class="activity-form">'] else: # to render, use the flattened content, withOUT resource paths: self.field.encodedContent = self.field.content_wo_resourcePaths html += ['<form name="cloze-form-'+self.id+'" action="#" onsubmit="showClozeScore(\''+self.id+'\',1);return false" class="activity-form">'] html += ['<div id="cloze%s">' % self.id] html += ['<script type="text/javascript">var YOUR_SCORE_IS="%s"</script>' % c_('Your score is ')] # Store our args in some hidden fields def storeValue(name): value = str(bool(getattr(self.field, name))).lower() return common.hiddenField('clozeFlag%s.%s' % (self.id, name), value) #html.append(storeValue('showScore')) if feedbackId: html.append(common.hiddenField('clozeVar%s.feedbackId' % self.id,'ta'+feedbackId)) # Mix the parts together words = "" wordslista='<option selected="selected"> </option>' wordsarray=[] listaotras=[] listaotras2=[] wordsarraylimpo=[] for i, (text, missingWord) in enumerate(self.field.parts): if missingWord: wordsarray.append([missingWord]) listaotras=self.field.otras.split('|') for i, (missingWord) in enumerate(listaotras): if missingWord: listaotras2.append([missingWord]) wordsarray=wordsarray + listaotras2 wordsarraylimpo= [wordsarray[i] for i in range(len(wordsarray)) if wordsarray[i] not in wordsarray[:i]] random.shuffle(wordsarraylimpo) for wdlista in wordsarraylimpo: wordslista +='<option value="%s">%s</option>' %(wdlista[0], wdlista[0]) for i, (text, missingWord) in enumerate(self.field.parts): if text: html.append(text) if missingWord: words += "'" + missingWord + "'," # The edit box for the user to type into inputHtml = ['<label for="clozeBlank%s.%s" class="sr-av">%s (%s):</label>' % (self.id, i, c_("Cloze"), (i+1))] inputHtml += ['<select id="clozeBlank%s.%s">' % (self.id, i),wordslista,'</select>'] html += inputHtml # Hidden span with correct answer html += ['<span style="display:none" id="clozeAnswer%s.%s">%s</span>' % (self.id, i, self.ecrypt(missingWord))] # Score string html += ['<div class="block iDevice_buttons">'] html += ['<p>'] if preview: html += [common.button('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id, onclick="showClozeScore('%s',1)" % self.id)] else: html += [common.submitButton('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id)] if feedbackId: html += [common.feedbackButton('feedback%s' % self.id, c_(u"Show Feedback"), onclick = "toggleClozeFeedback('%s',this)" % self.id)] codotras=self.ecrypt(self.field.otras) html += [common.hiddenField('clozeOtras%s' % self.id,codotras)] html += ['<input type="hidden" name="clozeFlag%s.strictMarking" id="clozeFlag%s.strictMarking" value="false" />' % (self.id,self.id)] html += ['<input type="hidden" name="clozeFlag%s.checkCaps" id="clozeFlag%s.checkCaps" value="false" />' % (self.id,self.id)] html += ['<input type="hidden" name="clozeFlag%s.instantMarking" id="clozeFlag%s.instantMarking" value="false" />' % (self.id,self.id)] html += [common.javaScriptIsRequired()] html += ['</p>'] html += ['</div>'] html += ['<div class="score js-feedback" id="clozeScore%s"></div>' % self.id] html += ['</div>'] if preview: html += ['</div>'] else: html += ['</form>'] html += ['</%s>' % sectionTag] return '\n'.join(html)