Moodle 3.3 cannot delete course

Moodle 3.3 cannot delete course

by Scott Christy -
Number of replies: 6

Setup info:

Moodle 3.3
MSSQL
PHP v7
Windows 2012 server


I upgraded to Moodle 3.3 today. I was so pleased as everything seemed to be working PERFECTLY after the upgrade but I did run into a couple of problems when I was trying to clean up a bunch of test courses.

Problem 1
I cannot delete any courses. When I attempt to do so I get the following error info:

-------------------------------------------------------------------------------------------------------------

error/file_not_writable

×Debug info: 
Error code: file_not_writable 
$a contents: [tempdir]/backup/e0fc0725dd522be47738b34bccec09ba.log
×Stack trace:
  • line 40 of \backup\util\loggers\file_logger.class.php: base_logger_exception thrown
  • line 65 of \backup\util\factories\backup_factory.class.php: call to file_logger->__construct()
  • line 109 of \backup\controller\backup_controller.class.php: call to backup_factory::get_logger_chain()
  • line 119 of \admin\tool\recyclebin\classes\category_bin.php: call to backup_controller->__construct()
  • line 185 of \admin\tool\recyclebin\lib.php: call to tool_recyclebin\category_bin->store_item()
  • line 4823 of \lib\moodlelib.php: call to tool_recyclebin_pre_course_delete()
  • line 67 of \course\delete.php: call to delete_course()
-------------------------------------------------------------------------------------------------------------


Problem 2
I cannot use restore to import a .mbz file to restore a course. When I do so I get the following error message:

-------------------------------------------------------------------------------------------------------------

error/file_not_writable

More information about this error

×Debug info: 
Error code: file_not_writable 
$a contents: [tempdir]/backup/b97763aae1e647d1b0a672db07e88389.log
×Stack trace:
  • line 40 of \backup\util\loggers\file_logger.class.php: base_logger_exception thrown
  • line 65 of \backup\util\factories\backup_factory.class.php: call to file_logger->__construct()
  • line 111 of \backup\controller\restore_controller.class.php: call to backup_factory::get_logger_chain()
  • line 62 of \backup\restore.php: call to restore_controller->__construct()
-------------------------------------------------------------------------------------------------------------

It does allow me to create a new course without any problem. If I try to delete the course I just created it will not allow me to delete it and I get the error as listed above for Problem 1.

Prior to the upgrade to v3.3 neither of these problems were present when using Moodle 3.2. I'm guessing I have a file permissions error somewhere? Anyone have any suggestions?


Average of ratings: -
In reply to Scott Christy

Re: Moodle 3.3 cannot delete course

by Damyon Wiese -

This is most likely a result of running one of the moodle cli scripts (maybe cron or upgrade) as the root or admin user instead of the same user as the webserver. 

All files in the moodledata folder need to be read and writable by the webserver user.

In reply to Damyon Wiese

Re: Moodle 3.3 cannot delete course

by Scott Christy -

Thanks for the advice.

I think you may be on to something. When I had one of our server admins set up the cron job in Windows Task Manager I think he created a special Windows Admin account to execute the cron every 5 minutes.

So what you're saying is that the account executing the cron job in Windows Task Manager should be the same account as the webserver user?


In reply to Scott Christy

Re: Moodle 3.3 cannot delete course

by Dan Bennett -

Certainly sounds like a permissions issue. I'd reset the permissions of Moodledata (chmod and chown). Ensure everything is owned by the right user (normally the web user) and try again.

You could even check that the permissions of the file that is failing - [tempdir]/backup/b97763aae1e647d1b0a672db07e88389.log - to double check it is a permissions issue.

In reply to Dan Bennett

Re: Moodle 3.3 cannot delete course

by Scott Christy -

The log file isn't getting created. I did a search for it and it doesn't exist. I assume because the permissions where it would be created are messed up.

So, chmod, I understand that on a Linux server. In Windows I assume that the user account for the webserver has to have read and write permissions for everything in Moodledata correct?

In reply to Scott Christy

Re: Moodle 3.3 cannot delete course

by Scott Christy -

I figured out the problem. If you're running Moodle on an IIS server and trying to solve this problem maybe this will help you.

Some how the folder at:

moodledata\temp\backup

had the WRITE permissions turned off for MOODLE-WEB\Users 

Not exactly sure how or why that happened but I added write permissions back in and everything is back to working ok now.

In reply to Dan Bennett

Re: Moodle 3.3 cannot delete course

by Wei Sern Lew -

Dear all,

I was looking for info on how to delete a course (trialling as a newbie) and stumbled upon this thread.

Here's how I managed to delete my trial course using the management page.

See the screenshot which I hope contains enough info...

Screencapture of the management page for deleting a moodle course as administrator


Hope this helps!