Differences Between: [Versions 400 and 402] [Versions 401 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace enrol_lti\local\ltiadvantage\task; 18 19 use core\task\scheduled_task; 20 use enrol_lti\helper; 21 22 /** 23 * LTI Advantage task responsible for pushing grades to tool platforms. 24 * 25 * @package enrol_lti 26 * @copyright 2021 Jake Dallimore <jrhdallimore@gmail.com> 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 class sync_grades extends scheduled_task { 30 31 /** 32 * Get a descriptive name for this task. 33 * 34 * @return string 35 */ 36 public function get_name() { 37 return get_string('tasksyncgrades', 'enrol_lti'); 38 } 39 40 /** 41 * Creates adhoc tasks (one per resource) to synchronize grades from the tool to any registered platforms. 42 * 43 * @return bool|void 44 */ 45 public function execute() { 46 47 if (!is_enabled_auth('lti')) { 48 mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti'))); 49 return true; 50 } 51 if (!enrol_is_enabled('lti')) { 52 mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti')); 53 return true; 54 } 55 56 $resources = helper::get_lti_tools([ 57 'status' => ENROL_INSTANCE_ENABLED, 58 'gradesync' => 1, 59 'ltiversion' => 'LTI-1p3' 60 ]); 61 if (empty($resources)) { 62 mtrace('Skipping task - There are no resources with grade sync enabled.'); 63 return true; 64 } 65 66 foreach ($resources as $resource) { 67 $task = new \enrol_lti\local\ltiadvantage\task\sync_tool_grades(); 68 $task->set_custom_data($resource); 69 $task->set_component('enrol_lti'); 70 \core\task\manager::queue_adhoc_task($task, true); 71 } 72 73 mtrace('Spawned ' . count($resources) . ' adhoc tasks to sync grades.'); 74 } 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body