Exemple #1
0
def startCreateCourses():
    model = CourseModel()

    if request.form.get('searchType', False):
        courseType = request.form['searchType']
        results = model.searchCourses(courseType=courseType)

        result = model.getNewestCourse()
        types = model.getCourseTypes()
        return render_template("courses.html",
                               types=types,
                               newUrl=result["url"],
                               newTitle=result['title'],
                               searchResults=results)
    else:
        name = request.form['name']
        count = request.form['questions']
        courseType = request.form['type']

        id = model.addCourse(userId=session['userId'],
                             title=name,
                             type=courseType)

        if name and count and courseType:
            return redirect(
                url_for("openCreateCourseForm", name=name, count=count, id=id))
Exemple #2
0
def courses():
    if "email" in session:
        model = CourseModel()
        result = model.getNewestCourse()
        types = model.getCourseTypes()
        return render_template("courses.html", types=types, newUrl=result["url"], newTitle=result['title'], searchResults={})

    return redirect(url_for('login'))
Exemple #3
0
def courses():
    if "email" in session:
        model = CourseModel()
        result = model.getNewestCourse()
        types = model.getCourseTypes()
        return render_template("courses.html",
                               types=types,
                               newUrl=result["url"],
                               newTitle=result['title'],
                               searchResults={})

    return redirect(url_for('login'))
Exemple #4
0
def startCreateCourses():
    model = CourseModel()

    if request.form.get('searchType', False):
        courseType = request.form['searchType']
        results = model.searchCourses(courseType=courseType)

        result = model.getNewestCourse()
        types = model.getCourseTypes()
        return render_template("courses.html", types=types, newUrl=result["url"], newTitle=result['title'], searchResults=results)
    else:
        name = request.form['name']
        count = request.form['questions']
        courseType = request.form['type']

        id = model.addCourse(userId=session['userId'], title=name, type=courseType)

        if name and count and courseType:
            return redirect(url_for("openCreateCourseForm", name=name, count=count, id=id))