Moodle
  1. Moodle
  2. MDL-18559

inconsitent constant types in questionlib.php

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.8, 1.9.4
    • Fix Version/s: 1.8.9, 1.9.5
    • Component/s: Quiz
    • Labels:
      None
    • Environment:
      any
    • Affected Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE
    • Rank:
      26247

      Description

      The constants in questionlib.php (http://cvs.moodle.org/moodle/lib/questionlib.php?annotate=1.189#l26) are defined as strings.

      However, in questiontype.php (http://cvs.moodle.org/moodle/question/type/questiontype.php?annotate=1.123#l1175) it is expected to be an integer ($state->event is an integer and it's using "!=="). As a result, line 1175 evaluates to true, even though the quiz is over and it should be false. If we don't know what types we will get from the database, then change !== to !=.

        Activity

        Hide
        Tim Hunt added a comment -

        You are right. Also, I think there is very similar code in the shortanswer question type. I'll check that too, and fix this on Monday.

        (This code has been there for years, well done for being the first person to notice and report the problem!)

        Show
        Tim Hunt added a comment - You are right. Also, I think there is very similar code in the shortanswer question type. I'll check that too, and fix this on Monday. (This code has been there for years, well done for being the first person to notice and report the problem!)
        Hide
        Tim Hunt added a comment -

        Thanks Alan, fix checked in.

        Show
        Tim Hunt added a comment - Thanks Alan, fix checked in.
        Hide
        Jérôme Mouneyrac added a comment -

        Fixed. Thanks Tim for the modification and thanks Alan for spotting the problem.

        Show
        Jérôme Mouneyrac added a comment - Fixed. Thanks Tim for the modification and thanks Alan for spotting the problem.

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: