MDL-47499 tasks: Scheduled tasks custom schedule is reset on upgrade.

Add a unit test for reset_scheduled_tasks_for_component and make sure it doesn't clear
customised schedules for existing tasks.
MDL-47704 Grades: Fix for set_usedinaggregation

Used in aggregation was not resetting previously set values
when recalculating an aggregation. This meant that items no longer
in the aggregation, were displayed with stale weights in the user report.
MDL-47684 mod: better validation of rating options
MDL-47752 grading: fixed bugs with the modgrade element
MDL-47077 report_participation: fixed pagination in groups
MDL-47675 phpunit: Update unit tests to pass on MSSQL

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.
MDL-47759 tool_monitor: Fix permissions issue
MDL-20367 Grades: Allow real numbers as grade boundaries

Patch by Huy Hoang (I just git-ified it).
MDL-47740 question engine: let qs update variant later if appropriate

Variant has two purposes. First to determine which version of the
question the student will see. Hence it is used to set up the state
of the quetsion when the question is started. Then the internal state of
the question is saved in the first step.

Once that has been done, the variant number is purely informative, and
just used to break down the statistics.

In some cases (the one I have in mind is qtype_opaque) then there is a
complex randomisation process, which may lead to several inital variant
numbers acutally giving the same version of the question. In this case
it is nice if the question can update the stored variant number, to make
the statistics more meaningful.
MDL-47791 question editing: remove permission info from above the form

This information is not really meaningful for users, and takes up prime
real-estate, so we are removing it.
MDL-47153 tool_monitor: added rule_created event
MDL-47153 tool_monitor: added rule_updated event
MDL-47153 tool_monitor: added rule_deleted event
MDL-47153 tool_monitor: added subscription_created event
MDL-47153 tool_monitor: added subscription_deleted event
MDL-47153 tool_monitor: added subscription_criteria_met event
MDL-47153 tool_monitor: altered unit tests to pass
MDL-47637 core_grades: Outcomes must not be weighted when non aggregated
MDL-47815 assign: Fix random unit test fails

This test was failing when it was run really slowly (looking at you oracle).
MDL-47814 core_grades: Improved coverage of user_graded event tests

The tests needed to use the API in order to trigger the user_graded
event that occurs when the course final grade has changed.