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)
Esempio n. 2
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)
        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()
            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()