From 0db7de7d329825017482f48ea76e27e84047a44f Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Mon, 9 May 2022 15:13:53 +0100 Subject: [PATCH] Add warning message to the bot enabled configuration --- local/o365/lang/en/local_o365.php | 2 +- local/o365/lib.php | 33 +++++++++++++++++++++++++++++++ local/o365/settings.php | 13 +++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/local/o365/lang/en/local_o365.php b/local/o365/lang/en/local_o365.php index d07770bb7..0aa2d1648 100644 --- a/local/o365/lang/en/local_o365.php +++ b/local/o365/lang/en/local_o365.php @@ -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'] = '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.'; $string['settings_bot_app_id'] = 'Application ID'; $string['settings_bot_app_id_desc'] = ''; $string['settings_bot_app_password'] = 'Client Secret'; diff --git a/local/o365/lib.php b/local/o365/lib.php index 3ad820f25..7552028fe 100644 --- a/local/o365/lib.php +++ b/local/o365/lib.php @@ -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; +} diff --git a/local/o365/settings.php b/local/o365/settings.php index e76017911..b0f302786 100644 --- a/local/o365/settings.php +++ b/local/o365/settings.php @@ -598,9 +598,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.