本文整理汇总了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)