def assignLaboratory(self, lab, fName, group):
        list = []
        f = open(fName, 'r')
        t = f.readline().strip()
        while t != '':
            list.append(t)
            t = f.readline().strip()
        f.close()
        studs = self.__repo.getAll()
        i = 0

        self.__undop = 2
        self.__prepop = copy.copy(self.__prepo.getAll())
        self.__redop = None
        self.__undor = None
        self.__redor = None
        for e in studs:
            if e.getGroup() == group:
                try:
                    if i == len(list):
                        i = 0
                    self.__prepo.add(Problem(e.getId(), lab, list[i], 0))
                    i += 1
                except ValueError:
                    pass
Beispiel #2
0
 def __addProblem(self):
     try:
         id=int(input("Input id "))
         lab=int(input("Input lab "))
         problem=input("Input problem ")
         self.__ctrl.addProblem(Problem(id,lab,problem,0))
         
         
     except ValueError as e:
         print(e)
Beispiel #3
0
 def __assignGrade(self):
     try:
         id=int(input("Input id "))
         lab=int(input("Input lab "))
         problem='random'
         grade=int(input('Input grade '))
         if grade<1 or grade>10:
             raise ValueError("wrong grade")
         self.__ctrl.gradeStudent(Problem(id,lab,problem,grade))
         
     except ValueError as e:
         print(e)
Beispiel #4
0
    def __loadFromFile(self):
        try:
            f = open(self._fName, 'r')
            t = f.readline().strip()
            while t != '':
                args = t.split(',')
                self.__data.append(
                    Problem(int(args[0]), int(args[1]), args[2], int(args[3])))
                t = f.readline().strip()

            f.close()
        except IOError:
            return
Beispiel #5
0
    def updateGrade(self, obj):
        self.__undo = copy.copy(self.__data)
        print(obj.getGrade())
        e = self.find(obj.getId(), obj.getLab())
        if e == None:
            raise ValueError("Object does not exist")
        elif e.getGrade() != 0:
            raise ValueError("Grade cannot be modified")
        else:
            idx = self.__data.index(e)

            obj2 = Problem(obj.getId(), obj.getLab(), e.getProblem(),
                           obj.getGrade())
            self.__data.remove(e)
            self.__data.insert(idx, obj2)
            print(str(obj2.getId()), str(obj2.getLab()), obj2.getProblem(),
                  str(obj2.getGrade()))
            self.__storeToFile()
Beispiel #6
0
 def __init__(self):
     self.__iniC = Configuration(self.readFile())
     self.__p = Problem(self.__iniC)
     self.__contr = Controller(self.__p)