コード例 #1
0
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")
コード例 #2
0
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")
コード例 #3
0
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
コード例 #4
0
ファイル: app.py プロジェクト: sagschwind/CanvasPath
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)
コード例 #5
0
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")
コード例 #6
0
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")
コード例 #7
0
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)
コード例 #8
0
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")
コード例 #9
0
ファイル: app.py プロジェクト: sagschwind/CanvasPath
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)
コード例 #10
0
ファイル: team_manager.py プロジェクト: sagschwind/CanvasPath
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")
コード例 #11
0
ファイル: app.py プロジェクト: sagschwind/CanvasPath
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
コード例 #12
0
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))
コード例 #13
0
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")