Exemplo n.º 1
0
 def refresh_scores(self, verbose):
     scores = []
     json_file = open(ROOT_PATH + "/data/item_scores.json")
     json_str = json_file.read()
     newdata = simplejson.loads(json_str)  # Load JSON file as object
     # Retrieve Proficiency. If new, then save it.
     for item in newdata:
         # Store Item in Datastore
         if item["type"] == "trash":
             continue
         if item["type"] == "temp":
             continue
         this_taker = QuizTaker.get(item["quiz_taker"]["key"])
         this_vendor = Employer.get(item["vendor"]["key"])
         this_item = QuizItem.get(item["quiz_item"]["key"])
         score = ItemScore(
             quiz_taker=this_taker,
             picked_answer=item["picked_answer"],
             correct_answer=item["correct_answer"],
             score=item["score"],
             quiz_item=this_item,
             vendor=this_vendor,
             type=item["type"],
         )
         # Add List of Answers
         scores.append(score)
         if verbose[0] == "loud":
             print encode(score)
     db.put(scores)  # save scores
Exemplo n.º 2
0
Arquivo: rpc.py Projeto: jamslevy/PQ
 def datastore(self, *args):
 	 from model.quiz import QuizItem
 	 qs = QuizItem.all().fetch(1000)
 	 save = []
 	 for q in qs:
 	 	q.content = q.content.replace('\n', ' ')
 	 	save.append(q)
 	 db.put(save) 
Exemplo n.º 3
0
 def make_scores(self, this_user, this_proficiency, correct_prob, SCORE_NUM = 10):
 	self.correct_prob = correct_prob
 	self.correct_scores = 0  	
 	from model.quiz import QuizItem
 	items = QuizItem.gql("WHERE proficiency = :1", this_proficiency).fetch(1000)
 	items = random.sample(items, SCORE_NUM)
 	self.save = []
 	for i in items: 
 	    self.make_score(i, this_user) 
 	print "saved ", len(self.save), " scores. ", self.correct_scores, " were correct." 
 	return self.save
Exemplo n.º 4
0
Arquivo: views.py Projeto: jamslevy/PQ
  def quiz_item(self, item_key):
		from model.quiz import QuizItem
		item = QuizItem.get(item_key)
		item_answers = []
		[item_answers.append(str(a)) for a in item.answers]  		
		quiz_item = {"answers": item_answers, "answer1" : item.answers[0], "answer2" : item.answers[1], "answer3": item.answers[2],  #answer1,2,3 is deprecated
		"proficiency": item.proficiency.name, "topic": item.topic.name, "key": item.key()}      
		template_values = {"quiz_items": [quiz_item]}
		logging.debug('loaded quiz...')
		path = tpl_path(QUIZTAKER_PATH + 'debug_quiz.html')
		self.response.out.write(template.render(path, template_values))