Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 19 grade synchronisation is not working #20

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update table names
  • Loading branch information
ajuszczyk committed Jul 19, 2023
commit 0da1c90570b13ceae053ed11af735b7b64368bc9
2 changes: 1 addition & 1 deletion classes/local/ltiadvantage/repository/user_repository.php
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ private function user_record_from_user(user $user): \stdClass {
}

/**
* Create the corresponding enrol_lti_user record from a user instance.
* Create the corresponding enrol_ct_users record from a user instance.
*
* @param user $user the user instance.
* @return \stdClass the record.
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ class published_resources_table extends \table_sql {
* @param string $courseid The id of the course.
*/
public function __construct($courseid) {
parent::__construct('enrol_lti_manage_table');
parent::__construct('enrol_ct_manage_table');

$this->define_columns(array(
'name',
2 changes: 1 addition & 1 deletion classes/manage_table.php
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ class manage_table extends \table_sql {
* @param string $courseid The id of the course.
*/
public function __construct($courseid) {
parent::__construct('enrol_lticoursetemplate_manage_table');
parent::__construct('enrol_ct_manage_table');

$this->define_columns(array(
'name',
2 changes: 1 addition & 1 deletion classes/task/sync_members.php
Original file line number Diff line number Diff line change
@@ -280,7 +280,7 @@ protected function sync_member_information(stdClass $tool, ToolConsumer $consume

// Check if this user has already been registered in the enrol_ct_users table.
if (!$DB->record_exists('enrol_ct_users', ['toolid' => $tool->id, 'userid' => $user->id])) {
// Create an initial enrol_lti_user record that we can use later when syncing grades and members.
// Create an initial enrol_ct_users record that we can use later when syncing grades and members.
$userlog = new stdClass();
$userlog->userid = $user->id;
$userlog->toolid = $tool->id;
14 changes: 7 additions & 7 deletions db/upgrade.php
Original file line number Diff line number Diff line change
@@ -554,31 +554,31 @@ function xmldb_enrol_lticoursetemplate_upgrade($oldversion) {
// 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
FROM {enrol_ct_users} lu
JOIN {enrol_ct_lti2_consumer} lc
ON (" . $DB->sql_compare_text('lu.consumerkey', 255) . " = lc.consumerkey256)
WHERE lc.ltiversion = :ltiversion
AND " . $DB->sql_compare_text('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]);
$DB->set_field('enrol_ct_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
}
$affectedltiusersrs->close();

// Update lti user information for any users missing a consumer secret.
// This applies to any user who has launched the tool (i.e. has lastaccess) but who doesn't have a secret recorded.
// This fixes a bug where enrol_lti_users records are created first during a member sync, and are missing the secret,
// This fixes a bug where enrol_ct_users records are created first during a member sync, and are missing the secret,
// even despite having launched the tool subsequently.
$sql = "SELECT lu.id, lc.secret
FROM {enrol_lti_users} lu
JOIN {enrol_lti_lti2_consumer} lc
FROM {enrol_ct_users} lu
JOIN {enrol_ct_lti2_consumer} lc
ON (" . $DB->sql_compare_text('lu.consumerkey', 255) . " = lc.consumerkey256)
WHERE lu.consumersecret IS NULL
AND lu.lastaccess IS NOT NULL";
$affectedltiusersrs = $DB->get_recordset_sql($sql);
foreach ($affectedltiusersrs as $ltiuser) {
$DB->set_field('enrol_lti_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
$DB->set_field('enrol_ct_users', 'consumersecret', $ltiuser->secret, ['id' => $ltiuser->id]);
}
$affectedltiusersrs->close();

2 changes: 1 addition & 1 deletion tooltemplate.php
Original file line number Diff line number Diff line change
@@ -317,7 +317,7 @@
// if ($ltiversion === \IMSGlobal\LTI\ToolProvider\ToolProvider::LTI_VERSION1) {
// $dataconnector = new \enrol_lticoursetemplate\data_connector();
// $consumer = new \IMSGlobal\LTI\ToolProvider\ToolConsumer($consumerkey, $dataconnector);
// // Check if the consumer has already been registered to the enrol_lti_lti2_consumer table. Register if necessary.
// // Check if the consumer has already been registered to the enrol_ct_lti2_consumer table. Register if necessary.
// $consumer->ltiVersion = \IMSGlobal\LTI\ToolProvider\ToolProvider::LTI_VERSION1;
// // For LTIv1, set the tool secret as the consumer secret.
// $consumer->secret = $tool->secret;
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023062600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2023071900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'enrol_lticoursetemplate'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = [