Exemplo n.º 1
0
def get_module_students():  #Not Yet implemented. Looks incomplete
    modulecode = request.form.get('modulecode')
    session = get_db_session()
    module = attendance.ModuleAttendance(modulecode, session)

    mod_students = module.students

    resp = dict()

    for student in mod_students:
        resp[student.id] = dict()
        resp[student.id]['Name'] = student.name

    return jsonify(resp)  #TODO: Have this returned by a pretty template
Exemplo n.º 2
0
def get_module_students():  #Not Yet implemented
    if request.method == 'POST':
        modulecode = request.form.get('modulecode')
        module = attendance.ModuleAttendance(modulecode, session)

        mod_students = module.students

        resp = dict()

        for student in mod_students:
            resp[student.id] = dict()
            resp[student.id]['Name'] = student.name
            #resp[student.id]['Attendance'] =

        #student_attendance = get_attendance_student_module(studentID,modulecode)

        return jsonify(resp)  #TODO: Have this returned by a pretty template
    return under_cons_msg + 'for a Get request'
Exemplo n.º 3
0
def set_student_module_attendance():
    if request.method == 'POST':
        req = request.get_json()
        studentID = req['studentID']
        modulecode = req['modulecode']
        status = req['status']
        sess_date = req[
            'SessionDate']  #Expects YYYY-MM-DDTHH:MM Format (Iso 8601)
        try:
            studentID = int(studentID)
        except ValueError:
            return "The student ID {} must be a number (integer)".format(
                studentID)
        try:
            sess_date = datetime.datetime.strptime(sess_date, '%Y-%m-%dT%H:%M')
        except ValueError:
            return "The date {} is not in the required YYYY-MM-DDTHH:mm format".format(
                sess_date)

        if status.lower() == "present":
            status = True
        else:
            status = False

        mod_attendance = attendance.ModuleAttendance(modulecode, session)

        # mod_attendance.updateAttendance(studentID,sess_date, present=status)
        try:
            mod_attendance.updateAttendance(studentID,
                                            sess_date,
                                            present=status)
        except ValueError:
            return "The date >>{}<< does not have a class session for the module with code >>{}<<".format(
                sess_date.isoformat(), modulecode)

        #redirect to show student's attendance for the module. Preserve the POST parameters
        return redirect(url_for('get_student_module_attendance'), code=307)
    return under_cons_msg + 'for a Get request'


# app.debug = True
# if __name__ == '__main__':
# 	app.run(debug = True)
#Because of this final comment, the only way to run the flask app is to `flask run` on cmd
Exemplo n.º 4
0
def set_student_module_attendance():
    if request.method == 'POST':
        req = request.get_json()
        studentID = req['studentID']
        modulecode = req['modulecode']
        status = req['status']
        sess_date = req[
            'SessionDate']  #Expects YYYY-MM-DDTHH:MM Format (Iso 8601)
        try:
            studentID = int(studentID)
        except ValueError:
            return "The student ID {} must be a number (integer)".format(
                studentID)
        try:
            sess_date = datetime.datetime.strptime(sess_date, '%Y-%m-%dT%H:%M')
        except ValueError:
            return "The date {} is not in the required YYYY-MM-DDTHH:mm format".format(
                sess_date)

        if status.lower() == "present":
            status = True
        else:
            status = False

        session = get_db_session()
        mod_attendance = attendance.ModuleAttendance(modulecode, session)

        try:
            mod_attendance.updateAttendance(studentID,
                                            sess_date,
                                            present=status)
        except ValueError:
            return "The date >>{}<< does not have a class session for the module with code >>{}<<".format(
                sess_date.isoformat(), modulecode)

        #redirect to show student's attendance for the module. Preserve the POST parameters
        return redirect(url_for('api.get_student_module_attendance'), code=307)