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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.1.6, 2.2.3
    • 2.1, 2.2.2
    • Questions
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • 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.

      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.

            ppichet Pierre Pichet
            ppichet Pierre Pichet
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Ankit Agarwal Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.