def get_level_stats(self, format, delta = datetime.timedelta(), page = 0, limit = 100): level = get_current_level() if level is not None: submissions = Submission.all().filter("time >", level.time - delta).order('time').order('-score').fetch(limit, page * limit) i = 1 ranks = [] for submission in submissions: obj = {"rank" : i, "user" : submission.user.name, "score" : submission.score} if format == "json": ranks.append(obj) elif format == "xml": ranks.append({"ranking": obj}) i = i + 1 res = {"response": ranks} else : res = {"response": {"error": "could not get the level"}} if format == "json": return simplejson.dumps(res) elif format == "xml": return dict2xml(res).to_string()
def get_all_attempts(self, magic, level, problemid, prob_type): return ( Submission.all() .filter("student_magic_number =", str(magic)) .filter("type =", str(prob_type)) .filter("level =", level) .filter("problem_id =", problemid) )
def get(self): magic = self.request.get('student') submissions = Submission.all().filter('student_magic_number =', str(magic)) submissions_objects = [] for submission in submissions: utc = int(time.mktime(submission.answered_on.timetuple())) submissions_objects.append({"type":submission.type, "level":submission.level, "id":submission.problem_id, "score":submission.score, "answered_on":utc, "answer":submission.answer}) blob = json.dumps(submissions_objects) self.response.out.write(blob)
def get(self): submissions = [] #subs= Submission.gql("WHERE pid=:1", 11) for submission in Submission.all().order('-post_time'): submissions.append({ 'name': submission.name, 'pid': submission.pid, 'image_url': submission.image_url, }) self.response.out.write(json.dumps(submissions))
def get(self): submissions = [] for submission in Submission.all().order('-post_time'): submissions.append({ 'name': submission.name, 'usid': submission.usid, 'pid': submission.pid, 'image_url': submission.image_url, 'post_time': str(submission.post_time), }) self.response.out.write(json.dumps(submissions))
def get_all_attempts(self, magic, level, problemid, prob_type): return Submission.all().filter('student_magic_number =', str(magic)).filter('type =', str(prob_type)).filter('level =', level).filter('problem_id =', problemid)