Exemplo n.º 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
Exemplo n.º 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()
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 5
0
from google.appengine.ext import db
from .model.quiz import QuizItem, RawQuizItem, ProficiencyTopic, ContentPage, Proficiency
from .utils.utils import ROOT_PATH
from utils import simplejson
from employer.methods import DataMethods as emp_data
from google.appengine.api import images
from .model.user import ProfilePicture	
from .model.proficiency import SubjectImage, Link
from model.employer import Employer
from model.account import MailingList
from google.appengine.api import memcache
from model.dev import Setting

DATA_TYPES = {"proficiencies": Proficiency.all(), 'proficiency_topics': ProficiencyTopic.all(), 'links': Link.all(), 'content_pages': ContentPage.all(), 'raw_items' : RawQuizItem.all(),
               'quiz_items': QuizItem.all(), 
               'mailing_list': MailingList.all(), 'employers': Employer.all(), 'settings': Setting.all()}

LOAD_INCREMENT = 10 # How many entities are loaded into datastore at a time
IMAGE_INCREMENT = 1 # How many entities are loaded into datastore at a time

#Refresh One Data Type
def refresh_data(data_type):
    data = DataMethods()
    data.delete_data(DATA_TYPES.get(data_type, False))
    data.load_data(data_type, "")
    data.special_processes(data_type)
    data.execute_load()


def delete_data(data_type):
    data = DataMethods()
Exemplo n.º 6
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