Пример #1
0
    def setUp(self, *args, **kwargs):
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({
            'num_timeslots': 3,
            'timeslot_length': 50,
            'timeslot_gap': 10,
            'num_teachers': 1,
            'classes_per_teacher': 2,
            'sections_per_class': 1
        })
        super(AvailabilityModuleTest, self).setUp(*args, **kwargs)

        # Get and remember the instance of AvailabilityModule
        am = ProgramModule.objects.get(handler='AvailabilityModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, am)
        self.moduleobj.user = self.teachers[0]

        # Set the section durations to 0:50 and 1:50
        sec = self.program.sections()[0]
        sec.duration = '0.83'
        sec.save()
        sec = self.program.sections()[1]
        sec.duration = '1.83'
        sec.save()
Пример #2
0
    def setUp(self, *args, **kwargs):
        super(TeacherClassRegTest, self).setUp(num_students=5,
                                               room_capacity=5,
                                               *args,
                                               **kwargs)

        # Select a primary teacher, two other teachers, and the class
        self.teacher = random.choice(self.teachers)
        self.cls = random.choice(self.teacher.getTaughtClasses())
        other_teachers = list(self.teachers)
        other_teachers.remove(self.teacher)
        self.other_teacher1 = random.choice(other_teachers)
        other_teachers.remove(self.other_teacher1)
        self.other_teacher2 = random.choice(other_teachers)

        self.free_teacher1, created = ESPUser.objects.get_or_create(
            username='******')
        self.free_teacher1.set_password('password')
        self.free_teacher1.save()
        self.free_teacher2, created = ESPUser.objects.get_or_create(
            username='******')
        self.free_teacher2.set_password('password')
        self.free_teacher2.save()
        # Make the primary teacher an admin of the class

        # Get and remember the instance of TeacherClassRegModule
        pm = ProgramModule.objects.get(handler='TeacherClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.teacher
Пример #3
0
    def setUp(self, *args, **kwargs):
        kwargs.update({
            'num_timeslots': 3,
            'timeslot_length': 50,
            'timeslot_gap': 10,
            'num_students': 30
        })
        super(UnenrollModuleTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()
        self.classreg_students()

        # mark some of the students as checked in
        for student in random.sample(self.students, 10):
            Record.objects.create(event='attended',
                                  program=self.program,
                                  user=student)

        self.timeslots = self.program.getTimeSlots()

        pm = ProgramModule.objects.get(handler='UnenrollModule')
        self.module = ProgramModuleObj.getFromProgModule(self.program, pm)

        self.admin, created = ESPUser.objects.get_or_create(username='******')
        self.admin.set_password('password')
        self.admin.makeAdmin()
Пример #4
0
    def setUp(self, *args, **kwargs):
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({
            'num_timeslots': 3,
            'timeslot_length': 50,
            'timeslot_gap': 10,
            'num_teachers': 6,
            'classes_per_teacher': 1,
            'sections_per_class': 2,
            'num_rooms': 6,
        })
        super(StudentRegTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()

        #   Make all modules non-required for now, so we don't have to be shown required pages
        for pmo in self.program.getModules():
            pmo.__class__ = ProgramModuleObj
            pmo.required = False
            pmo.save()

        # Get and remember the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.students[0]
Пример #5
0
    def setUp(self, *args, **kwargs):
        super(ClassSearchModuleTest, self).setUp(*args, **kwargs)
        self.program.getModules()
        self.schedule_randomly()
        pm = ProgramModule.objects.get(handler='ClassSearchModule')
        self.module = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.qb = self.module.query_builder()

        self.admin, created = ESPUser.objects.get_or_create(username='******')
        self.admin.set_password('password')
        self.admin.makeAdmin()
    def setUp(self, *args, **kwargs):
        from esp.program.models import Program
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({'num_students': 3,})
        super(RegProfileModuleTest, self).setUp(*args, **kwargs)

        # Get and remember the instance of this module
        m = ProgramModule.objects.get(handler='RegProfileModule', module_type='learn')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, m)
Пример #7
0
    def setUp(self, *args, **kwargs):
        from esp.program.models import Program
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({'num_students': 3,})
        super(RegProfileModuleTest, self).setUp(*args, **kwargs)

        # Get and remember the instance of this module
        m = ProgramModule.objects.get(handler='RegProfileModule', module_type='learn')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, m)
    def setUp(self):
        super(ResourceModuleTest, self).setUp()

        if not getattr(self, 'isSetUp', False):
            self.pm = ProgramModule.objects.get(handler='ResourceModule')
            self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, self.pm)
            self.moduleobj.user = self.admins[0]

            self.client.login(username=self.admins[0].username, password='******')
            self.response = self.client.get('/manage/%s/dashboard' % self.program.getUrlBase())

            self.isSetUp = True  ## Save duplicate sets of queries on setUp
Пример #9
0
    def setUp(self):
        super(ResourceModuleTest, self).setUp()

        if not getattr(self, 'isSetUp', False):
            self.pm = ProgramModule.objects.get(handler='ResourceModule')
            self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, self.pm)
            self.moduleobj.user = self.admins[0]

            self.client.login(username=self.admins[0].username, password='******')
            self.response = self.client.get('/manage/%s/dashboard' % self.program.getUrlBase())

            self.isSetUp = True  ## Save duplicate sets of queries on setUp
Пример #10
0
    def setUp(self, *args, **kwargs):
        from esp.program.models import Program
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({'num_students': 3, 'num_teachers': 3})
        super(CommunicationsPanelTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()
        self.classreg_students()

        # Get and remember the instance of this module
        m = ProgramModule.objects.get(handler='CommModule', module_type='manage')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, m)
Пример #11
0
    def setUp(self):
        super(JSONDataModuleTest, self).setUp()
        # Generate some nonzero stats
        self.schedule_randomly()
        self.add_user_profiles()
        self.classreg_students()

        self.pm = ProgramModule.objects.get(handler='AdminCore')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, self.pm)
        self.moduleobj.user = self.students[0]

        self.client.login(username=self.admins[0].username, password='******')
        self.stats_response = self.client.get('/json/%s/stats'
                                              % self.program.getUrlBase())
        self.classes_response = self.client.get('/json/%s/class_subjects'
                                                % self.program.getUrlBase())
Пример #12
0
 def setUp(self, *args, **kwargs):
     super(TeacherCheckinModuleTest, self).setUp(*args, **kwargs)
     self.add_user_profiles()
     self.schedule_randomly()  # only scheduled classes used in module
     self.ccc = ClassCreationController(self.program)
     pm = ProgramModule.objects.get(handler='TeacherCheckinModule')
     self.module = ProgramModuleObj.getFromProgModule(self.program, pm)
     self.now = self.settings['start_time']
     self.past = datetime.datetime(1970, 1, 1)
     self.future = datetime.datetime.max
     self.admin = self.admins[0]
     self.teacher = self.teachers[0]
     self.cls = self.teacher.getTaughtClasses()[0]
     self.event = 'teacher_checked_in'
     self.teacher2 = ESPUser.objects.create(username='******')
     self.teacher2.makeRole("Teacher")
 def setUp(self, *args, **kwargs):
     super(TeacherCheckinModuleTest, self).setUp(*args, **kwargs)
     self.add_user_profiles()
     self.schedule_randomly() # only scheduled classes used in module
     self.ccc      = ClassCreationController(self.program)
     pm            = ProgramModule.objects.get(handler='TeacherCheckinModule')
     self.module   = ProgramModuleObj.getFromProgModule(self.program, pm)
     self.now      = self.settings['start_time']
     self.past     = datetime.datetime(1970, 1, 1)
     self.future   = datetime.datetime.max
     self.admin    = self.admins[0]
     self.teacher  = self.teachers[0]
     self.cls      = self.teacher.getTaughtClasses()[0]
     self.event    = 'teacher_checked_in'
     self.teacher2 = ESPUser.objects.create(username='******')
     self.teacher2.makeRole("Teacher")
Пример #14
0
    def setUp(self, *args, **kwargs):
        from esp.datatree.models import GetNode
        from esp.program.models import Program
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({'num_students': 3, 'num_teachers': 3})
        super(CommunicationsPanelTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()
        self.classreg_students()

        # Get and remember the instance of this module
        m = ProgramModule.objects.get(handler='CommModule', module_type='manage')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, m)
    def setUp(self, *args, **kwargs):
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update( {
            'num_timeslots': 3, 'timeslot_length': 50, 'timeslot_gap': 10,
            'num_teachers': 6, 'classes_per_teacher': 1, 'sections_per_class': 2,
            'num_rooms': 6,
            } )
        ProgramFrameworkTest.setUp(self, *args, **kwargs)
        SeleniumTestCase.setUp(self)

        self.add_student_profiles()
        self.schedule_randomly()

        # Get and remember the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.students[0]
Пример #16
0
    def setUp(self, *args, **kwargs):
        from esp.program.models import Program
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({
            'num_students': 3,
        })
        super(ProgramPrintablesModuleTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()
        self.classreg_students()

        # Get and remember the instance of this module
        m = ProgramModule.objects.get(handler='ProgramPrintables',
                                      module_type='manage')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, m)

        self.factory = RequestFactory()
Пример #17
0
    def setUp(self, *args, **kwargs):
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update({
            'num_timeslots': 3,
            'timeslot_length': 50,
            'timeslot_gap': 10,
            'num_teachers': 6,
            'classes_per_teacher': 1,
            'sections_per_class': 2,
            'num_rooms': 6,
        })
        ProgramFrameworkTest.setUp(self, *args, **kwargs)
        SeleniumTestCase.setUp(self)

        self.add_student_profiles()
        self.schedule_randomly()

        # Get and remember the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.students[0]
    def setUp(self, *args, **kwargs):
        super(TeacherClassRegTest, self).setUp(num_students=5, room_capacity=5, *args, **kwargs)

        # Select a primary teacher, two other teachers, and the class
        self.teacher = random.choice(self.teachers)
        self.cls = random.choice(self.teacher.getTaughtClasses())
        other_teachers = list(self.teachers)
        other_teachers.remove(self.teacher)
        self.other_teacher1 = random.choice(other_teachers)
        other_teachers.remove(self.other_teacher1)
        self.other_teacher2 = random.choice(other_teachers)

        self.free_teacher1, created = ESPUser.objects.get_or_create(
            username='******',
            first_name='Free',
            last_name='Teacher1',
            email='*****@*****.**')
        self.free_teacher1.set_password('password')
        self.free_teacher1.save()
        self.free_teacher2, created = ESPUser.objects.get_or_create(
            username='******',
            first_name='Free',
            last_name='Teacher2',
            email='*****@*****.**')
        self.free_teacher2.set_password('password')
        self.free_teacher2.save()

        # Make the teachers available all the time
        for ts in self.program.getTimeSlots():
            self.free_teacher1.addAvailableTime(self.program, ts)
            self.free_teacher2.addAvailableTime(self.program, ts)
        # Make the primary teacher an admin of the class

        # Get and remember the instance of TeacherClassRegModule
        pm = ProgramModule.objects.get(handler='TeacherClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.teacher
    def setUp(self, *args, **kwargs):
        kwargs.update({
            'num_timeslots': 3, 'timeslot_length': 50, 'timeslot_gap': 10,
            'num_students': 30
        })
        super(UnenrollModuleTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()
        self.classreg_students()

        # mark some of the students as checked in
        for student in random.sample(self.students, 10):
            Record.objects.create(
                event='attended', program=self.program, user=student)

        self.timeslots = self.program.getTimeSlots()

        pm = ProgramModule.objects.get(handler='UnenrollModule')
        self.module = ProgramModuleObj.getFromProgModule(self.program, pm)

        self.admin, created = ESPUser.objects.get_or_create(username='******')
        self.admin.set_password('password')
        self.admin.makeAdmin()
Пример #20
0
    def setUp(self, *args, **kwargs):
        from esp.program.modules.base import ProgramModule, ProgramModuleObj

        # Set up the program -- we want to be sure of these parameters
        kwargs.update( {
            'num_timeslots': 3, 'timeslot_length': 50, 'timeslot_gap': 10,
            'num_teachers': 6, 'classes_per_teacher': 1, 'sections_per_class': 2,
            'num_rooms': 6,
            } )
        super(StudentRegTest, self).setUp(*args, **kwargs)

        self.add_student_profiles()
        self.schedule_randomly()

        #   Make all modules non-required for now, so we don't have to be shown required pages
        for pmo in self.program.getModules():
            pmo.__class__ = ProgramModuleObj
            pmo.required = False
            pmo.save()

        # Get and remember the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        self.moduleobj = ProgramModuleObj.getFromProgModule(self.program, pm)
        self.moduleobj.user = self.students[0]
Пример #21
0
    def test_teachers(self):
        # Get the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        ProgramModuleObj.getFromProgModule(self.program, pm)

        d = self.moduleobj.teachers()

        # Reject a class from self.teacher, approve a class from self.other_teacher1, make a class from self.other_teacher2 proposed
        cls1 = random.choice(self.teacher.getTaughtClasses())
        cls1.status = -1
        cls1.save()
        cls2 = random.choice(self.other_teacher1.getTaughtClasses())
        cls2.status = 1
        cls2.save()
        cls3 = random.choice(self.other_teacher2.getTaughtClasses())
        cls3.status = 0
        cls3.save()
        # Check them
        d = self.moduleobj.teachers()
        self.failUnless(self.teacher in d['class_rejected'])
        self.failUnless(self.other_teacher1 in d['class_approved'])
        self.failUnless(self.other_teacher2 in d['class_proposed'])
        # Undo the statuses
        cls1.status = 10
        cls1.save()
        cls2.status = 10
        cls2.save()
        cls3.status = 10
        cls3.save()

        # Schedule the classes randomly
        self.schedule_randomly()
        # Find an empty class
        cls = random.choice([
            cls for cls in self.program.classes() if not cls.isFull()
            and not cls.is_nearly_full(ClassSubject.get_capacity_factor())
        ])
        teacher = cls.get_teachers()[0]
        classes = list(teacher.getTaughtClasses())
        classes.remove(cls)
        for c in classes:
            c.removeTeacher(teacher)
        #print teacher.getTaughtClasses()
        d = self.moduleobj.teachers()
        # Check it
        self.failUnless(teacher not in d['class_full']
                        and teacher not in d['class_nearly_full'])

        # Mostly fill it
        self.add_student_profiles()
        for i in range(0, 4):
            cur_student = self.students[i]
            cls.preregister_student(cur_student)
        # Check it
        d = self.moduleobj.teachers()
        self.failUnless(teacher in d['class_nearly_full'])
        self.failUnless(teacher not in d['class_full'])

        # Fill it
        cls.get_sections()[0].preregister_student(self.students[4])
        # Check it
        d = self.moduleobj.teachers()
        self.failUnless(teacher in d['class_full'])
        self.failUnless(teacher in d['class_nearly_full'])

        # Make a program
        self.create_past_program()

        # Create a class for the teacher
        new_class, created = ClassSubject.objects.get_or_create(
            category=self.categories[0],
            grade_min=7,
            grade_max=12,
            parent_program=self.new_prog,
            class_size_max=30,
            class_info='Previous class!')
        new_class.makeTeacher(self.teacher)
        new_class.add_section(duration=50.0 / 60.0)
        new_class.accept()
        # Check taught_before
        d = self.moduleobj.teachers()
        self.failUnless(self.teacher in d['taught_before'])

        transaction.rollback()
    def test_teachers(self):
        # Get the instance of StudentClassRegModule
        pm = ProgramModule.objects.get(handler='StudentClassRegModule')
        ProgramModuleObj.getFromProgModule(self.program, pm)

        d = self.moduleobj.teachers()

        # Reject a class from self.teacher, approve a class from self.other_teacher1, make a class from self.other_teacher2 proposed
        cls1 = random.choice(self.teacher.getTaughtClasses())
        cls1.status = -1
        cls1.save()
        cls2 = random.choice(self.other_teacher1.getTaughtClasses())
        cls2.status = 1
        cls2.save()
        cls3 = random.choice(self.other_teacher2.getTaughtClasses())
        cls3.status = 0
        cls3.save()
        # Check them
        d = self.moduleobj.teachers()
        self.assertTrue(self.teacher in d['class_rejected'])
        self.assertTrue(self.other_teacher1 in d['class_approved'])
        self.assertTrue(self.other_teacher2 in d['class_proposed'])
        # Undo the statuses
        cls1.status = 10
        cls1.save()
        cls2.status = 10
        cls2.save()
        cls3.status = 10
        cls3.save()

        # Schedule the classes randomly
        self.schedule_randomly()
        # Find an empty class
        cls = random.choice([cls for cls in self.program.classes() if not cls.isFull() and not cls.is_nearly_full(ClassSubject.get_capacity_factor())])
        teacher = cls.get_teachers()[0]
        classes = list(teacher.getTaughtClasses())
        classes.remove(cls)
        for c in classes:
            c.removeTeacher(teacher)
        d = self.moduleobj.teachers()
        # Check it
        self.assertTrue(teacher not in d['class_full'] and teacher not in d['class_nearly_full'])

        # Mostly fill it
        self.add_student_profiles()
        for i in range(0, 4):
            cur_student = self.students[i]
            cls.preregister_student(cur_student)
        # Check it
        d = self.moduleobj.teachers()
        self.assertTrue(teacher in d['class_nearly_full'])
        self.assertTrue(teacher not in d['class_full'])

        # Fill it
        cls.get_sections()[0].preregister_student(self.students[4])
        # Check it
        d = self.moduleobj.teachers()
        self.assertTrue(teacher in d['class_full'])
        self.assertTrue(teacher in d['class_nearly_full'])

        # Make a program
        self.create_past_program()

        # Create a class for the teacher
        new_class, created = ClassSubject.objects.get_or_create(category=self.categories[0], grade_min=7, grade_max=12, parent_program=self.new_prog, class_size_max=30, class_info='Previous class!')
        new_class.makeTeacher(self.teacher)
        new_class.add_section(duration=50.0/60.0)
        new_class.accept()
        # Check taught_before
        d = self.moduleobj.teachers()
        self.assertTrue(self.teacher in d['taught_before'])