def startNewAttendance(): if request.method == 'POST': attendance = Attendance(attendanceCollection) data = request.get_json() courseCode = data['courseCode'] date = helpers.getDate() attendanceExits = attendance.getAttendance(date, courseCode) attendanceExits = loads(attendanceExits) if (len(attendanceExits) > 0): res = jsonify('Attendace has already been taken for today') return res student = Students(studentCollection) students = student.getStudentsForParticleCourse(courseCode) stdAttendance = loads(students) for student in stdAttendance: student['present'] = False classAttendance = {'allStudents': stdAttendance, 'unknownStudents': []} obj = { 'courseCode': courseCode, 'date': date, 'classAttendance': classAttendance } att = attendance.addNewAttendance(obj) res = jsonify('New Attendance started.') return res
def getStudents(): if request.method == 'POST': student = Students(studentCollection) data = request.get_json() courseCode = data['courseCode'] students = student.getStudentsForParticleCourse(courseCode) studentsObj = loads(students) for student in studentsObj: student.pop('encodings') return dumps(studentsObj)