コード例 #1
0
ファイル: views.py プロジェクト: jamslevy/PQ
 def get(self):
   logging.info('loading quiz item')
   template_values = {}
   if self.request.get('item_key'): this_quiz_item = QuizItem.get(self.request.get('item_key'))
   if self.request.get('token'): 
       from google.appengine.api import memcache
       self.session = memcache.get(self.request.get('token'))
       this_item = self.session.get('current_item', False)
       if this_item: this_quiz_item = QuizItem.get(this_item['key'])
       else: 
           logging.warning('token used past expiration', self.request.get('token'))
           return False
   quiz_item = {}
   try: quiz_item['topic_name'] = this_quiz_item.topic.name
   except: print this_quiz_item
   if this_quiz_item.content.endswith('.'): this_quiz_item.content = this_quiz_item.content[:-1] + "<br/>" # this should be done in advance,and it should replace </span>. with </span><br/>
   quiz_item['content'] = this_quiz_item.content
   quiz_item['answers'] = this_quiz_item.answers
   quiz_item['theme'] = this_quiz_item.theme
   template_values = quiz_item
   template_values['browser'] = self.get_browser()
   if self.request.get('demo') == 'true': path = tpl_path(QUIZDEMO_PATH + 'quiz_item.html')
   else: path = tpl_path(QUIZTAKER_PATH + 'quiz_item.html')
   if self.request.get("callback"):
           self.response.out.write(jsonp(self.request.get("callback"), template.render(path, template_values)))
   else:
           self.response.out.write(template.render(path, template_values))
コード例 #2
0
ファイル: views.py プロジェクト: jamslevy/PQ
   def get(self):
	logging.info('Loading Quiz Completed Frame')
	template_values = {}
	path = tpl_path(QUIZDEMO_PATH + 'quiz_complete.html')
	if self.request.get("callback"):
			response = jsonp(self.request.get("callback"), template.render(path, template_values))
			self.response.out.write(response);
	else:
			self.response.out.write(template.render(path, template_values))
コード例 #3
0
ファイル: views.py プロジェクト: jamslevy/PQ
 def get(self):
         template_values = {}
         path = tpl_path(QUIZTAKER_PATH + 'quizframe.html')
         if self.request.get("callback"):
                 response = jsonp(self.request.get("callback"), template.render(path, template_values))
                 self.response.headers['Content-Type'] = 'application/x-javascript'
                 self.response.out.write(response);
         else:
                 self.response.out.write(template.render(path, template_values))
コード例 #4
0
ファイル: views.py プロジェクト: jamslevy/PQ
  def get(self):
	logging.info('loading quiz intro')
	template_values = {}
	if self.request.get('subject'): template_values['proficiencies'] = self.get_quiz_subjects()
	    
	intro_template = QUIZTAKER_PATH + self.request.get('page') + ".html"
	if self.request.get('demo') == "true": intro_template = QUIZDEMO_PATH + self.request.get('page') + ".html" # only for demo
	path = tpl_path(intro_template)
	if self.request.get("callback"):
			response = jsonp(self.request.get("callback"), template.render(path, template_values))
			self.response.out.write(response);
	else:
			self.response.out.write(template.render(path, template_values))
コード例 #5
0
ファイル: ubiquity.py プロジェクト: jamslevy/PQ
 def get_html(self):   
   import urllib
   template_values = {'text': urllib.unquote( self.request.get('text') ) }
   from model.proficiency import Proficiency 
   if self.request.get('subject_key'): template_values['subject_key'] = self.request.get('subject_key')
   else: 
     subjects = Proficiency.gql("WHERE status = 'public'").fetch(1000) 
     template_values['subjects'] = subjects
   if self.request.get('topic_key'): template_values['topic_key'] = self.request.get('topic_key')
   if self.request.get('topic_name'): 
       from model.proficiency import ProficiencyTopic
       p = ProficiencyTopic.gql("WHERE name = :1",  self.request.get('topic_name')).get()
       template_values['topic_key'] = p.key()
   path = tpl_path(DEV_PATH +'ubiquity_builder.html')
   response = simplejson.dumps(template.render(path, template_values))
   self.response.out.write(jsonp(self.request.get("callback"), response))
コード例 #6
0
ファイル: rpc.py プロジェクト: jamslevy/PQ
	def get(self):    
		from utils.random import jsonp
		if self.request.get('action') == "LoadUbiquityAnswers": return self.response.out.write( jsonp(self.request.get("callback"),self.LoadUbiquityAnswers()) )
		if self.request.get('action') == "SubmitItem": return self.response.out.write( jsonp(self.request.get("callback"), self.SubmitItem() ) )