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

Core question privacy provider incorrectly uses question attempt lazy-loading, leading to errors

XMLWordPrintable

    • MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
    • MOODLE_404_STABLE, MOODLE_405_STABLE
    • MDL-83727-404
    • MDL-83727-405
    • MDL-83727-master
    • Hide

      Prerequisites:

      1. Log in as admin
      2. Go to site administration > Users > Privacy and policies > Privacy settings
      3. Turn on "Contact the privacy officer" and "Automatic data export request approval"
      4. Save the changes.
      5. Install the "variable numeric set" question type into the Moodle core system.
        1. Open a terminal and go to your instance's root folder.
        2. Clone the repository

          git clone https://github.com/moodleou/moodle-qtype_varnumericset question/type/varnumericset
          

        3. Run the upgrade to install the plugin
      Test

      1. Create a Quiz with a "Variable Numeric Set" Question filling out the form with the following values

      1. Question text: What is [[a,d]] + [[b,d]] = _____ ?
      2. General feedback: [[a,d]] + [[b,d]] = [[c,d]]
      3. Variables:
        1. Variable 1: a
        2. Change from "Calculated variable" to "Predefined variable"
        3. Set some numbers in the Value for variant ... fields.
        4. Variable 2: b
        5. Change from "Calculated variable" to "Predefined variable"
        6. Set some numbers in the Value for variant ... fields.
        7. Variable 2: c=a+b
        8. "Calculated variable"
      4. Save the changes.

      2. Log in as a student and attempt the quiz

      • Ensure that when the student submits their response, the general feedback with the variable value displays correctly as expected based on the student's input.

      3. Go to your profile and submit a data export request through Privacy and policies > Export all of my personal data.

      4. Trigger the ad-hoc cron job manually by running the ad-hoc task: \tool_dataprivacy\task\process_data_request_task

      php admin/cli/adhoc_task.php --classname=\\tool_dataprivacy\\task\\process_data_request_task
      

      5. Check Notifications:

      After the cron job has processed the data request, verify that the following happens:

      • A notification message appears in the notification.
      • Confirm that there is no error message on the notification details and that your data export is ready for download.
      Show
      Prerequisites : Log in as admin Go to site administration > Users > Privacy and policies > Privacy settings Turn on "Contact the privacy officer" and "Automatic data export request approval" Save the changes. Install the "variable numeric set" question type into the Moodle core system. Open a terminal and go to your instance's root folder. Clone the repository git clone https: //github .com /moodleou/moodle-qtype_varnumericset question /type/varnumericset Run the upgrade to install the plugin Test 1. Create a Quiz with a "Variable Numeric Set" Question filling out the form with the following values Question text: What is [ [a,d] ] + [ [b,d] ] = _____ ? General feedback: [ [a,d] ] + [ [b,d] ] = [ [c,d] ] Variables: Variable 1: a Change from "Calculated variable" to "Predefined variable" Set some numbers in the Value for variant ... fields. Variable 2: b Change from "Calculated variable" to "Predefined variable" Set some numbers in the Value for variant ... fields. Variable 2: c=a+b "Calculated variable" Save the changes. 2. Log in as a student and attempt the quiz Ensure that when the student submits their response, the general feedback with the variable value displays correctly as expected based on the student's input. 3. Go to your profile and submit a data export request through Privacy and policies > Export all of my personal data. 4. Trigger the ad-hoc cron job manually by running the ad-hoc task: \tool_dataprivacy\task\process_data_request_task php admin /cli/adhoc_task .php --classname=\\tool_dataprivacy\\task\\process_data_request_task 5. Check Notifications: After the cron job has processed the data request, verify that the following happens: A notification message appears in the notification. Confirm that there is no error message on the notification details and that your data export is ready for download.
    • Hide

      Code verified against automated checks.

      Checked MDL-83727 using repository: https://github.com/NashTechOpenUniversity/moodle.git

      More information about this report

      Built on: Fri 29 Nov 2024 12:48:23 PM UTC

      Show
      Code verified against automated checks. Checked MDL-83727 using repository: https://github.com/NashTechOpenUniversity/moodle.git MOODLE_404_STABLE (0 errors / 0 warnings) [branch: MDL-83727-404 | CI Job ] MOODLE_405_STABLE (0 errors / 0 warnings) [branch: MDL-83727-405 | CI Job ] main (0 errors / 0 warnings) [branch: MDL-83727-master | CI Job ] More information about this report Built on: Fri 29 Nov 2024 12:48:23 PM UTC
    • Show
      Launching automatic jobs for branch MDL-83727 -404 https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17585/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59888/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59889/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-83727 -405 https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17586/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59890/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59891/ Behat (Firefox - boost) Launching automatic jobs for branch MDL-83727 -master https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17587/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59892/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59893/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59894/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/59895/ App tests (stable app version) Built on: Fri Nov 29 10:25:23 AM UTC 2024

      This is a regression from MDL-67183, which only affects some question types (we found it with https://moodle.org/plugins/qtype_varnumericset.

      The stack trace looks like:

      Exception occurred while calling mod_quiz\privacy\provider::export_user_data.
      This means that plugin mod_quiz did not complete the processing of data. The following exception information may be passed on to the plugin developer:
       
      Call to a member function evaluate() on null
       
      #0 /var/www/html/moodle/question/type/varnumericset/calculatorbase.php(400): qtype_varnumeric_calculator_base->evaluate('b', 'temp') 
       
      #1 /var/www/html/moodle/question/type/varnumericset/questionbase.php(522): qtype_varnumeric_calculator_base->evaluate_variables_in_text(' 
       
      The correct ...')
       
      #2 /var/www/html/moodle/question/type/questionbase.php(468): qtype_varnumeric_question_base->format_text('
       
      The correct ...', '1', Object(question_attempt), 'question', 'generalfeedback', '1770197')
       
      #3 /var/www/html/moodle/question/classes/privacy/provider.php(200): question_definition->format_generalfeedback(Object(question_attempt))
       
      #4 /var/www/html/moodle/mod/quiz/classes/privacy/provider.php(549): core_question\privacy\provider::export_question_usage(1332701, Object(core\context\module), Array, 7623405, Object(mod_quiz\question\display_options), true)
       
      #5 /var/www/html/moodle/mod/quiz/classes/privacy/provider.php(337): mod_quiz\privacy\provider::export_quiz_attempts(Object(core_privacy\local\request\approved_contextlist))
       
      #6 /var/www/html/moodle/lib/moodlelib.php(8303): mod_quiz\privacy\provider::export_user_data(Object(core_privacy\local\request\approved_contextlist))
       
      #7 /var/www/html/moodle/privacy/classes/manager.php(578): component_class_callback('mod_quiz\\privac...', 'export_user_dat...', Array)
       
      #8 /var/www/html/moodle/privacy/classes/manager.php(611): core_privacy\manager::component_class_callback('mod_quiz', 'core_privacy\\lo...', 'export_user_dat...', Array)
       
      #9 /var/www/html/moodle/privacy/classes/manager.php(338): core_privacy\manager->handled_component_class_callback('mod_quiz', 'core_privacy\\lo...', 'export_user_dat...', Array)
       
      #10 /var/www/html/moodle/admin/tool/dataprivacy/classes/task/process_data_request_task.php(122): core_privacy\manager->export_user_data(Object(core_privacy\local\request\contextlist_collection))
       
      #11 /var/www/html/moodle/lib/classes/cron.php(556): tool_dataprivacy\task\process_data_request_task->execute()
       
      #12 /var/www/html/moodle/lib/classes/cron.php(350): core\cron::run_inner_adhoc_task(Object(tool_dataprivacy\task\process_data_request_task))
       
      #13 /var/www/html/moodle/lib/classes/cron.php(169): core\cron::run_adhoc_tasks(1731501142, 0, true, 1731501046)
       
      #14 /var/www/html/moodle/admin/cli/cron.php(186): core\cron::run_main_process('60')
       
      #15 {main} 
      

      The problem is line 172 of question/classes/privacy/provider.php

      $question = $qa->get_question(false);
      

      The false there means that the question does not need to be fully initialised, which would be a performance saving, but ...

      1. That is not true, as the error message indicates. To export the user's data, we need the question to be fully initialised with the attempt data.
      2. Anyway, there is no performance saving, since later, there is a call to export_question_attempt_steps, which calls $qa->summarise_action which does ->ensure_question_initialised(), which is the think the lazy-loading is trying to avoid, so nothing is saved.

      Therefore, we should just fully initialise the questoin fully from the start, by deleting the false in like 172, and therefore we should also get rid of the false in get_behaviour(false) on line 305.

      (Most of the work of fixing this will be doing the testing to verify that what I think the required fix is, is actually right. – Tim)

            khoand Khoa Nguyen Dang
            timhunt Tim Hunt
            Anupama Sarjoshi Anupama Sarjoshi
            Jun Pataleta Jun Pataleta
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 36 minutes
                2h 36m

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