Skip to content

Commit

Permalink
Merge branch 'wip-83613-m40' into MOODLE_40_STABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
weilai-irl committed May 11, 2022
2 parents 3f02ffd + 0db7de7 commit 39adcc1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion local/o365/lang/en/local_o365.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@
$string['settings_teams_deploy_bot_1'] = 'Once you have completed the above steps and have an active Azure subscription, click here to deploy the bot:';
$string['settings_teams_deploy_bot_2'] = 'Need help?';
$string['settings_bot_feature_enabled'] = 'Bot feature enabled';
$string['settings_bot_feature_enabled_desc'] = '';
$string['settings_bot_feature_enabled_desc'] = '<span class="warning">NOTE: There is a known issue in which if the bot feature is enabled in the Teams app, the Moodle Teams app cannot be provisioned to class teams unless the team is manually activated.</span>';
$string['settings_bot_app_id'] = 'Application ID';
$string['settings_bot_app_id_desc'] = '';
$string['settings_bot_app_password'] = 'Client Secret';
Expand Down
33 changes: 33 additions & 0 deletions local/o365/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,36 @@ function local_o365_get_auth_token() {

return $authtoken;
}

/**
* Check Moodle and local_o365 versions to see if LTI feature is included in the plugin.
*
* @return bool
*/
function local_o365_is_lti_feature_included() {
global $CFG;

$hasltifeature = false;

$releaseparts = explode(' ', $CFG->release);
$release = $releaseparts[0];
$localo365version = get_config('local_o365', 'version');
switch ($release) {
case '3.10':
if ($localo365version >= 2020110935) {
$hasltifeature = true;
}
break;
case '3.11':
if ($localo365version >= 2021051720) {
$hasltifeature = true;
}
break;
default:
if (substr($release, 0, 1) >= 4) {
$hasltifeature = true;
}
}

return $hasltifeature;
}
13 changes: 12 additions & 1 deletion local/o365/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,20 @@
'Moodle'));

// Setting bot_feature_enabled.
$botfeatureenableddescription = '';
if (local_o365_is_lti_feature_included()) {
if (\local_o365\utils::is_connected() === true) {
$graphclient = utils::get_graphclient();
if ($graphclient) {
if ($graphclient->has_education_license()) {
$botfeatureenableddescription = get_string('settings_bot_feature_enabled_desc', 'local_o365');
}
}
}
}
$settings->add(new admin_setting_configcheckbox('local_o365/bot_feature_enabled',
get_string('settings_bot_feature_enabled', 'local_o365'),
get_string('settings_bot_feature_enabled_desc', 'local_o365'),
$botfeatureenableddescription,
'0'));

// Setting bot_webhook_endpoint.
Expand Down

0 comments on commit 39adcc1

Please sign in to comment.