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

Details

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

    Description

      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.

      Attachments

        Activity

          People

            timhunt Tim Hunt
            timhunt Tim Hunt
            Simey Lameze Simey Lameze
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            CiBoT CiBoT
            Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              8/Jul/19

              Time Tracking

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