def admin_add_course(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: handle_add_course(request.form) return redirect(host + "/admin/courses")
def admin_drop_course(course_id): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: course_management_api.delete_course(course_id) return redirect(host + "/admin/courses")
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 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 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 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 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 drop_student(user_type, student_id): user_name, _ = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") _type = "X" if user_type == "student": _type = USER.STUDENT else: return redirect(host + "/logout") user_manager_api.delete_user(student_id, _type) return redirect(host + "/admin/" + user_type)
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 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")
def handle_section_action(course_id, sec_no, action): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") elif action == "add_professor": team_id = course_management_api.get_team_id(course_id, sec_no) course_management_api.add_professor_to_teaching_team( request.form["email"], team_id) elif action == "drop_professor": team_id = course_management_api.get_team_id(course_id, sec_no) course_management_api.drop_professor_from_teaching_team( request.form["email"], team_id) elif action == "add_student": course_management_api.add_student_section(request.form["email"], course_id, sec_no) elif action == "drop_student": course_management_api.drop_student_section(request.form["email"], course_id, sec_no) return redirect("/".join([host, "admin/courses", course_id, sec_no]))
def home_page(): error = None 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_template('login.html', error="Email invalid") return render_private_user_info(user_email, user_type) # Login request if request.method == 'POST': email = request.form['Email'] password = request.form['Password'] user_type, login_error = user_manager_api.valid_login(email, password) print(email, password, user_type, login_error) if login_error is not None: return render_template('login.html', error=login_error, url=host) else: return render_private_user_info(email, user_type) return render_template('login.html', error="Email invalid")
def add_section(course_id): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") handle_add_section(course_id, request.form) return redirect("/".join([host, "admin/courses", course_id]))
def render_admin_home(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return make_response(render_template("admin/home.html"))
def render_admin_section(course_id, sec_no): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return render_admin_single_section(course_id, sec_no)
def render_admin_courses(): user_name, user_type = get_email_and_type(request) if not admin_management_api.validate_admin(user_name, user_type): return redirect(host + "/logout") else: return render_admin_courses_page()