Exemple #1
0
def courseDelete(course_id):
    instructor_id = getInstructorIdForACourse(course_id)
    if current_user.isInstructor(
    ) and current_user.user_id == instructor_id:  # checking if the user is instructor and opened this course
        if deleteCourse(course_id):
            flash("The course has been deleted.")
    else:
        flash("You don't have authorization to delete this course.")
    return redirect(url_for('home'))
Exemple #2
0
def courseAdd():
    if (current_user.isInstructor() == False):
        flash("You don't have permission to add a course.")
        return redirect('home')
    form = CourseRegistrationForm()
    if form.validate_on_submit():
        if registerCourse(form, current_user.user_id):
            flash('New course has been created!', 'success')
            return redirect(url_for('home'))
        else:
            flash('The crn already exist.')
    return render_template('courseAdd.html', form=form, title='Courses')
Exemple #3
0
def outcomeAdd():
    if (current_user.isInstructor() == False):
        flash("You don't have permission to add an outcome.")
        return redirect('home')
    form = OutcomeRegistrationForm()
    if form.validate_on_submit():
        if registerOutcome(form):
            flash('New outcome has been created!', 'success')
            return redirect(url_for('home'))
        else:
            flash('The outcome already exists.')
    return render_template('outcomeAdd.html',
                           form=form,
                           title='Add a new outcome')
Exemple #4
0
def home():
    userType = ""
    courses = []
    nodes = []
    connections = []
    if not current_user.is_authenticated:
        userType = 'guest'
    elif current_user.isInstructor():
        userType = 'instructor'
        courses = getInstructorsCourses(current_user.user_id)
    elif current_user.isStudent():
        userType = 'student'
        nodes, connections = getCourseConnections(current_user.user_id)

    keys, cons = ConnectionModifier(nodes, connections)
    return render_template('rootHOME.html',
                           keys=keys,
                           cons=cons,
                           title='Home',
                           courses=courses,
                           userType=userType)
Exemple #5
0
def courseEdit(course_id):
    if (current_user.isInstructor() == False):
        return redirect(url_for('home'))
    course = getCourse(course_id)
    form = CourseUpdateForm()
    if form.validate_on_submit():
        if updateCourseData(course_id, form):
            flash('Course edited!', 'success')
            return redirect(url_for('course', course_id=course_id))
        else:
            flash('Course could not be edited.')
    elif request.method == 'GET':
        form.name.data = course.name
        form.crn.data = course.crn
        form.course_code.data = course.course_code
        form.credit.data = course.credit
        form.department.data = course.department_id
        form.prerequisites.data = getPrerequisitesIds(course_id)
        form.outcomes.data = getOutcomeIds(course_id)

    return render_template('courseAdd.html',
                           form=form,
                           course=course,
                           title='Courses')