Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete course containing activity instance #198

Open
logan-reynolds opened this issue Apr 10, 2021 · 5 comments
Open

Cannot delete course containing activity instance #198

logan-reynolds opened this issue Apr 10, 2021 · 5 comments
Labels
bug Something isn't working critical to be confirmed

Comments

@logan-reynolds
Copy link

Describe the bug
When trying to delete a course containing an instance of the mod_capquiz activity module version 2021021100 release 0.6.0 on Moodle 3.9, course deletion fails with an error message, leaving an empty course that cannot be deleted unless the plugin is completely uninstalled.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a test course and add an instance of the mod_capquiz activity module
  2. Go to Site administration -> Courses -> Manage courses and categories and click the trash can icon for the given course containing the activity instance
  3. Confirm deletion of the course
  4. See error

Expected behavior
The course should be deleted without encountering any error.

Additional context
Error message encountered on the course deletion processing screen is the following:

Can't find data record in database.

More information about this error
Debug info: SELECT cm.*, m.name, md.name AS modname
FROM {course_modules} cm
JOIN {modules} md ON md.id = cm.module
JOIN {capquiz} m ON m.id = cm.instance

WHERE cm.id = :cmid AND md.name = :modulename

[array (
'cmid' => 1,
'modulename' => 'capquiz',
)]
Error code: invalidrecordunknown
Stack trace:

    line 1627 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
    line 1243 of /lib/datalib.php: call to moodle_database->get_record_sql()
    line 54 of /mod/capquiz/classes/capquiz.php: call to get_coursemodule_from_id()
    line 48 of /mod/capquiz/lib.php: call to mod_capquiz\capquiz->__construct()
    line 5294 of /lib/moodlelib.php: call to capquiz_delete_instance()
    line 5159 of /lib/moodlelib.php: call to remove_course_contents()
    line 68 of /course/delete.php: call to delete_course()

Noting I also get the following error when deleting the activity instance indicating the subplugins file needs to be migrated to the newer format and filename, although this is unrelated to the primary course deletion problem :

Use of subplugins.php has been deprecated. Please update your plugin to provide a subplugins.json file instead.

    line 142 of /lib/adminlib.php: call to debugging()
    line 1515 of /lib/classes/plugin_manager.php: call to uninstall_plugin()
    line 97 of /admin/plugins.php: call to core_plugin_manager->uninstall_plugin()
@logan-reynolds logan-reynolds added the bug Something isn't working label Apr 10, 2021
@hgeorgsch
Copy link
Contributor

Thank you @logan-reynolds for reporting this. Do you happen to know what database backend you use in your installation (mysql? postgres?).

I know we have warnings about SQL statements which may not be cross-db compatible, so we should be aware of this when we reproduce the error.

@hgeorgsch
Copy link
Contributor

I get the same error on our installation (Moodle 3.9 and postgresql 10.16.

@hgeorgsch
Copy link
Contributor

When I attempt to delete the course the CAPQuiz activity disappears but the course becomes undeletable. My guess is that CAPQuiz deletes its activity prematurely, and when the core function tries to do it later, it fails.

@erno774
Copy link

erno774 commented Jan 14, 2022

Thank you @logan-reynolds for reporting this. Do you happen to know what database backend you use in your installation (mysql? postgres?).

I know we have warnings about SQL statements which may not be cross-db compatible, so we should be aware of this when we reproduce the error.

Hello hgeorgsch, I've got the same bug on Moodle 3.11.4 with MySQL 5.7.

@erno774
Copy link

erno774 commented Apr 30, 2023

I can still confirm this bug on Moodle 4.1 with MariaDB 10.6 and CAPQuiz 0.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical to be confirmed
Projects
None yet
Development

No branches or pull requests

3 participants