bozoh / moodle-mod_simplecertificate

It's NOT RECOMMENDED to install version below 2.2.6 (MOODLE_31), due a security issues See more in README
17 stars 44 forks source link

Using simple certs in a course causes error when using course 'reset' functionality #221

Closed jjs105 closed 4 years ago

jjs105 commented 5 years ago

When resetting a course in moodle the simplecertificate_reset_userdata function (lib.php) is called which, if the course reset includes a 'timeshift', tries to apply date operations to non-existent database columns 'timeopen' and 'timeclose' (lines 120-123).

This in turn causes an unrecoverable error that breaks the reset operation.

To reproduce:

  1. Create a course ensuring that a non-midnight start date is specified
  2. Add a simple certificate to the course
  3. Reset the course setting a new start date, but keeping the same non-midnight time

The solution to the issue is to either a) remove the 'timeshift' code if it is not needed or b) update the code to only modify appropriate database columns.

This error seems to have originated from the original creation of the plugin being based on an activity which does have the 'timeopen' and 'timeopen' database columns.