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

Adding and deleting a Question Custom Field can break the Question Bank Sort Order screen

XMLWordPrintable

    • MOODLE_403_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-81407_403
    • MDL-81407_404
    • Hide

      Running the SQL

      DELETE FROM mdl_config_plugins
      WHERE plugin = 'qbank_columnsortorder'
      AND name = 'hiddencols'

      then purging the "Config settings" cache (core/config) makes the error go away.

      Show
      Running the SQL DELETE FROM mdl_config_plugins WHERE plugin = 'qbank_columnsortorder' AND name = 'hiddencols' then purging the "Config settings" cache (core/config) makes the error go away.
    • Hide

      Test 1: To check it works fine for global settings

      1. Login as admin.
      2. Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields.
      3. Click on the Add a new category button.
      4. Click on the Add a new custom field -> Text area (e.g. call both required fields "test1").
      5. Navigate to Site Administration / Plugins / Question bank plugins / Column sort order.
      6. Verify "test1" is automatically added as a row. 
      7. Delete (row settings > Remove) the custom field from the Custom Sort Order screen.
      8. Go back to Question custom fields and delete the test1 custom field or entire category.
      9. Then on going back to Custom Sort Order (or any Question Bank) and refresh
      10.  Verify that there is no error

      Test 2: To check it works fine for user preferences.

      1. Create a course and enrol a teacher to this course.
      2. Login as admin.
      3. Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields.
      4. Click on the Add a new category button.
      5. Click on the Add a new custom field -> Text area (e.g. call both required fields "test2").
      6. Login as a teacher.
      7. Navigate to the created course.
      8. Go to question bank and remove the custom field from the question bank table.
      9. Login as admin,
      10. Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields.
      11. Delete the test2 custom field or entire category.
      12. Login as teacher, go back to the question bank of the created course.
      13. Verify that there is no error

      Behat tests has also been added to test these.

      Show
      Test 1: To check it works fine for global settings Login as admin. Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields. Click on the Add a new category button. Click on the Add a new custom field -> Text area (e.g. call both required fields "test1"). Navigate to Site Administration / Plugins / Question bank plugins / Column sort order. Verify "test1" is automatically added as a row.  Delete (row settings > Remove) the custom field from the  Custom Sort Order  screen. Go back to  Question custom fields and delete the test1 custom field or entire category. Then on going back to  Custom Sort Order  (or  any Question Bank ) and refresh   Verify that there is no error Test 2: To check it works fine for user preferences. Create a course and enrol a teacher to this course. Login as admin. Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields. Click on the Add a new category button. Click on the Add a new custom field -> Text area (e.g. call both required fields "test2"). Login as a teacher. Navigate to the created course. Go to question bank and remove the custom field from the question bank table. Login as admin, Navigate to Site Administration / Plugins / Question bank plugins / Question custom fields. Delete the test2 custom field or entire category. Login as teacher, go back to the question bank of the created course. Verify that there is no error Behat tests has also been added to test these.

      1. Go to Custom Fields (https://[[moodleroot]]/question/bank/customfields/customfield.php) and add a new Category.
      2. Add a new Text Area field (e.g. call both required fields "Text").
      3. Then go to Custom Sort Order https://[[moodleroot]]/question/bank/columnsortorder/sortcolumns.php?section=columnsortorder (or refresh the page if already open).
      4. "Test" is automatically added as a row. Move the new row up one.
      5. Delete (row settings > Remove) the custom field from the Custom Sort Order screen.
      6. Go back to Question custom fields and delete the entire category.
      7. Then on going back to Custom Sort Order (or any Question Bank) and refresh, you'll get an error.
      8.  It doesn't feel like the database is cleaning itself very well here. 

      Question Bank Custom Sort Order is a Moodle 4.3 feature.

      Expected: Should still be able to access to the Custom Sort Order screen after deleting the custom field category.

      Actual: You get the following error instead....

       
      Coding error detected, it must be fixed by a programmer: Custom field text does not exist.

      Debug info:
      Error code: codingerror×Dismiss this notification
      Stack trace: * line 54 of /question/bank/customfields/classes/custom_field_column.php: coding_exception thrown

      • line 373 of /question/bank/columnsortorder/classes/column_manager.php: call to qbank_customfields\custom_field_column::from_column_name()
      • line ? of unknownfile: call to qbank_columnsortorder\column_manager->qbank_columnsortorder {closure}()
      • line 371 of /question/bank/columnsortorder/classes/column_manager.php: call to array_reduce()
      • line 57 of /question/bank/columnsortorder/classes/output/add_column.php: call to qbank_columnsortorder\column_manager->get_hidden_columns()
      • line 87 of /question/bank/columnsortorder/classes/output/column_sort_ui.php: call to qbank_columnsortorder\output\add_column->export_for_template()
      • line 266 of /lib/outputrenderers.php: call to qbank_columnsortorder\output\column_sort_ui->export_for_template()
      • line 42 of /question/bank/columnsortorder/sortcolumns.php: call to renderer_base->render()

        1. 1_custom_field_created.png
          61 kB
          Mihail Geshoski
        2. 2_field_exists_in_column_sort_order.png
          71 kB
          Mihail Geshoski
        3. 4_custom_field_deleted.png
          61 kB
          Mihail Geshoski
        4. 4_deleting_custom_filed.png
          69 kB
          Mihail Geshoski
        5. 5_no_errors_in_column_sort_order.png
          77 kB
          Mihail Geshoski
        6. MDL-81407-test-2.png
          446 kB
          Ron Carl Alfon Yu
        7. MDL-81407-test-1.png
          561 kB
          Ron Carl Alfon Yu

            Anupama Sarjoshi Anupama Sarjoshi
            oucnelson Chris Nelson
            Tim Hunt Tim Hunt
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 15 minutes
                3h 15m

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