Merge branch 'MDL-76113-master' of https://github.com/snake/moodle

This commit is contained in:
Jun Pataleta 2022-11-08 12:02:00 +08:00
commit cede2b1420
3 changed files with 23 additions and 2 deletions

View File

@ -354,7 +354,7 @@ class tool_provider extends ToolProvider {
$userlog->serviceurl = $serviceurl; $userlog->serviceurl = $serviceurl;
$userlog->sourceid = $sourceid; $userlog->sourceid = $sourceid;
$userlog->consumerkey = $this->consumer->getKey(); $userlog->consumerkey = $this->consumer->getKey();
$userlog->consumersecret = $tool->secret; $userlog->consumersecret = $this->consumer->secret;
$userlog->lastgrade = 0; $userlog->lastgrade = 0;
$userlog->lastaccess = time(); $userlog->lastaccess = time();
$userlog->timecreated = time(); $userlog->timecreated = time();

View File

@ -462,5 +462,26 @@ function xmldb_enrol_lti_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2022061500, 'enrol', 'lti'); upgrade_plugin_savepoint(true, 2022061500, 'enrol', 'lti');
} }
if ($oldversion < 2022103100) {
// Update lti user information for LTI 2.0 users having the wrong consumer secret recorded.
// This applies to any LTI 2.0 user who has launched the tool (i.e. has lastaccess) and fixes a non-functional grade sync
// for LTI 2.0 consumers.
$sql = "SELECT lu.id, lc.secret
FROM {enrol_lti_users} lu
JOIN {enrol_lti_lti2_consumer} lc
ON (lu.consumerkey = lc.consumerkey256)
WHERE lc.ltiversion = :ltiversion
AND lu.consumersecret != lc.secret
AND lu.lastaccess IS NOT NULL";
$affectedltiusersrs = $DB->get_recordset_sql($sql, ['ltiversion' => 'LTI-2p0']);
foreach ($affectedltiusersrs as $ltiuser) {
$DB->set_field('enrol_lti_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
}
$affectedltiusersrs->close();
// Lti savepoint reached.
upgrade_plugin_savepoint(true, 2022103100, 'enrol', 'lti');
}
return true; return true;
} }

View File

@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2022061500; // The current plugin version (Date: YYYYMMDDXX). $plugin->version = 2022103100; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version. $plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'enrol_lti'; // Full name of the plugin (used for diagnostics). $plugin->component = 'enrol_lti'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = [ $plugin->dependencies = [