Example #1
0
    def test_random(self):
        students = [course.Student(i, "Shit" + str(i)) for i in range(5)]
        questions = [survey.NumericQuestion(i, "FUCKNQ" + str(i), 2, 8) for i in range(5)]
        s = survey.Survey(questions)

        answers = [1, 0, 0, 3, 4] * 5
        i = 0
        for q in questions:
            for stu in students:
                stu.set_answer(q, survey.Answer(2 + answers[i]))
                i += 1

        c = course.Course("Asshole101")
        c.enroll_students(students)

        grouping1 = grouper.RandomGrouper(1).make_grouping(c, s)
        assert len(grouping1) == 5
        assert grouping_to_list_of_list_flatten(grouping1) == [0, 1, 2, 3, 4]

        grouping2 = grouper.RandomGrouper(2).make_grouping(c, s)
        assert len(grouping2) == 3
        assert grouping_to_list_of_list_flatten(grouping2) == [0, 1, 2, 3, 4]

        grouping3 = grouper.RandomGrouper(3).make_grouping(c, s)
        assert len(grouping3) == 2
        assert grouping_to_list_of_list_flatten(grouping3) == [0, 1, 2, 3, 4]

        grouping5 = grouper.RandomGrouper(5).make_grouping(c, s)
        assert len(grouping5) == 1
        assert grouping_to_list_of_list_flatten(grouping5) == [0, 1, 2, 3, 4]
Example #2
0
 def test_random_grouper(self) -> None:
     self.c.enroll_students(self.answer_questions())
     g = grouper.RandomGrouper(3)
     gps = g.make_grouping(self.c, self.s).get_groups()
     assert len(gps) == 2
     assert len(gps[1].get_members()) == 2
     g = grouper.RandomGrouper(2)
     gps = g.make_grouping(self.c, self.s).get_groups()
     assert len(gps) == 3
     h = []
     for group in gps:
         h.extend(group.get_members())
     for student in self.c.students:
         assert student in h
Example #3
0
 def test_make_grouping_random(self):
     new_course = course.Course('CSC148')
     q1 = survey.CheckboxQuestion(1, 'Hobbies?',
                                  ['Movie', 'Sing', 'Dance', 'Game'])
     new_survey = survey.Survey([q1])
     students = [course.Student(1, 'Zoro'),
                 course.Student(2, 'Aaron'),
                 course.Student(3, 'Gertrude'),
                 course.Student(4, 'Yvette'),
                 course.Student(6, 'Steph'),
                 course.Student(7, 'Draymond'),
                 course.Student(8, 'Andrew')]
     new_course.enroll_students(students)
     new_grouper = grouper.RandomGrouper(2)
     new_grouping = new_grouper.make_grouping(new_course, new_survey)
     groups = new_grouping.get_groups()
     temp_list = []
     for i in range(0, len(groups)):
         people = groups[i].get_members()
         temp_list.extend(people)
         if i == (len(groups) - 1):
             assert len(groups[i]) <= 2
         else:
             assert len(groups[i]) == 2
     course_students = new_course.get_students()
     for student in course_students:
         assert student in temp_list
     assert len(temp_list) == 7
Example #4
0
 def test_make_grouping(self, course_with_students_with_answers,
                        survey_) -> None:
     grouper_ = grouper.RandomGrouper(2)
     grouping = grouper_.make_grouping(course_with_students_with_answers,
                                       survey_)
     member_ids = get_member_ids(grouping)
     assert len(member_ids) == 2
     for ids in member_ids:
         assert len(ids) == 2
     assert len(frozenset.intersection(*member_ids)) == 0
Example #5
0
def test_make_rangrouping() -> None:
    grouper_ = grouper.RandomGrouper(3)
    s1 = Student(1, "John")
    s2 = Student(2, "Carl")
    s3 = Student(3, "Anne")
    c = Course('dd')
    c.enroll_students([s1, s2, s3])
    sur = return_sur()
    group = Group([s3, s2, s1])
    assert len(grouper_.make_grouping(
        c, sur).get_groups()[0].get_members()) == len(group.get_members())
Example #6
0
def test_grouper_randomgrouper() -> None:
    c1 = course.Course('CSC148')
    s1 = course.Student(1, 'Ali')
    s2 = course.Student(2, 'Kat')
    s3 = course.Student(3, 'Dorsa')
    s4 = course.Student(4, 'Sophia')
    s5 = course.Student(5, 'Momo')
    s6 = course.Student(6, 'Joseph')
    c1.enroll_students([s1, s2, s3, s4, s5, s6])
    a1 = grouper.RandomGrouper(2)
    q1 = survey.MultipleChoiceQuestion(1, 'What is your choice?',
                                       ['A', 'B', 'C'])
    sur1 = survey.Survey([q1])
    assert len(a1.make_grouping(c1, sur1).get_groups()) == 3
    assert len(a1.make_grouping(c1, sur1).get_groups()[2].get_members()) == 2
Example #7
0
def RandomGrouper1():
    return grouper.RandomGrouper(2)