General developer forum

View all courses without categories

 
Picture of Sandip Shrestha
Re: View all courses without categories
 

After you have created a new course helper and set the display option by doing

$chelper = new coursecat_helper();

$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->

set_courses_display_options(array(

    'recursive' => true,

    'limit' => $CFG->frontpagecourselimit,

    'sort' => array('sortorder' => 0),

    'viewmoreurl' => new moodle_url('/course/index.php'),

    'viewmoretext' => new lang_string('fulllistofcourses'),

));

you will need to fetch all courses by doing

$courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
it returns an indexed array of objects (key is courseid and value is course object). Then you can sort it using something like
arsort($courses);
 
Average of ratings: -