-
Bug
-
Resolution: Fixed
-
Minor
-
3.5.8, 3.6.6, 3.7.2, 3.8
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
-
MOODLE_36_STABLE, MOODLE_37_STABLE
-
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