Example #1
0
def add_grade_():
    form = AddGradeForm()
    if form.validate_on_submit():
        try:
            with db.transaction():
                grade = Grade.create(
                    student=Student.get(Student.username == form.student_select.data),
                    subject=Subject.get(Subject.name == form.subject_select.data),
                    teacher=get_current_user(),
                    grade=form.grade.data
                )
        except DatabaseError:
            flash('An error occurred while adding a grade')
        else:
            flash('Grade ' + str(grade.grade) + ' assigned to student ' + str(grade.student))
            return redirect(url_for('groups', group=grade.student.username))
    flash_errors(form)
    students = Student.select()
    subjects = Subject.select()
    return render_template('add_grade.html', students=students, subjects=subjects, form=form)
Example #2
0
def group_():
    group_number = get_current_user().group
    students = Student.select().where(Student.group == group_number)
    return render_template('group.html', group=group_number, students=students)
Example #3
0
def group_foreign_(group_number):
    students = Student.select().where(Student.group == group_number)
    return render_template('group.html', group=group_number, students=students)
Example #4
0
def groups_():
    student_groups = Student.select(Student.group).distinct().order_by(Student.group.asc())
    return render_template('groups.html', student_groups=student_groups)