Note: You are currently viewing documentation for Moodle 2.2. Up-to-date documentation for the latest stable version is available here: Calculated question 1.7 bug solving proposal.

Development:Calculated question 1.7 bug solving proposal: Difference between revisions

From MoodleDocs
Line 63: Line 63:
==Further testing of actual saving question process==
==Further testing of actual saving question process==
Trying to validate datasets before a quiz or preview, I will summarize here some observations before putting them in a table.
Trying to validate datasets before a quiz or preview, I will summarize here some observations before putting them in a table.
actual code
*actual code
When creating a new question if a category parameter already exists, it is not detected before adding a first item in step three.(datasetitems.php).
**When creating a new question if a category parameter already exists, it is not detected before adding a first item in step three.(datasetitems.php).
If you are using mixed parameters (category and local), as the local ones are empty, no dataitems are shown and you need to add 1 to exit.  
**If you are using mixed parameters (category and local), as the local ones are empty, no dataitems are shown and you need to add 1 to exit.  
If you are using only category parameters , no dataitems are shown and you need to add 1 to exit.However when you add 1 all the preceding dataitems appears + one.  If there was already 6 dataitems clicking add give a seventh one.   
**If you are using only category parameters , no dataitems are shown and you need to add 1 to exit.However when you add 1 all the preceding dataitems appears + one.  If there was already 6 dataitems clicking add give a seventh one.   
If you save as new  
**If you save as new.
The choice will be to set as local although the already present category will be offered.
The choice will be to set as local although the already present category will be offered.
If you are using only category parameters and chose them the preceeding dataitems will be listed.
If you are using only category parameters and chose them the preceeding dataitems will be listed.


 
*modify to saving question after first form
modify to saving question after first form


==Management of datasets shareable over a category==
==Management of datasets shareable over a category==

Revision as of 15:52, 17 October 2006

This page will describe the various improvements and bugs solving that are being planned for 1.7 release. I almost suceed in developping a "cloze" version of the calculated question with a lot of interesting features. However the actual calculated qusetion needs more basic improvements or bug solving. I will list here the order in which I propose to solve them. I have already a working solution for most of the following items although each of them need to be tested before porting in the Moodle code.

Removing old code

There is a quite large number of code older that 1.5 that is always present in the calculated/questiontype.php or datasetdependent/abstractype.php some already as comments in abstractype.php line 374-483

/*
   function save_question($question, &$form, $course) {
  ----
       }
       return true;
   }
*/

and the function line 140 of questiontype.php

  function create_runtime_question($question, $form) {
       $question = parent::create_runtime_question($question, $form);
       $question->options->answers = array();
       foreach ($form->answers as $key => $answer) {
           $a->answer              = trim($form->answer[$key]);
           $a->tolerance           = $form->tolerance[$key];
           $a->tolerancetype       = $form->tolerancetype[$key];
           $a->correctanswerlength = $form->correctanswerlength[$key];
           $a->correctanswerformat = $form->correctanswerformat[$key];
           $question->options->answers[] = clone($a);
       }
       return $question;
   }

the question = parent::create_runtime_question($question, $form); i.e datasetdependet/abstractype.php/create_runtime_question($question, $form); is already as comments as just described (lines 432-463). A search in Moodle_15_STABLE, Moodle_16_STABLE and Moodle_17_STABLE shows that this function is no more used.

Function validate_form($form): Wait and see

the function (lines 155-199) of questiontype.php is no more used

   function validate_form($form) {
       switch($form->wizardpage) {
           case 'question':
  -----
           default:
               return parent::validate_form($form);
               break;
       }
       return true;
   }

as the parent::validate_form($form); i.e. abstractype.php/validate_form($form); the call to these functions line 211 of abstractype is already a comment

       // $this->validate_form($form);

this is true also for Moodle_15_STABLE.

BUT This call to validate_form could be uncommented and used because this test the input from the first part of the edition or creation process.

So the code related to these functions except for the  validate_form() were removed either in calculated/questiontype.php or datasetdependent/abstractype.php.

Function validate_form($form): Tested and deleted

I modify the code so that there was a return to the first form if the was an error detected by function validate_form($form). However this gives place to a specific question general parameter code which is not a good option in Mooodle. So I decide to delete the function validate_form($form) but to change the code so that the question is saved but with a return to the first step if there are errors in the first form data.

Further testing of actual saving question process

Trying to validate datasets before a quiz or preview, I will summarize here some observations before putting them in a table.

  • actual code
    • When creating a new question if a category parameter already exists, it is not detected before adding a first item in step three.(datasetitems.php).
    • If you are using mixed parameters (category and local), as the local ones are empty, no dataitems are shown and you need to add 1 to exit.
    • If you are using only category parameters , no dataitems are shown and you need to add 1 to exit.However when you add 1 all the preceding dataitems appears + one. If there was already 6 dataitems clicking add give a seventh one.
    • If you save as new.

The choice will be to set as local although the already present category will be offered. If you are using only category parameters and chose them the preceeding dataitems will be listed.

  • modify to saving question after first form

Management of datasets shareable over a category

Bad choice of data item number when generating a question [https://tracker.moodle.org/browse/MDL-6777 MDL-6777]

The calculated question allow to define datasets variable (i.e. {a}) that could be common to questions from the same category. This NEVER work correctly because you can define a common variable say {b} in question 1 , create say 6 data items. Create a question 2 that will use the same common {b} in another equation (ex. {cb}+{c}. You then create a number of datasets for example 2 dataitems so question 2 will have 2 new {c} data items and will use 2 {b} common dataitems When you will attempt question 2, the actual code will choose the data item number between 6 and 1 so most often the question will retrun with an error. There is a solution and with some simple testing it could be coded in 1.7, 1.6 and even 1.5 (with change in the table names (i.e. question_datasets to quiz_question_datasets ). See details notes inDevelopment:Calculated question validating the datasets

Adding a table showing the available datasets in the category.

There is no place where this information is available, you just need to memorize it! This table should be shown in the 3 steps

  • Step1 When you write the question and equations
  • Step2 When you decide to use or not a shareable dataset
  • Step3 When you add data items, the table showing you the number of dataitems already in the shareable datasets that you used.

The first proposal diplay all the shareable datasets in the category .example But we could restrict to the one used by the question in the step3

Saving datasets and generating default data items by default when saving questions

The actual calculated question creation process is a 3 steps process and nothin is saved until you create a first dataitem. However when you edit a question everythingis saved at each of the 3 steps. So the proposals are in this order

Saving the data sets after step 1

Use and modify the actual functions so that

  1. default datasets specific to this question (i.e. dataset_definitions->category set to 0) are generated.If the user at step 2 change his mind to shareable datasets the actual code will change it correctly as when editing an exiting question.
  2. Generate a data item is on the fly is the question is used before the user do the 3 steps process. A Notify should be done so that qhen testing the question or the quiz the user see the problem.

Should we create a status parameter in question table?

This status could be used to warn the user when he access the questions display by the showbank.php. The status could contains warnings, errors or nothing (i.e. OK) and be modified when saving question or question options.

Adding multi answer capability to calculated question

Integrating the numerical question code.

Coding a more general solution to moving questions to another category.

Actually ( up to 1.7 HEAD moving questions to another category is done in showbank.php. See Calculated_question_development#Moving_calculated_questions_to_another_category.

This apply also to other complex questiontypes like cloze (i.e. multianswer) type.

Creating a cloze version of calculated question

The actual prototype allows to edit up to 5 subquestions as illustrated by this prewiew[1]

Creating a subquestions interface in the actual cloze question

Following the work done on calculated question cloze version.