Пример #1
0
class TestMirtEquality(unittest.TestCase):

    # Sets up a test.
    @classmethod
    def setUpClass(self):
        # Read the data from the test data directory.
        content = ''
        with open(EXAM_DATA) as file_handle:
            content = file_handle.read()
        students = file_processing.to_student_array(content, prescored = True)

        # Create the ltm test.
        self.ltm_test = LtmTest(students, None)
        # Create the mIRT test.
        self.mirt_test = Test(students, None)
        
        # Run ltm on the response matrix.
        self.ltm_test.calculate_question_stats(store = False)
        self.ltm_test.calculate_student_stats(store = False)
        # Run mirt on the response matrix.
        self.mirt_test.calculate_question_stats(store = False)
        self.mirt_test.calculate_student_stats(store = False)

    # Tests that the difference between discriminations calculated with mIRT and ltm is not too large.
    def test_discriminations_equal(self):
        for i in range(len(self.ltm_test.questions)):
            ltm_discrimination = self.ltm_test.questions[i].get_discrimination()
            mirt_discrimination = self.mirt_test.questions[i].get_discrimination()
            self.assertAlmostEqual(ltm_discrimination, mirt_discrimination, delta = 0.03)

    # Tests that the difference between item weights calculated with mIRT and ltm is not too large.
    def test_item_weights_equal(self):
        for i in range(len(self.ltm_test.questions)):
            ltm_weight = self.ltm_test.questions[i].get_item_weight()
            mirt_weight = self.mirt_test.questions[i].get_item_weight()
            self.assertAlmostEqual(ltm_weight, mirt_weight, delta = 0.03)

    # Tests that the difference between locations calculated with mIRT and ltm is not too large.
    def test_item_weights_equal(self):
        for i in range(len(self.ltm_test.students)):
            ltm_location = self.ltm_test.students[i].get_location()
            mirt_location = self.mirt_test.students[i].get_location()
            self.assertAlmostEqual(ltm_location, mirt_location, delta = 0.03)