Fatal error: Cannot declare class mod_assign\event\course_module_viewed, because the name is already in use

Re: Fatal error: Cannot declare class mod_assign\event\course_module_viewed, because the name is already in use

by Mark Sharp -
Number of replies: 3
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Do you have the rest of the error message?
Have you made any recent updates to your Moodle (upgrades, new plugins)? Which version are you on?
In reply to Mark Sharp

Re: Fatal error: Cannot declare class mod_assign\event\course_module_viewed, because the name is already in use

by wz z -
Sorry for so long time to reply. Actually the problem always exists. Strangely, when I edit & save any activity or resource in any course, the problem dissappeared. However, it will occur someday randomly.
In reply to wz z

Re: Fatal error: Cannot declare class mod_assign\event\course_module_viewed, because the name is already in use

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
The error is that that class \mod_assign\event\course_module_viewed has been defined twice. So somewhere there is another file that is also defining that class.
You'll have to search your code base. Do a search for "course_module_viewed". And look to see if either there is a namespace declaration "namespace mod_assign\event;" or a class name "class mod_assign\event\course_module_viewed extends" in a file other than at "mod/assign/classes/event/course_module_viewed.php".

It's possible the file has been copied to another plugin and not edited correctly.
In reply to Mark Sharp

Re: Fatal error: Cannot declare class mod_assign\event\course_module_viewed, because the name is already in use

by wz z -
Thank you, Mark! I grepped and can confirm that there is no repeating class declarations. Very cubersome.