Ejemplo n.º 1
0
    def convertJSONToList(itemType: type, jsonObject):
        list = json.loads(jsonObject)
        newList = []
        newItem = None
        for item in list:
            if itemType is Student:
                newItem = Student(
                    TypeParser.parseInt(item["studentId"], InvalidStudentId),
                    item["name"],
                    TypeParser.parseInt(item["group"], InvalidStudentGroup))
                StudentValidator.validateStudent(newItem)
            elif itemType is Grade:
                newItem = Grade(
                    TypeParser.parseInt(item["studentId"], InvalidStudentId),
                    TypeParser.parseInt(item["assignmentId"],
                                        InvalidAssignmentId), item["grade"])
                GradeValidator.validateGrade(newItem)
            elif itemType is Assignment:
                newItem = Assignment(
                    TypeParser.parseInt(item["assignmentId"],
                                        InvalidAssignmentId),
                    item["description"],
                    TypeParser.parseDate(item["deadline"],
                                         InvalidAssignmentDeadline))
                AssignmentValidator.validateAssignment(newItem)
            newList.append(newItem)

        return newList
Ejemplo n.º 2
0
 def gradeStudent(self):
     gradeController = self.controllerWrapper.getGradeController()
     studentId = input("Choose student id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = gradeController.findStudent(studentId)
     print("You are grading the student with name " + student.getName() +
           " from group " + str(student.getGroup()))
     assignmentList = gradeController.getStudentUngradedAssignments(
         studentId)
     if len(assignmentList) == 0:
         print("The student has no ungraded assignments")
         return
     print("\nID - Description - Deadline")
     for assignment in assignmentList:
         print(ManageAssignmentsMenu.assignmentToStr(assignment))
     assignmentId = input("Choose assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = gradeController.findAssignment(assignmentId)
     gradeController.validateGrading(studentId, assignmentId)
     print("You are grading the assignment with description '" +
           assignment.getDescription() + "' and deadline " +
           ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     grade = input("Choose grade: ")
     grade = TypeParser.parseInt(grade, InvalidGrade)
     gradeController.grade(studentId, assignmentId, grade)
     print("Assignment was graded")
Ejemplo n.º 3
0
    def gradeStudent(self):
        gradeController = self.controllerWrapper.getGradeController()
        studentId = self.studentId.get()
        studentId = TypeParser.parseInt(studentId, InvalidStudentId)
        student = gradeController.findStudent(studentId)
        # print("You are grading the student with name " + student.getName() + " from group " + str(
        #     student.getGroup()))
        assignmentList = gradeController.getStudentUngradedAssignments(
            studentId)
        if len(assignmentList) == 0:
            messagebox.showinfo("Info",
                                "The student has no ungraded assignments")
            return
        assignmentId = self.assignmentId.get()

        try:
            assignmentId = TypeParser.parseInt(assignmentId,
                                               InvalidAssignmentId)
            assignment = gradeController.findAssignment(assignmentId)
            gradeController.validateGrading(studentId, assignmentId)
        except Exception:
            output = ["\nID - Description - Deadline\n"]
            for assignment in assignmentList:
                output.append(GUI.assignmentToStr(assignment) + '\n')
            messagebox.showinfo("Ungraded assignments", ''.join(output))
            return

        # print(
        #     "You are grading the assignment with description '" + assignment.getDescription() +
        #     "' and deadline " + GUI.dateToStr(assignment.getDeadline()))
        grade = self.grade.get()
        grade = TypeParser.parseInt(grade, InvalidGrade)
        gradeController.grade(studentId, assignmentId, grade)
        messagebox.showinfo("Info", "Assignment was graded")
Ejemplo n.º 4
0
 def __CSVToStudent(csvString: str):
     values = csvString.split(',')
     student = Student(TypeParser.parseInt(values[0], InvalidStudentId),
                       values[1],
                       TypeParser.parseInt(values[2], InvalidStudentGroup))
     StudentValidator.validateStudent(student)
     return student
Ejemplo n.º 5
0
 def addStudent(self):
     studentId = input("Student's id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     name = input("Student's name: ")
     group = input("Student's group: ")
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.studentController.addStudent(studentId, name, group)
     print("Student added")
Ejemplo n.º 6
0
 def addStudent(self):
     studentId = self.studentId.get()
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     name = self.studentName.get()
     group = self.studentGroup.get()
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.studentController.addStudent(studentId, name, group)
     messagebox.showinfo("Info", "Student added")
Ejemplo n.º 7
0
 def updateStudent(self):
     studentId = self.studentId.get()
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.studentController.findStudent(studentId)
     # print("You are modifying the student with name " + student.getName() + " from group " + str(
     #     student.getGroup()))
     name = self.studentName.get()
     group = self.studentGroup.get()
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.studentController.updateStudent(studentId, name, group)
     messagebox.showinfo("Info", "Student information updated")
Ejemplo n.º 8
0
 def __CSVToGrade(csvString: str):
     values = csvString.split(',')
     if values[2] == 'None':
         gradeValue = None
     else:
         gradeValue = TypeParser.parseInt(values[2], InvalidGrade)
     grade = Grade(TypeParser.parseInt(values[0], InvalidStudentId),
                   TypeParser.parseInt(values[1], InvalidAssignmentId),
                   gradeValue)
     GradeValidator.validateGrade(grade)
     return grade
Ejemplo n.º 9
0
 def updateStudent(self):
     studentId = input("Student id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.studentController.findStudent(studentId)
     print("You are modifying the student with name " + student.getName() +
           " from group " + str(student.getGroup()))
     name = input("Student's new name: ")
     group = input("Student's new group: ")
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.studentController.updateStudent(studentId, name, group)
     print("Student information updated")
Ejemplo n.º 10
0
 def assignToGroup(self):
     group = input("Choose group: ")
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.gradeController.checkGroupExistence(group)
     assignmentId = input("Choose assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.gradeController.findAssignment(assignmentId)
     print("You are giving the assignment with description '" +
           assignment.getDescription() + "' and deadline " +
           ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     self.gradeController.assignToGroup(group, assignmentId)
     print("Assignments were given")
Ejemplo n.º 11
0
 def assignToGroup(self):
     group = self.studentGroup.get()
     group = TypeParser.parseInt(group, InvalidStudentGroup)
     self.gradeController.checkGroupExistence(group)
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.gradeController.findAssignment(assignmentId)
     # print(
     #     "You are giving the assignment with description '" + assignment.getDescription() +
     #     "' and deadline " + ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     self.gradeController.assignToGroup(group, assignmentId)
     messagebox.showinfo("Info", "Assignments were given")
Ejemplo n.º 12
0
 def assignToStudent(self):
     studentId = input("Choose student id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.gradeController.findStudent(studentId)
     print("You giving an assignment to the student with name " +
           student.getName() + " from group " + str(student.getGroup()))
     assignmentId = input("Choose assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.gradeController.findAssignment(assignmentId)
     print("You are giving the assignment with description '" +
           assignment.getDescription() + "' and deadline " +
           ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     self.gradeController.assignToStudent(studentId, assignmentId)
     print("Assignment was given")
Ejemplo n.º 13
0
 def assignToStudent(self):
     studentId = self.studentId.get()
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.gradeController.findStudent(studentId)
     # print("You giving an assignment to the student with name " + student.getName() + " from group " + str(
     #     student.getGroup()))
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.gradeController.findAssignment(assignmentId)
     # print(
     #     "You are giving the assignment with description '" + assignment.getDescription() +
     #     "' and deadline " + ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     self.gradeController.assignToStudent(studentId, assignmentId)
     messagebox.showinfo("Info", "Assignment was given")
Ejemplo n.º 14
0
 def __CSVToAssignment(csvString: str):
     values = csvString.split(',')
     assignment = Assignment(
         TypeParser.parseInt(values[0], InvalidAssignmentId), values[1],
         TypeParser.parseDate(values[2], InvalidAssignmentDeadline))
     AssignmentValidator.validateAssignment(assignment)
     return assignment
Ejemplo n.º 15
0
 def addAssignment(self):
     assignmentId = input("Assignment's id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     description = input("Assignment's description: ")
     deadline = input("Assignment's deadline (format: day.month.year): ")
     deadline = TypeParser.parseDate(deadline, InvalidAssignmentDeadline)
     self.assignmentController.addAssignment(assignmentId, description,
                                             deadline)
     print("Assignment added")
Ejemplo n.º 16
0
 def addAssignment(self):
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     description = self.assignmentDescription.get()
     deadline = self.assignmentDeadline.get()
     deadline = TypeParser.parseDate(deadline, InvalidAssignmentDeadline)
     self.assignmentController.addAssignment(assignmentId, description,
                                             deadline)
     messagebox.showinfo("Info", "Assignment added")
Ejemplo n.º 17
0
 def listStudentGrades(self):
     studentId = input("Student id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.studentController.findStudent(studentId)
     print(student.getName() + "'s grades are:")
     gradeList = self.controllerWrapper.getGradeController(
     ).listStudentGrades(studentId)
     if len(gradeList) == 0:
         print("No grades to show")
     else:
         print("Grade - Assignment ID")
         for grade in gradeList:
             print(self.gradeToStr(grade))
Ejemplo n.º 18
0
 def updateAssignment(self):
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.assignmentController.findAssignment(assignmentId)
     # print(
     #     "You are modifying the assignment with description '" + assignment.getDescription() +
     #     "' and deadline " + GUI.dateToStr(assignment.getDeadline()))
     description = self.assignmentDescription.get()
     deadline = self.assignmentDeadline.get()
     deadline = TypeParser.parseDate(deadline, InvalidAssignmentDeadline)
     self.assignmentController.updateAssignment(assignmentId, description,
                                                deadline)
     messagebox.showinfo("Info", "Assignment information updated")
Ejemplo n.º 19
0
 def listAssignmentGrades(self):
     assignmentId = input("Assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.assignmentController.findAssignment(assignmentId)
     print("List of grades for the assignment with description '" +
           assignment.getDescription() + "':")
     gradeList = self.controllerWrapper.getGradeController(
     ).listAssignmentGrades(assignmentId)
     if len(gradeList) == 0:
         print("No grades to show")
     else:
         print("Grade - Student ID")
         for grade in gradeList:
             print(self.gradeToStr(grade))
Ejemplo n.º 20
0
 def updateAssignment(self):
     assignmentId = input("Assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.assignmentController.findAssignment(assignmentId)
     print("You are modifying the assignment with description '" +
           assignment.getDescription() + "' and deadline " +
           ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))
     description = input("Assignment's new description: ")
     deadline = input(
         "Assignment's new deadline (format: day.month.year): ")
     deadline = TypeParser.parseDate(deadline, InvalidAssignmentDeadline)
     self.assignmentController.updateAssignment(assignmentId, description,
                                                deadline)
     print("Assignment information updated")
Ejemplo n.º 21
0
 def listStudentGrades(self):
     studentId = self.studentId.get()
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     student = self.studentController.findStudent(studentId)
     gradeList = self.controllerWrapper.getGradeController(
     ).listStudentGrades(studentId)
     if len(gradeList) == 0:
         messagebox.showinfo("Info", "No grades to show")
     else:
         output = [
             student.getName() + "'s grades are:\n",
             "Grade - Assignment ID\n"
         ]
         for grade in gradeList:
             output.append(self.gradeToStr(grade) + '\n')
         messagebox.showinfo("Student grades", ''.join(output))
Ejemplo n.º 22
0
 def listAssignmentGrades(self):
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     assignment = self.assignmentController.findAssignment(assignmentId)
     gradeList = self.controllerWrapper.getGradeController(
     ).listAssignmentGrades(assignmentId)
     if len(gradeList) == 0:
         messagebox.showinfo("Info", "No grades to show")
     else:
         output = [
             "List of grades for the assignment with description '" +
             assignment.getDescription() + "':\n", "\nGrade - Student ID\n"
         ]
         for grade in gradeList:
             output.append(self.gradeToStr(grade) + '\n')
         messagebox.showinfo("List of grades", ''.join(output))
Ejemplo n.º 23
0
    def studentsSortedAlphabetically(self):
        assignmentId = input("Choose assignment id: ")
        assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
        assignment = self.gradeController.findAssignment(assignmentId)
        print(
            "You are viewing the students ordered alphabetically for the assignment with "
            "description '" + assignment.getDescription() + "' and deadline " +
            ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))

        studentList = self.gradeController.getStudentsForAssignmentSortedAlphabetically(
            assignmentId)
        if len(studentList) == 0:
            print("No students received this assignment")
            return
        print("\nID - Name - Group")
        for student in studentList:
            print(ManageStudentsMenu.studentToStr(student))
Ejemplo n.º 24
0
    def studentsSortedAlphabetically(self):
        assignmentId = self.assignmentId.get()
        assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
        assignment = self.gradeController.findAssignment(assignmentId)
        # print(
        #     "You are viewing the students ordered alphabetically for the assignment with "
        #     "description '" + assignment.getDescription() +
        #     "' and deadline " + ManageAssignmentsMenu.dateToStr(assignment.getDeadline()))

        studentList = self.gradeController.getStudentsForAssignmentSortedAlphabetically(
            assignmentId)
        if len(studentList) == 0:
            messagebox.showinfo("Info", "No students received this assignment")
            return
        output = ["\nID - Name - Group\n"]
        for student in studentList:
            output.append(self.studentToStr(student) + '\n')
        messagebox.showinfo("Student list", ''.join(output))
Ejemplo n.º 25
0
 def removeAssignment(self):
     assignmentId = self.assignmentId.get()
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     self.assignmentController.removeAssignment(assignmentId)
     messagebox.showinfo("Info", "Assignment removed")
Ejemplo n.º 26
0
 def removeStudent(self):
     studentId = self.studentId.get()
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     self.studentController.removeStudent(studentId)
     messagebox.showinfo("Info", "Student removed")
Ejemplo n.º 27
0
 def removeAssignment(self):
     assignmentId = input("Assignment id: ")
     assignmentId = TypeParser.parseInt(assignmentId, InvalidAssignmentId)
     self.assignmentController.removeAssignment(assignmentId)
     print("Assignment removed")
Ejemplo n.º 28
0
 def removeStudent(self):
     studentId = input("Student id: ")
     studentId = TypeParser.parseInt(studentId, InvalidStudentId)
     self.studentController.removeStudent(studentId)
     print("Student removed")