Ejemplo n.º 1
0
    def post(self, semester):
        data = GetStudentMarks.parser.parse_args()

        student = StudentMain.find_by_roll_number(data['roll_no'])
        student_marks = {
            'roll_no': student.roll_no,
            'semester': semester,
            'subjects': []
        }
        if student:
            subject_code_list = Subjects.find_subject(student.discipline,
                                                      semester)
            for subject in subject_code_list:
                subject_marks = StudentMarks.get_marks_all(
                    subject, student.roll_no, semester)
                marks_details = {
                    'subject_name': Subjects.get_subject_name(subject),
                    'subject_code': subject_marks['subject_code'],
                    'cat': subject_marks['cat'],
                    'mid': subject_marks['mid'],
                    'end': subject_marks['end'],
                    'assignment': subject_marks['assignment'],
                    'attendance': subject_marks['attendance']
                }
                student_marks['subjects'].append(marks_details)
            return student_marks
        else:
            return {'message': 'No student with that roll number exists'}
Ejemplo n.º 2
0
    def post(self, semester):
        data = GetStudentAttendance.parser.parse_args()

        student = StudentMain.find_by_roll_number(data['roll_no'])
        student_attendance = {
            'roll_no': student.roll_no,
            'semester': semester,
            'subjects': []
        }
        if student:
            subject_code_list = Subjects.find_subject(student.discipline,
                                                      semester)
            for subject in subject_code_list:
                subject_attendance = StudentAttendance.get_attendance_max_present(
                    subject, student.roll_no, semester)
                attendance_details = {
                    'subject_name': Subjects.get_subject_name(subject),
                    'subject_code': subject_attendance['subject_code'],
                    'max_attendance': subject_attendance['max_attendance'],
                    'present_attendance':
                    subject_attendance['present_attendance']
                }
                student_attendance['subjects'].append(attendance_details)
            return student_attendance
        else:
            return {'message': 'No student with that roll number exists.'}
Ejemplo n.º 3
0
 def populate_submission_table(self, course, discipline, semester,
                               material_code):
     roll_no_list = StudentMain.find_by_course_discipline_semester(
         course, discipline, semester)
     for roll_no in roll_no_list:
         material_submission = MaterialSubmissionModel(
             material_code, roll_no, None, None, None)
         material_submission.save_to_db()
Ejemplo n.º 4
0
 def get(self, roll_no):
     student = StudentMain.find_by_roll_number(roll_no)
     if student:
         filename = "".join(student.get_file_name(roll_no))
         file_list = filename.split(".")
         file_extension = file_list[1]
         file_dictionary = {
             'filename': filename
         }
         return send_file(file_dictionary['filename'], mimetype='image/' + file_extension)
Ejemplo n.º 5
0
    def post(self):
        data = self.parser.parse_args()
        student = StudentMain.find_by_roll_number(data['roll_no'])

        discipline = student.discipline
        semester = student.current_sem

        material_list = MaterialUploadModel.get_all_by_discipline_semester(
            discipline, semester)

        return material_list
Ejemplo n.º 6
0
    def post(cls):
        data = cls.parser.parse_args()

        student = StudentMain.find_by_roll_number(data['roll_no'])
        if student and safe_str_cmp(student.password, data['password']):
            access_token = create_access_token(identity=student.roll_no, fresh=True)
            refresh_token = create_refresh_token(student.roll_no)
            return {
                'access_token' : access_token,
                'refresh_token': refresh_token
            }, 200
        return {'message': 'Invalid credentials'}, 401
Ejemplo n.º 7
0
    def post(self):
        data = StudentRegister.parser.parse_args()

        if StudentMain.find_by_roll_number(data['roll_no']):
            return {'message': 'A student with that roll number already exists'}

        file = request.files['file']
        if file.filename == '':
            return {'message': 'The uploaded file has no filename'}
        if file and self.allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file_name_list = filename.split(".")
            new_file_name = os.path.normpath(os.path.join(self.UPLOAD_FOLDER_PROFILE_PICTURES_PATH, data['roll_no'] +
                                                          "-profile-picture." + file_name_list[len(file_name_list)-1]))
            #  The length function is used for images with multiple '.' in their name.
            #  This makes sure only the last string after the '.' is used that will be the extension
            file.save(new_file_name)
            student = StudentMain(data['roll_no'], data['reg_no'], data['first_name'], data['last_name'], data['dob'],
                                  data['school'], data['course'], data['discipline'], data['current_sem'],
                                  data['final_sem'], data['join_year'], data['final_year'], data['tenth_marks'],
                                  data['twelfth_marks'], data['jee_score'], data['password'], data['phone'],
                                  data['mail'], data['gender'], data['father_first'], data['father_last'],
                                  data['mother_first'], data['mother_last'], new_file_name)
            student.save_to_db()
            return {
                'message': 'Student registration successful!',
                'data': student.json(),
            }, 201