Note:

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

Calculated question improvements: Difference between revisions

From MoodleDocs
mNo edit summary
m (Calculated question development moved to Development:Calculated question improvements)
(No difference)

Revision as of 09:01, 21 February 2007

I will use this page to describe the various improvements I will try to develop related to the calculated questions.

Creation and modification of calculated questions

See the Calculated question bugs and new features proposal

See the Calculated question actual 1.7 interface summary

See the Calculated question 1.7 bugs solving proposal

A more FOOL-PROOF code proposal

The code can be improved

  • by allowing user to do normal browser operations like a click on the BACK button to comeback at the first step and correct the question text
If the HTML editor of the question text is activated, all the text already written will be lost.
If the HTML editor is not activated (ex. on MACs with OS 9) and the simple HTML textarea is used, the text already written is not lost.
  • by checking ALL the content of the first form elements (i.e. name, question text, answer formula etc.) when the user click the SAVE CHANGES button.
If the javascript perform all the tests done in the PHP code before saving the calculated question parameters, we eliminate almost all the possibility of loosing the work when clicking the ADD button in the third form.

The editquestion.html being specific to each questiontype can perform tests specific to the calculated question which are known to the developers of the calculated question PHP code.

Full proof 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.

Import and export of calculated question

Actually there is no import or export mudle that works for calculated questions

Import from webct

At Uqam we are migrating to Moodle from Webct.

Export and import in moodle format

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.
 Pierre Pichet  August 2006 (WST)

Developer_notes Calculated question creation developper docs