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
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 dataitemsWhen you will attempt question 2, you will call datasetdependent/abstractype.php function create_session_and_responses()
This function will search for the MAXIMUM data items possible using
if(!$maxnumber = (int)get_field_sql(
"SELECT MIN(a.itemcount)
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE b.question = $question->id
AND a.id = b.datasetdefinition")) {
error("Couldn't get the specified dataset for a calculated " .
"question! (question: {$question->id}");
}
it will return $maxnumber =6 from the itemcount of common {b}
data items.
You will ask for a random number between 1 and 6.
$state->options->datasetitem = rand(1, $maxnumber);
If you get greater the 2 you are in TROUBLE because there is just 2
{c} data items available.http://www.chimie.uqam.ca/images/2809/maxnumber6.jpg
However is you change the SQL to
if(!$maxnumber = (int)get_field_sql(
"SELECT MIN(a.itemcount)
FROM {$CFG->prefix}question_dataset_definitions a,
{$CFG->prefix}question_datasets b
WHERE b.question = $question->id
AND a.id = b.datasetdefinition")) {
error("Couldn't get the specified dataset for a calculated " .
"question! (question: {$question->id}");
}
you get $maxnumber = 2 so
$state->options->datasetitem = rand(1, $maxnumber);
will give you a value that is in the range of the smallest dataset {c}
and you get
http://www.chimie.uqam.ca/images/2809/minnumber2.jpg
I am also implementing showing the available common category datasetdefs when creating a calculated question.
http://www.chimie.uqam.ca/images/2809/showcommon.jpg
but that's another story....
- will be (partly) resolved by
-
MDL-8552 The dataitem number is not choosen correctly when using a calculated question in a quiz
-
- Closed
-