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

Validation error does not always show correct messages for numerical and calculateds question types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2.2
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      To test, create a numerical question with units shown on select or radio element.
      On preview with adaptative mode verify that you have the correct error message

      1. use a , in your number if your are set in english , select a unit

      the error :Please enter your answer without using the thousand separator (,).

      2. use a , in your number if your are set in english , DO NOT select a unit

      the error : You must select a unit.

      This confirms that the error function have the same codeflow that the is_complete_response()

      3. put a unit in the number field and select or not a unit

      the error : You must enter a valid number. Do not include a unit in your response.

      and so on

      As calculated and calculatedsimple use the numerical renderer, there in no need to test them.

      Show
      To test, create a numerical question with units shown on select or radio element. On preview with adaptative mode verify that you have the correct error message 1. use a , in your number if your are set in english , select a unit the error :Please enter your answer without using the thousand separator (,). 2. use a , in your number if your are set in english , DO NOT select a unit the error : You must select a unit. This confirms that the error function have the same codeflow that the is_complete_response() 3. put a unit in the number field and select or not a unit the error : You must enter a valid number. Do not include a unit in your response. and so on As calculated and calculatedsimple use the numerical renderer, there in no need to test them.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      I was using my french keyboard so the , was used for the numbers.
      I received the message that the unit was not selected.
      This message comes from numerical/question.php
      public function get_validation_error(array $response) {
      which code reproduces the steps of public function is_complete_response(array $response)

      { to select the correct message. This will work as long as the two functions receive the same data. In numerical this imply answer and unit, the actual call in numerical/renderer.php is $question->get_validation_error(array('answer' => $currentanswer) the $selectedunit was forgotten so I received the no unit selected message. Adding the unitseletected {noformat}

      if ($qa->get_state() == question_state::$invalid)

      { $result .= html_writer::nonempty_tag('div', $question->get_validation_error(array('answer' => $currentanswer,'unit' => $selectedunit)), array('class' => 'validationerror')); }

       

      solves the problem.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/12