def post(self): teacher = valid_user() if teacher: studentID = self.request.get('student_id') courseID = self.request.get('course_id') badgeID = self.request.get('badge_id') teacherID = teacher.key.id() badge_action = self.request.get('action') if badge_action == 'award': status = 'awarded' elif badge_action == 'revoke': status = 'revoked' elif badge_action == 'deny': status = 'denied' html = self.render_str('badge_actions.html', studentID = studentID, courseID = courseID, badgeID = badgeID, current_achievement_status = status, ) self.response.out.write(html) if badge_action in ['award', 'revoke', 'deny']: course = existing_course(courseID, teacher) badge = get_badge(valid_user(),badgeID) new_achievement( teacher = teacher, student = get_student(studentID), badge = badge, course = course, status = status ) for course_checkpoint_key in badge.checkpoints: courseID, checkpointID = course_checkpoint_key.split('_') update_checkpoint_progress(studentID, badgeID, checkpointID, courseID, teacherID, status)
def post(self, studentID, courseID, badgeID): if valid_user(): if courseID: badge = get_badge(valid_user(), badgeID) content = self.request.get('content') create_evidence(studentID, badge, content, teacher=True) self.redirect('/student_badge/%s/%s/%s/teacher_view' % (studentID, courseID, badgeID))
def get(self, courseID): if valid_user(): teacher = valid_user() teacherID = teacher.key.id() html_cache_key = "html_course:%s_%s" % (teacherID, courseID) cached_html = None #get_cached_html_page(html_cache_key) if cached_html: self.write(cached_html) else: course = existing_course(courseID, teacher) checkpoints = get_course_checkpoints(course) raw_html = self.render('course.html', course = course, registrations = get_registered_students(course), number_of_pending_registrations = get_number_of_pending_registrations(course), checkpoints = get_course_checkpoints(course), courseID = int(courseID), teacherID = int(teacherID), teacher = teacher, active_tab = self.request.get('active_tab')) logging.info('start set memcache html course') memcache.set(html_cache_key, raw_html) logging.info('end set memcache html course') else: self.redirect('/front')
def post(self, teacherID, courseID, badgeID): if valid_user(): if courseID: teacher = get_teacher(teacherID) badge = get_badge(teacher, badgeID) content = self.request.get('content') create_evidence(valid_user().key.id(), badge, content, teacher=False) self.redirect('/student_badge/%s/%s/%s' % (teacherID, courseID, badgeID))
def post(self, courseID = None): if valid_user(): course_name = self.request.get('course_name') course_code = self.request.get('course_code') if verify_unique_course_code(course_code, valid_user(), courseID = courseID): course = edit_course(course_name = course_name, course_code = course_code, courseID = courseID, user = valid_user()) self.redirect('/profile') else: self.redirect('/edit_course?error=you are already using that course code in another course')
def post(self): if valid_user(): code = self.request.get('teacher_code') if code == 'matt_damon': valid_user().teacher = True valid_user().put() self.redirect('/profile') else: self.redirect('/request_teacher_access?error=invalid code')
def get(self, courseID, checkpointID): if valid_user(): teacher = valid_user() teacherID = teacher.key.id() course = existing_course(courseID, teacher) checkpoint = get_single_checkpoint(course, checkpointID) self.render('delete_checkpoint.html', checkpoint = checkpoint, course = course )
def post(self, courseID): if valid_user(): course_name = self.request.get('course_name') course_code = self.request.get('course_code') delete_cached_course(courseID, valid_user().key.id()) if verify_unique_course_code(course_code,valid_user(), courseID = courseID): course = edit_course(course_name = course_name, course_code = course_code, courseID = courseID, user = valid_user()) self.redirect('/course/%s' % courseID) else: self.redirect('/course/%s?active_tab=settings&error=you are already using that course code in another course' % courseID)
def get(self, courseID, checkpointID): if valid_user(): teacher = valid_user() course = existing_course(courseID = courseID, user = teacher) if course: self.render('edit_checkpoint.html', course = course, courseID = int(courseID), new_checkpoint = False, checkpoint = get_single_checkpoint(course, checkpointID))
def post(self, courseID, checkpointID): if valid_user(): delete_phrase = self.request.get('delete_phrase') if delete_phrase == 'Delete': course = existing_course(courseID, valid_user()) checkpoint = get_single_checkpoint(course, checkpointID) checkpoint.key.delete() delete_cached_course(courseID, valid_user().key.id()) self.redirect('/course/%s' % courseID) else: self.redirect('/delete_checkpoint/%s/%s?error=You did not type "Delete" correctly' % (courseID, checkpointID))
def post(self, courseID): if valid_user(): teacher = valid_user() course = existing_course(courseID = courseID, user = teacher) if course: name = self.request.get('checkpoint_name') description = self.request.get('description') featured = self.request.get('featured_checkpoint') create_new_checkpoint(name = name, description = description, course = course, featured = featured) teacherID = teacher.key.id() delete_cached_course(courseID, teacherID) self.redirect('/course/%s' % courseID)
def get(self, badgeID): if valid_user(): self.render('single_badge.html', badge = get_badge(valid_user(),badgeID), achievement_status = achievement_status, teacher=valid_user(), badges_active = 'active', get_checkpoints_for_badge = get_checkpoints_for_badge, active_course = self.request.get('active_course'), get_section_string = get_section_string, active_section = self.request.get('active_section'), get_registered_students = get_registered_students )
def get(self, studentID, courseID): if valid_user(): if courseID: teacher = valid_user() student = get_student(studentID) course = existing_course(courseID, teacher) teacherID = teacher.key.id() self.render('course.html', course = course, checkpoints = get_course_checkpoints(course), teacherID= int(teacherID), studentID = studentID, courseID = int(courseID), student = student, teacher_view_student_profile = True, active_tab = self.request.get('active_tab'), )
def get(self, badgeID=None): if valid_user() and valid_user().teacher: badge = get_badge(valid_user(),badgeID) checkpointID = self.request.get('checkpointID') courseID = self.request.get('courseID') badge_creator_active = 'active' if checkpointID.isdigit() and courseID.isdigit(): checkpointID = int(checkpointID) courseID = int(courseID) badge_creator_active = "" self.render('badge_creator.html', badge = get_badge(valid_user(),badgeID), icon_array = the_list, badge_creator_active = badge_creator_active, checkpointID = checkpointID, courseID = courseID, get_course_checkpoints = get_course_checkpoints)
def get(self): if valid_user(): teacher = valid_user() for course in get_user_courses(teacher): all_students = get_registered_students(course) if all_students: for checkpoint in get_course_checkpoints(course): for badgeID in checkpoint.badges: badge = get_badge(teacher, badgeID) for registration in all_students: progress = checkpoint.progress studentID = str(registration.student_id) if studentID in progress: if badgeID not in progress[studentID]: student = registration.student status = achievement_status(student, badge, teacher, course) update_checkpoint_progress(studentID, badgeID, checkpoint.key.id(), course.key.id(), teacher.key.id(), status)
def get(self, badgeID, studentID, courseID): if valid_user(): teacher = valid_user() teacherID = teacher.key.id() course = existing_course(courseID, teacher) badge = get_badge(teacher,badgeID) new_achievement( teacher = teacher, student = get_student(studentID), badge = badge, course = course, status = 'awarded' ) for course_checkpoint_key in badge.checkpoints: courseID, checkpointID = course_checkpoint_key.split('_') update_checkpoint_progress(studentID, badgeID, checkpointID, courseID, teacherID, 'awarded') self.redirect('/student_profile/%s/%s/teacher_view' % (studentID, courseID))
def post(self): if valid_user(): teacher_email = self.request.get('teacher_email') course_code = self.request.get('course_code') if teacher_email: teacher = get_user_by_email(teacher_email) if teacher: success = register_for_course(student = valid_user(), teacher = teacher, course_code = course_code) if success: self.redirect('/profile') course = get_course_by_code(teacher=teacher, course_code = course_code) delete_cached_course(course.key.id(), teacher.key.id()) else: self.redirect('/register?error=invalid course code') else: self.redirect('/register?error=that teacher email does not exist in the system') else: self.redirect('/register?error=you cannot leave the teacher email field blank')
def post(self, badgeID=None): if valid_user() and valid_user().teacher: teacher = valid_user() teacherID = valid_user().key.id() old_checkpoints=[] if badgeID: old_badge = get_badge(teacher, badgeID) if old_badge: old_checkpoints = old_badge.checkpoints checkpoint_keys = self.request.get_all("checkpoint_options") badgeID = edit_badge( badgeID = badgeID, icon = self.request.get("icon"), icon_color = self.request.get("icon_color"), border_color = self.request.get("border_color"), background = self.request.get("background"), name = self.request.get("badge_name"), requirement = self.request.get("requirement"), value = self.request.get("badge_value"), teacher = teacher, checkpoints = checkpoint_keys ) #remove badge from old checkpoints if applicable for old_checkpoint_key in old_checkpoints: if old_checkpoint_key not in checkpoint_keys: old_courseID, old_checkpointID = old_checkpoint_key.split('_') remove_badge_from_checkpoint(badgeID, old_checkpointID, old_courseID, teacherID) #add badge to new checkpoints if applicable for checkpoint_key in checkpoint_keys: courseID, checkpointID = checkpoint_key.split('_') delete_cached_course(courseID, teacherID) add_badge_to_checkpoint(badgeID, checkpointID, courseID, teacherID) #update percent complete for every student affected by this badge update_percent_completions(checkpointID, courseID, teacherID) checkpointID = self.request.get('checkpointID') courseID = self.request.get('courseID') if courseID and checkpointID: self.redirect('/course/%s#%s' % (courseID, checkpointID)) else: self.redirect('/badge/%s' % badgeID)
def get(self, teacherID, courseID): if valid_user(): if courseID: teacher = get_teacher(teacherID) student = valid_user() course = existing_course(courseID, teacher) self.render('course.html', course = course, checkpoints = get_course_checkpoints(course), teacherID = int(teacherID), get_badge = get_badge, courseID = int(courseID), student_profile = True, student = student, teacher = teacher, studentID = str(student.key.id()), ) else: self.write('You are not registered for this course...')
def get(self, teacherID, courseID, badgeID): if valid_user(): teacher = get_teacher(teacherID) course = existing_course(courseID, teacher) student = valid_user() badge = get_badge(teacher, badgeID) this_badge_status = achievement_status(student = student, course = course, badge = badge, teacher = teacher) self.render('single_badge.html', badge = badge, achievement_status = this_badge_status, student_badge = True, courseID = courseID, course = course, teacher = teacher, student = valid_user(), teacherID = int(teacherID), get_checkpoints_for_badge = get_checkpoints_for_badge, evidence = get_evidence(badge, student.key.id()) )
def get(self, courseID, checkpointID): if valid_user(): teacher = valid_user() teacherID = teacher.key.id() html_cache_key = "html_checkpoint:%s_%s_%s" % (teacherID, courseID, checkpointID) cached_html = None #get_cached_html_page(html_cache_key) if cached_html: self.write(cached_html) else: course = existing_course(courseID, teacher) checkpoint = get_single_checkpoint(course, checkpointID) raw_html = self.render('single_checkpoint.html', checkpoint = checkpoint, registrations = get_registered_students(course), course = course, courseID = int(courseID), checkpointID = int(checkpointID), section_string = get_section_string(course) ) memcache.set(html_cache_key, raw_html)
def post(self): teacher = valid_user() if teacher: courseID = self.request.get('course_id') studentID = self.request.get('student_id') teacherID = teacher.key.id() section_number = self.request.get('section_number') if section_number in '12345678': course = existing_course(courseID, teacher) change_section_number(course, studentID, section_number) html = self.render_str('section_list.html', studentID = studentID, section_number = section_number, courseID = courseID ) self.response.out.write(html) delete_cached_course(courseID, teacherID)
def post(self): teacher = valid_user() student_id = self.request.get('student_id') course_id = self.request.get('course_id') badge_id = self.request.get('badge_id') status = self.request.get('status') student = get_student(student_id) course = existing_course(user = teacher, courseID = course_id) badge = get_badge(teacher, badge_id) new_achievement(teacher = teacher, student =student, badge = badge, course = course, status = status) courses = get_user_courses(teacher) html = self.render_str('badge_course_list.html', courses = get_cached_user_courses(teacher), badge = badge, active_course = course_id, teacher = teacher, achievement_status = achievement_status) get_cached_course(course, refresh = True) get_cached_course(course, studentID = student_id, refresh = True) self.response.out.write(html)
def get(self): if valid_user(): self.render('register.html')
def get(self): if valid_user(): self.redirect('/profile') else: self.render('link.html')
def post(self): if valid_user(): formalName = self.request.get('formalName') edit_user(valid_user(), formalName = formalName) self.redirect('/profile')
def get(self): if valid_user(): self.render('change_user.html', profile_active = 'active')
def get(self): if valid_user(): self.render('request_teacher_access.html')
def get(self, courseID, studentID, action): if valid_user(): edit_registration(courseID = courseID, teacher = valid_user(), action = action, studentID = studentID, new=True) delete_cached_course(courseID, valid_user().key.id()) self.redirect('/course/%s?active_tab=students' % courseID)
def get(self, courseID): if valid_user(): course = existing_course(courseID = courseID, user = valid_user()) if course: self.render('edit_checkpoint.html', course = course, new_checkpoint = True, courseID = int(courseID))