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

Cannot save an empty question_usage_by_activity

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.8, 3.6.6, 3.7.2, 3.8
    • Fix Version/s: 3.6.7, 3.7.3
    • Component/s: Questions
    • Labels:

      Description

      It is not very useful to have a question_usage_by_activity that contains zero question_attempts, but actually I hit this in a plugin I was working.

      (I only wanted to create the usage, store it in the database so I had its id, then add questions. https://github.com/moodleou/moodle-report_embedquestion. I was able to work around this by adding the question before saving, but becuse of what the code was doing that was a bit of a pain.)

      Anyway, the system should support creating an empty usage and saving it, and only later loading it back and adding questions, and the fix is simple, so here is the necessary fix.

      Before the fix, the error when trying to save an empty usage was

      array_merge() expects at least 1 parameter, 0 given

      C:\Users\tjh238\workspace\ou-moodle2\question\engine\datalib.php:103
      C:\Users\tjh238\workspace\ou-moodle2\question\engine\lib.php:100
      C:\Users\tjh238\workspace\ou-moodle2\question\engine\tests\datalib_test.php:245

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            timhunt Tim Hunt
            Peer reviewer:
            Andrew Nicols
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            CiBoT
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, 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:
              11/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m