Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Quiz Item Analysis of Multianswers Question Types: Difference between revisions

From MoodleDocs
Line 11: Line 11:
==We need a convention of how to store the responses from the different embedded questions==
==We need a convention of how to store the responses from the different embedded questions==
The same convention should be used in the $session states and in the get_responses function.
The same convention should be used in the $session states and in the get_responses function.
The actual responses convention used an array to contains the different answers and put in [''] element the actual response.
The actual responses convention used an array to contains the different answers and put in <nowiki>['']</nowiki> element the actual response.
an example for a numerical question with the tolerance limit
stdClass Object
(
    [id] => 2312
    [responses] => Array
        (
            [6837] => stdClass Object
                (
                    [answer] => 1822 (1817..1827)
                    [credit] => 1
                )
        )
)
In a multianswers qtype the different answers responses are stored in an array as.
stdClass Object
(
    [id] => 2815
    [responses] => Array
        (
            [1] => stdClass Object
                (
                    [id] => 2816
                    [responses] => Array
                        (
                            [7300] => stdClass Object
                                (
                                    [answer] => Wrong answer
                                    [credit] => 0
                                )
                            [7302] => stdClass Object
                                (
                                    [answer] => Correct answer
                                    [credit] => 1
                                )
                            [7305] => stdClass Object
                                (
                                    [answer] => Answer that gives half the credit
                                    [credit] => 0.5
                                )
                        )
                )
            [2] => stdClass Object
                (
                    [id] => 2817
                    [responses] => Array
                        (
                            [7303] => stdClass Object
                                (
                                    [answer] => Wrong answer
                                    [credit] => 0
                                )
 
                            [7304] => stdClass Object
                                (
                                    [answer] => Correct answer
                                    [credit] => 1
                                )
                        )
                )
            [3] => stdClass Object
                (
                    [id] => 2818
                    [responses] => Array
                        (
                            [7307] => stdClass Object
                                (
                                    [answer] => 65 (64.9..65.1)
                                    [credit] => 1
                                )
                        )
                )
        )
)
So the one question question types responses is tranformed in a similar structure
The upper example becomes
To distinguish
To distinguish

Revision as of 03:11, 8 January 2008

This page described a code proposal to access the embedded questions data in multianswers questiion types so that they can be displayed in the Item analysis report. See http://moodle.org/mod/forum/discuss.php?d=86598#387154 The code is experimental and need more testing and is not optimized.

All question types to be analyzed contain at least one embedded question

If we set this as a general framework, the code will be valid for all question types.

We need a question type function to retrieve the embedded questions

There is actually no question type function to know the number the embedded questions in a question. The default function number_of_embedded_questions() returns 1;

This is not the same as  actual_number_of_questions().

We need a convention of how to store the responses from the different embedded questions

The same convention should be used in the $session states and in the get_responses function. The actual responses convention used an array to contains the different answers and put in [''] element the actual response. an example for a numerical question with the tolerance limit

stdClass Object
(
   [id] => 2312
   [responses] => Array
       (
           [6837] => stdClass Object
               (
                   [answer] => 1822 (1817..1827)
                   [credit] => 1
               )
       )
)

In a multianswers qtype the different answers responses are stored in an array as.

stdClass Object
(
   [id] => 2815
   [responses] => Array
       (
           [1] => stdClass Object
               (
                   [id] => 2816
                   [responses] => Array
                       (
                           [7300] => stdClass Object
                               (
                                   [answer] => Wrong answer
                                   [credit] => 0
                               )
                           [7302] => stdClass Object
                               (
                                   [answer] => Correct answer
                                   [credit] => 1
                               )
                           [7305] => stdClass Object
                               (
                                   [answer] => Answer that gives half the credit
                                   [credit] => 0.5
                               )
                       )
               )
           [2] => stdClass Object
               (
                   [id] => 2817
                   [responses] => Array
                       (
                           [7303] => stdClass Object
                               (
                                   [answer] => Wrong answer
                                   [credit] => 0
                               )
                           [7304] => stdClass Object
                               (
                                   [answer] => Correct answer
                                   [credit] => 1
                               )
                       )
               )
           [3] => stdClass Object
               (
                   [id] => 2818
                   [responses] => Array
                       (
                           [7307] => stdClass Object
                               (
                                   [answer] => 65 (64.9..65.1)
                                   [credit] => 1
                               )
                       )
               )
       )

) So the one question question types responses is tranformed in a similar structure The upper example becomes To distinguish