Example #1
0
 def updateCGPAForAllStudents():
     for student in Student.select():
         cgpa = GPACalculator.calculateGpaForStudent(student)
         update_student = Student()
         update_student.roll = student.roll
         update_student.cgpa = cgpa
         studentDAO = StudentDAO()
         if (cgpa is not None):
             studentDAO.createOrUpdateModel(update_student)
 def updateCGPAForAllStudents():
     for student in Student.select():
         cgpa = GPACalculator.calculateGpaForStudent(student)
         update_student = Student()
         update_student.roll = student.roll
         update_student.cgpa = cgpa
         studentDAO = StudentDAO()
         if(cgpa is not None):
             studentDAO.createOrUpdateModel(update_student)
Example #3
0
 def __init__(self):
     try:
         School.create_table()
         UserType.create_table()
         Application.create_table()
         Users.create_table()
         ApplicationPermission.create_table()
         Device.create_table()
         OSContainer.create_table()
         SessionInfo.create_table()
         Student.create_table()
         Teacher.create_table()
     except peewee.InternalError as e:
         print(str(e))
Example #4
0
    def __init__(self, controller):
        self.__controller = controller

        self.store = Store()
        self.student = Student(model=self, controller=self.__controller)
        self.activity = Activity(controller=self.__controller,
                                 store=self.store)
 def readEntry(self, roll):
     try:
         student = Student.get(Student.roll == roll)
     except Exception:
         print("Error: invalid roll number")
         return None
     return student
Example #6
0
 def readEntry(self, roll):
     try:
         student = Student.get(Student.roll == roll)
     except Exception:
         print("Error: invalid roll number")
         return None
     return student
Example #7
0
 def getAllStudents(self):
     try:
         list_students = [student for student in Student.select()]
     except Exception:
         print("Exception occurred.")
         traceback.print_exc()
         return None
     return list_students
 def getAllStudents(self):
     try:
         list_students = [student for student in Student.select()]
     except Exception:
         print("Exception occurred.")
         traceback.print_exc()
         return None
     return list_students
 def getStudentsByBatch(self, department, year_of_passing, course):
     try:
         list_students = [student for student in Student.select().where((Student.department == department) & (Student.batch_passing_year == year_of_passing) & (Student.course == course))]
     except:
         print("Exception occurred")
         traceback.print_exc()
         return []
     return list_students
Example #10
0
 def getStudentsByBatch(self, department, year_of_passing, course):
     try:
         list_students = [
             student for student in Student.select().where(
                 (Student.department == department)
                 & (Student.batch_passing_year == year_of_passing)
                 & (Student.course == course))
         ]
     except:
         print("Exception occurred")
         traceback.print_exc()
         return []
     return list_students
Example #11
0
def add_student():
    # часть функционала обрабатывает GET, а часть POST запросы, сделаем условие
    form = StudentForm()
    if form.validate_on_submit():
        name = form.name.data
        email = form.email.data
        phone = form.phone.data
        try:
            student = Student(name=name, email=email, phone=phone)
            db.session.add(student)
            db.session.commit()
        except:
            print('Что -то пошло не так')
        return redirect(url_for('students.index'))  # возврат на пустую форму
    #form = StudentForm() # иначе вернем форму
    return render_template('student/add_student.html', form=form)
Example #12
0
    def create_new_user(self, username, password, query):
        try:
            new_user = Users()
            new_user.user_name = username
            new_user.hashed_password = bcrypt.hashpw(password.encode('utf-8'),
                                                     bcrypt.gensalt())
            new_user.school_id = query.school_id
            new_user.first_name = query.first_name
            new_user.last_name = query.last_name
            new_user.user_type = query.user_type
            new_user.email = query.email
            new_user.profession = query.profession
            new_user.save()
            if query.user_type.lower() == "teacher":
                new_teacher = Teacher()
                new_teacher.user_id = new_user.user_id
                new_teacher.has_system_access = True
                new_teacher.save()
                response.body = json.dumps({
                    'success':
                    'Successfully created teacher ' + new_user.user_name +
                    ' with id ' + str(new_user.user_id),
                    'id':
                    new_user.user_id
                })
                response.status = 200
            elif query.user_type.lower() == "student":
                new_student = Student()
                new_student.user_id = new_user.user_id
                new_student.has_system_access = False
                new_student.save()

                response.body = json.dumps({
                    'success':
                    'Successfully created student ' + new_user.user_name +
                    ' with id ' + str(new_user.user_id),
                    'id':
                    new_user.user_id
                })
                response.status = 200
            else:
                response.body = json.dumps({'error': 'Unknown user type'})
                response.status = 500

        except Exception as e:
            response.body = json.dumps({'error': str(e)})
            response.status = 500
        return response
            x = elem.text.split(':')
            #             print(x)
            if ('SGPA' in x[0]):
                #                 print('yes',x[1].strip())
                try:
                    gpa_value = float(x[1].strip())
                except Exception:
                    print("Exception occurred in extracting GPA")
                    traceback.print_exc()
                else:
                    gpa_flag = True
        if (gpa_flag):
            list_td = soup.find_all("td",
                                    attrs={
                                        "align": "center",
                                        "class": "underlineresult"
                                    })
            for elem in list_td:
                text = elem.text.strip()
                if (re.search("^0012105010", text)):
                    class_roll = text
        if (gpa_flag and class_roll):
            print(exam_roll, class_roll, gpa_value)
            student = Student()
            student.roll = class_roll
            student.gpa5 = gpa_value
            studentDAO = StudentDAO()
            studentDAO.createOrUpdateModel(student)
except Exception:
    print("Exception occurred")
    traceback.print_exc()
Example #14
0
        studentDAO = StudentDAO()
        studentDAO.createOrUpdateModel(studentDAO.dictionaryToModel(dict))

# for student in Student.select():
#     cgpa = GPACalculator.calculateGpaForStudent(student)

#GPACalculator.updateCGPAForAllStudents()
# studentDAO = StudentDAO()
# list_students = studentDAO.getStudentsByBatch("CSE", "2016", "BE")#[student for student in Student.select()]
# list_students_2 = studentDAO.getStudentsByBatch("IT", "2016", "BE")
# list_students = list_students + list_students_2
# for student in list_students:
#     print(student.name, student.roll)

if (write_flag):
    studentDAO = StudentDAO()
    list_students = [
        student for student in Student.select().order_by(
            Student.course, Student.department, Student.batch_passing_year,
            Student.roll)
    ]
    #print(list_students)
    csvDatabaseWriter = CsvDatabaseWriter(*fieldnames_write)
    print(fieldnames_write)
    list_students_dictionaries = [
        student.__dict__.get('_data') for student in list_students
    ]
    #print(list_students_dictionaries)
    csvDatabaseWriter.dictionaryListToCsv(csv_write_filename,
                                          *list_students_dictionaries)
        list_strong = soup.find_all("strong")
        for elem in list_strong:
#             print("item: ")
#             print(elem.text)
            x = elem.text.split(':')
#             print(x)
            if('SGPA' in x[0]):
#                 print('yes',x[1].strip())
                try:
                    gpa_value = float(x[1].strip())
                except Exception:
                    print("Exception occurred in extracting GPA")
                    traceback.print_exc()
                else:
                    gpa_flag = True
        if(gpa_flag):       
            list_td = soup.find_all("td", attrs={"align":"center", "class":"underlineresult"})
            for elem in list_td:
                text = elem.text.strip()
                if(re.search("^0012105010", text)):
                    class_roll = text
        if(gpa_flag and class_roll):
            print(exam_roll, class_roll, gpa_value)
            student = Student()
            student.roll = class_roll
            student.gpa5 = gpa_value
            studentDAO = StudentDAO()
            studentDAO.createOrUpdateModel(student)
except Exception:
    print("Exception occurred")
    traceback.print_exc()
 def createDictonary(self, student):
     try:
         Student.create(**student)
     except Exception:
         print("Error: unable to update database entry")
         traceback.print_exc()
    dict_list = csv_reader.csvToDictionaryList(csv_read_filename)
    print(dict_list)
    for dict in dict_list:
        print(dict)
        studentDAO = StudentDAO()
        studentDAO.createOrUpdateModel(studentDAO.dictionaryToModel(dict))
        
        
# for student in Student.select():
#     cgpa = GPACalculator.calculateGpaForStudent(student)

#GPACalculator.updateCGPAForAllStudents()
# studentDAO = StudentDAO()
# list_students = studentDAO.getStudentsByBatch("CSE", "2016", "BE")#[student for student in Student.select()]
# list_students_2 = studentDAO.getStudentsByBatch("IT", "2016", "BE")
# list_students = list_students + list_students_2
# for student in list_students:
#     print(student.name, student.roll)

if(write_flag):
    studentDAO = StudentDAO()
    list_students = [student for student in Student.select().order_by(Student.course, Student.department, Student.batch_passing_year, Student.roll)]
    #print(list_students)
    csvDatabaseWriter = CsvDatabaseWriter(*fieldnames_write)
    print(fieldnames_write)
    list_students_dictionaries = [student.__dict__.get('_data') for student in list_students]
    #print(list_students_dictionaries)
    csvDatabaseWriter.dictionaryListToCsv(csv_write_filename, *list_students_dictionaries)


Example #18
0
 def createDictonary(self, student):
     try:
         Student.create(**student)
     except Exception:
         print("Error: unable to update database entry")
         traceback.print_exc()
Example #19
0
 def dictionaryToModel(self, dictionary):
     student = Student()
     for key in dictionary:
         setattr(student, key, dictionary[key])
     return student