本文整理汇总了Python中models.Exercise.all方法的典型用法代码示例。如果您正苦于以下问题:Python Exercise.all方法的具体用法?Python Exercise.all怎么用?Python Exercise.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Exercise
的用法示例。
在下文中一共展示了Exercise.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import all [as 别名]
def get(self):
# task name token
uid = self.request_string('uid', uuid.uuid4())
yesterday = dt.date.today() - dt.timedelta(days=1)
yesterday_dt = dt.datetime.combine(yesterday, dt.time())
date = self.request_date('date', "%Y/%m/%d", yesterday_dt)
start_dt, end_dt = ExerciseStatistic.date_to_bounds(date)
exercises = self.request_string('exercises', '')
exercises = [e for e in exercises.split(',') if e]
if not exercises:
exercises = [e.name for e in Exercise.all()]
for exercise in exercises:
logging.info("Creating task chain for %s", exercise)
enqueue_task(exercise, start_dt, end_dt, None, uid, 0)
示例2: get
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import all [as 别名]
def get(self):
exid = self.request.get('exid')
exercise = Exercise.all().filter('name =', exid).get()
exercise_videos = []
for exercise_video in ExerciseVideo.all().filter('exercise =', exercise):
v = exercise_video.video
video_dict = {'youtube_id': v.youtube_id,
'youtube_url': v.url,
'title': v.title,
'description': v.description,
'keywords': v.keywords,
'readable_id': v.readable_id,
'ka_url': "http://www.khanacademy.org/video/%s" % (v.readable_id,)
}
exercise_videos.append(video_dict)
self.response.out.write(json.dumps(exercise_videos, indent=4))
示例3: get
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import all [as 别名]
def get(self):
from exercises import attempt_problem
login_user = UserData.current()
exercises_list = [exercise for exercise in Exercise.all()]
videos_list = [video for video in Video.all()]
user_count = self.request_int('users', 5)
for user_id in xrange(0, user_count):
# Create a new user
first_name = random.choice(CreateRandomGoalData.first_names)
last_name = random.choice(CreateRandomGoalData.last_names)
nickname = "%s %s" % (first_name, last_name)
email = 'test_%[email protected]' % user_id
user = users.User(email)
logging.info("Creating user %s: (%i/%i)"
% (nickname, user_id + 1, user_count))
user_data = UserData.get_or_insert(
key_name="test_user_%i" % user_id,
user=user,
current_user=user,
user_id=str(user_id),
moderator=False,
last_login=datetime.now(),
proficient_exercises=[],
suggested_exercises=[],
need_to_reassess=True,
points=0,
coaches=[login_user.user_email],
user_email=email,
user_nickname=nickname,
)
user_data.put()
# Delete user exercise & video progress
query = UserExercise.all()
query.filter('user = ', user)
for user_exercise in query:
user_exercise.delete()
query = VideoLog.all()
query.filter('user = ', user)
for user_video in query:
user_video.delete()
# Delete existing goals
GoalList.delete_all_goals(user_data)
for goal_idx in xrange(1, random.randint(-1, 4)):
# Create a random goal
obj_descriptors = []
for objective in xrange(1, random.randint(2, 4)):
obj_descriptors.append({
'type': 'GoalObjectiveExerciseProficiency',
'exercise': random.choice(exercises_list)})
for objective in xrange(1, random.randint(2, 4)):
obj_descriptors.append({
'type': 'GoalObjectiveWatchVideo',
'video': random.choice(videos_list)})
title = first_name + "'s Goal #" + str(goal_idx)
logging.info("Creating goal " + title)
objectives = GoalObjective.from_descriptors(obj_descriptors,
user_data)
goal = Goal(parent=user_data, title=title,
objectives=objectives)
user_data.save_goal(goal)
for objective in obj_descriptors:
if objective['type'] == 'GoalObjectiveExerciseProficiency':
user_exercise = user_data.get_or_insert_exercise(
objective['exercise'])
chooser = random.randint(1, 120)
if chooser >= 60:
continue
elif chooser > 15:
count = 1
hints = 0
elif chooser < 7:
count = 20
hints = 0
else:
count = 25
hints = 1
logging.info(
"Starting exercise: %s (%i problems, %i hints)" %
(objective['exercise'].name, count, hints * count))
for i in xrange(1, count):
attempt_problem(user_data, user_exercise, i, 1,
'TEST', 'TEST', 'TEST', True, hints, 0, False,
"TEST", 'TEST', '0.0.0.0')
elif objective['type'] == 'GoalObjectiveWatchVideo':
seconds = random.randint(1, 1200)
logging.info("Watching %i seconds of video %s"
#.........这里部分代码省略.........