Пример #1
0
 def __init__(self, repository):
     '''
     Constructor
     '''
     self.__grade_repository = Grade_repository()
     self.__grade_validator = Grade_validator()
     self.__stud_repository = Student_repository()
     self.__assign_repository = Assignment_repository()
Пример #2
0
class Test_Grade_repository(TestCase):

    def setUp(self):
        super().setUp()
        self.__repository = Grade_repository()

    def test_add_grade(self):
        grade = Grade(1, 1, 10)
        self.__repository.add_grade(grade)
        self.assertEqual(len(self.__repository.list_all_grades()), 1, "There should be 1 grade in the test repository!")
class Grade_controller:
    '''
    classdocs
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''
        self.__grade_repository = Grade_repository()
        self.__grade_validator = Grade_validator()
        self.__stud_repository = Student_repository()
        self.__assign_repository = Assignment_repository()

    def give_assignment(self, assign_id, stud_id):
        grade = Grade(assign_id, stud_id, 0)
        self.__grade_validator.validate_grade(grade)
        self.__grade_repository.add_grade(grade)

    def add_sample_data(self):
        self.give_assignment(1, 2)
        self.give_assignment(2, 3)
        self.give_assignment(3, 5)
        self.give_assignment(4, 7)
        self.give_assignment(5, 9)
        self.give_assignment(6, 7)
        self.give_assignment(7, 5)
        self.give_assignment(8, 3)
        self.give_assignment(9, 1)
        self.give_assignment(10, 2)

    def give_grade_by_group(self, assign_id, group):
        for student in self.__stud_repository.list_all_students:
            if str(student.group) == str(group):
                stud_id = student.stud_id
                grade = Grade(assign_id, stud_id, 0)
                self.__grade_validator.validate_grade(grade)
                self.__grade_repository.add_grade(grade)

    def delete_grade_by_id(self, assign_id, stud_id):
        self.__grade_repository.remove_grade_by_id(assign_id, stud_id)

    def find_grade_by_id(self, assign_id, stud_id):
        return self.__repo[(assign_id, stud_id)]

    def list_all_grades(self):
        return self.__grade_repository.list_all_grades()

    def list_zero_grades_of_student(self, stud_id):
        return self.__grade_repository.list_zero_grades_of_student(stud_id)

    def evaluate_grade(self, stud_id, grade_to_evaluate, evaluation):
        self.__grade_repository.evaluate_grade(stud_id, grade_to_evaluate,
                                               evaluation)
class Grade_controller:
    '''
    classdocs
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''
        self.__grade_repository = Grade_repository()
        self.__grade_validator = Grade_validator()

    def add_grade(self, assign_id, stud_id, grade):
        grade = Grade(assign_id, stud_id, grade)
        self.__grade_validator.validate_grade(grade)
        self.__grade_repository.add_grade(grade)

    def list_all_grades(self):
        return self.__grade_repository.list_all_grades()
Пример #5
0
'''
Created on Nov 3, 2016

@author: AndreiMsc
'''

from repository.Student_repository import Student_repository
from controller.Student_controller import Student_controller
from repository.Assignment_repository import Assignment_repository
from controller.Assignment_controller import Assignment_controller
from repository.Grade_repository import Grade_repository
from controller.Grade_controller import Grade_controller
from ui.Commands import Commands
from ui.Menu import Menu
from ui.ui_Selector import ui_Selector

stud_repo = Student_repository()
stud_ctrl = Student_controller(stud_repo)
assign_repo = Assignment_repository()
assign_ctrl = Assignment_controller(assign_repo)
grade_repo = Grade_repository()
grade_ctrl = Grade_controller(grade_repo)
method = ui_Selector.ui_selector()
if method == "command":
    com = Commands(stud_ctrl,assign_ctrl,grade_ctrl)
    com.ui_run()
else:
    menu = Menu(stud_ctrl,assign_ctrl,grade_ctrl)
    menu.ui_run()
Пример #6
0
class Grade_controller:
    '''
    classdocs
    '''
    def __init__(self, repository):
        '''
        Constructor
        '''
        self.__grade_repository = Grade_repository()
        self.__grade_validator = Grade_validator()
        self.__stud_repository = Student_repository()
        self.__assign_repository = Assignment_repository()

    def give_assignment(self, assign_id, stud_id):
        grade = Grade(assign_id, stud_id, 0)
        self.__grade_validator.validate_grade(grade)
        self.__grade_repository.add_grade(grade)

    def add_sample_data(self):
        self.give_assignment(1, 3)
        self.give_assignment(1, 2)
        self.give_assignment(1, 5)
        self.give_assignment(2, 3)
        self.give_assignment(3, 5)
        self.give_assignment(4, 7)
        self.give_assignment(5, 9)
        self.give_assignment(6, 7)
        self.give_assignment(7, 5)
        self.give_assignment(8, 3)
        self.give_assignment(9, 1)
        self.give_assignment(10, 2)
        self.evaluate_grade(3, 1, 10)
        self.evaluate_grade(2, 1, 4)
        self.evaluate_grade(5, 1, 6)

    def give_grade_by_group(self, assign_id, group):
        for student in self.__stud_repository.list_all_students:
            if str(student.group) == str(group):
                stud_id = student.stud_id
                grade = Grade(assign_id, stud_id, 0)
                self.__grade_validator.validate_grade(grade)
                self.__grade_repository.add_grade(grade)

    def delete_grade_by_id(self, assign_id, stud_id):
        self.__grade_repository.remove_grade_by_id(assign_id, stud_id)

    def remove_grade_after_student_id(self, stud_id):
        self.__grade_repository.remove_grade_after_student_id(stud_id)

    def remove_grade_after_assignment_id(self, assign_id):
        self.__grade_repository.remove_grade_after_assignment_id(assign_id)

    def find_grade_by_id(self, assign_id, stud_id):
        return self.__repo[(assign_id, stud_id)]

    def list_all_grades(self):
        return self.__grade_repository.list_all_grades()

    def list_zero_grades_of_student(self, stud_id):
        return self.__grade_repository.list_zero_grades_of_student(stud_id)

    def evaluate_grade(self, stud_id, grade_to_evaluate, evaluation):
        self.__grade_repository.evaluate_grade(stud_id, grade_to_evaluate,
                                               evaluation)

    def list_students_with_assignment(self, assign_id):
        return self.__grade_repository.list_students_with_assignment(assign_id)

    def possible_late(self, possible_late_assign):
        possible_late = []
        for assign in possible_late_assign:
            studs_w_assign = self.__grade_repository.list_students_with_assignment(
                assign)
            for stud in studs_w_assign:
                possible_late.append(stud)
        return possible_late

    def average_for_students(self, list_of_all_students):
        student_with_average_list = []
        for student in list_of_all_students:
            student_id = student.stud_id
            student_with_average_list.append(
                self.__grade_repository.calculate_average_for_students(
                    student_id))
        return student_with_average_list

    def average_for_assignments(self, list_of_all_assignments):
        assignments_with_average_list = []
        for assignment in list_of_all_assignments:
            assign_id = assignment.assign_id
            assignments_with_average_list.append(
                self.__grade_repository.calculate_average_for_assignments(
                    assign_id))
        return assignments_with_average_list
Пример #7
0
 def setUp(self):
     super().setUp()
     self.__repository = Grade_repository()
 def __init__(self, repository):
     '''
     Constructor
     '''
     self.__grade_repository = Grade_repository()
     self.__grade_validator = Grade_validator()