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

Answer input field in cloze question too long

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.3, 2.4.1, 2.5
    • Fix Version/s: 2.3.7, 2.4.4
    • Component/s: Questions
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. Create the suggested multianswer question:

      1. Маша {1:SA:=ест} (есть) яйцо и {1:SA:=говорит} (говорить): − Я {1:SA:=хочу} (хотеть) пить сок. Или молоко.
      

      2. Preview it.

      3. Click the 'Fill in correct responses' button.

      4. Verify that the input boxes are just a little bit larger than required to display the right answers.

      Show
      1. Create the suggested multianswer question: 1. Маша {1:SA:=ест} (есть) яйцо и {1:SA:=говорит} (говорить): − Я {1:SA:=хочу} (хотеть) пить сок. Или молоко. 2. Preview it. 3. Click the 'Fill in correct responses' button. 4. Verify that the input boxes are just a little bit larger than required to display the right answers.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      When using different languages (Russian, Greek etc.) in cloze questions answer field is usually longer than the actual answer is.

      How to reproduce:
      1. Create a cloze question with following content

                  1. Маша {1:SA:=ест} (есть) яйцо и {1:SA:=говорит} (говорить):
                     − Я {1:SA:=хочу} (хотеть) пить сок. Или молоко. 

      2. Open preview of the question and fill in the answers (input fields are almost double the size of the answer)

      Since all pages are UTF-8 enconding, fixing this looked simple. In 2.4.1 applied the same solution as in 2.3.3 - replace strlen with mb_strlen

      For 2.4.1 the affected file is question/type/multianswer/rendere.php at line 192 here with two occurrences of strlen commented and replaced:

      // $size = max(1, strlen(trim($response)) + 1);
      $size = max(1, textlib::strlen(trim($response)) + 1);
      foreach ($subq->answers as $ans) {
      // $size = max($size, strlen(trim($ans->answer)));
      $size = max($size, textlib::strlen(trim($ans->answer)));
      

      For 2.3.3 question/type/multianswer/questiontype.php strlen replaced with mb_strlen:

      foreach ($answers as $answer) {
      if (mb_strlen(trim($answer->answer),"UTF-8") > $size ){
      $size = mb_strlen(trim($answer->answer), "UTF-8");
      }
      }
      if (mb_strlen(trim($response),"UTF-8")> $size ){
      $size = mb_strlen(trim($response),"UTF-8")+1;
      }
      $size = $size + rand(0,$size*0.15);
       
      $size > 60 ? $size = 60 : $size = $size;
                          $styleinfo = "size=\"$size\"";
      

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/May/13