def render_GET(self, request): """Render the preferences""" log.debug("render_GET") # Rendering html = common.docType() html += u'<html xmlns="http://www.w3.org/1999/xhtml">\n' html += u"<head>\n" html += u'<style type="text/css">\n' html += u"@import url(/css/exe.css);\n" html += u"@import url(/style/base.css);\n" html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u"""<script language="javascript" type="text/javascript"> function doImportPDF(path, pages) { opener.nevow_clientToServerEvent('importPDF', this, '', path, pages); window.close(); } </script>""" html += '<script src="scripts/common.js" language="JavaScript">' html += "</script>\n" html += u"<title>" + _("Import PDF") + "</title>\n" html += u'<meta http-equiv="content-type" content="text/html; ' html += u' charset=UTF-8"></meta>\n' html += u"</head>\n" html += u"<body>\n" html += u'<div id="main"> \n' html += u'<form method="post" action="" ' html += u'id="contentForm" >' # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField( "textInput", this_package, _("Path to PDF"), "path", instruction=_("Enter path to pdf you want to import") ) html += u'<input type="button" onclick="addPdf(\'\')"' html += u'value="%s"/>\n' % _(u"Add file") html += common.formField( "textInput", this_package, _("Pages to import"), "pages", instruction=_("Comma-separated list of pages to import"), ) html += u'<div id="editorButtons"> \n' html += u"<br/>" html += common.button( "ok", _("OK"), enabled=True, _class="button", onClick="doImportPDF(document.forms.contentForm.path.value," + "document.forms.contentForm.pages.value)", ) html += common.button("cancel", _("Cancel"), enabled=True, _class="button", onClick="window.close()") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode("utf8")
def render_GET(self, request): """Render the preferences""" log.debug("render_GET") # Rendering html = common.docType() html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" html += u"<head>\n" html += u"<style type=\"text/css\">\n" html += u"@import url(/css/exe.css);\n" html += u'@import url(/style/base.css);\n' html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u'''<script language="javascript" type="text/javascript"> function setLocaleAndAnchors(l,anchors) { parent.nevow_clientToServerEvent('setLocale', this, '', l) parent.nevow_clientToServerEvent('setInternalAnchors', this, '', anchors) parent.Ext.getCmp('preferenceswin').close() } </script>''' html += u"<title>"+_("eXe : elearning XHTML editor")+"</title>\n" html += u"<meta http-equiv=\"content-type\" content=\"text/html; " html += u" charset=UTF-8\"></meta>\n"; html += u"</head>\n" html += u"<body>\n" html += u"<div id=\"main\"> \n" html += u"<form method=\"post\" action=\"\" " html += u"id=\"contentForm\" >" # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField('select', this_package, _(u"Select Language"), 'locale', options = self.localeNames, selection = self.config.locale) internal_anchor_options = [(_(u"Enable All Internal Linking"), "enable_all"), (_(u"Disable Auto-Top Internal Linking"), "disable_autotop"), (_(u"Disable All Internal Linking"), "disable_all")] html += common.formField('select', this_package, _(u"Internal Linking (for Web Site Exports only)"), 'internalAnchors', '', # TODO: Instructions options = internal_anchor_options, selection = self.config.internalAnchors) html += u"<div id=\"editorButtons\"> \n" html += u"<br/>" html += common.button("ok", _("OK"), enabled=True, _class="button", onClick="setLocaleAndAnchors(document.forms.contentForm.locale.value," "document.forms.contentForm.internalAnchors.value)") html += common.button("cancel", _("Cancel"), enabled=True, _class="button", onClick="parent.Ext.getCmp('preferenceswin').close()") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode('utf8')
def render_GET(self, request): """Render the preferences""" log.debug("render_GET") # Rendering html = common.docType() html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" html += u"<head>\n" html += u"<style type=\"text/css\">\n" html += u"@import url(/css/exe.css);\n" html += u'@import url(/style/base.css);\n' html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u'<script type="text/javascript" src="/scripts/common.js">' html += u'</script>\n' html += u'''<script language="javascript" type="text/javascript"> function importXliff(from_source) { parent.nevow_clientToServerEvent('mergeXliffPackage', this, '', '%s', from_source); parent.Ext.getCmp("xliffimportwin").close(); } </script>''' % quote(request.args['path'][0]) html += u"<title>"+_("eXe : elearning XHTML editor")+"</title>\n" html += u"<meta http-equiv=\"content-type\" content=\"text/html; " html += u" charset=UTF-8\"></meta>\n"; html += u"</head>\n" html += u"<body>\n" html += u"<div id=\"main\"> \n" html += u"<p> </p>\n" html += u"<form method=\"post\" action=\"\" " html += u"id=\"contentForm\" >" # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField('checkbox', this_package, _(u"Import from source language"), 'from_source', name = 'from_source', checked = False, title = None, instruction = _(u"If you choose this option, \ the import process will take the texts from source language instead of target \ language.")) html += u"<div id=\"editorButtons\"> \n" html += u"<br/>" html += common.button("ok", _("OK"), enabled=True, _class="button", onClick="importXliff(document.forms.contentForm.from_source.checked \ )") html += common.button("cancel", _("Cancel"), enabled=True, _class="button", onClick="parent.Ext.getCmp('xliffimportwin').close()") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode('utf8')
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="#" class="activity-form cloze-form">'] html += ['<div id="cloze%s">' % self.id] # 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>' % (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, class_ = "cloze-score-toggler")] else: html += [common.submitButton('getScore%s' % self.id, c_(u"Check"), id='getScore%s' % self.id)] if feedbackId: html += [common.button('feedback%s' % self.id, c_(u"Show Feedback"), class_ = "feedbackbutton cloze-feedback-toggler")] 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 render_GET(self, request): """Render the preferences""" log.debug("render_GET") # Rendering html = common.docType() html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" html += u"<head>\n" html += u"<style type=\"text/css\">\n" html += u"@import url(/css/exe.css);\n" html += u'@import url(/style/base.css);\n' html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u'''<script language="javascript" type="text/javascript"> function setLocaleAndAnchors(l,anchors) { opener.nevow_clientToServerEvent('setLocale', this, '', l) opener.nevow_clientToServerEvent('setInternalAnchors', this, '', anchors) window.close() } </script>''' html += u"<title>" + _("eXe : elearning XHTML editor") + "</title>\n" html += u"<meta http-equiv=\"content-type\" content=\"text/html; " html += u" charset=UTF-8\"></meta>\n" html += u"</head>\n" html += u"<body>\n" html += u"<div id=\"main\"> \n" html += u"<form method=\"post\" action=\"\" " html += u"id=\"contentForm\" >" # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField('select', this_package, _(u"Select Language"), 'locale', options=self.localeNames, selection=self.config.locale) internal_anchor_options = [ (_(u"Enable All Internal Linking"), "enable_all"), (_(u"Disable Auto-Top Internal Linking"), "disable_autotop"), (_(u"Disable All Internal Linking"), "disable_all") ] html += common.formField( 'select', this_package, _(u"Internal Linking (for Web Site Exports only)"), 'internalAnchors', '', # TODO: Instructions options=internal_anchor_options, selection=self.config.internalAnchors) html += u"<div id=\"editorButtons\"> \n" html += u"<br/>" html += common.button( "ok", _("OK"), enabled=True, _class="button", onClick= "setLocaleAndAnchors(document.forms.contentForm.locale.value," "document.forms.contentForm.internalAnchors.value)") html += common.button("cancel", _("Cancel"), enabled=True, _class="button", onClick="window.close()") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode('utf8')
def render_GET(self, request): """Render the preferences""" log.debug("render_GET") if self.localeNames_lang != self.config.locale: self.updateLocaleNames() # Rendering html = common.docType() html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" html += u"<head>\n" html += u"<style type=\"text/css\">\n" html += u"@import url(/css/exe.css);\n" html += u'@import url(/style/base.css);\n' html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u'<script type="text/javascript" src="/scripts/common.js">' html += u'</script>\n' html += u'''<script language="javascript" type="text/javascript"> function exportXliff(source, target, copy, cdata) { opener.nevow_clientToServerEvent('exportXliffPackage', this, '', '%s', source, target, copy, cdata); window.close(); } </script>''' % quote(request.args['path'][0]) html += u"<title>"+_("eXe : elearning XHTML editor")+"</title>\n" html += u"<meta http-equiv=\"content-type\" content=\"text/html; " html += u" charset=UTF-8\"></meta>\n"; html += u"</head>\n" html += u"<body>\n" html += u"<div id=\"main\"> \n" html += u"<form method=\"post\" action=\"\" " html += u"id=\"contentForm\" >" # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField('select', this_package, _(u"Select source language"), 'source', options = self.localeNames, selection = self.config.locale) html += common.formField('select', this_package, _(u"Select target language"), 'target', options = self.localeNames, selection = 'eu') html += common.formField('checkbox', this_package, _(u"Copy source also in target"), 'copy', name = 'copy', checked = True, title = None, instruction = _(u"If you don't choose this \ option, target field will be empty. Some Computer Aided Translation tools \ (i.g. OmegaT ) just translate the content of the target field. If you are \ using this kind of tools, you will need to pre-fill target field with a copy \ of the source field.")) html += common.formField('checkbox', this_package, _(u"Wrap fields in CDATA"), 'cdata', name = 'cdata', checked = False, title = None, instruction = _(u"This option will wrap all \ the exported fields in CDATA sections. This kind of sections are not \ recommended by XLIFF standard but it could be a good option if you want to \ use a pre-process tool (i.g.: Rainbow) before using the Computer Aided \ Translation software.")) html += u"<div id=\"editorButtons\"> \n" html += u"<br/>" html += common.button("ok", _("OK"), enabled=True, _class="button", onClick="exportXliff(document.forms.contentForm.source.value, \ document.forms.contentForm.target.value, \ document.forms.contentForm.copy.checked, \ document.forms.contentForm.cdata.checked \ )") html += common.button("cancel", _("Cancel"), enabled=True, _class="button", onClick="window.close()") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode('utf8')
def render_GET(self, request): """Render the preferences""" log.debug("render_GET") if self.localeNames_lang != self.config.locale: self.updateLocaleNames() # Rendering html = common.docType() html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" html += u"<head>\n" html += u"<style type=\"text/css\">\n" html += u"@import url(/css/exe.css);\n" html += u'@import url(/style/base.css);\n' html += u"@import url(/style/standardwhite/content.css);</style>\n" html += u'<script type="text/javascript" src="/scripts/common.js">' html += u'</script>\n' html += u'''<script language="javascript" type="text/javascript"> function exportXliff(source, target, copy, cdata) { parent.nevow_clientToServerEvent('exportXliffPackage', this, '', '%s', source, target, copy, cdata); parent.Ext.getCmp("xliffexportwin").close(); } </script>''' % quote(request.args['path'][0]) html += u"<title>" + _("eXe : elearning XHTML editor") + "</title>\n" html += u"<meta http-equiv=\"content-type\" content=\"text/html; " html += u" charset=UTF-8\"></meta>\n" html += u"</head>\n" html += u"<body>\n" html += u"<div id=\"main\"> \n" html += u"<form method=\"post\" action=\"\" " html += u"id=\"contentForm\" >" # package not needed for the preferences, only for rich-text fields: this_package = None html += common.formField('select', this_package, _(u"Select source language"), 'source', options=self.localeNames, selection=self.config.locale) html += common.formField('select', this_package, _(u"Select target language"), 'target', options=self.localeNames, selection='eu') html += common.formField('checkbox', this_package, _(u"Copy source also in target"), 'copy', name='copy', checked=True, title=None, instruction=_(u"If you don't choose this \ option, target field will be empty. Some Computer Aided Translation tools \ (i.g. OmegaT ) just translate the content of the target field. If you are \ using this kind of tools, you will need to pre-fill target field with a copy \ of the source field.")) html += common.formField('checkbox', this_package, _(u"Wrap fields in CDATA"), 'cdata', name='cdata', checked=False, title=None, instruction=_(u"This option will wrap all \ the exported fields in CDATA sections. This kind of sections are not \ recommended by XLIFF standard but it could be a good option if you want to \ use a pre-process tool (i.g.: Rainbow) before using the Computer Aided \ Translation software.")) html += u"<div id=\"editorButtons\"> \n" html += u"<br/>" html += common.button( "ok", _("OK"), enabled=True, _class="button", onClick="exportXliff(document.forms.contentForm.source.value, \ document.forms.contentForm.target.value, \ document.forms.contentForm.copy.checked, \ document.forms.contentForm.cdata.checked \ )") html += common.button( "cancel", _("Cancel"), enabled=True, _class="button", onClick="parent.Ext.getCmp('xliffexportwin').close();") html += u"</div>\n" html += u"</div>\n" html += u"<br/></form>\n" html += u"</body>\n" html += u"</html>\n" return html.encode('utf8')
def renderView(self, feedbackId=None, preview=False): # Shows the text with inputs for the missing parts if preview: # to render, use the content with the preview-able resource paths: self.field.encodedContent = self.field.content_w_resourcePaths else: # to render, use the flattened content, withOUT resource paths: self.field.encodedContent = self.field.content_wo_resourcePaths html = ['<div id="cloze%s">' % self.id] # 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 = [ '<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">\n'] html += [common.button('submit%s' % self.id, _(u"Check"), id='submit%s' % self.id, onclick="clozeSubmit('%s')" % self.id), common.button('submit%s' % self.id, _(u"Check"), id='restart%s' % self.id, style="display: none;", onclick="clozeSubmit('%s')" % 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 += ['<div id="clozeScore%s"></div>' % self.id] html += ['</div>\n'] return '\n'.join(html) + '</div>'