예제 #1
0
    def test_sample_analyze(self):
        analysis = analyze_test(sample)
        assert json.dumps(analysis) == json.dumps(sample_output[0])

        sample["exclude_items"] = [2, 6, 9, 12, 15, 16, 17, 18]
        analysis2 = analyze_test(sample)
        assert json.dumps(analysis2) == json.dumps(sample_output[1])
    def test_one_student(self):
        data = {"student_list": [{}]}

        expected = {"analysis": "Invalid data - Not enough students"}
        analysis = analyze_test(data)

        assert analysis == expected
예제 #3
0
def get_quiz_responses(json_data):
    edit_url = json_data.get('edit_url')
    provider_id = json_data.get('provider_id')
    responses = json_data.get('responses')
    params = [edit_url or provider_id, int(responses)]
    credentials = GoogleCredentials().get_credential()
    socket.setdefaulttimeout(300)
    results = run_app_script(credentials,
                             function_name='getQuizResponses',
                             params=params)
    responses = results.get('responses', [])
    # TODO Convert to json format needed for Item Analysis
    # Call Analyze_test and send analysis data in the below dict
    exam_info = {'exam': {'name': results.get('title')}, 'student_list': []}

    for i in results.get('students'):
        curr_id = str(i[0].get('student_id'))
        exam_info['student_list'].append({'id': curr_id, 'item_responses': []})

    for i in responses:
        for k in i:
            for j in exam_info['student_list']:
                if str(k.get('student_id')) == j['id']:
                    j['item_responses'].append({
                        'item_id': str(k.get('item_id')),
                        'response': k.get('score')})

    quiz_analysis = analyze_test(exam_info)['analysis']

    return {"quiz_analysis": quiz_analysis}
    def test_empty_json(self):
        data = {}

        expected = {"analysis": "Invalid data - Not enough students"}
        analysis = analyze_test(data)

        assert analysis == expected
    def test_optional_inputs(self):
        data = {
            "student_list": [
                {
                    "item_responses": [
                        {"response": 1},
                        {"response": 0},
                        {"response": 0}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0},
                        {"response": 1},
                        {"response": 1}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0},
                        {"response": 1},
                    ]
                }
            ]
        }

        expected = {'analysis': {'assumptions': {'3': {'assumed': ['3']}}, 'exclude': ['1'], 'group_analysis': 'No groups were found, or all students are in the same group', 'item_analysis': [{'difficulty': 0.667, 'idr': -0.037, 'item_id': '1', 'num_correct': 1},
                  {'difficulty': 0.333, 'idr': 0.037, 'item_id': '2', 'num_correct': 2}, {'difficulty': 0.667, 'idr': 0.074, 'item_id': '3', 'num_correct': 1}], 'overall_items': {'diff_avg': 0.556, 'idr_avg': 0.025},    
          'overall_quiz': {'average': 0.444, 'kr20': -3.0, 'weighted_avg': 0.4}, 'student_scores': [{'score': 0.333,  'student': '1',  'weighted_score': 0.4}, {'score': 0.667,  'student': '2',  'weighted_score': 0.6},      
                           {'score': 0.333,  'student': '3',  'weighted_score': 0.2}], 'topic_avgs': 'No topics were found', 'topic_rights': 'No topics were found'}}
        analysis = analyze_test(data)

        assert analysis == expected
예제 #6
0
    def test_optional_inputs(self):
        data = {
            "student_list": [
                {
                    "item_responses": [
                        {"response": 1},
                        {"response": 0},
                        {"response": 0}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0},
                        {"response": 1},
                        {"response": 1}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0},
                        {"response": 1},
                    ]
                }
            ]
        }

        expected = {"analysis": {
                        "assumptions": {"3": {"assumed": ["3"]}},
                        "average": 0.444,
                        "diff_avg": 0.556,
                        "difficulty": {"1": 0.667,
                                    "2": 0.333,
                                    "3": 0.667},
                        "exclude": ["1"],
                        "group_analysis": "No groups were found, or all students are in the same group",
                        "idr": {"1": -0.037,
                                "2": 0.037,
                                "3": 0.074},
                        "idr_avg": 0.025,
                        "kr20": -3.0,
                        "num_correct": {"1": 1,
                                        "2": 2,
                                        "3": 1},
                        "scores": {"1": 0.333,
                                "2": 0.667,
                                "3": 0.333},
                        "topic_avgs": "No topics were found",
                        "topic_rights": "No topics were found",
                        "weighted_avg": 0.4,
                        "weighted_scores": {"1": 0.4,
                                            "2": 0.6,
                                            "3": 0.2}},
                    }
        analysis = analyze_test(data)

        assert analysis == expected
    def test_no_items(self):
        data = {"student_list": [
            {
                "item_responses": []
            },
            {
                "item_responses": []
            },
            {
                "item_responses": []
            }
        ]}

        expected = {"analysis": "Invalid data - Not enough items"}
        analysis = analyze_test(data)

        assert analysis == expected
예제 #8
0
    def test_missing_data_1(self):
        data = {
            "student_list": [
                {
                    "item_responses": [
                        {"response": 1},
                        {"response": 0}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0}
                    ]
                },
                { 
                }
            ]
        }

        expected = {"analysis": {"assumptions": {"2": {"assumed": ["2"]},
                                                 "3": {"assumed": ["1", "2"]}},
                                "average": 0.167,
                                "diff_avg": 0.834,
                                "difficulty": {"1": 0.667, "2": 1.0},
                                "exclude": "Invalid data - No mean",
                                "group_analysis": "No groups were found, or all "
                                                    "students are in the same group",
                                "idr": "Invalid data - No mean",
                                "idr_avg": "Invalid data - No mean",
                                "kr20": -0.0,
                                "num_correct": {"1": 1, "2": 0},
                                "scores": {"1": 0.5, "2": 0.0, "3": 0.0},
                                "topic_avgs": "No topics were found",
                                "topic_rights": "No topics were found",
                                "weighted_avg": 0.133,
                                "weighted_scores": {"1": 0.4, "2": 0.0, "3": 0.0}}}
        analysis = analyze_test(data)

        assert analysis == expected
    def test_missing_data_1(self):
        data = {
            "student_list": [
                {
                    "item_responses": [
                        {"response": 1},
                        {"response": 0}
                    ]
                },
                { 
                    "item_responses": [
                        {"response": 0}
                    ]
                },
                { 
                }
            ]
        }

        expected = {'analysis': {'assumptions': {'2': {'assumed': ['2']}, '3': {'assumed': ['1', '2']}}, 'exclude': 'Invalid data - No mean', 'group_analysis': 'No groups were found, or all students are in '   'the same group', 'item_analysis': [{'difficulty': 0.667,    'idr': 'Invalid data - No mean', 'item_id': '1',    'num_correct': 1},   {'difficulty': 1.0,    'idr': 'Invalid data - No mean', 'item_id': '2',    'num_correct': 0}], 'overall_items': {'diff_avg': 0.834,   'idr_avg': 'Invalid data - No mean'}, 'overall_quiz': {'average': 0.167,  'kr20': -0.0,  'weighted_avg': 0.133}, 'student_scores': [{'score': 0.5,     'student': '1', 'weighted_score': 0.4},    {'score': 0.0,     'student': '2',     'weighted_score': 0.0},    {'score': 0.0,     'student': '3',     'weighted_score': 0.0}], 'topic_avgs': 'No topics were found', 'topic_rights': 'No topics were found'}}
        analysis = analyze_test(data)

        assert analysis == expected
예제 #10
0
    def test_analyze(self):
        expected = exp.test_analysis

        analysis = analyze_test(self.data)
        assert analysis == expected
    def test_missing_data_2(self):
        data = {
            "item_topics":[
                {
                    "item_id":"1",
                    "tags":[
                        {
                        "topic_tagged":"DNA",
                        "scored":"Y"
                        },
                        {
                        "topic_tree":"Biology",
                        "topic_branch_hierarchy":{
                            "0":"Cell biology",
                            "1":"Cells",
                            "2":"Organelles"
                        },
                        "topic_tagged":"Ribosomes",
                        "scored":"Y"
                        }
                    ]
                },
                {
                    "tags":[
                        {
                        "topic_tree":"A",
                        "topic_branch_hierarchy":{
                            "0":"B",
                            "1":"C",
                            "2":"D",
                            "3":"E"
                        },
                        "topic_tagged":"f",
                        "scored":"Y"
                        },
                        {
                        "topic_tree":"m",
                        "topic_branch_hierarchy":{
                        }
                        }
                    ]
                },
                {
                    "item_id":"6",
                },
            ],
            "student_list": [
                { 
                  "item_responses": [
                        {"item_id": "1", "response": 1},
                        {"item_id": "2", "response": 0},
                        {"item_id": "3", "response": 1},
                        {"item_id": "4", "response": 1},
                        {"item_id": "5", "response": 0},
                        {"item_id": "6", "response": 1}
                    ]
                },
                { "group": ["2022"],
                  "email": "*****@*****.**",
                  "item_responses": [
                        {"item_id": "4", "response": 1},
                        {"item_id": "5", "response": 1},
                        {"item_id": "6", "response": 1}
                    ]
                },
                { "group": ["2024"],
                  "item_responses": [
                        {"item_id": "1", "response": 0},
                        {"item_id": "2", "response": 1},
                        {"item_id": "3", "response": 0},
                        {"item_id": "4", "response": 0}
                    ]
                }
            ]
        }

        expected = exp.missing_data_2
        analysis = analyze_test(data)

        assert analysis == expected