def get(self): user = self.personalizePageAndGetUser() if user: self.templateValue['units'] = Unit.get_units() self.templateValue['navbar'] = {'course': True} self.render('course.html') else: self.redirect('/preview')
def get(self): user = users.get_current_user() if not user: self.templateValue['loginUrl'] = users.create_login_url('/') else: self.templateValue['email'] = user.email() self.templateValue['logoutUrl'] = users.create_logout_url("/") self.templateValue['navbar'] = {'course': True} self.templateValue['units'] = Unit.get_units() if user and Student.get_enrolled_student_by_email(user.email()): self.redirect('/course') else: self.render('preview.html')
def get(self): # Set template values for user user = self.personalizePageAndGetUser() if not user: self.redirect(users.create_login_url(self.request.uri)) return # Extract incoming args c = self.request.get('unit') if not c: unit_id = 1 else: unit_id = int(c) self.templateValue['unit_id'] = unit_id l = self.request.get('lesson') if not l: lesson_id = 1 else: lesson_id = int(l) self.templateValue['lesson_id'] = lesson_id # Set template values for a unit and its lesson entities for unit in Unit.get_units(): if unit.unit_id == str(unit_id): self.templateValue['units'] = unit lessons = Unit.get_lessons(unit_id) self.templateValue['lessons'] = lessons # Set template values for nav bar self.templateValue['navbar'] = {'course': True} # Set template values for back and next nav buttons if lesson_id == 1: self.templateValue['back_button_url'] = '' elif lessons[lesson_id - 2].activity: self.templateValue['back_button_url'] = '/activity?unit=' + str(unit_id) + '&lesson=' + str(lesson_id - 1) else: self.templateValue['back_button_url'] = '/unit?unit=' + str(unit_id) + '&lesson=' + str(lesson_id - 1) if lessons[lesson_id - 1].activity: self.templateValue['next_button_url'] = '/activity?unit=' + str(unit_id) + '&lesson=' + str(lesson_id) elif lesson_id == lessons.count(): self.templateValue['next_button_url'] = '' else: self.templateValue['next_button_url'] = '/unit?unit=' + str(unit_id) + '&lesson=' + str(lesson_id + 1) self.render('unit.html')