USER38
USER38

Reputation: 21

Courses in moodle API

Get enrolled courses of a user: $mcourses = enroll_get_my_courses();

    $mycourses = new html_table();
    $mycourses->head = array('userid', 'mycourses');
    $mycourses->attributes['class'] = 'tabler';

    foreach ($mcourses as $all) {
        $mycourses->data[] = new html_table_row(array(implode(array($all->userid)), $all->fullname));                                                                                 
    } 

Get all courses in the moodle system:

$syscourses = enrol_get_all_users_courses();

    $allcourses = new html_table();
    $allcourses->head = array('allcourses');
    $allcourses->attributes['class'] = 'tabler';

    foreach ($syscourses as $sys) {
         $allcourses->data[] = new html_table_row(array(implode(array($all->fullname)));                                                                                  
    }

Upvotes: 0

Views: 861

Answers (1)

Yousuf Tafhim
Yousuf Tafhim

Reputation: 361

To get all courses of a particular user:

$mycourses = enrol_get_my_courses();

The word is "enrol" with a single "L" not two Ls

To get all the courses you have to use

$courses = get_courses();

Upvotes: 0

Related Questions