Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-6777

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.5.4, 1.6, 1.6.1, 1.6.2
    • None
    • Questions, Quiz
    • None
    • 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....

      Attachments

        Issue Links

          Activity

            People

              ppichet Pierre Pichet
              ppichet Pierre Pichet
              Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: