Calculated question improvements

From MoodleDocs
Revision as of 06:35, 6 March 2009 by Bruno Vernier (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

I will use this page to describe the various improvements I am developping related to the calculated questions. The code of 1.8 with the QuickForm HTML structure offer a considerable improvement in the interface user over the preceeding versions. However at Université du Québec à Montréal, we moved from WebCT 4 to Moodle 1.6.3 in spring 2007 and will maintian this version for the next academic year. So exceptionnally, I will port down to 1.6 most of the improvements being made to the Moodle HEAD version.

The following content of this page will be updated soon.

Working progress

Improvements HEAD 1.8 1.7 1.6

Moodle XML Import , Export

Done Done Done Done

WebCT Import

Done Done Done Done

Saving question at each step

  • remove use of $SESSION to store parameters
Done Done Done Done

Allow save as new question

  • saving also the datasets and data items
Done Done TO DO TO DO

Allow saving of multiple answers

Done Done Done Done

Allow edition of multiple answers


Validation of user data before saving

  • For QuickForm redisplay with red text
  • Older version use notice when saving question->options so there is a return to editquestion

Allow addition and removal of dataitems by steps of 5,10,15, etc


larger field for formula




Possible steps are :

  • TO DO
  • Done i.e CVS and merged


Foolproof and clearer creation process

Actually the creation or edition of calculated question is a three steps process ( 3 different pages) where the user can make errors that he cannot readily recuperate.

  • Identify the steps and renaming the save changes or continue buttons.
  • Using javascript to correct for errors or non valid values in each steps before going to the next step.Calculated question js validating forms
  • Creating buttons to access the previous steps for corrections.
  • Creating a table showing the variables used by the other calculated questions in the same category.
  • Allowing to create or delete data items by 1, 10, 20 etc in one step.

Moving calculated questions to another category

Actually the code (Moodle 1.7) for moving questions to another category means simply to change the category field in the database question record. Although this is correct for most questions types, this is not the right way to do it with calculated questions because the same category field is also used in the datasets records. A dataset can be shared by questions of the same category. To search if there is a already sharable dataset in a category, the parameters used are the dataset->name and the dataset->category. The possibilities are

  1. All the dataset used by the question to be moved are reserved for this question (dataset->category=0). The calculated question can be moved to another category without restriction.This is the actual implementation.
  2. At least one of the dataset used by the question to be moved is sharable (dataset->category = actual question category)
    1. If all the sharable dataset are only used by the question to be moved, the calculated question can be selected to move to the other category .
    2. If all the questions that are selected to be moved, and all the sharable datasets are only used by these questions to be moved, this set of questions can be selected to move to the other category .
    3. In the case that there are questions not selected that could used a sharable dataset, this dataset cannot be moved in the another category.
      1. Notify the user that another questions in the initial category share a parameter with this category.
        1. The user can choose to cancel the move and select all the other questions (Case 2.2).
        2. The user can choose to keep the question in the selected questions to be moved. In this case, the dataset should be duplicated when moving the another category.

Duplicate datasets?

If a similar sharable dataset already exists in the moveto category ( identical dataset->name and dataset->category = movetocategory). Notify the user and giving information on the

  1. sharable dataset in selected questions to be moved
  2. already existing sharable datasets in the move_to_category.

The user should be able to select which dataset will be used in move_to_category.

To implement these choices we need to add new functions in default questiontype class.

function movable_to_category(&$questions,$categoryid)

default return null 
$questions contain all the question records data for all the selected questions 
so that qtype implementation could test 
if the selected questions satisfy option 2.2 a $questions->notify can be added to be used by showbank.php and move_to_category.

function move_to_category($question,$tocategory)

the default implementation should something like the actual code

          if (!set_field('question', 'category', $tocategory->id, 'id', $question->id)) {
                           error('Could not update category field');
       return null;

the calculated question implementation should be able to duplicate the datasets in the new category

Improvements in general question editing interface

  • Showing the text of the questions

Creation of a short (simple) calculated question

The actual calculated question allows for calculated params that can be shared by different problems. This could lead to a somewhat cloze used of calculated questions.However the questions cannot migrate individually to another category. A short calculated question that just allow for calculated parameters reserved for this question will allow use of this question in drag and drop cloze lesson.

Manipulating data items

Actual functions and propôsal for new ones for manipulating data items are discussed in Data_Item_Functions

Side effects to other modules

  • Modification of the question type to allow moving of calculated question to another category.
  • Creation of general functions to standardize the import or export process.

Creation and modification of calculated questions

See the Calculated question bugs and new features proposal

See the Calculated multiquestions proposal

See the Calculated question actual 1.7 interface summary

See the Calculated question 1.7 bugs solving proposal

 Pierre Pichet  August 2007 (WST)

Developer_notes Calculated question creation developper docs