MDL-41819: Grades lost when editing grader report due to max_input_vars

Shift the function written for MDL-41451 from formslib into weblib.php
and make use of it in data_submitted() as well as formslib.  Also update
it to correctly merge arrays which use IDs as numeric indices, as found
in the grader report.