Ejemplo n.º 1
0
Archivo: rpc.py Proyecto: jamslevy/PQ
  def working(self, *args):

  	from model.proficiency import Proficiency, ProficiencyTopic
  	q = Proficiency.get_by_key_name("QuiztheBill")
  	save = []
  	pts = ProficiencyTopic.all().fetch(1000)
  	for p in pts:
  		if p.subject is None: 
  		    p.subject = q
  		    print p.name
  		    save.append(p)
     
  	db.put(save)
Ejemplo n.º 2
0
 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))
Ejemplo n.º 3
0
Archivo: rpc.py Proyecto: jamslevy/PQ
	def SubmitItem(self):   
		from model.proficiency import Proficiency, ProficiencyTopic
		this_subject = Proficiency.gql("WHERE name = :1", self.request.get('subject_name') ).get()
		logging.info('submitting item')
		from utils.appengine_utilities.sessions import Session
		session = Session()
		if len( self.request.get('item_key') ) < 1:
			this_item = QuizItem(pending_proficiency = this_subject)
			if session['user']: this_item.author= session['user']
		else: 
			this_item = QuizItem.get(self.request.get('item_key'))         	
		if self.request.get('item_status') == "approved":
			this_item.active = True
			this_item.pending_proficiency = None
			this_item.proficiency = this_subject        	
		if self.request.get('item_status') == "not_approved":
			this_item.active = False
			this_item.pending_proficiency = this_subject  
			this_item.proficiency = None        		
		this_item.topic = ProficiencyTopic.get( self.request.get('topic_key') )
		this_item.index = self.request.get('correct_answer')
		this_item.answers = [a.strip("'") for a in self.request.get('answers').split(",")] 
		this_item.content = self.request.get('item_text')
		save = [ this_subject, this_item]
		#if session['user']: save.append(session['user'])
		db.put( save )
		logging.info('saving new quiz item %s with subject %s and index %s' % (this_item.__dict__, self.request.get('subject_name'), self.request.get('correct_answer') ))
		if self.request.get('ubiquity'): return "OK"
		from utils.webapp import template
		from utils.utils import tpl_path        
		from editor.methods import get_membership, get_user_items		
		template_values = {"subject": this_subject, 
						   'subject_membership': get_membership(session['user'], this_subject),
						   'user_items': get_user_items(session['user'], this_subject), }
		path = tpl_path(EDITOR_PATH + 'quiz_item_editor_template.html')
		return template.render(path, template_values)
Ejemplo n.º 4
0
Archivo: rpc.py Proyecto: jamslevy/PQ
  def add_topic(self, *args):
  	this_subject = Proficiency.get(args[1])
	save_topic = ProficiencyTopic(name = args[0], proficiency = this_subject)
	save_topic.put()
  	return self.dump_data(["proficiency_topics"])