def load_quiz_js(self): JQUERY_VERSION = '1.3.2' DEFAULT_QUIZ_SUBJECT = "Recovery.Gov" try : proficiency_arg = self.request.path.split('/quiz/')[1].replace('%20',' ') this_proficiency = Proficiency.get_by_key_name(proficiency_arg) assert this_proficiency != None self.these_proficiencies = [this_proficiency] except: self.these_proficiencies = [Proficiency.get_by_key_name(DEFAULT_QUIZ_SUBJECT)] proficiency_names = [str(p.name) for p in self.these_proficiencies] session_token = self.get_session_token() template_values = { 'proficiencies': encode(proficiency_names).replace("\n", ""), 'user_token': session_token, 'css': self.get_widget_css().replace('\n','').replace("'",'"'), 'widget_html': self.get_widget_html(), 'widget_subject': self.these_proficiencies[0].key(), 'jquery_version' : JQUERY_VERSION, 'jquery_location': JQUERY_VERSION, 'auto_start': self.get_auto_start() } path = widget_path('pqwidget.js') from utils.utils import minify self.response.out.write( minify(template.render(path, template_values)) )
def browser_error(self): DEFAULT_QUIZ_SUBJECT = "Recovery.Gov" if not Debug(): self.set_expire_header() try : proficiency_arg = self.request.path.split('/quiz/')[1].replace('%20',' ') this_proficiency = Proficiency.get_by_key_name(proficiency_arg) assert this_proficiency != None self.these_proficiencies = [this_proficiency] except: self.these_proficiencies = [Proficiency.get_by_key_name(DEFAULT_QUIZ_SUBJECT)] proficiency_names = [str(p.name) for p in self.these_proficiencies] session_token = self.get_session_token() template_values = { 'quiz_subject': encode(proficiency_names[0]).replace("\n", "") } path = widget_path('error.js') from utils.utils import minify self.response.out.write( minify(template.render(path, template_values)) )