def courses_delete(course_id): Course.poista_KurssiKayttaja(course_id) c = Course.query.get(course_id) db.session().delete(c) db.session().commit() return redirect(url_for("courses_index"))
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) c = Course(form.name.data, form.description.data) c.account_id = current_user.id db.session().add(c) db.session().commit() return redirect(url_for("courses_index"))
def courses_index(): courses = Course.count_enrolled_students_in_each_course() mycourses = User.query.get(current_user.id).courses course_array = [] for course in mycourses: course_array.append(course.course_id) length = Course.count_courses() return render_template("courses/courses.html", courses=courses, mycourses=course_array, length=length)
def kurssimateriaalitaulu_index(): return render_template( "kurssimateriaalitaulu/kurssimateriaalitauluform.html", form=UnionForm(), course_materials=Course.courseto_material(), courses=Course.query.all(), materials=Material.query.all())
def delete_attendance(course_id): Reservation.query.filter_by(course_id=course_id).filter_by( account_id=current_user.id).delete() course = Course.query.filter_by(id=course_id).first() tbd = db.session.query(User).filter_by(id=current_user.id).first() course.users.remove(tbd) db.session().commit() return render_template("courses/user_courses.html", my_courses=Course.find_my_courses(current_user.id))
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) t = Course(form.name.data, form.location.data, form.startingDate.data, form.endingDate.data, form.description.data, form.price.data, form.organizerIban.data) if current_user.iban == "": current_user.iban = form.organizerIban.data t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("courses_index"))
def delete_attendance_admin(course_id, account_id): Reservation.query.filter_by(course_id=course_id).filter_by( account_id=account_id).delete() course = Course.query.filter_by(id=course_id).first() tbd = db.session.query(User).filter_by(id=account_id).first() course.users.remove(tbd) db.session().commit() return render_template("courses/user_in_course.html", all_courses=Course.all_courses())
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) c = Course(form.nimi.data) db.session().add(c) db.session().commit() return redirect(url_for("courses_index"))
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) c = Course(form.name.data, form.description.data, form.max_participants.data) db.session().add(c) db.session().commit() return redirect(url_for("courses_index"))
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form = form) courseExists = Course.query.filter_by(name=form.name.data).first() if courseExists: return render_template("courses/new.html", form = form, error = "Course already exists") courseCodeExists = Course.query.filter_by(coursecode=form.coursecode.data).first() if courseCodeExists: return render_template("courses/new.html", form = form, error = "Course code already exists") course = Course(form.name.data, form.coursecode.data, form.language.data, \ form.level.data, form.spots.data, form.course_location.data.id, form.description.data, form.registrationsopen.data) course.registrationsopen = form.registrationsopen.data db.session().add(course) db.session().commit() return redirect(url_for("courses_index"))
def before_feature(context, feature): User.bulk_create([ User(pk=1, username='******', password='******', role=Role.Student), User(pk=2, username='******', password='******', role=Role.Student), User(pk=3, username='******', password='******', role=Role.Student), User(pk=4, username='******', password='******', role=Role.Professor), User(pk=5, username='******', password='******', role=Role.Staff), ]) Course.bulk_create([ Course(pk=1, name='Basic Programming', professor_id=4, capacity=2), Course(pk=2, name='Advanced Programming', professor_id=4, capacity=2), Course(pk=3, name='Documentation', professor_id=4, capacity=2), ]) CourseDependency.create(pk=1, dependant=2, dependee=1) CourseEnrollment.bulk_create([ CourseEnrollment(student_id=1, course=1), CourseEnrollment(student_id=3, course=1), CourseEnrollment(student_id=1, course=2), CourseEnrollment(student_id=2, course=3), ]) context.base_url = 'http://localhost:5000' context.browser = WebDriver()
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) course = Course(form.name.data, form.datestart.data, form.dateend.data, form.place.data, form.teachers.data, form.desc.data, form.topic.data) db.session().add(course) db.session().commit() return redirect(url_for("courses_index"))
def step_impl(context, course): c: Course = Course.select().where(Course.name == course).first() context.course_url = '%s/courses/%d' % (context.base_url, c.pk) context.browser.get(context.course_url) course_data = context.browser.find_element_by_class_name('lead') student_count = int( re.search(r'Student count: (\d+)', course_data.text)[1]) capacity = int(re.search(r'Capacity: (\d+)', course_data.text)[1]) assert student_count == capacity context.student_count = student_count context.capacity = capacity
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("/courses/new.html", form=form) c = Course(form.course_id.data, form.title.data, form.description.data, form.duration.data, form.deadline.data) u = User.query.get(current_user.id) c.users.append(u) db.session().add(c) db.session().commit() return redirect(url_for("courses_mycourses"))
def index(): if not current_user.is_authenticated: return render_template("index.html") user = User.query.get(current_user.id) name = user.firstname + ' ' + user.lastname if user.is_student(): courses = Log.fetch_five_most_recent_courses_with_activity() return render_template("index.html", name = name, courses = courses) if user.is_teacher(): courses = Course.fetch_five_most_recent_courses() return render_template("index.html", name = name, courses = courses) return render_template("index.html")
def courses_create(): form = CourseForm(request.form) if not form.validate(): return render_template("courses/new.html", form=form) t = Course(form.name.data) m = Course.query.filter(Course.name == form.name.data).count() if m > 0: return redirect(url_for("course_index")) else: db.session().add(t) db.session().commit() return redirect(url_for("courses_form"))
def courses_search(): search_term = request.form.get("search") courses = Course.count_enrolled_students_in_each_course_with_search_term( search_term) mycourses = User.query.get(current_user.id).courses mycourses_array = [] for course in mycourses: mycourses_array.append(course.course_id) course_array = [] length = len(courses) return render_template("courses/courses.html", courses=courses, mycourses=mycourses_array, length=length)
def courses_index(): search = CourseSearchForm(request.form) if request.method == 'POST': return search_results(search) return render_template("courses/list.html", courses = Course.query.all(), form=search, find_location=Course.find_location_name())
def logs_all(): active_courses = Log.fetch_students_courses_with_progress() inactive_courses = Course.fetch_users_courses_without_logs() return render_template("logs/logs.html", active_courses=active_courses, inactive_courses=inactive_courses)
def search_students_options(): return render_template("courses/user_in_course.html", all_courses=Course.all_courses())
def search_students(): name = request.form.get("option") return render_template( "auth/user_in_course.html", students_in_course=Course.find_student_by_course(name))
def index(): return render_template( "index.html", count_courses=Course.count_courses_per_location(), count_registrations=Registration.count_registrations_per_course(), most_popular=Registration.most_popular_courses())
def my_courses(): return render_template("courses/user_courses.html", my_courses=Course.find_my_courses(current_user.id))
def student_home(): return render_template( 'users/student_home.html.j2', courses=Course.select().join(CourseEnrollment).where( CourseEnrollment.student == session['current_user']['id']))
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Course name': query = db.session().query(Course).filter(Course.name.contains(search_string)) results = query.all() elif search.data['select'] == 'Course code': query = db.session().query(Course).filter(Course.coursecode.contains(search_string)) results = query.all() elif search.data['select'] == 'Language': query = db.session().query(Course).filter(Course.language.contains(search_string)) results = query.all() elif search.data['select'] == 'Level': query = db.session().query(Course).filter(Course.level.contains(search_string)) results = query.all() if not results: flash('No results') return redirect(url_for("courses_index")) else: return render_template("courses/list.html", courses = results, form=search, find_location=Course.find_location_name())