Cannot delete course after upgrade

Cannot delete course after upgrade

by John Holt -
Number of replies: 5
I have just completed a version upgrade from 2.2 to the latest version 3.0.1

The upgrade went smoothly and I converted all assignments with no issue.

after the update I tried to remove some old courses that were no longer needed.


This process fails. I went into the course and deleted everything I could see and it didn't help.

I turned on debugging and here is the output.

Deleting USH1bs

Deleted - Completion tracking
Deleted - Grades, Items, Categories
Deleted - Outcomes
Deleted - Scales
Deleted - Settings
Deleted - Letters
Deleted - Blocks

Invalid course module ID

More information about this error

Debug info:
Error code: invalidcoursemodule
Stack trace:
  • line 230 of /lib/modinfolib.php: moodle_exception thrown
  • line 1253 of /mod/assign/locallib.php: call to course_modinfo->get_cm()
  • line 1186 of /mod/assign/locallib.php: call to assign->get_course_module()
  • line 546 of /mod/assign/submission/onlinetext/locallib.php: call to assign->get_instance()
  • line 699 of /mod/assign/locallib.php: call to assign_submission_onlinetext->delete_instance()
  • line 56 of /mod/assign/lib.php: call to assign->delete_instance()
  • line 4801 of /lib/moodlelib.php: call to assign_delete_instance()
  • line 4682 of /lib/moodlelib.php: call to remove_course_contents()
  • line 65 of /course/delete.php: call to delete_course()



I have admin rights to moodle, full access to the files via FTP and sql access via Mysql Workbench to do any debugging.


Thanks,

John

Average of ratings: -
In reply to John Holt

Re: Cannot delete course after upgrade

by Ken Task -
Picture of Particularly helpful Moodlers

Do a backup of the DB first before trying the suggestion below:

Using your MySQL tool, do a search on mdl_course_modules for the course ID number (the '2' below in the example query)

select * from `mdl_course_modules` where `course` like "2"

Delete those rows.

When you go back to the course, containing the links, the links might appear to be there.  Clicking on any of them will show another error.   That's true.   You removed references in DB.   Try to delete the course again.

So the upgrade 'appeared' to go smoothly.   Hmmmm ... just goes to show that 'appearances can be mis-leading' (IMHO). :\   Something could be lurking and just waiting to rear it's ugly head! sad

'spirit of sharing'. Ken


In reply to Ken Task

Re: Cannot delete course after upgrade

by John Holt -

I followed your directions using the course ID of one of the offending courses.


My error is now this


Deleted - Completion tracking
Deleted - Grades, Items, Categories
Deleted - Outcomes
Deleted - Scales
Deleted - Settings
Deleted - Letters
Deleted - Blocks

Can not 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 {assign} m ON m.id = cm.instance

WHERE m.id = :instance AND md.name = :modulename

[array (
'instance' => '286',
'modulename' => 'assign',
)]
Error code: invalidrecordunknown
Stack trace:
  • line 1481 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
  • line 1379 of /lib/datalib.php: call to moodle_database->get_record_sql()
  • line 52 of /mod/assign/lib.php: call to get_coursemodule_from_instance()
  • line 4801 of /lib/moodlelib.php: call to assign_delete_instance()
  • line 4682 of /lib/moodlelib.php: call to remove_course_contents()
  • line 65 of /course/delete.php: call to delete_course()


I have a DB Backup

In reply to John Holt

Re: Cannot delete course after upgrade

by Ken Task -
Picture of Particularly helpful Moodlers

'One of the offending courses'!!!!   Got the impression it was only one ... :\  How many 'offending courses' are we talking about now?

We could be seeing more of these only pointing to something else so 'fixing' this by DB is/might be a slow way to go.

This last one is about assignments, yet you say it converted successfully?

Maybe it missed one or two!!!????

Do you have the 'Assignment Upgrade Helper' link in your Site Admin menu still?  Is the old mod for assignments visiable when checking plugins or is it hidden?   Un-hide it.   What does it report when using that link for Assignment Upgrade Helper?

So what does a query of the DB look like when listing mdl_assignment (that's the old table for assignments that should have been converted into mdl_assign [new]) table rows?

Since you have a DB backup, might see about this:

Again for '2' is the ID of the course (now courses) that you are trying to delete.

select * from `mdl_assignment` where `course` like "2"

If you can re-cognize those as assignments in a course you desire to delete, remove the rows.

For other courses in this state ... wash/rinse/repeat.

Am beginning to think that a hyperjump from 2.2 to 3.0.1 may not have been a good approach.   Too far a jump after all that's going from a 2 series to a 3 series (and a .0 at that!).  You  might have to resort to restoring the original 2.2 and taking that upwards to 2.3.highest where the new Assignments first showed ... along with the Assignment Upgrade Helper link.   Convert them all there.

Remove the courses you no longer need when arriving at 3.0.1 in the 2.3.highest.   BACKUP.

Then try the 'hyperjump' from 2.3.highest to the 3.0.1 (if you feel brave).

Personally, I don't trust hperjumping without stopping at versions where some major changes took place.   2.6 -> 2.7, for example, changed all the themes.  So something like: 2.2 -> 2.3.highest -> 2.6.highest (setting theme to something core) -> 2.7.highest ... and if you feel brave -> 3.0.1.   Ok, I know that's lots of work, but ....

'spirit of sharing', Ken

In reply to Ken Task

Re: Cannot delete course after upgrade

by John Holt -

The sql query returned nothing.  In fact the mdl_assignment table is empty.


I am willing to run the update again as long as I know which versions I should stop at to be safe.



In reply to John Holt

Re: Cannot delete course after upgrade

by Ken Task -
Picture of Particularly helpful Moodlers

Suggest, at this point to restore the 2.2 you have.

Found a discussion about 2.2 with same issue.
https://moodle.org/mod/forum/discuss.php?d=194005
appears to have been resolved by changing the course format.
Are your troubled courses set to use grid course format?

Can you change the course format in one of those to be deleted/troubled courses to
something else (topics) and attempt to delete?

An additional thought ... same sort of thing could happen IF there is an addon for course assignments.  OR, for that matter, ANY addons.   So how many addons do you have in the 2.2?

https://moodle.org/plugins/browse.php?list=category&id=44

Suggest upgrading to one version higher to start ... 2.3.highest.

Choose another one of those troubled courses and see if it can be deleted - same checks of course format and assignment addons, etc.

IF everything ok there, then take it to 2.6.highest.   Check out themes (use no theme other than a standard theme).

Check out assignments and course formats.   Delete another one of those courses.

OK?   Then take the 2.6.highest up to 2.9.highest.

This does assume one has the required versions of PHP and MySQL as those needed to be upgraded along the upgrade path.

2.9 -> 2.7: PHP 5.4.4, MariaDB 5.5.31 or MySQL 5.5.31

2.6: PHP 5.3.3, MariaDB 5.3.5 or MySQL 5.1.33

2.4: PHP 5.3.2, MySQL 5.1.33

2.2: PHP 5.3.2, MySQL 5.0.25

Also, just before EACH upgrade, do a minimal site backup: moodle code and DB dump..

Taking the time to backup after each step will save time as one could restore to the previous version that was known to work to address any newly discovered issues on the march.

Now about which versions to upgrade to ....  how good is my memory?   2.2 was release in 2013 ... almost 3 years ago.  Would I know now at what versions to jump through now IF using something other than git to upgrade?   Afraid, at this point, that is a 'best guess' from what I can re-call of major changes that occurred in each version.

I, personally, don't worry about that as I run Linux and use git for updates/upgrades which makes the whole process of 'marching a moodle' less stressful.

Am also not suggesting you use git at present, but investigate if you can use it on your system.

Maybe someone else who has experience at 'marching a moodle' upwards from 2.2 to 2.9.x and upwards to 3.0.x would jump in here and share their experiences. ;)

'spirit of sharing', Ken