本文整理汇总了Python中models.models.Student.get_enrolled_student_by_user方法的典型用法代码示例。如果您正苦于以下问题:Python Student.get_enrolled_student_by_user方法的具体用法?Python Student.get_enrolled_student_by_user怎么用?Python Student.get_enrolled_student_by_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.models.Student
的用法示例。
在下文中一共展示了Student.get_enrolled_student_by_user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: personalize_page_and_get_enrolled
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def personalize_page_and_get_enrolled(
self, supports_transient_student=False):
"""If the user is enrolled, add personalized fields to the navbar."""
user = self.personalize_page_and_get_user()
if user is None:
student = TRANSIENT_STUDENT
else:
student = Student.get_enrolled_student_by_user(user)
if not student:
self.template_value['transient_student'] = True
student = TRANSIENT_STUDENT
if student.is_transient:
if supports_transient_student and (
self.app_context.get_environ()['course']['browsable']):
return TRANSIENT_STUDENT
elif user is None:
self.redirect(
users.create_login_url(self.request.uri), normalize=False
)
return None
else:
self.redirect('/preview')
return None
# Patch Student models which (for legacy reasons) do not have a user_id
# attribute set.
if not student.user_id:
student.user_id = user.user_id()
student.put()
return student
示例2: get
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def get(self):
param_map = {}
for k in self.request.arguments():
param_map[k] = self.request.get(k)
client_id = param_map.get('client_id', 0)
logging.debug("vanilla request: " + str(param_map))
user = users.get_current_user()
if Roles.is_course_admin(self.app_context):
role= "administrator"
else:
role="member"
logging.debug(str(user))
if user:
student = Student.get_enrolled_student_by_user(user)
user = {
"name": student.name,
"email": user.email(),
"uniqueid": user.user_id(),
"photourl": "",
}
course = self.app_context.get_environ()['course']
client_id = course['VANILLA_CLIENT_ID']
secret_key = course['VANILLA_SECRET_KEY']
jsconn_str = get_jsconnect_string(user, param_map, client_id, secret_key)
logging.debug("mooc-ed response: " + jsconn_str)
self.response.out.write(jsconn_str)
示例3: get
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def get(self):
"""Handles GET request."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(users.create_login_url(self.request.uri), normalize=False)
return
student = Student.get_enrolled_student_by_user(user)
if student:
self.redirect("/course")
return
can_register = self.app_context.get_environ()["reg_form"]["can_register"]
if not can_register:
self.redirect("/course#registration_closed")
return
# pre-fill nick name from the profile if available
self.template_value["current_name"] = ""
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
if profile and profile.nick_name:
self.template_value["current_name"] = profile.nick_name
self.template_value["navbar"] = {}
self.template_value["transient_student"] = True
self.template_value["register_xsrf_token"] = XsrfTokenManager.create_xsrf_token("register-post")
alternate_content = []
for hook in self.PREVENT_REGISTRATION_HOOKS:
alternate_content.extend(hook(self.app_context, user.user_id()))
self.template_value["alternate_content"] = alternate_content
self.render("register.html")
示例4: get
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def get(self):
"""Handles GET requests."""
models.MemcacheManager.begin_readonly()
try:
user = self.personalize_page_and_get_user()
if user is None:
student = TRANSIENT_STUDENT
else:
student = Student.get_enrolled_student_by_user(user)
profile = StudentProfileDAO.get_profile_by_user(user)
self.template_value['has_global_profile'] = profile is not None
if not student:
student = TRANSIENT_STUDENT
if (student.is_transient and
not self.app_context.get_environ()['course']['browsable']):
self.redirect('/preview')
return
# If we are on this page due to visiting the course base URL
# (and not base url plus "/course"), redirect registered students
# to the last page they were looking at.
last_location = self.get_redirect_location(student)
if last_location:
self.redirect(last_location)
return
tracker = self.get_progress_tracker()
units = self.get_track_matching_student(student)
units = filter_assessments_used_within_units(units)
self.template_value['units'] = units
self.template_value['show_registration_page'] = True
if student and not student.is_transient:
augment_assessment_units(self.get_course(), student)
self.template_value['course_progress'] = (
tracker.get_course_progress(student))
elif user:
profile = StudentProfileDAO.get_profile_by_user_id(
user.user_id())
additional_registration_fields = self.app_context.get_environ(
)['reg_form']['additional_registration_fields']
if profile is not None and not additional_registration_fields:
self.template_value['show_registration_page'] = False
self.template_value['register_xsrf_token'] = (
XsrfTokenManager.create_xsrf_token('register-post'))
self.template_value['transient_student'] = student.is_transient
self.template_value['progress'] = tracker.get_unit_progress(student)
course = self.app_context.get_environ()['course']
set_image_or_video_exists(self.template_value, course)
self.template_value['is_progress_recorded'] = is_progress_recorded(
self, student)
self.template_value['navbar'] = {'course': True}
finally:
models.MemcacheManager.end_readonly()
self.render('course.html')
示例5: get
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def get(self):
"""Handles GET requests."""
user = self.personalize_page_and_get_user()
if user is None:
student = TRANSIENT_STUDENT
else:
student = Student.get_enrolled_student_by_user(user)
if not student:
student = TRANSIENT_STUDENT
# If the course is browsable, or the student is logged in and
# registered, redirect to the main course page.
if ((student and not student.is_transient) or
self.app_context.get_environ()['course']['browsable']):
self.redirect('/course')
return
self.template_value['transient_student'] = True
self.template_value['can_register'] = self.app_context.get_environ(
)['reg_form']['can_register']
self.template_value['navbar'] = {'course': True}
self.template_value['units'] = self.get_units()
self.template_value['show_registration_page'] = True
course = self.app_context.get_environ()['course']
self.template_value['video_exists'] = bool(
'main_video' in course and
'url' in course['main_video'] and
course['main_video']['url'])
self.template_value['image_exists'] = bool(
'main_image' in course and
'url' in course['main_image'] and
course['main_image']['url'])
if user:
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
additional_registration_fields = self.app_context.get_environ(
)['reg_form']['additional_registration_fields']
if profile is not None and not additional_registration_fields:
self.template_value['show_registration_page'] = False
self.template_value['register_xsrf_token'] = (
XsrfTokenManager.create_xsrf_token('register-post'))
self.render('preview.html')
示例6: get_list
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def get_list(self):
"""Shows a list of announcements."""
student = None
user = self.personalize_page_and_get_user()
transient_student = False
if user is None:
transient_student = True
else:
student = Student.get_enrolled_student_by_user(user)
if not student:
transient_student = True
self.template_value['transient_student'] = transient_student
items = AnnouncementEntity.get_announcements()
items = AnnouncementsRights.apply_rights(self, items)
if not roles.Roles.is_course_admin(self.get_course().app_context):
items = models.LabelDAO.apply_course_track_labels_to_student_labels(
self.get_course(), student, items)
self.template_value['announcements'] = self.format_items_for_template(
items)
self._render()
示例7: personalize_page_and_get_enrolled
# 需要导入模块: from models.models import Student [as 别名]
# 或者: from models.models.Student import get_enrolled_student_by_user [as 别名]
def personalize_page_and_get_enrolled(self, supports_transient_student=False):
"""If the user is enrolled, add personalized fields to the navbar."""
user = self.personalize_page_and_get_user()
if user is None:
student = TRANSIENT_STUDENT
else:
student = Student.get_enrolled_student_by_user(user)
if not student:
self.template_value["transient_student"] = True
student = TRANSIENT_STUDENT
if student.is_transient:
if supports_transient_student and (self.app_context.get_environ()["course"]["browsable"]):
return TRANSIENT_STUDENT
elif user is None:
self.redirect(users.create_login_url(self.request.uri), normalize=False)
return None
else:
self.redirect("/preview")
return None
return student