Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 25... Línea 25...
25
 * @covers     \mod_h5pactivity\output\result
25
 * @covers     \mod_h5pactivity\output\result
26
 * @category   test
26
 * @category   test
27
 * @copyright  2023 Laurent David <laurent.david@moodle.com>
27
 * @copyright  2023 Laurent David <laurent.david@moodle.com>
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 */
29
 */
30
class result_test extends \advanced_testcase {
30
final class result_test extends \advanced_testcase {
31
    /**
31
    /**
32
     * Data provider for result export_options test
32
     * Data provider for result export_options test
33
     *
33
     *
34
     * @return array[]
34
     * @return array[]
35
     */
35
     */
36
    public static function result_data_provider(): array {
36
    public static function result_data_provider(): array {
37
        return [
37
        return [
38
            'fill-in with case sensitive' => [
38
            'fill-in with case sensitive' => [
39
                'result' => [
39
                'providedresultdata' => [
40
                    'interactiontype' => 'fill-in',
40
                    'interactiontype' => 'fill-in',
41
                    'description' => '<p>Fill in the missing words</p>
41
                    'description' => '<p>Fill in the missing words</p>
42
                              <p>Meow .... this is a __________</p>
42
                              <p>Meow .... this is a __________</p>
43
                              <p>Bark... this is a __________</p>',
43
                              <p>Bark... this is a __________</p>',
44
                    'correctpattern' => '["{case_matters=true}cat[,]dog"]',
44
                    'correctpattern' => '["{case_matters=true}cat[,]dog"]',
45
                    'response' => 'Cat[,]dog',
45
                    'response' => 'Cat[,]dog',
46
                    'additionals' => '{"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":31,'
46
                    'additionals' => '{"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":31,'
47
                        . '"https:\\/\\/h5p.org\\/x-api\\/case-sensitivity":true,'
47
                        . '"https:\\/\\/h5p.org\\/x-api\\/case-sensitivity":true,'
48
                        . '"https:\\/\\/h5p.org\\/x-api\\/alternatives":[["cat"],["dog"]]},"contextExtensions":{}}',
48
                        . '"https:\\/\\/h5p.org\\/x-api\\/alternatives":[["cat"],["dog"]]},"contextExtensions":{}}',
49
                ],
49
                ],
50
                'useranswers' => [
50
                'expecteduseranswers' => [
51
                    'Gap #1 - cat' => (object) ['answer' => 'Cat', 'incorrect' => true],
51
                    'Gap #1 - cat' => (object) ['answer' => 'Cat', 'incorrect' => true],
52
                    'Gap #2 - dog' => (object) ['answer' => 'dog', 'correct' => true],
52
                    'Gap #2 - dog' => (object) ['answer' => 'dog', 'correct' => true],
53
                ],
53
                ],
54
            ],
54
            ],
55
            'fill-in with case insensitive' => [
55
            'fill-in with case insensitive' => [
56
                'result' => [
56
                'providedresultdata' => [
57
                    'interactiontype' => 'fill-in',
57
                    'interactiontype' => 'fill-in',
58
                    'description' => '<p>Fill in the missing words</p>
58
                    'description' => '<p>Fill in the missing words</p>
59
                              <p>Meow .... this is a __________</p>
59
                              <p>Meow .... this is a __________</p>
60
                              <p>Bark... this is a __________</p>',
60
                              <p>Bark... this is a __________</p>',
61
                    'correctpattern' => '["{case_matters=false}cat[,]dog"]',
61
                    'correctpattern' => '["{case_matters=false}cat[,]dog"]',
62
                    'response' => 'Cat[,]dog',
62
                    'response' => 'Cat[,]dog',
63
                    'additionals' => '{"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":31,'
63
                    'additionals' => '{"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":31,'
64
                        . '"https:\\/\\/h5p.org\\/x-api\\/case-sensitivity":false,'
64
                        . '"https:\\/\\/h5p.org\\/x-api\\/case-sensitivity":false,'
65
                        . '"https:\\/\\/h5p.org\\/x-api\\/alternatives":[["cat"],["dog"]]},"contextExtensions":{}}',
65
                        . '"https:\\/\\/h5p.org\\/x-api\\/alternatives":[["cat"],["dog"]]},"contextExtensions":{}}',
66
                ],
66
                ],
67
                'useranswers' => [
67
                'expecteduseranswers' => [
68
                    'Gap #1 - cat' => (object) ['answer' => 'Cat', 'correct' => true],
68
                    'Gap #1 - cat' => (object) ['answer' => 'Cat', 'correct' => true],
69
                    'Gap #2 - dog' => (object) ['answer' => 'dog', 'correct' => true],
69
                    'Gap #2 - dog' => (object) ['answer' => 'dog', 'correct' => true],
70
                ],
70
                ],
71
            ],
71
            ],
72
            'drag and drop' => [
72
            'drag and drop' => [
73
                'result' => [
73
                'providedresultdata' => [
74
                    'interactiontype' => 'matching',
74
                    'interactiontype' => 'matching',
75
                    'description' => 'Drag and Drop Test',
75
                    'description' => 'Drag and Drop Test',
76
                    'correctpattern' => '["0[.]0[,]0[.]2[,]1[.]1[,]1[.]0"]',
76
                    'correctpattern' => '["0[.]0[,]0[.]2[,]1[.]1[,]1[.]0"]',
77
                    'response' => '0[.]0[,]1[.]1[,]0[.]2[,]0[.]3',
77
                    'response' => '0[.]0[,]1[.]1[,]0[.]2[,]0[.]3',
78
                    'additionals' => '{"source":[{"id":"0","description":{"en-US":"Answer 1 (DZ1 and DZ2)\n"}},'
78
                    'additionals' => '{"source":[{"id":"0","description":{"en-US":"Answer 1 (DZ1 and DZ2)\n"}},'
Línea 83... Línea 83...
83
                        . '{"id":"1","description":{"en-US":"Dropzone 2\n"}}],'
83
                        . '{"id":"1","description":{"en-US":"Dropzone 2\n"}}],'
84
                        . '"extensions":{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":41,'
84
                        . '"extensions":{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":41,'
85
                        . '"http:\/\/h5p.org\/x-api\/h5p-subContentId":"59590246-f16e-4855-8dd6-c80e892ef96b"},'
85
                        . '"http:\/\/h5p.org\/x-api\/h5p-subContentId":"59590246-f16e-4855-8dd6-c80e892ef96b"},'
86
                        . '"contextExtensions":{}}',
86
                        . '"contextExtensions":{}}',
87
                ],
87
                ],
88
                'useranswers' => [
88
                'expecteduseranswers' => [
89
                    'Answer 1 (DZ1 and DZ2) - Dropzone 1, Dropzone 2' => (object) ['answer' => 'Dropzone 1', 'correct' => true],
89
                    'Answer 1 (DZ1 and DZ2) - Dropzone 1, Dropzone 2' => (object) ['answer' => 'Dropzone 1', 'correct' => true],
90
                    'Anwser 2 (DZ2) - Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
90
                    'Anwser 2 (DZ2) - Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
91
                    'Anwser 3 (DZ1) - Dropzone 1' => (object) ['answer' => 'Dropzone 1', 'correct' => true],
91
                    'Anwser 3 (DZ1) - Dropzone 1' => (object) ['answer' => 'Dropzone 1', 'correct' => true],
92
                    'Anwser 4 (neither) - ' => (object) ['answer' => 'Dropzone 1', 'incorrect' => true],
92
                    'Anwser 4 (neither) - ' => (object) ['answer' => 'Dropzone 1', 'incorrect' => true],
93
                ],
93
                ],
94
            ],
94
            ],
95
            'drag and drop with no answer' => [
95
            'drag and drop with no answer' => [
96
                'result' => [
96
                'providedresultdata' => [
97
                    'interactiontype' => 'matching',
97
                    'interactiontype' => 'matching',
98
                    'description' => 'Drag and Drop Test',
98
                    'description' => 'Drag and Drop Test',
99
                    'correctpattern' => '["0[.]0[,]0[.]2[,]1[.]1[,]1[.]0"]',
99
                    'correctpattern' => '["0[.]0[,]0[.]2[,]1[.]1[,]1[.]0"]',
100
                    'response' => '1[.]0[,]1[.]1',
100
                    'response' => '1[.]0[,]1[.]1',
101
                    'additionals' => '{"source":[{"id":"0","description":{"en-US":"Answer 1 (DZ1 and DZ2)\n"}},'
101
                    'additionals' => '{"source":[{"id":"0","description":{"en-US":"Answer 1 (DZ1 and DZ2)\n"}},'
Línea 106... Línea 106...
106
                        . '{"id":"1","description":{"en-US":"Dropzone 2\n"}}],'
106
                        . '{"id":"1","description":{"en-US":"Dropzone 2\n"}}],'
107
                        . '"extensions":{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":41,'
107
                        . '"extensions":{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":41,'
108
                        . '"http:\/\/h5p.org\/x-api\/h5p-subContentId":"59590246-f16e-4855-8dd6-c80e892ef96b"},'
108
                        . '"http:\/\/h5p.org\/x-api\/h5p-subContentId":"59590246-f16e-4855-8dd6-c80e892ef96b"},'
109
                        . '"contextExtensions":{}}',
109
                        . '"contextExtensions":{}}',
110
                ],
110
                ],
111
                'useranswers' => [
111
                'expecteduseranswers' => [
112
                    'Answer 1 (DZ1 and DZ2) - Dropzone 1, Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
112
                    'Answer 1 (DZ1 and DZ2) - Dropzone 1, Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
113
                    'Anwser 2 (DZ2) - Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
113
                    'Anwser 2 (DZ2) - Dropzone 2' => (object) ['answer' => 'Dropzone 2', 'correct' => true],
114
                    'Anwser 3 (DZ1) - Dropzone 1' => (object) ['answer' => 'None', 'incorrect' => true],
114
                    'Anwser 3 (DZ1) - Dropzone 1' => (object) ['answer' => 'None', 'incorrect' => true],
115
                    'Anwser 4 (neither) - ' => (object) ['answer' => 'None', 'correct' => true],
115
                    'Anwser 4 (neither) - ' => (object) ['answer' => 'None', 'correct' => true],
116
                ],
116
                ],
117
            ],
117
            ],
118
            'sort the paragraph text' => [
118
            'sort the paragraph text' => [
119
                'result' => [
119
                'providedresultdata' => [
120
                    'interactiontype' => 'sequencing',
120
                    'interactiontype' => 'sequencing',
121
                    'description' => 'SortParagraphs',
121
                    'description' => 'SortParagraphs',
122
                    'correctpattern' => '["0[,]1[,]2[,]3[,]4"]',
122
                    'correctpattern' => '["0[,]1[,]2[,]3[,]4"]',
123
                    'response' => '0[,]1[,]3[,]2[,]4',
123
                    'response' => '0[,]1[,]3[,]2[,]4',
124
                    'additionals' => '{"choices":[{"id":0,"description":{"en":"First I wake up at 7.30 am\\n",'
124
                    'additionals' => '{"choices":[{"id":0,"description":{"en":"First I wake up at 7.30 am\\n",'
Línea 129... Línea 129...
129
                        . '{"id":4,"description":{"en":"Finally I go school\\n","en-US":"Finally I go school\\n"}}],'
129
                        . '{"id":4,"description":{"en":"Finally I go school\\n","en-US":"Finally I go school\\n"}}],'
130
                        .
130
                        .
131
                        '"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":39,'
131
                        '"extensions":{"http:\\/\\/h5p.org\\/x-api\\/h5p-local-content-id":39,'
132
                        . '"https:\\/\\/h5p.org\\/x-api\\/duplicates-interchangeable":1},"contextExtensions":{}}',
132
                        . '"https:\\/\\/h5p.org\\/x-api\\/duplicates-interchangeable":1},"contextExtensions":{}}',
133
                ],
133
                ],
134
                'useranswers' => [
134
                'expecteduseranswers' => [
135
                    '#1 - First I wake up at 7.30 am' => (object) ['answer' => 'Correct answer', 'pass' => true],
135
                    '#1 - First I wake up at 7.30 am' => (object) ['answer' => 'Correct answer', 'pass' => true],
136
                    '#2 - Next I get dressed' => (object) ['answer' => 'Correct answer', 'pass' => true],
136
                    '#2 - Next I get dressed' => (object) ['answer' => 'Correct answer', 'pass' => true],
137
                    '#3 - Afterward I have breakfast' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
137
                    '#3 - Afterward I have breakfast' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
138
                    '#4 - I brush my teeth' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
138
                    '#4 - I brush my teeth' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
139
                    '#5 - Finally I go school' => (object) ['answer' => 'Correct answer', 'pass' => true],
139
                    '#5 - Finally I go school' => (object) ['answer' => 'Correct answer', 'pass' => true],
140
                ],
140
                ],
141
            ],
141
            ],
142
            'sequencing images' => [
142
            'sequencing images' => [
143
                'result' => [
143
                'providedresultdata' => [
144
                    'interactiontype' => 'sequencing',
144
                    'interactiontype' => 'sequencing',
145
                    'description' => 'Order the planets from smallest to largest',
145
                    'description' => 'Order the planets from smallest to largest',
146
                    'correctpattern' => '["item_3[,]item_0[,]item_7[,]item_1[,]item_5[,]item_2[,]item_4[,]item_6"]',
146
                    'correctpattern' => '["item_3[,]item_0[,]item_7[,]item_1[,]item_5[,]item_2[,]item_4[,]item_6"]',
147
                    'response' => 'item_0[,]item_1[,]item_3[,]item_2[,]item_5[,]item_4[,]item_6[,]item_7',
147
                    'response' => 'item_0[,]item_1[,]item_3[,]item_2[,]item_5[,]item_4[,]item_6[,]item_7',
148
                    'additionals' => '{"choices":[{"id":"item_3","description":{"en-US":"Mercury"}},'
148
                    'additionals' => '{"choices":[{"id":"item_3","description":{"en-US":"Mercury"}},'
Línea 150... Línea 150...
150
                        . '{"id":"item_1","description":{"en-US":"Venus"}},{"id":"item_5","description":{"en-US":"Uranus"}},'
150
                        . '{"id":"item_1","description":{"en-US":"Venus"}},{"id":"item_5","description":{"en-US":"Uranus"}},'
151
                        . '{"id":"item_2","description":{"en-US":"Neptune"}},{"id":"item_4","description":{"en-US":"Saturn"}},'
151
                        . '{"id":"item_2","description":{"en-US":"Neptune"}},{"id":"item_4","description":{"en-US":"Saturn"}},'
152
                        . '{"id":"item_6","description":{"en-US":"Jupiter"}}],"extensions":'
152
                        . '{"id":"item_6","description":{"en-US":"Jupiter"}}],"extensions":'
153
                        . '{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":43},"contextExtensions":{}}',
153
                        . '{"http:\/\/h5p.org\/x-api\/h5p-local-content-id":43},"contextExtensions":{}}',
154
                ],
154
                ],
155
                'useranswers' => [
155
                'expecteduseranswers' => [
156
                    '#1 - Mercury' => (object) ['answer' => 'Correct answer', 'pass' => true],
156
                    '#1 - Mercury' => (object) ['answer' => 'Correct answer', 'pass' => true],
157
                    '#2 - Mars' => (object) ['answer' => 'Correct answer', 'pass' => true],
157
                    '#2 - Mars' => (object) ['answer' => 'Correct answer', 'pass' => true],
158
                    '#3 - Earth' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
158
                    '#3 - Earth' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
159
                    '#4 - Venus' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
159
                    '#4 - Venus' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
160
                    '#5 - Uranus' => (object) ['answer' => 'Incorrect answer', 'fail' => true],
160
                    '#5 - Uranus' => (object) ['answer' => 'Incorrect answer', 'fail' => true],