コード例 #1
0
ファイル: a1_test_v4 .py プロジェクト: 148zhuanyong/csc148
    def test_alpha(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.AlphaGrouper(1).make_grouping(c, s)
        assert len(grouping1) == 5
        assert grouping_to_list_of_list(grouping1) == [[0], [1], [2], [3], [4]]

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

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

        grouping5 = grouper.AlphaGrouper(5).make_grouping(c, s)
        assert len(grouping5) == 1
        assert grouping_to_list_of_list(grouping5) == [[0, 1, 2, 3, 4]]
コード例 #2
0
ファイル: tests.py プロジェクト: mshankar58/a1w20
 def test_alpha_grouper(self) -> None:
     self.c.enroll_students(self.answer_questions())
     g = grouper.AlphaGrouper(3)
     gps = g.make_grouping(self.c, self.s).get_groups()
     assert len(gps) == 2
     assert gps[1].get_members()[1].id == 34
     assert len(gps[1].get_members()) == 2
     g = grouper.AlphaGrouper(2)
     gps = g.make_grouping(self.c, self.s).get_groups()
     assert gps[1].get_members()[1].id == 25  # number incorrect
     assert len(gps) == 3
     h = []
     for group in gps:
         h.extend(group.get_members())
     for student in self.c.students:
         assert student in h
コード例 #3
0
 def test_make_grouping_alpha(self, questions):
     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.AlphaGrouper(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
コード例 #4
0
ファイル: tests.py プロジェクト: mshankar58/a1w20
 def test_score_grouping(self) -> None:
     self.c.enroll_students(self.answer_questions())
     g = grouper.AlphaGrouper(3)
     gps = g.make_grouping(self.c, self.s)
     assert self.s.score_grouping(gps) == 0.3125
     self.c.enroll_students(self.answer_questions())
     g2 = grouper.GreedyGrouper(3)
     gps2 = g2.make_grouping(self.c, self.s)
     assert self.s.score_grouping(gps2) == 0.5892857142857143
コード例 #5
0
    def test_make_grouping(self, courses, students, questions, answers,
                           surveys, criterions, weights):
        course1 = courses[0]
        course1.enroll_students(students)
        survey1 = surveys[0]
        question1 = questions[0]
        answer1 = answers[0]
        survey1.set_weight(weights)
        survey1.set_criterion(criterions)

        assert grouper.AlphaGrouper(course1) == students
コード例 #6
0
ファイル: tests.py プロジェクト: jiheechoi6/CSC148-A1
def test_make_grouping() -> None:
    grouper_ = grouper.AlphaGrouper(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 grouper_.make_grouping(
        c, sur).get_groups()[0].get_members()[0] == group.get_members()[0]
コード例 #7
0
def test_grouper_class_grouping_get_groups_() -> 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.AlphaGrouper(2)
    q1 = survey.MultipleChoiceQuestion(1, 'What is your choice?',
                                       ['A', 'B', 'C'])
    sur1 = survey.Survey([q1])
    a1.make_grouping(c1, sur1)
    assert len(a1.make_grouping(c1, sur1).get_groups()) == 3
コード例 #8
0
 def test_score_grouping(self, questions, students_with_answers):
     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_with_answers)
     new_grouper = grouper.AlphaGrouper(2)
     new_grouping = new_grouper.make_grouping(new_course, new_survey)
     s = survey.Survey(questions)
     score = s.score_grouping(new_grouping)
     assert score == 2.0
コード例 #9
0
 def test_make_grouping(self, course_with_students_with_answers,
                        alpha_grouping, survey_) -> None:
     grouper_ = grouper.AlphaGrouper(2)
     grouping = grouper_.make_grouping(course_with_students_with_answers,
                                       survey_)
     compare_groupings(grouping, alpha_grouping)
コード例 #10
0
ファイル: a1_test_v4 .py プロジェクト: 148zhuanyong/csc148
    def test_combination(self):
        students = [course.Student(i, "Shit" + str(i)) for i in range(8)]
        q1 = survey.YesNoQuestion(0, "To be, or not to be")
        q2 = survey.NumericQuestion(1, "How many times you f**k up", 0, 10000)
        q3 = survey.MultipleChoiceQuestion(2, "What's your favorite thing to do", ['A', 'B', 'C', 'D'])
        q4 = survey.CheckboxQuestion(3, "How many things you have done", ['A', 'B', 'C', 'D', 'E'])
        questions = [q1, q2, q3, q4]
        s = survey.Survey(questions)

        answers = [True, 1111, 'A', ['A', 'C'],
                   False, 44, 'C', ['A', 'B', 'C'],
                   True, 3, 'B', ['A', 'C', 'D'],
                   True, 56, 'C', ['D', 'C'],
                   False, 12, 'C', ['E'],
                   True, 0, 'A', ['A'],
                   False, 888, 'C', ['A', 'B', 'C', 'D'],
                   True, 12, 'B', ['A', 'B', 'C', 'D', 'E']]

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

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

        grouping = grouper.AlphaGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]

        grouping = grouper.GreedyGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 2, 5], [1, 4, 6], [3, 7]]

        grouping = grouper.WindowGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 4, 5], [1, 2, 3], [6, 7]]

        s.set_criterion(criterion.HeterogeneousCriterion(), q2)
        s.set_weight(2, q1)
        s.set_weight(2, q1)
        s.set_weight(3, q2)
        s.set_weight(55, q4)

        grouping = grouper.AlphaGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]

        grouping = grouper.GreedyGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 2, 6], [1, 3, 7], [4, 5]]

        grouping = grouper.WindowGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4], [5, 6, 7]]

        s.set_weight(2, q1)
        s.set_weight(1, q2)
        s.set_weight(5, q3)
        s.set_weight(2, q4)
        s.set_criterion(criterion.LonelyMemberCriterion(), q1)
        s.set_criterion(criterion.LonelyMemberCriterion(), q2)
        s.set_criterion(criterion.LonelyMemberCriterion(), q3)
        s.set_criterion(criterion.LonelyMemberCriterion(), q4)

        grouping = grouper.AlphaGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]

        grouping = grouper.GreedyGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 2, 5], [1, 4, 6], [3, 7]]

        grouping = grouper.WindowGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]

        # make one of the student's answer invalid
        students[0].set_answer(q1, survey.Answer('F**K'))

        grouping = grouper.AlphaGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]

        grouping = grouper.GreedyGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 6], [5, 7]]

        grouping = grouper.WindowGrouper(3).make_grouping(c, s)
        assert len(grouping) == 3
        assert grouping_to_list_of_list(grouping) == [[0, 1, 2], [3, 4, 5], [6, 7]]
コード例 #11
0
ファイル: tests.py プロジェクト: s-nau/148-project-1
def Alpha_size2():
    return grouper.AlphaGrouper(2)
コード例 #12
0
ファイル: tests.py プロジェクト: s-nau/148-project-1
def Alpha1():
    return grouper.AlphaGrouper(1)