mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-59287 core_completion: Update API to use less DB calls.
This commit is contained in:
parent
350700bf8b
commit
1930749f46
@ -45,18 +45,23 @@ class api {
|
||||
*
|
||||
* @param int $cmid The course module id
|
||||
* @param string $modulename The name of the module (eg. assign, quiz)
|
||||
* @param int $instanceid The instance idLOL
|
||||
* @param stdClass|int $instanceorid The instance object or ID.
|
||||
* @param int|null $completionexpectedtime The time completion is expected, null if not set
|
||||
* @return bool
|
||||
*/
|
||||
public static function update_completion_date_event($cmid, $modulename, $instanceid, $completionexpectedtime) {
|
||||
public static function update_completion_date_event($cmid, $modulename, $instanceorid, $completionexpectedtime) {
|
||||
global $CFG, $DB;
|
||||
|
||||
// Required for calendar constant CALENDAR_EVENT_TYPE_ACTION.
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
|
||||
$instance = $DB->get_record($modulename, array('id' => $instanceid), '*', MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $instance->course), '*', MUST_EXIST);
|
||||
$instance = null;
|
||||
if (is_object($instanceorid)) {
|
||||
$instance = $instanceorid;
|
||||
} else {
|
||||
$instance = $DB->get_record($modulename, array('id' => $instanceorid), '*', MUST_EXIST);
|
||||
}
|
||||
$course = get_course($instance->course);
|
||||
|
||||
$completion = new \completion_info($course);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user