本文整理匯總了Python中models.Submission.all方法的典型用法代碼示例。如果您正苦於以下問題:Python Submission.all方法的具體用法?Python Submission.all怎麽用?Python Submission.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Submission
的用法示例。
在下文中一共展示了Submission.all方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_level_stats
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import all [as 別名]
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()
示例2: get_all_attempts
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import all [as 別名]
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)
)
示例3: get
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import all [as 別名]
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)
示例4: get
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import all [as 別名]
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))
示例5: get_all_attempts
# 需要導入模塊: from models import Submission [as 別名]
# 或者: from models.Submission import all [as 別名]
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)