Moodle 3.6 - use coursecat;

Moodle 3.6 - use coursecat;

by Chris Kenniburg -
Number of replies: 9
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello All,

It appears in Moodle 3.6 that class "coursecat" is going away.  Any idea on how to use the new class?  Is it as simple as just replacing out coursecat for something else?  

Chris

Average of ratings: -
In reply to Chris Kenniburg

Re: Moodle 3.6 - use coursecat;

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Chris,

I'm inclined to think this is really a 'General development' question rather than a theme one and thus really needs to be asked there.  So will think a short while then may move the post.

Where did you get the information from, does that not tell you what to do?

G

In reply to Gareth J Barnard

Re: Moodle 3.6 - use coursecat;

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I installed Fordson on the latest Moodle 3.6 download.  Had debug turned on and it was showing errors on course listing pages.

I guess it should be moved to general Dev forum because it's related to the course renderer override in the theme.  Others will have this issue too.

In reply to Chris Kenniburg

Re: Moodle 3.6 - use coursecat;

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Are you sure it's generic error or is it actually a theme specific usage error?  What is the stack trace?

In reply to Gareth J Barnard

Re: Moodle 3.6 - use coursecat;

by Daniele Cordella -
Picture of Core developers Picture of Plugin developers

Class 'course_in_list' has been renamed for the autoloader and is now deprecated. Please use 'core_course_list_element' instead.
  • line 120 of /lib/classes/component.php: call to debugging()
  • line ? of unknownfile: call to core_component::classloader()
  • line 601 of /theme/fordson/classes/output/core/course_renderer.php: call to spl_autoload_call()
  • line 1261 of /theme/fordson/classes/output/core/course_renderer.php: call to theme_fordson\output\core\course_renderer->view_available_courses()
  • line 1439 of /course/renderer.php: call to theme_fordson\output\core\course_renderer->coursecat_courses()
  • line 1532 of /course/renderer.php: call to core_course_renderer->coursecat_category_content()
  • line 1662 of /course/renderer.php: call to core_course_renderer->coursecat_tree()
  • line 65 of /course/index.php: call to core_course_renderer->course_category()
Class 'coursecat' has been renamed for the autoloader and is now deprecated. Please use 'core_course_category' instead.
  • line 120 of /lib/classes/component.php: call to debugging()
  • line ? of unknownfile: call to core_component::classloader()
  • line 614 of /theme/fordson/classes/output/core/course_renderer.php: call to spl_autoload_call()
  • line 1261 of /theme/fordson/classes/output/core/course_renderer.php: call to theme_fordson\output\core\course_renderer->view_available_courses()
  • line 1439 of /course/renderer.php: call to theme_fordson\output\core\course_renderer->coursecat_courses()
  • line 1532 of /course/renderer.php: call to core_course_renderer->coursecat_category_content()
  • line 1662 of /course/renderer.php: call to core_course_renderer->coursecat_tree()
  • line 65 of /course/index.php: call to core_course_renderer->course_category()

Average of ratings: Useful (1)
In reply to Daniele Cordella

Re: Moodle 3.6 - use coursecat;

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

And I get these on the Site Homepage when displaying courses.

Class coursecat is now alias to autoloaded class core_course_category, course_in_list is an alias to core_course_list_element. Class coursecat_sortable_records is deprecated without replacement. Do not include coursecatlib.php
  • line 31 of /lib/coursecatlib.php: call to debugging()
  • line 55 of /theme/fordson/classes/output/core/course_renderer.php: call to require_once()
  • line 2430 of /course/renderer.php: call to theme_fordson\output\core\course_renderer->frontpage_available_courses()
  • line 133 of /index.php: call to core_course_renderer->frontpage()
Class 'coursecat' has been renamed for the autoloader and is now deprecated. Please use 'core_course_category' instead.
  • line 120 of /lib/classes/component.php: call to debugging()
  • line ? of unknownfile: call to core_component::classloader()
  • line 66 of /theme/fordson/classes/output/core/course_renderer.php: call to spl_autoload_call()
  • line 2430 of /course/renderer.php: call to theme_fordson\output\core\course_renderer->frontpage_available_courses()
  • line 133 of /index.php: call to core_course_renderer->frontpage()
Class 'course_in_list' has been renamed for the autoloader and is now deprecated. Please use 'core_course_list_element' instead.
  • line 120 of /lib/classes/component.php: call to debugging()
  • line ? of unknownfile: call to core_component::classloader()
  • line 102 of /theme/fordson/classes/output/core/course_renderer.php: call to spl_autoload_call()
  • line 2430 of /course/renderer.php: call to theme_fordson\output\core\course_renderer->frontpage_available_courses()
  • line 133 of /index.php: call to core_course_renderer->frontpage()

In reply to Chris Kenniburg

Re: Moodle 3.6 - use coursecat;

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Ok, the stack trace states the file. The git commit log for that file reports both the MDL being 'MDL-62742' and the commit, being: https://github.com/moodle/moodle/commit/442f12f81ae3be9fc27b712ec06b63f52653f4b7. That has all the information you need. Simple debugging.

In reply to Gareth J Barnard

Re: Moodle 3.6 - use coursecat;

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Thanks Gareth!  That certainly sheds some light on the situation.  

I didn't look to git for commit logs but I think the initial warning messages spelled out what the issue was.  I just wasn't sure about what needed to happen to correct it.  My previous post outlines the actions I took and I believe this fixes the issue.


Chris

In reply to Chris Kenniburg

Re: Moodle 3.6 - use coursecat;

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I am still testing all of this but it does appear to be a simple find and replace to point to the new class.  I am still testing and verifying all this but it looks like I am back on track and will be ready to release a 3.6 version of Fordson.  


For others who may experience this with their themes here is what I did.  Most of my errors stemmed from course_renderer.php because we change the way courses are displayed and viewed in Fordson.

The first thing I did was add in the new classes at the top of the page and removed the classes no longer in the coursecat.php file:

//use coursecat;  
use core_course_category;

//use course_in_list;
use core_course_list_element;

These are the two main culprits in my code: coursecat and course_in_list and I commented them out.


The next thing I did was search and replace where the classes were used.  

Throughout the code I looked for "coursecat::" and replaced it with the new class "core_course_category::".  Same for "course_in_list".


Lastly, I commented out any instance of this:  "require_once ($CFG->libdir . '/coursecatlib.php');".  


The error messages have gone away.  I think this is fixed but maybe someone else has some insights.


Hope this helps the next person,

Chris

Average of ratings: Useful (3)