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

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.4, 3.7, 3.8
    • Fix Version/s: 3.6.5, 3.7.1
    • Component/s: Questions
    • Labels:

      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

            • Assignee:
              timhunt Tim Hunt
              Reporter:
              timhunt Tim Hunt
              Peer reviewer:
              Simey Lameze
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                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