def my_courses(): # User logged in already user_email, user_type = get_email_and_type(request) if user_email is not None: if user_email == "NULL": return render_error("Email invalid") return render_user_courses(user_email, user_type) return render_error("Not logged in properly")
def course_information(course_id, sec_no): user_email, user_type = get_email_and_type(request) if user_email is not None: return render_user_course(user_email, user_type, course_id, sec_no) return render_error(request.url, "Not logged in properly")
def render_user_courses(email, user_type): if user_type == USER.STUDENT: response = render_student_courses(email) elif user_type == USER.PROFESSOR: response = render_professor_courses(email) else: return render_error("Not properly logged in") return response
def user_info(user_id): user_email, user_type = get_email_and_type(request) # User logged in already if user_email is not None: if user_email == "NULL": return render_error("Email invalid, please logout") return render_public_user_info(user_id) else: return redirect(host)
def display_course_info(course_id): user_email, user_type = get_email_and_type(request) if user_email is not None: response = render_course_info(user_email, user_type, course_id) if response is not None: return response return render_error("Not logged in properly")
def add_project_team(course_id, sec_no, number): user_email, user_type = get_email_and_type(request) if user_email is not None: if request.method == "POST": handle_add_project_team(course_id, sec_no, number) return redirect("/".join( [host, "courses", course_id, sec_no, "project", number])) return render_error("You do not have access to the page")
def render_assignment_info(professor_email, course_id, sec_no, assignment_type, assignment_number, grade_id): teaches = course_management_api.check_professor_teaches_section( professor_email, course_id) if not teaches: return render_error("You are not allowed to access this page") switch = { "homework": render_homework_information, "exam": render_exam_information, "project": render_capstone_project_information } assignment_handler = switch.get(assignment_type, None) if assignment_handler is None: return render_error("Something went wrong") return assignment_handler(course_id, sec_no, assignment_number, grade_id)
def add_assignment(course_id, sec_no): user_email, user_type = get_email_and_type(request) if user_email is not None: if request.method == "POST": handle_add_assignment(course_id, sec_no, request.form) url = "/".join([host, "courses", course_id, sec_no]) return redirect(url) else: return render_add_assignment_info(user_email, course_id, sec_no) return render_error("You do not have access to the page")
def present_user_change_page(): user_email, user_type = get_email_and_type(request) # User logged in already if user_email is not None: if user_email == "NULL": return render_error("Email invalid, please logout") error = None if request.method == "POST": error = handle_change_information_request(user_email, user_type, request.form) return render_change_user_information(user_email, user_type, error) else: return redirect(host)
def get_team_data(course_id, sec_no, team_id): user_email, user_type = get_email_and_type(request) if user_email is not None: if request.method == "POST": if request.form["action"] == "add": handle_add_team_member(course_id, sec_no, team_id, request.form) elif request.form["action"] == "drop": handle_drop_team_member(course_id, sec_no, team_id, request.form) return render_team_data(user_type, course_id, sec_no, team_id) return render_error("Not logged in")
def render_private_user_info(email, user_type): response = None print(user_type) if user_type == USER.STUDENT: response = render_student_info(email) elif user_type == USER.PROFESSOR: response = render_professor_info(email) elif user_type == USER.ADMIN: response = redirect(host + "/admin") else: return render_error("Not properly logged in") response.set_cookie("user_email", email) response.set_cookie("user_type", user_type) return response
def render_add_assignment_info(user_email, course_id, sec_no): teaches = course_management_api.check_professor_teaches_section( user_email, course_id) if not teaches: return render_error("You are not allowed to access this page") section_type = course_management_api.get_section_type(course_id, sec_no) professor_emails = None if section_type == "Cap": professor_emails = course_management_api.get_all_professor_emails() return make_response( render_template('courses/add_assignment.html', course_id=course_id, sec_no=sec_no, professor_emails=professor_emails))
def assignment_information(course_id, sec_no, assignment_type, number): user_email, user_type = get_email_and_type(request) if user_email is not None: grade_id = None # For POST To identify if the grade was successful if request.method == "POST": grade_id = handle_add_course_grade(user_email, course_id, sec_no, assignment_type, number, request.form) if user_type == USER.PROFESSOR: return render_assignment_info(user_email, course_id, sec_no, assignment_type, number, grade_id) elif user_type == USER.STUDENT and assignment_type == "project": return render_student_capstone_project_information( course_id, sec_no, number) return render_error("You do not have access to the page")