Exemple #1
0
 def update_user_awards(self):      
     from accounts.methods import Awards
     awards = Awards()
     # check for new awards
     logging.info('Updating Awards for User %s', self.session['user'].unique_identifier)
     from model.quiz import QuizTaker
     qt = QuizTaker.get_by_key_name(self.session['user'].unique_identifier)
     new_awards = awards.check_all(qt)
     if new_awards > 0: self.session['flash_msg'] = 'new_award'
     print "OK"
     return "OK"
Exemple #2
0
 def update_user_stats(self):
     from quiztaker.methods import ProficiencyLevels
     pl = ProficiencyLevels()
     from model.quiz import QuizTaker
     qt = QuizTaker.get_by_key_name(self.session['user'].unique_identifier)
     logging.info('Updating Level Stats for User %s', qt.unique_identifier)
     saved_stats = pl.set_for_user(qt)
     logging.info(len(saved_stats)) 
     if len(saved_stats) < 2: return False
     print "OK"
     return "OK"
Exemple #3
0
  def make_score(self, i, this_user): 
	from model.quiz import QuizTaker
	from model.quiz import ItemScore
	import random
	this_user = QuizTaker.get_by_key_name(this_user.unique_identifier)
	picked_answer = ''
	if random.randint(1,100) > self.correct_prob: #wrong answer -- could also just use normal distribution of correct probability
		while picked_answer == i.index: picked_answer = i.answers.pop()
	else:  picked_answer = i.index
	score = ItemScore(quiz_item = i,
						  quiz_taker = this_user,
						  correct_answer = i.index,
						  picked_answer = picked_answer,
						  type = "stub")	
	if score.picked_answer == score.correct_answer: 
		this_score = int(random.normalvariate(int( self.correct_prob ), 15))
		if this_score > 99: this_score = 99
		score.score = this_score
		self.correct_scores += 1
	else: score.score = 0
	self.save.append(score)