Example #1
0
	def update_stats(self):
	  save = []
	  self.fixture_offset = Setting.get_by_key_name('fixture_offset') 
	  if self.fixture_offset.status != "update_stats":
		   logging.warning('Update Stats Job Hit Twice In A Row')
		   print "error -- current status: ", self.fixture_offset.status
		   return False
	  (this_account, this_user, this_quiz_taker) = memcache.get('current_fixture')
	  logging.info('Updating User Stats for User %s', this_user.unique_identifier)
	  from quiztaker.methods import ProficiencyLevels
	  pl = ProficiencyLevels()
	  pl.set_for_user(this_quiz_taker)
	  from accounts.methods import Awards
	  awards = Awards()
	  # check for new awards
	  new_awards = awards.check_all(this_quiz_taker)
	  from accounts.methods import Sponsorships
	  sponsorships = Sponsorships()
	  # check for new sponsorships, both personal and business
	  new_sponsorships = sponsorships.check_user(this_user)
	  self.fixture_offset.value += 1
	  self.fixture_offset.status = "create_account"
	  save.append(self.fixture_offset)
	  db.put(self.fixture_offset)
	  return new_awards, new_sponsorships
Example #2
0
	def load(self):
		save = []
		logging.info('loading fixture')
		self.fixture_offset = Setting.get_by_key_name('fixture_offset')  
		if self.fixture_offset.status == "update_stats": #instead of 'create_account'
			logging.warning('Load Fixtures Cron Job Hit Twice In a Row')
			print "error -- current status: ", self.fixture_offset.status
			return False
		this_account, this_user, this_quiz_taker = self.get_fixture()
		scores = Scores()
		import random
		correct_prob = random.randint(80,95)
		FIXTURE_PROFICIENCY = self.get_fixture_subject()
		from model.proficiency import Proficiency 
		this_proficiency = random.sample( Proficiency.gql("WHERE status = 'public'").fetch(1000), 1 )[0]
		save_scores = scores.make_scores(this_user, this_proficiency, correct_prob, SCORE_NUM = 10) 
		memcache.set('current_fixture', ( this_account, this_user, this_quiz_taker ), 600000)
		self.fixture_offset.status = "update_stats"
		print this_user.nickname
		save.append(self.fixture_offset)
		save.extend(save_scores)
		db.put(save)
		# open fixture.xml, go to offset.
		# load one name, email pair. register. 

		FIXTURE_PROFICIENCY = self.get_fixture_subject()
Example #3
0
def get_featured_quiz():
	try: 
	    from model.dev import Setting
	    featured_subject = Setting.get_by_key_name('fixture_subject').status
	except:
		from model.proficiency import Proficiency
		featured_subject = Proficiency.gql("WHERE status = 'public' ORDER BY status, modified DESC" ).get()
	return featured_subject
Example #4
0
	def get_fixture_subject(self):
		try:
			fixture_subject = Setting.get_by_key_name('fixture_subject').status
			from model.proficiency import Proficiency
			this_subject = Proficiency.get_by_key_name(fixture_subject)
			assert this_subject is not None
			return Proficiency.get_by_key_name(fixture_subject)
		except:
			DEFAULT_SUBJECT = "Smart Grid"
			logging.error('unable to load fixture subject - returning default: %s', DEFAULT_SUBJECT)
			return DEFAULT_SUBJECT
Example #5
0
	def load_settings(self, qt=False): # we want to make sure these reads only occur when necessary.
		from model.dev import Setting
		self.EXCELLENCE_PROFICIENCY_THRESHOLD = Setting.get_by_key_name("excellence_proficiency_threshold").value
		self.FLUENCY_PROFICIENCY_THRESHOLD = Setting.get_by_key_name("fluency_proficiency_threshold").value	
		self.EXCELLENCE_TOPIC_THRESHOLD = Setting.get_by_key_name("excellence_topic_threshold").value
		self.FLUENCY_TOPIC_THRESHOLD = Setting.get_by_key_name("fluency_topic_threshold").value