本文整理汇总了Python中models.models.Student类的典型用法代码示例。如果您正苦于以下问题:Python Student类的具体用法?Python Student怎么用?Python Student使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Student类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(
users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.redirect('/course#registration_closed')
return
if 'name_from_profile' in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get('form01')
Student.add_new_student_for_current_user(
name, transforms.dumps(self.request.POST.items()))
# Render registration confirmation page
self.redirect('/course#registration_confirmation')
示例2: post
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, "register-post"):
return
can_register = self.app_context.get_environ()["reg_form"]["can_register"]
if not can_register:
self.redirect("/course#registration_closed")
return
if "name_from_profile" in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get("form01")
Student.add_new_student_for_current_user(name, transforms.dumps(self.request.POST.items()))
course = sites.get_course_for_current_request()
if course.get_slug().split("_")[-1] == "DFR":
self.redirect("/gDefier/register")
else:
self.redirect("/course#registration_confirmation")
示例3: get
def get(self):
schedule_items = []
schedule_items.append(ScheduleItem(time_from='10.30',
time_until='12.50',
vak_code='ANL05',
docent_code='paris',
chamber='h.05.002'))
schedule_items.append(ScheduleItem(time_from='13.30',
time_until='15.50',
vak_code='SLC',
docent_code='muill',
chamber='H.04.318'))
schedule_item_keys = []
for i in schedule_items:
schedule_item_keys.append(i.put())
schedule = Schedule(day='Wednesday',
schedule_item=schedule_item_keys)
schedule_key = [schedule.put()]
grade = Grade(study_points=4,
passed=True,
grades=8.1,
docent='Busker',
concept=False,
exam_date='1-5-2015',
mutation_date='5-5-2015',
weight=1)
grade_key = grade.put()
grades_list = GradesList(vak_code='dev06',
grades=grade_key)
grades_list_key = [grades_list.put()]
student = Student(
parent=student_key(key="0846735"),
student_nr="0846735",
password='Hello',
first_name='Jeroen',
last_name='Stravers',
country='Nederland',
birthday='12-08-1988',
email='[email protected]',
telephone_nr='0678945032',
groups=['inf1F', 'inf2c'],
zip_address='4435-GK',
street='Kruisplein',
schedule=schedule_key,
grade_list=grades_list_key
)
student.put()
obj = {"test:", "done"}
self.response.write(obj)
示例4: get
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))
return
student = Student.get_enrolled_student_by_email(user.email())
if student:
self.redirect("/course")
return
# Check global student data
namespace = namespace_manager.get_namespace()
try:
namespace_manager.set_namespace("")
student = Student.get_enrolled_student_by_email(user.email())
finally:
namespace_manager.set_namespace(namespace)
if student:
create_or_enroll_student(user, student.name)
self.template_value["navbar"] = {"registration": True}
self.render("confirmation.html")
return
self.template_value["navbar"] = {"registration": True}
self.template_value["register_xsrf_token"] = XsrfTokenManager.create_xsrf_token("register-post")
self.render("register.html")
示例5: post
def post(self):
user = self.personalizePageAndGetUser()
if not user:
self.redirect(users.create_login_url(self.request.uri))
return
if (MAX_CLASS_SIZE and Student.all(keys_only=True).count() >= MAX_CLASS_SIZE):
self.templateValue['course_status'] = 'full'
else:
# Create student record
name = self.request.get('form01')
# create new or re-enroll old student
student = Student.get_by_email(user.email())
if student:
if not student.is_enrolled:
student.is_enrolled = True
student.name = name
else:
student = Student(key_name=user.email(), name=name, is_enrolled=True)
student.put()
# Render registration confirmation page
self.templateValue['navbar'] = {'registration': True}
self.render('confirmation.html')
示例6: get
def get(self):
"""Handles GET requests."""
user = self.personalize_page_and_get_user()
student = Student.get_by_email(user.email())
if not user:
self.template_value['loginUrl'] = users.create_login_url('/')
else:
self.template_value['playlist'] = student.playlist
self.template_value['playlist_urls'] = student.playlist_urls
self.template_value['email'] = user.email()
self.template_value['logoutUrl'] = users.create_logout_url('/')
if len(student.playlist) > 0:
#unit_id = str(student.playlist[0][0])
#lesson_id = str(student.playlist[0][2])
self.template_value['start_plist_url'] = str(student.playlist[0]) #('unit?unit=%s&lesson=%s' % (unit_id, lesson_id))
self.template_value['hasList'] = True
else:
self.template_value['hasList'] = False
self.template_value['navbar'] = {'course': True}
self.template_value['units'] = self.get_units()
if user and Student.get_enrolled_student_by_email(user.email()):
self.render('playlist.html')
else:
self.redirect('/preview')
示例7: finish
def finish(self):
leader_badge_slugs = ('expert.leader', 'expert.expertise.leader')
leader_badges = dict((k, Badge.get_by_key_name(k)) for k in leader_badge_slugs)
for group_id, (emails, count) in self.best_by_group.iteritems():
self.log.append('Considering group %s, best score is %d' % (
str(group_id), count))
if count < 1:
self.log.append('... Best score is too low, skipping.')
continue
for email in emails:
report = ExpertBadgeReport.on(
db.Key.from_path(Student.kind(), email),
course=self.course,
force_re_run=self.re_run)
base_badge_version = choose_expert_badge_version(report.completion())
if not base_badge_version:
raise AssertionError('They should have passed, wat?')
leader_badge_slug = base_badge_version + '.leader'
if self.really:
leader_badge = leader_badges[leader_badge_slug]
b = Badge.issue(leader_badge,
db.Key.from_path(Student.kind(), email), put=False)
b.evidence = self.host_url + '/badges/expert_evidence?id=%d' % report.key().id()
b.put()
self.log.append('... ISSUED %s to %s, id=%d' % (
leader_badge_slug, email, b.key().id()))
else:
self.log.append('... WOULD ISSUE %s to %s' % (
leader_badge_slug, email))
self._batch_write()
示例8: get
def get(self):
if not(Roles.is_course_admin(self.app_context)):
self.redirect("preview")
self.response.headers['Content-type'] = 'text/csv'
self.response.headers['Content-disposition'] = 'attachment; filename=students.csv'
course = self.get_course()
assessments=[]
for unit in course.get_units():
if (unit.type=="A"):
assessments.append(str(unit.unit_id))
writer = UnicodeWriter(self.response.out)
keys = Student.all(keys_only=True).run()
rows=[]
for key in keys:
student=Student.get_by_key_name(key.name())
rec={"email": key.name(), "name": student.name, "enrolled": unicode(student.is_enrolled), "dateEnrolled": unicode(student.enrolled_on) }
if (student.scores):
scores=json.loads(student.scores)
for assessmentName, score in scores.iteritems():
rec[assessmentName]=str(score)
rows.append(rec)
headerRow = ["Email", "Name", "Is Enrolled", "Enrolled On"]
for assessmentName in assessments:
headerRow.append(course.find_unit_by_id(assessmentName).title)
writer.writerow(headerRow)
for row in rows:
renderedRow=[row["email"],row["name"],row["enrolled"],row["dateEnrolled"]]
for assessmentName in assessments:
if (assessmentName in row):
renderedRow.append(row[assessmentName])
else:
renderedRow.append("")
writer.writerow(renderedRow)
示例9: post
def post(self):
schedule_items = []
schedule_items.append(ScheduleItem(time_from='08.30',
time_until='10.50',
vak_code='Dev05',
docent_code='paris',
chamber='wd.03.002'))
schedule_items.append(ScheduleItem(time_from='11.30',
time_until='13.50',
vak_code='Skils',
docent_code='Yolo',
chamber='H.04.318'))
schedule_item_keys = []
for i in schedule_items:
schedule_item_keys.append(i.put())
schedule = Schedule(day='Monday',
schedule_item=schedule_item_keys)
schedule_key = [schedule.put()]
grade = Grade(study_points=3,
passed=True,
grades=7.0,
docent='busker',
concept=False,
exam_date='1-5-2015',
mutation_date='5-5-2015',
weight=1)
grade_key = grade.put()
grades_list = GradesList(vak_code='dev04',
grades=grade_key)
grades_list_key = [grades_list.put()]
student = Student(
parent=student_key(key="0883374"),
student_nr="0883374",
password='Hello',
first_name='Geddy',
last_name='Schellevis',
country='Nederland',
birthday='05-03-1990',
email='[email protected]',
telephone_nr='0653380120',
groups=['inf1F', 'inf2c'],
zip_address='4444-LP',
street='ergens',
schedule=schedule_key,
grade_list=grades_list_key
)
student.put()
示例10: post
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(
users.create_login_url(self.request.uri), normalize=False)
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.redirect('/course#registration_closed')
return
if 'name_from_profile' in self.request.POST.keys():
profile = StudentProfileDAO.get_profile_by_user_id(user.user_id())
name = profile.nick_name
else:
name = self.request.get('form01')
Student.add_new_student_for_current_user(
name, transforms.dumps(self.request.POST.items()))
# CGL-MOOC-Builder: Get user's Google App email and
# course title, email body from course setting page.
course = self.app_context.get_environ()['course']
if 'google_app_email' in course:
sender_email = course['google_app_email']
else:
sender_email = ''
if 'title' in course:
course_title = course['title']
else:
course_title = ''
if 'email_body' in course and course['email_body'] != '':
email_body = course['email_body']
else:
email_body = "<div style='background-color: #999999; color: #ffffff; padding: 0px 20px 20px 20px; font-family: 'Verdana', sans-serif;'> <div style='width: 500px; margin: 0 auto;'> <p style='background-color: #093359; height: 100px; margin: 0px; padding: 0px;'> <img src='http://cloudmooc.pti.indiana.edu:8080/assets/img/Logo.png'></img> </p> <div style='background-color: #CCC; color: black; padding: 15px;'> <p>Welcome " + name + ",</p> <p>Thank you for enrolling in this.</p> </div> <p style='background-color: #012256; height: 50px; margin: 0px; padding: 0px;'></p></div></div>"
# CGL-MOOC-Builder starts:
# Send an notification email after registration
sender_address = course_title + " <"+sender_email+">"
user_address = name + " <" + user.email() + ">"
subject = "Welcome "+name+" to "+course_title
body = "Welcome!"
html = email_body
mail.send_mail(sender_address, user_address, subject, body, html=html)
# CGL-MOOC-Builder ends
# Render registration confirmation page
self.redirect('/course#registration_confirmation')
示例11: post
def post(self):
"""Handles POST requests."""
user = self.personalize_page_and_get_user()
if not user:
self.redirect(users.create_login_url(self.request.uri))
return
if not self.assert_xsrf_token_or_fail(self.request, 'register-post'):
return
can_register = self.app_context.get_environ(
)['reg_form']['can_register']
if not can_register:
self.template_value['course_status'] = 'full'
else:
name = self.request.get('form01')
surname = self.request.get('form02')
age = self.request.get('form03')
# create new or re-enroll old student
student = Student.get_by_email(user.email())
if not student:
student = Student(key_name=user.email())
student.user_id = user.user_id()
student.is_enrolled = False
student.name = name
student.surname = surname
student.age = age
student.put()
# Render registration confirmation page
self.template_value['navbar'] = {'registration': True}
self.render('confirmation.html')
示例12: post_save
def post_save(self):
if not Roles.is_course_admin(self.app_context):
self.abort(403, 'You are not an admin :(')
user = self.personalize_page_and_get_enrolled()
student_email = self.request.GET.get('email', None)
if not student_email:
self.abort(404, 'email= parameter required')
student = Student.get_enrolled_student_by_email(student_email)
if not student:
self.abort(404, Markup('Could not find a student with email "%s"') % student_email)
badge_slug = custom_badge_name(student)
badge = Badge.get_or_insert(badge_slug)
badge_form = BadgeForm(self.request.POST, badge)
comments_form = CommentsForm(self.request.POST)
if not (badge_form.validate() and comments_form.validate()):
self.render_edit(badge_form, comments_form)
return
comments_form.validate()
reviewer = Student.get_by_email(comments_form.review_source.data)
if not reviewer:
comments_form.review_source.errors.append("Could not find a user with that e-mail address")
self.render_edit(badge_form, comments_form)
return
page = WikiPage.get_page(student, unit=UNIT_NUMBER)
if not page:
self.abort(404, Markup('Could not find unit %d wikifolio for student "%s"') % (UNIT_NUMBER, student_email))
old_reviews = Annotation.reviews(whose=student, unit=UNIT_NUMBER).run()
db.delete(old_reviews)
Annotation.review(page, who=reviewer, text=comments_form.public_comments.data)
if not Annotation.endorsements(what=page, who=user).count(limit=1):
Annotation.endorse(page, who=user, optional_done=True)
badge_form.populate_obj(badge)
badge.put()
report = PartReport.on(student, self.get_course(), 4, force_re_run=True, put=False)
for rep in report.unit_reports:
rep._run()
rep.put()
report.slug = badge_slug
report.put()
assertion = Badge.issue(badge, student, put=False)
assertion.evidence = urljoin(self.request.host_url, '/badges/evidence?id=%d' % report.key().id())
assertion.put()
self.response.write(
Markup("Issued badge %s to %s, evidence %s") % (
badge.key().name(), student_email, assertion.evidence))
示例13: post
def post(self):
"""Handles POST requests."""
student = self.personalize_page_and_get_enrolled()
if not student:
return
if not self.assert_xsrf_token_or_fail(self.request, 'student-edit'):
return
Student.rename_current(self.request.get('name'))
self.redirect('/student/home')
示例14: post
def post(self):
"""Handles POST requests."""
student = self.personalize_page_and_get_enrolled()
if not student:
return
if not self.assert_xsrf_token_or_fail(self.request, 'student-unenroll'):
return
for hook in self.POST_HOOKS:
hook(student, self.request)
Student.set_enrollment_status_for_current(False)
self.template_value['navbar'] = {}
self.template_value['transient_student'] = True
self.render('unenroll_confirmation.html')
示例15: get_list
def get_list(self):
"""Shows a list of announcements."""
user = self.personalize_page_and_get_user()
transient_student = False
if user is None:
transient_student = True
else:
student = Student.get_enrolled_student_by_email(user.email())
if not student:
transient_student = True
else:
# CGL-MOOC-Builder starts:
# Set template value for progress bar that shows on the top navigation(header.html)
total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
self.template_value['progress_value'] = total_progress.get('progress_score', 0)
self.template_value['complete_value'] = total_progress.get('completed_score', 0)
self.template_value['percentage'] = total_progress.get('percentage', '')
# CGL-MOOC-Builder ends
self.template_value['transient_student'] = transient_student
items = AnnouncementEntity.get_announcements()
if not items and AnnouncementsRights.can_edit(self):
items = self.put_sample_announcements()
items = AnnouncementsRights.apply_rights(self, items)
self.template_value['announcements'] = self.format_items_for_template(
items)
self.template_value['navbar'] = {'announcements': True}
self.render('announcements.html')