示例#1
0
 def removeStudentFromDiscipline(self, discipline, studentID):
     '''
     removes a student from a discipline
     Input: discipline - string, the name of the discipline that the student must be removed from
            studentID - positive integer, the ID of the student to remove from the discipline
     Output: if such a Grade exists, it is removed and returned
     Exceptions: raises GradeException if a Grade with the given discipline and studentID does not exist
     '''
     indexDisciplineAndStudentID = self.__find(discipline, studentID)
     if indexDisciplineAndStudentID == -1:
         raise GradeException("There is no student with the ID: " + str(studentID) + " added to discipline: " + discipline + "!")
     self.__data.pop(indexDisciplineAndStudentID)
示例#2
0
 def updateGrade(self, discipline, studentID, grade):
     '''
     updates a Grade's grade
     Input: discipline - string, the name of the discipline that the student must be added to
            studentID - positive integer, the ID of the student to add to a discipline
            grade - float, 1<= grade <= 10, the grade to be updated
     Output: if such a Grade exists, it is updated
     Exceptions: raises GradeException if a Grade with the given discipline and studentID does not exist
     '''
     indexGrade = self.__find(discipline, studentID)
     if indexGrade == -1:
         raise GradeException("Student with ID " + str(self.__data[indexGrade].getStudentID()) + " must be added first to discipline " + self.__data[indexGrade].getDiscipline() + "!")
     self.__data[indexGrade].setGrade(grade)
示例#3
0
 def addStudentToDiscipline(self, discipline, studentID):
     '''
     adds a student to a discipline
     Input: discipline - string, the name of the discipline that the student must be added to
            studentID - positive integer, the ID of the student to add to the discipline
     Output: the given Grade is added to the repository, if no other Grade with the same discipline and studentID exists
             ! the given Grade's grade is initialized with 0
     Exceptions: raises GradeException if another Grade with the same discipline and studentID already exists
     '''
     if self.findByDisciplineAndStudentID(discipline, studentID) != None:
         raise GradeException("Student with ID " + str(studentID) + " already added to discipline " + discipline + "!")
     gra = Grade(discipline, studentID, 0)
     self.__data.append(gra)
    def removeGrade(self, disID, stuID):
        '''
        removes a grade with the given student ID and discipline ID
        Input: disID - positive integer, the ID of the grade's discipline to be removed
               stuID - positive integer, the ID of the grade's student to be removed
        Output: if such a Grade exists, it is removed and returned
        Exceptions: raises GradeException if a Grade with the given disID and stuID does not exist
        '''
        indexDisciplineIDandStudentID = self.__find(disID, stuID)
        if indexDisciplineIDandStudentID == -1:
            raise GradeException("There is no grade with the student ID: " +
                                 str(stuID) + " and discipline ID: " +
                                 str(disID) + "!")

        self.__data.pop(indexDisciplineIDandStudentID)
 def addGrade(self, gra, sturepo, disrepo):
     '''
     adds a grade to the grade repository
     Input: gra - object type of grade
     Output: the given grade is added to the repository, if the studentID and disciplineID of the grade exists
     Exception: the disID or the stuID does not exist
     '''
     if disrepo.findBydID(
             gra.getDisciplineID()) != None and sturepo.findBysID(
                 gra.getStudentID()) != None:
         self.__data.append(gra)
     else:
         #print(sturepo.findBysID(gra.getStudentID()))
         raise GradeException("Student with ID: " +
                              str(gra.getStudentID()) +
                              " or the discipline with ID: " +
                              str(gra.getDisciplineID()) +
                              " does not exist!")