Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Diane Soini -
Number of replies: 7

I'm going to try this again with way more info.

Moodle 3.5 on an under-powered dev system. I'm trying to upgrade our codebase from 3.1 to 3.5, we have a ton of plugins and we're trying to test everything. I've created a dev system with a copy of our database but there isn't a complete copy of all the files in the moodle files directory. We have a script that uses a snapshot from a few months ago so it's not quite a perfect match. We can still upload files and stuff. moodledata is there, it's just missing a bunch of newer stuff.

We have recyclebin installed and enabled.

We have a number of courses that show the warning "Warning: Activity deletion in progress! Some grades are about to be removed." at the top of the gradebook setup page and [Deletion in progress] next to some items. I have been told that cron should clean these up eventually. But it doesn't.

I have attempted running cron manually on the command line but cron fails all over the place in the adhoc tasks. For example, it tries to run core_course\task\course_delete_modules and barfs at deleting a lesson

Adhoc task failed: core_course\task\course_delete_modules,Coding error detected, it must be fixed by a programmer: The course module 1599741 could not be deleted. #0 /var/www/ssl/gs_35/lib/dml/moodle_database.php(1522): moodle_database->get_record_select('lesson', 'WHERE id = ?', Array, '*', 2)
#1 /var/www/ssl/gs_35/mod/lesson/lib.php(355): moodle_database->get_record('lesson', Array, '*', 2)
#2 /var/www/ssl/gs_35/course/lib.php(1194): lesson_delete_instance('2376')
#3 /var/www/ssl/gs_35/course/classes/task/course_delete_modules.php(66): course_delete_module('1599741')
#4 /var/www/ssl/gs_35/lib/cronlib.php(185): core_course\task\course_delete_modules->execute()
#5 /var/www/ssl/gs_35/lib/cronlib.php(74): cron_run_inner_adhoc_task(Object(core_course\task\course_delete_modules))
#6 /var/www/ssl/gs_35/admin/cli/cron.php(61): cron_run()
#7 {main}

I think that lesson got halfway deleted. The lesson is not in the mdl_lesson table. But the item is still in the mdl_course_modules table. It's not listed in the recycle bin. I tried fixing the lesson delete function so it wouldn't throw up an error but that didn't fix the original problem which is that there are multiple items in the gradebook that say [deletion in progress] and that warning message at the top. How do I fix this???

I am flailing around trying to figure out what is the problem. Is there a problem with cron? With recycle bin? With the lesson module? With there not being all the files on the filesystem? With memory on the system? If I knew where to look, maybe I could fix it or maybe I could say this is a problem only because of the dev system.


Please help with my problem. If you need a refresher, my problem is in bold above.

Average of ratings: Useful (1)
In reply to Diane Soini

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is drastic... but as it's just a dev site and it doesn't really matter...

Open the mysql client and select your moodle's database...

truncate mdl_task_adhoc;

try again. 

DON'T do this on a production system.

Average of ratings: Useful (1)
In reply to Howard Miller

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Diane Soini -

Hmm, it was empty, but those items are still showing as deletion in progress and the warning "Activity deletion in progress!" is still showing.

In reply to Diane Soini

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Diane Soini -

I want to reply to myself here because I discovered the problem.

In my case the problem was with the ouwiki activity module. If you deleted an ouwiki activity from a course, it would break the gradebook. I discovered this when I exported a course with an ouwiki and imported it to create a new course. I saw an error message after the import that said "You have declared one of ouwiki_grade_item_update and ouwiki_update_grades but not both. This will cause broken behaviour."

Sure enough, the module didn't define both functions. I submitted in an issue with the ouwiki people. I solved it myself by defining both functions.

If you don't have an ouwiki, you might try the same trick I did and see if some other module has a similar problem.

Here are the functions I added to make it work:

/**
* Update activity grades.
*
* @param stdClass $ouwiki database record
* @param int $userid specific user only, 0 means all
* @param bool $nullifnone - not used
*/
function ouwiki_update_grades($ouwiki, $userid=0, $nullifnone=true) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

if ($ouwiki->grade == 0) {
ouwiki_grade_item_update($ouwiki);

} else if ($grades = ouwiki_get_user_grades($ouwiki, $userid)) {
foreach ($grades as $k => $v) {
if ($v->rawgrade == -1) {
$grades[$k]->rawgrade = null;
}
}
ouwiki_grade_item_update($ouwiki, $grades);

} else {
ouwiki_grade_item_update($ouwiki);
}
}

/**
* Return grade for given user or all users.
*
* @global object
* @global object
* @param object $ouwiki
* @param int $userid optional user id, 0 means all users
* @return array array of grades, false if none
*/
function ouwiki_get_user_grades($ouwiki, $userid = 0) {
global $CFG;

require_once($CFG->libdir.'/gradelib.php');

$grading_info = grade_get_grades($ouwiki->course, 'mod', 'ouwiki', $ouwiki->id, $userid);

$grade_item_grademax = $grading_info->items[0]->grademax;
$user_final_grade = $grading_info->items[0]->grades[$userid];
}


Average of ratings: Useful (3)
In reply to Diane Soini

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by William Franz -

I had much the same problem, but when I attempted to backup and then restore the course, it worked flawlessly.  The problem is that I have not found out what caused the problem to begin with.  If I'd received error messages, I could have tracked the problem, but I did not receive any errors.  The newly restored course no longer had the offending grades [pending deletion].

I don't want to restore over a course every time I delete a quiz, so any additional information about how to track down the root cause of this problem would be appreciated.

Average of ratings: Useful (1)
In reply to William Franz

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Ariane Cleverly -

i have the same issue.  That warning will not go away.  I restored as a new class and the message went away for a few minutes and now it's back.  The only activity I have in one quiz.  That's it, It's a brand new course.  Any suggestions would help.  I tried the : http://your.site.moodle/admin/cron.php and get this error message 

500 - Internal server error.

There is a problem with the resource you are looking for, and it cannot be displayed.

In reply to William Franz

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Thomas Renard -
This worked for me too. But same here, don't want to restore over a course every time I delete a quiz. Anyone has a solution yet?
In reply to Thomas Renard

Re: Warning: Activity deletion in progress! Some grades are about to be removed. [Deletion in progress]

by Ibrahim Sayed_Ahmad -

Its sure not the right solution but I forced to do that

Go to databse -> mdl_grade_items table : delete the records for the deleted activity

Average of ratings: Useful (1)