Quiz Item Analysis of All Question Types

From MoodleDocs

This page will be used to described a code proposal to a general including plug -in quiz item analysis. see http://moodle.org/mod/forum/discuss.php?d=86598

Classification of the different question types

Question types can be classified in different ways and this classification is related to how to obtain from the various question types the necessary data for item analysis.

Single or multi answers (questions) question type

Single answer "normal" question types

Short answer question type

Numerical answer question type

An extension of short answer

Calculated question type

An extension of numerical answer

Multichoice question type

True False question type

A limited choice multichoice

Multi answers or questions question types

Multi answers (cloze) question types

Match question type

Although generally not included in multi questions, this is a multiquestions one.

Random Short-Answer Matching question type

Random or not question types

Either the question id (and related data) is always the same in a quiz (same formula in the calculated question type) or the question itself change or its composants


Random question type

It is just a rediredtion to a question of of the other question types that are useable by random

Random Short-Answer Matching question type

The internal questions of this multi questions type is build on fly for each attempt. That is to say that this is a "virtual" question that is defined in the $state session parameter. So we need another class


Random Short-Answer Matching question type

The internal questions of this multi questions type is build on fly for each attempt. The question options are not in the database but in the $state session parameter.

Question type functions necessary for the report.php

Actual functions specific to report.php


In questionlib

   global $QTYPES;
   $r = $QTYPES[$question->qtype]->get_all_responses($question, $state);
   return $r;

get_all_responses($question, $state)


In questionlib

function get_question_actual_response($question, $state) {
   global $QTYPES; 
   $r = $QTYPES[$question->qtype]->get_actual_response($question, $state);
   return $r;

get_actual_response($question, $state)


Which is also use by preview.php



In questionlib

function get_question_fraction_grade($question, $state) {
   global $QTYPES;
   $r = $QTYPES[$question->qtype]->get_fractional_grade($question, $state);
   return $r;

How to identify multiquestions question type

We could set a specific function but a more easy way is to add another parameter in the data from $r =$QTYPES[$question->qtype]->get_all_responses($question, $state).

$r->multiquestions = 0 or 1 The actual monoquestion types do not have this parameter so this is transparent to them.

if ( !isset($r->multiquestions) || $r->multiquestions === 0 ) {
// then the monoquestion responses array is converted to a multiquestion one and process through the report.php code.

How to identify random question types

Actually there is just one general random question type. But specifics qtype random could be created (i.e. numerical questions ) although this can be done by putting all the numerical questions in a specific category. Designing a general code, it is better to create a new function like is_random_question().

How to identify virtual question types

Here we need a new function is_virtual_question() with some specs about the "virtual" state.

Question texts

In a monoquestion type, the question text is the db table questiontext field. In multiquestion there could be a question text and subquestion texts. We need a function to access them get_question_texts() and this function should also return the text format. As this function will be Item analysis report.php specific, the question text could be transformed by the $QTYPES so as to be useable in a report or a worksheet cell (i.e. questions with image or math formulas)as the question text here is just a reminder.

New Question type functions

is_random_question() returns false (default) or true

is_virtual_question() returns false (default) or true

   function get_question_texts(&$question, $state)  {
     // return an array as the values will be stored in an array in report.php

       $subtext = array();
       $subtext['questiontext'] = $question->questiontext ;
       $subtext['questionformat'] = $question->questiontextformat ;
       $subtext['subquestiontext'] =  ;
       $subtext['subquestionformat'] =  ;

       return $subtext ;

Pierre Pichet 20:03, 13 January 2008 (CST)