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

question_engine::save_questions_usage_by_activity should set up a question_engine_unit_of_work when inserting a new usage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.6.5, 3.7.1
    • 3.6.4, 3.7, 3.8
    • Questions

      The sequence:

      $quba = question_engine::make_questions_usage_by_activity('core_test', context_system::instance());
      $quba->set_preferred_behaviour('interactive');
      $slot = $this->quba->add_question($question, $maxmark);
      $quba->start_question($slot);
      question_engine::save_questions_usage_by_activity($quba);
      $quba->process_all_actions(time(), $postdata);
      question_engine::save_questions_usage_by_activity($quba);
      

      deoes not work as one would expect (first save creates a new the new usage structure in the DB, second save updates it. Instead, both calls to save will create a whole new structre in the DB.

      In constrast, this code does work (updates the same usage structure twice:

      $quba = question_engine::load_questions_usage_by_activity($qubaid);
      $quba->process_all_actions(time(), $postdata1);
      question_engine::save_questions_usage_by_activity($quba);
      $quba->process_all_actions(time(), $postdata2);
      question_engine::save_questions_usage_by_activity($quba);
      

      This is confusing and should just be fixed. I dont' believe anyone would be relying on the current behaviour, and it is currently causing huge confusion for Jim Kinsman in developer chat.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Simey Lameze Simey Lameze
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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