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.