Cron can cause duplicate completion records if triggered during a long
running restore process. If this is the case, replace the new record
with the record from the backup file
Unit tests were failing on MSSQL. gc_collect_cycles() was
removed from the phpunit utils.php file to save time in running
the tests, but MSSQL doesn't clean up open files as well as
other databases.
This patch includes the garbage collection for the unit tests
that require it.
This setting is not compatible with combinations of aggregation methods
and the ways in which it does and does not work are not documented. It
was voted to remove it completely by the gradebook workshop, so I have
completely removed it and added a warning for all affected courses + restored
backups.
When we restore a course, the grade that a user has for the
grade item of the course cannot be created twice. If we try
to create it when it already exists, a database exception is
raised because of index duplication.
The safest way to proceed is certainly to ignore the grade
information from the backup, otherwise we could potentially
overwrite existing information. Though, this only applies
to restore as merge, and it does not affect the update of
the course grade.
Implements backup and restore for the new conditional availability
data. This includes:
* Backup and restore of new field.
* Restore updates IDs in conditions, as required.
* Restore converts availability data from legacy (Moodle 2.6) backups.
* Unit tests for all this.
The sequence of questions that made up a quiz used to be stored as a
comma-separated list in quiz.questions. Now the same information is
stored in the rows in the quiz_slots table. This is not just 'better' in
a database design sense, but it allows for the future changes we will
need as we enhance the quiz in the MDL-40987 epic.
Having changed the database structure, all the rest of the code needs to
be changed to account for it, and that is done here.
Note that there are not many unit tests for the changed bit. That is
because as part of MDL-40987 we will be changing the code further, and
we will add unit tests then.
While restoring course/activity, restore will blindly insert grade_item
sortorder. Which cause dulicate sortorder and lead to unpredicatble sorting
results.
Now we will call grade_item::fix_duplicate_sortorder() after restore is finished
to fix duplicate sortorder and order grade items to the closest order possible