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

The error when importing a GIFT question file with the wrong encoding does not make the problem clear

    XMLWordPrintable

Details

    • MySQL, PostgreSQL
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_38_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE
    • MDL-69078-better-error-message-for-wrong-encoding
    • Hide

      To be tested both with 311_STABLE and master, patches are noticeably different.

      Manual Testing

      Set up

      1. Prepare a question import file in GIFT Format with windows-1252 encoding (it must contain characters with encoding not valid in utf8 encoding, eg. ö - umlaut o) and with utf8 encoding (see attachments)

      Testing instructions

      1. Login as teacher
      2. Access question import within a course (/question/import.php?courseid=xxx)
      3. Select "GIFT format" as file format
      4. Upload GIFT file with windows-1252 encoding
      5. Click "Import"
        1. Verify the following error message is shown: "The file you selected is not in UFT-8 character encoding. GIFT format files must use UTF-8."
      6. Upload GIFT file with utf8 encoding
        1. Verify the import was successful

      Automated Testing

      • The behat scenario in question/format/gift/tests/behat/import_export.feature should be successful.
      Show
      To be tested both with 311_STABLE and master, patches are noticeably different. Manual Testing Set up Prepare a question import file in GIFT Format with windows-1252 encoding (it must contain characters with encoding not valid in utf8 encoding, eg. ö - umlaut o) and with utf8 encoding (see attachments) Testing instructions Login as teacher Access question import within a course (/question/import.php?courseid=xxx) Select "GIFT format" as file format Upload GIFT file with windows-1252 encoding Click "Import" Verify the following error message is shown: "The file you selected is not in UFT-8 character encoding. GIFT format files must use UTF-8." Upload GIFT file with utf8 encoding Verify the import was successful Automated Testing The behat scenario in question/format/gift/tests/behat/import_export.feature should be successful.

    Description

      If someone uploads a question file in GIFT format with a non-UTF-8 encoding (eg. windows-1252) it fails ungracefully with "error writing to database" giving the user no idea what is actually wrong.

      I suggest to test the encoding of the file if it's valid UTF-8 or not prior to importing and giving hints to the user what needs to be corrected.

      The debug output is more helpful, but debug output is not enabled in production and therefore not visible to the average user.

       

      FULL STEPS:

      • open question import (/question/import.php)
      • select "GIFT format" as file format
      • upload GIFT file with windows-1252 encoding
      • click "Import"

      WHAT WAS EXPECTED

      • error message with hint "wrong encoding"

      WHAT ACTUALLY HAPPENS

      • Error writing to database

      Attachments

        1. Automation Test_311.PNG
          Automation Test_311.PNG
          42 kB
        2. Automation Test_master.PNG
          Automation Test_master.PNG
          40 kB
        3. Bildschirmfoto von 2020-06-17 12-10-28.png
          Bildschirmfoto von 2020-06-17 12-10-28.png
          158 kB
        4. gift-import-error.log
          0.9 kB
        5. Step 5_Screenshot.PNG
          Step 5_Screenshot.PNG
          40 kB
        6. Step 6_Screenshot.PNG
          Step 6_Screenshot.PNG
          28 kB
        7. test_questions_utf-8.txt
          0.4 kB
        8. test_questions_windows-1252.txt
          0.4 kB

        Issue Links

          Activity

            People

              Daniel Ziegenberg Daniel Ziegenberg
              Daniel Ziegenberg Daniel Ziegenberg
              Tim Hunt Tim Hunt
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Gladys Basiana Gladys Basiana
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 45 minutes
                  1h 45m

                  Clockify

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