示例#1
0
def create_course():
    cd = request.form['code']
    nm = request.form['name']
    dcptn = request.form['description']
    new = Course(cd, nm, dcptn)
    db.session.add(new)
    db.session.commit()
    return redirect('/courses')
示例#2
0
def add_course():
    try:
        course = Course(request.form['code'], request.form['name'])
        db.session.add(course)
        db.session.commit()
        return make_response('Course Added')
    except:
        return make_response('Error! While Adding Course')
示例#3
0
def add_course():
    if request.method == 'POST':
        try:
            course = Course(request.form['id'], request.form['name'])
            db.session.add(course)
            db.session.commit()
            return 'success: Created a course'
        except:
            return 'error: Enter the field values correctly'
示例#4
0
def add_course():
    try:
        course_id = request.form['Course_id']
        course_name = request.form['Course_name']
        Cour1 = Course(course_id, course_name)
        db.session.add(Cour1)
        db.session.commit()
        return jsonify(success=True)
    except:
        return jsonify(success=False)
示例#5
0
def create_course():
    if request.method == 'POST':
        if not request.form['code'] or not request.form[
                'name'] or not request.form['description']:
            flash('Please enter all fields', 'error')
        else:
            course = Course(request.form['code'], request.form['name'],
                            request.form['description'])
            db.session.add(course)
            db.session.commit()
            return redirect(url_for('courses.get_all_courses'))
    return render_template('courses/addNew.html')
def add_course():
    code = request.form['id']
    name = request.form['name']

    if (code == '' or name == ''):
        return make_response('error: Fill all the fields!', 400, None)
    elif (Course.query.filter(Course.code == code).all()):
        return make_response('error: Course already added!', 400, None)
    try:
        course = Course(code, name)
        db.session.add(course)
        db.session.commit()
        return make_response('success: Created a course!', 200, None)
    except:
        return make_response('error: Enter the valid values!', 400, None)
示例#7
0
def course_create():
    class_code_list = ClassCode.query.all()
    form = CourseCreateForm()
    form.classes.choices = [(class_code.id, class_code.name)
                            for class_code in class_code_list]

    if form.is_submitted():
        selections = form.classes.data
        course = Course(name=form.name.data, course_code=form.course_code.data)
        db.session.add(course)
        db.session.commit()

        # Establish many to many relationship between the classess and course
        for selection in selections:
            class_course = ClassCourses(class_code_id=selection,
                                        course_id=course.id)
            db.session.add(class_course)
            db.session.commit()

        flash(f'{course.name} has been created')

        return redirect(url_for('pages.educator_dashboard'))

    return render_template('courses/create.html', form=form)