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

Cannot save an empty question_usage_by_activity

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.6.7, 3.7.3
    • 3.5.8, 3.6.6, 3.7.2, 3.8
    • Questions

      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

            timhunt Tim Hunt
            timhunt Tim Hunt
            Andrew Lyons Andrew Lyons
            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 - 30 minutes
                30m

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