def viewProfile(): id = session['userId'] model = CourseModel() userData = model.getUserData(userId=id) courses = model.getUserCourses(userId=id) return render_template("profile.html", userData=userData[0], courses=courses)
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'))
def openCourse(): id = request.args.get("id") title = request.args.get("title") model = CourseModel() result = model.getCourse(courseId=id) descr = model.getDescription(courseId=id) return render_template('/loadCourse.html', courseData=result, id=id, title=title, description=descr[0])
def createCourse(): course_id = int(request.args.get('courseId')) count = int(request.args.get('count')) model = CourseModel() model.createCourse(courseId=course_id, count=count) return redirect(url_for("courses"))
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))
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))
def finishCourse(): model = CourseModel() courseId = request.args.get('id') model.finishCourse(session['userId'], courseId) return redirect(url_for('courses'))