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

Multichoice question with multianswer and custom score: illogic questionsum and behaviour

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8
    • 1.8.4, 1.9
    • Lesson
    • None
    • Standard on Linux
    • MySQL
    • MOODLE_18_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE

    Description

      If you have a custom question (multichoice) with more than one answer that is right, ie that has more than one answer with a score > 0
      example:

      • how many nails do mammals have on one foot?
      • 1 (15)
      • 2 (15)
      • 3 (0)
      • 4 (15)
      • 5 (15)
      • first weird behaviour:
      • the total of that question is 15 but should be 60 (the answer is correct if you choos all of the items!)
      • let select the first 2 answers
      • the feedback is set to "wrong answer"
      • you get 15 points out of 15

      ============= FIRST ISSUE ================
      I understand the need of scaling the answers from one totally correct, down to totally wrong ones, as for

      • Do mammals lay eggs?
      • never (90)
      • some peculiar species (100)
      • yes (0)
        in which the right answer is the second but the first is almost right...
        This small sub-issue is resolved assigning a maxvalue to the question itself, and the score given for that question is min(question_max_value, useranswer_total_score) or just using multichoice-one answer only question type!

      Comming back to the main first issue, it is resolved by changing the lines in /mod/lesson/locallib.php near line 1474
      // Find the highest possible score per page to get our total
      foreach ($answers as $answer) {
      if(!isset($bestscores[$answer->pageid]))

      { $bestscores[$answer->pageid] = $answer->score; } else if ($bestscores[$answer->pageid] < $answer->score) { $bestscores[$answer->pageid] = $answer->score; }

      }

      in

      // Find the highest possible score per page to get our total
      foreach ($answers as $answer) {
      if(!isset($bestscores[$answer->pageid]))

      { $bestscores[$answer->pageid] = 0; }

      $bestscores[$answer->pageid] += $answer->score);
      }

      =========== SECOND ISSUE =========
      The second issue should be resolved in file /mod/lesson/action/continue.php rewriting the logic of how the correctness is evaluated: in the example case, you got half the question right and no wrong answers!
      It should be implemented as a tristate variable.

      I did implement in another way:

      • first set to false a flag for wrong answers ($wronguseranswer)!
      • add a flag for incemplete answers that defaults to false ($missinganswers)
      • in the check cycle set it to true if the user has sent a wrong answer
      • on the final check reverse the filter (near line 313)
        if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) { $correctanswer = true; $response = $correctresponse; $newpageid = $correctpageid; }

        else

        { $response = $wrongresponse; $newpageid = $wrongpageid; }

        will then be

      if($wronguseranswer)

      { // at least one useranswer is wrong $response = $wrongresponse; $newpageid = $wrongpageid; }

      else {
      // no wrong answers and the user has provided at least one answer
      if ($nhits!= $ncorrect)

      { $missinganswers=true; }

      $correctanswer = true;
      $response = $correctresponse;
      $newpageid = $correctpageid;
      }

      On the result page the user then shoul be presented with a third type of report: "Answer provided are correct but incomplete"

      Hope this helps

      Attachments

        Activity

          People

            bushido Mark Nielsen
            deligant Christian Deligant
            Nobody Nobody
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              11/Jan/08