Ejemplo n.º 1
0
def index():
    dept_form = DepartmentForm()
    if dept_form.validate_on_submit():
        dept = Departments(dept_name=dept_form.dept_name.data,
                           building=dept_form.building.data,
                           budget=dept_form.budget.data)
        db.session.add(dept)
        db.session.commit()
        return redirect(url_for('index'))

    departments = Departments.query.all()

    form = StudentForm()
    form.dept_name.choices = [(i, i)
                              for i in [ii.dept_name for ii in departments]]
    if form.validate_on_submit():
        student = Students(first_name=form.first_name.data,
                           last_name=form.last_name.data,
                           email=form.email.data,
                           dept_name=form.dept_name.data)
        db.session.add(student)
        db.session.commit()
        return redirect(url_for('index'))

    students = Students.query.all()

    return render_template('index.html',
                           title='Home',
                           dept_form=dept_form,
                           form=form,
                           departments=departments,
                           students=students)
Ejemplo n.º 2
0
def student_add_mac():
    form = StudentForm()
    if form.validate_on_submit():
        mac_addresses = form.mac_addresses.data
        email = form.email.data
        name = form.name.data
        if ',' in mac_addresses:
            mac_addresses_array = mac_addresses.split(',')
        else:
            mac_addresses_array = [mac_addresses]

        for mac_address in mac_addresses_array:
            if db.session.query(
                    db.exists().where(Student.email == email)).scalar():
                student = db.session.query(Student).filter(
                    Student.email == email).first()
                SID = student.id
                new_mac = Mac(mac_address=mac_address, student_id=SID)
                db.session.add(new_mac)
                db.session.commit()
            else:
                new_student = Student(email=email, name=name)
                db.session.add(new_student)
                db.session.commit()
                SID = new_student.id
                new_mac = Mac(mac_address=mac_address, student_id=SID)
                db.session.add(new_mac)
                db.session.commit()

        flash('Mac Address has been updated!')
        return redirect(url_for('student_add_mac'))
    return render_template('studentaddmac.html', title='Student', form=form)
Ejemplo n.º 3
0
def index():
    if Users.query.filter_by(net_id=cas.username).all() == []:
        abort(403)
    form = StudentForm(request.form)
    if form.validate_on_submit():
        print(form.searchStudents.data)
        students = Examrequest.query.all()
        searchResults = []
        for student in students:
            print(
                'ID:{}, STUDENT_ID:{}, STUDENT_NETID:{}, STUDENT_NAME:{}, COURSE_ID:{}, COURSE_NAME:{}, EXAM_TYPE:{}, EXAM_FORMAT:{}, EXAM_TIME:{}, EXAM_CSD_TIME:{}, CSD_CAMPUS:{}, CSD_BUILDING:{}, CSD_ROOM:{}, CSD_SEAT:{}, INSTRUCTOR_NETID:{}, INSTRUCTOR_NAME:{}, INSTRUCTOR_PHONE:{}, INSTRUCTOR_EMAIL:{}, MATERIAL:{}, ACCOMMODATIONS:{}, INSTRUCTOR_NOTES:{}>'
                .format(student.id, student.student_id, student.student_netid,
                        student.student_name, student.course_id,
                        student.course_name, student.exam_type,
                        student.exam_format, student.exam_time,
                        student.exam_csd_time, student.csd_campus,
                        student.csd_building, student.csd_room,
                        student.csd_seat, student.instructor_netid,
                        student.instructor_name, student.instructor_phone,
                        student.instructor_email, student.material,
                        student.accommodations, student.instructor_notes))
            if student.student_name == form.searchStudents.data:
                searchResults.append(student)
        return render_template('index.html', form=form, results=searchResults)
    return render_template('index.html', form=form)
Ejemplo n.º 4
0
def student():
    form = StudentForm()
    # years = ['Freshman', 'Sophomore', 'Junior', 'Senior']
    app.logger.info('test')

    if form.validate_on_submit():
        fname = form.firstname.data
        lname = form.firstname.data
        year_id = form.year.data

        db.session.add(Student(first_name=fname, last_name=lname, year_id=int(year_id)))
        db.session.commit()

    students = Student.query.all()

    return render_template('student.html', title='Students', form=form, students=students)
Ejemplo n.º 5
0
def addStudent():

    addStudentForm = StudentForm()
    addAssignmentForm = AssignmentForm()

    if addStudentForm.validate_on_submit():
        newstudent = Student(addStudentForm.first.data.strip(),
                             addStudentForm.last.data.strip(),
                             addStudentForm.email.data.strip())
        students.append(newstudent)
        # anything you print here gets printed to your terminal
        print(newstudent.first, newstudent.last, newstudent.email)
        return redirect(url_for('index'))
    return render_template('gradebook.html',
                           addStudentForm=addStudentForm,
                           addAssignmentForm=addAssignmentForm,
                           students=students,
                           assignments=assignments)
Ejemplo n.º 6
0
def college_recommend():
    import numpy as np
    form = StudentForm()
    area_city = json.load(open("data/city.json"))
    res = []
    scores = []
    inps = []
    points = []
    majors = []
    all_std = []
    factors = [1, 1, 1, 1]
    factorForm = FactorForm()

    if form.validate_on_submit():
        area_id = ""
        for k, v in area_city.items():
            if (form.city.data in v):
                area_id = areas[k]

        # factors = [int(form.area_factor.data),int(form.fee_factor.data),int(form.point_factor.data),int(form.major_factor.data)]
        st_data = (area_id, form.subject1.data, float(form.point1.data),
                   form.subject2.data, float(form.point2.data),
                   float(form.fee.data), form.favor.data)

        input_array = make_matrix(t, st_data)
        print(st_data, "ssssss")
        # print(type(form.area_factor.data),form.area_factor.data,"tttt")
        ids, ids_bot, _ = topsis(input_array, factors, [-1, -1, -1, 1])
        # ids = np.append(ids,ids_bot)

        inps = [[round(t, 2) for t in input_array[i]] for i in ids]

        all_std = [(j[0], [round(t, 2) for t in j[1]], j[2])
                   for j in sorted(zip([k["name"] for k in t], input_array, _),
                                   key=lambda x: x[2])[::-1]]
        print(all_std, _)
        scores = [_[i] for i in ids]

        for id in ids:
            p = []
            if form.subject1.data in t[id]["point"]:
                p = [[
                    form.subject1.data,
                    round(t[id]["point"][form.subject1.data], 2)
                ]]
            if form.subject2.data in t[id]["point"]:
                p.append([
                    form.subject2.data,
                    round(t[id]["point"][form.subject2.data], 2)
                ])
            points.append(p)
        majors = [
            sorted(t[i]["major_name"],
                   key=lambda x: similar(st_data[6], x))[-5:][::-1]
            for i in ids
        ]
        for id in ids:
            res.append(t[id])
        print(points, majors)
        print(len(ids), "tttttt")
        # res = t[id]

    return render_template('college_recommend.html',
                           title='College Recomender',
                           form=form,
                           ress=zip(res, scores, inps, points, majors),
                           all_std=all_std)
Ejemplo n.º 7
0
def index():
    form = StudentForm()
    if form.validate_on_submit():
        flash("Create Successful ...!!!")
    return render_template("index.html", form=form)