简体   繁体   中英

How to get moodle course completion status

I want to get course completion states in a moodle i enable the completion for site and for course and activities and set conditions to it.i can get activities completion form mdl_course_modules_completion DB table now i want get course completion i look in mdl_course_completions and mdl_course_completion_criteria
tables but no records found.,is there any moodle inbuilt function for this

i tried follwing code also but did find a good result

require_once("{$CFG->libdir}/completionlib.php");
$cinfo = new completion_info(51);
$iscomplete = $cinfo->is_course_complete($USER->id);
var_dump($iscomplete);  

this works for me

              require_once("{$CFG->libdir}/completionlib.php");
              $course = new stdClass();
              $course->id = 51;
              $cinfo = new completion_info($course);
              $iscomplete = $cinfo->is_course_complete($USER->id);
              var_dump($iscomplete);

the parameter to give is the course object

global $COURSE;

completionlib.php :

 /*
 * @param stdClass $course Moodle course object.
 */
public function __construct($course) {
    $this->course = $course;
    $this->course_id = $course->id;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM