Note:

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

Calculated question type creation: Difference between revisions

From MoodleDocs
No edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 35: Line 35:
   2.'''Defining the dataset definitions range''' steps.
   2.'''Defining the dataset definitions range''' steps.
  before adding your first set of data items.
  before adding your first set of data items.
==Editing of a question==
When you modify the an actual question, if you click '''Saving changes'''. the changes are saved in the database.
==Creating a copy of a question==
When you create a new question as a copy of an actual question , the ordinary parameters are copied but you havo to reconstruct the database sets and the database.
==Moving a question to another category==
When you move a question to another category, the ordinary parameters are copied but you havo to reconstruct the database sets and the database.If you come back to the initial category, the initial datasets are retrivied. There is a bug in the transfer related to the complex structure of the calculated questions.
Correcting this bug is one of my priorities([[User:Pierre Pichet|Pierre Pichet]] 11:59, 21 August 2006 (CDT)).
==A summary of the actual functions==
See the [[Calculated question actual 1.7 interface summary]]


==NOTHING is SAVED UNTIL you CLICK the ADD BUTTON==
==NOTHING is SAVED UNTIL you CLICK the ADD BUTTON==
In the preceding Moodle version (<1.5), the user could click the BACK TO QUIZ EDITING button before adding a first data set item
In the preceding Moodle version (<1.6), the user could click the BACK TO QUIZ EDITING button before adding a first data set item
  If the user at the third step click BACK TO QUIZ EDITING when NO dataset items added,  
  If the user at the third step click BACK TO QUIZ EDITING when NO dataset items added,  
  he LOOSE all his work because the question general parameters where not solved.
  he LOOSE all his work because the question general parameters where not solved.
In the newer Moodle versions (1.65 beta,1.7 June 2006), the BACK TO QUIZ EDITING button does not appear unless there is at least one data set item.
In the newer Moodle versions (1.65 beta,1.7, June 2006), the BACK TO QUIZ EDITING button does not appear unless there is at least one data set item.
see [[Calculated question back to quiz button]]
see [[Calculated question back to quiz button]]


Because of this three steps procedure, the creation of a calculated question is a process which can abort easily if the user do not follow exactly all the three steps in the order the Moodle code expect them.
Because of this three steps procedure, the creation of a calculated question is a process which can abort easily if the user do not follow exactly all the three steps in the order the Moodle code expect them.
Improvements to obtain a '''FULL PROOF PROCESS''' are proposed in the next section.
Improvements to obtain a '''FOOLPROOF PROCESS''' are proposed in the next section.


However, the teacher should always verify that for each added data item set, a valid answer, minimum and maximum value are obtained.
However, the teacher should always verify that for each added data item set, a valid answer, minimum and maximum value are obtained.
Fortunately, at this step the newly created calculated question is saved in the database.
Fortunately, at this step the newly created calculated question is already saved in the database and the user could go back and modify the question if necessary.
 
==A more FULL PROOF code proposal ==
The code can be improved --[[User:Pierre Pichet|Pierre Pichet]] 20:19, 19 June 2006 (WST)
* 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 developpers of the calculated questiont PHP code.
* by adding supplementary PHP code to eliminate the conditions that could lead to problems
** when creating or editing the calculated questions
** using them in quizzes, lessons etc.
These steps require more complex coding and should be done when the simpler and safer preceeding problems have been resolved.
 


==A more FOOLPROOF code proposal ==
See also [[Calculated question development| a proposed calculated question development]] in Developer notes 


[[Category:Quiz]]
[[Category:Quiz]]

Latest revision as of 06:29, 15 June 2011

I will use this page and the followings to describe the PHP code principal processes of the calculated question creation and see how it could be improved.

Calculated question parameters

Calculated question is an extended numerical question where parameters of a mathematical problems are generated and used to calculate the answer using a mathematical formula.

So the answer parameter of a numerical question is replaced by the mathematical formula using the same answer database structure that the numerical question.

The generated parameters are identified by a special format that is not used in a mathematical PHP equation {param} where the param name begins by a letter and can include alphanumerics symbol a-z A-Z _ 0-9

ex. {ad} {a_2} {a4_r} are valid parameter names 
{1a} {a+1} {a(0)} are invalid parameter names
 

These parameters are transform in datasets defined by a min,max,decimal and generation mode. Using these datasets definitions a number of different values are generated (the dataset items) and used to generate different question instances where the parameters have different values although the question structure and answer formula are constant.

Creating a calculated question

Actually the creation of a calculated question is a three step process

  • Defining the common question parameters
    • Question name
    • Question text
    • answer formula, limit, units
  • Defining the dataset definitions range for each of them. The dataset definition ({params}) can be used in this new question only or could be used or add been already created by other questions in the question category in which the new question is created.
 question category is a set of questions that can contain various question types
  • Defining the dataset definitions parameters (min,max, decimal and generation mode and adding at least one data item for each dataset definitions
Actually a set of all the data items is created when you click the add button
  • Saving the question parameters,dataset definitions parameters and data items.

The real saving procedure is done when you add the first set of data items.

Because in the actual code a calculated question needs that
all these components be defined to be a valid calculated question,
the saving is postponed until you click the add button to add the first set of data items.
The parameters already entered are stored in the $Session object
even if you click Saving changes at least
twice 
  1.Defining the common question parameters 
  2.Defining the dataset definitions range steps.
before adding your first set of data items.

Editing of a question

When you modify the an actual question, if you click Saving changes. the changes are saved in the database.

Creating a copy of a question

When you create a new question as a copy of an actual question , the ordinary parameters are copied but you havo to reconstruct the database sets and the database.

Moving a question to another category

When you move a question to another category, the ordinary parameters are copied but you havo to reconstruct the database sets and the database.If you come back to the initial category, the initial datasets are retrivied. There is a bug in the transfer related to the complex structure of the calculated questions. Correcting this bug is one of my priorities(Pierre Pichet 11:59, 21 August 2006 (CDT)).

A summary of the actual functions

See the Calculated question actual 1.7 interface summary

NOTHING is SAVED UNTIL you CLICK the ADD BUTTON

In the preceding Moodle version (<1.6), the user could click the BACK TO QUIZ EDITING button before adding a first data set item

If the user at the third step click BACK TO QUIZ EDITING when NO dataset items added, 
he LOOSE all his work because the question general parameters where not solved.

In the newer Moodle versions (1.65 beta,1.7, June 2006), the BACK TO QUIZ EDITING button does not appear unless there is at least one data set item. see Calculated question back to quiz button

Because of this three steps procedure, the creation of a calculated question is a process which can abort easily if the user do not follow exactly all the three steps in the order the Moodle code expect them. Improvements to obtain a FOOLPROOF PROCESS are proposed in the next section.

However, the teacher should always verify that for each added data item set, a valid answer, minimum and maximum value are obtained. Fortunately, at this step the newly created calculated question is already saved in the database and the user could go back and modify the question if necessary.

A more FOOLPROOF code proposal

See also a proposed calculated question development in Developer notes