Moodle

Solving why sharable parameters does not work correctly in calculated question (15, 1.6 etc)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.5.4, 1.6, 1.6.1, 1.6.2
  • Fix Version/s: None
  • Component/s: Questions, Quiz
  • Labels:
    None
  • Affected Branches:
    MOODLE_15_STABLE, MOODLE_16_STABLE

Description

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, 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....

Issue Links

Activity

Hide
Pierre Pichet added a comment -

This is just one part of the solution.

If we got a minimum! $maxnumber that is less that 1, this means that one of the questions is not correctly defined.
if we got $maxnumber =1 the rand() should not be called.

I am working also on generating temporary data items ( or even at least one ) so that the question remains somewhat useable although with an explicit NOTIFY.
This is related to the 3 steps actually necessary to create a calculated question.

Show
Pierre Pichet added a comment - This is just one part of the solution. If we got a minimum! $maxnumber that is less that 1, this means that one of the questions is not correctly defined. if we got $maxnumber =1 the rand() should not be called. I am working also on generating temporary data items ( or even at least one ) so that the question remains somewhat useable although with an explicit NOTIFY. This is related to the 3 steps actually necessary to create a calculated question.
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it has become inactive and does not appear to affect a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: