From 2d1b21581ca9426683d1b49ee13a7ad3ec5e6de0 Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Tue, 22 Oct 2024 15:30:42 +0100 Subject: [PATCH] Fix Moodle plugin CI errors part 2 --- .github/workflows/{main.yml => ci.yml} | 4 +- blocks/microsoft/block_microsoft.php | 59 +++-- blocks/microsoft/db/access.php | 9 +- blocks/microsoft/db/caches.php | 4 +- blocks/microsoft/lang/en/block_microsoft.php | 8 +- blocks/microsoft/sass/styles.scss | 88 ------- blocks/microsoft/styles.css | 85 ++++--- local/o365/classes/adminsetting/tabs.php | 4 +- .../usersynccreationrestriction.php | 4 +- .../classes/adminsetting/usersyncoptions.php | 10 +- .../o365/classes/adminsetting/verifysetup.php | 8 +- local/o365/classes/event/api_call_failed.php | 2 - .../classes/event/calendar_subscribed.php | 2 - .../classes/event/calendar_unsubscribed.php | 2 - .../feature/calsync/form/element/calendar.php | 16 +- .../feature/calsync/form/subscriptions.php | 20 +- local/o365/classes/feature/calsync/main.php | 33 +-- .../classes/feature/calsync/observers.php | 4 +- .../calsync/task/importfromoutlook.php | 6 +- .../feature/calsync/task/syncoldevents.php | 9 +- .../o365/classes/feature/cohortsync/main.php | 32 +-- .../classes/feature/courserequest/main.php | 27 ++- .../o365/classes/feature/coursesync/main.php | 64 ++--- .../classes/feature/coursesync/observers.php | 3 +- .../o365/classes/feature/coursesync/utils.php | 43 ++-- local/o365/classes/feature/sds/task/sync.php | 21 +- local/o365/classes/feature/sds/utils.php | 6 +- .../feature/userconnections/filtering.php | 10 +- local/o365/classes/feature/usersync/main.php | 28 ++- local/o365/classes/form/cohortsync.php | 2 +- local/o365/classes/form/courserequestform.php | 12 +- .../classes/form/teamstabconfiguration.php | 6 +- .../healthcheck/healthcheckinterface.php | 14 +- local/o365/classes/healthcheck/ratelimit.php | 2 - local/o365/classes/httpclient.php | 49 ++-- local/o365/classes/httpclientinterface.php | 64 +++-- local/o365/classes/oauth2/apptoken.php | 6 +- local/o365/classes/oauth2/clientdata.php | 2 +- local/o365/classes/oauth2/token.php | 12 +- local/o365/classes/obj/o365user.php | 4 - local/o365/classes/observers.php | 43 ++-- local/o365/classes/page/acp.php | 30 +-- local/o365/classes/page/ajax.php | 8 +- local/o365/classes/page/base.php | 2 - local/o365/classes/privacy/provider.php | 48 ++-- local/o365/classes/rest/o365api.php | 4 +- local/o365/classes/rest/unified.php | 223 +++++++++--------- local/o365/classes/task/cohortsync.php | 8 +- .../classes/task/coursemembershipsync.php | 4 +- local/o365/classes/task/coursesync.php | 5 +- .../o365/classes/task/groupmembershipsync.php | 2 +- .../o365/classes/task/notifysecretexpiry.php | 11 +- .../task/processcourserequestapproval.php | 7 +- local/o365/classes/task/processmatchqueue.php | 4 +- .../task/updatecourserequeststatus.php | 2 - local/o365/classes/task/usersync.php | 13 +- local/o365/classes/tests/mockhttpclient.php | 4 +- local/o365/classes/utils.php | 33 +-- .../webservices/create_onenoteassignment.php | 3 +- .../webservices/delete_onenoteassignment.php | 2 +- .../webservices/exception/assignnotfound.php | 2 - .../exception/couldnotsavegrade.php | 2 - .../exception/invalidassignment.php | 2 - .../webservices/exception/modulenotfound.php | 2 - .../webservices/exception/sectionnotfound.php | 2 - .../classes/webservices/read_assignments.php | 111 ++++----- .../classes/webservices/read_courseusers.php | 2 +- .../webservices/read_onenoteassignment.php | 2 +- .../webservices/read_teachercourses.php | 4 +- .../o365/classes/webservices/update_grade.php | 64 ++--- .../webservices/update_onenoteassignment.php | 2 +- local/o365/classes/webservices/utils.php | 4 +- local/o365/db/access.php | 2 +- local/o365/db/caches.php | 2 +- local/o365/db/services.php | 2 +- local/o365/db/tasks.php | 14 +- local/o365/db/upgrade.php | 136 ++++------- local/o365/export_manifest.php | 2 + local/o365/lang/cs/local_o365.php | 6 + local/o365/lang/de/local_o365.php | 6 + local/o365/lang/en/local_o365.php | 16 +- local/o365/lang/es/local_o365.php | 6 + local/o365/lang/fi/local_o365.php | 6 + local/o365/lang/fr/local_o365.php | 8 +- local/o365/lang/it/local_o365.php | 6 + local/o365/lang/ja/local_o365.php | 6 + local/o365/lang/nl/local_o365.php | 6 + local/o365/lang/pl/local_o365.php | 6 + local/o365/lang/pt_br/local_o365.php | 6 + local/o365/lib.php | 45 +++- local/o365/sass/styles.scss | 129 ---------- local/o365/settings.php | 2 +- local/o365/sso_end.php | 1 + local/o365/sso_login.php | 1 + local/o365/sso_start.php | 1 + local/o365/styles.css | 55 +++-- local/o365/teams_tab.php | 5 +- local/o365/teams_tab_configuration.php | 1 + local/o365/teams_tab_redirect.php | 1 + local/o365/tests/coursesyncutils_test.php | 54 +++-- local/o365/tests/observers_test.php | 26 +- local/o365/tests/privacy_provider_test.php | 82 ++++--- local/o365/tests/token_test.php | 15 +- local/o365/tests/usersync_test.php | 109 +++++---- .../webservices_onenoteassignment_test.php | 163 +++++++------ local/o365/tests/webservices_utils_test.php | 56 +++-- .../onenote/amd/build/onenotedelete.min.js | 5 +- .../amd/build/onenotedelete.min.js.map | 2 +- .../feedback/onenote/amd/src/onenotedelete.js | 65 +++-- ...assignfeedback_onenote_subplugin.class.php | 11 +- ...assignfeedback_onenote_subplugin.class.php | 9 +- .../onenote/classes/privacy/provider.php | 22 +- mod/assign/feedback/onenote/db/install.php | 2 - mod/assign/feedback/onenote/db/upgrade.php | 2 - mod/assign/feedback/onenote/externallib.php | 6 +- .../lang/cs/assignfeedback_onenote.php | 14 +- .../lang/de/assignfeedback_onenote.php | 14 +- .../lang/en/assignfeedback_onenote.php | 26 +- .../lang/es/assignfeedback_onenote.php | 14 +- .../lang/fi/assignfeedback_onenote.php | 14 +- .../lang/fr/assignfeedback_onenote.php | 16 +- .../lang/it/assignfeedback_onenote.php | 14 +- .../lang/ja/assignfeedback_onenote.php | 14 +- .../lang/nl/assignfeedback_onenote.php | 14 +- .../lang/pl/assignfeedback_onenote.php | 14 +- .../lang/pt_br/assignfeedback_onenote.php | 14 +- mod/assign/feedback/onenote/lib.php | 7 +- mod/assign/feedback/onenote/locallib.php | 4 +- .../onenote/tests/privacy/provider_test.php | 24 +- ...signsubmission_onenote_subplugin.class.php | 2 - .../classes/event/assessable_uploaded.php | 2 - .../classes/event/submission_created.php | 2 - .../classes/event/submission_updated.php | 2 - .../onenote/classes/privacy/provider.php | 14 +- .../lang/cs/assignsubmission_onenote.php | 19 +- .../lang/de/assignsubmission_onenote.php | 19 +- .../lang/en/assignsubmission_onenote.php | 35 ++- .../lang/es/assignsubmission_onenote.php | 19 +- .../lang/fi/assignsubmission_onenote.php | 19 +- .../lang/fr/assignsubmission_onenote.php | 19 +- .../lang/it/assignsubmission_onenote.php | 19 +- .../lang/ja/assignsubmission_onenote.php | 19 +- .../lang/nl/assignsubmission_onenote.php | 19 +- .../lang/pl/assignsubmission_onenote.php | 19 +- .../lang/pt_br/assignsubmission_onenote.php | 19 +- mod/assign/submission/onenote/lib.php | 1 - mod/assign/submission/onenote/locallib.php | 2 - .../onenote/tests/privacy/provider_test.php | 35 ++- .../amd/build/iframeChecker.min.js | 4 +- .../amd/build/iframeChecker.min.js.map | 1 + .../amd/build/teamsThemeChecker.min.js | 4 +- .../amd/build/teamsThemeChecker.min.js.map | 1 + .../boost_o365teams/amd/src/iframeChecker.js | 13 +- .../amd/src/teamsThemeChecker.js | 8 +- .../classes/output/core_renderer.php | 32 ++- .../classes/privacy/provider.php | 6 +- theme/boost_o365teams/config.php | 126 +++++----- .../lang/en/theme_boost_o365teams.php | 26 +- theme/boost_o365teams/layout/login.php | 2 +- theme/boost_o365teams/lib.php | 4 +- theme/boost_o365teams/renderers.php | 88 +++---- theme/boost_o365teams/style/custom.css | 139 +++++------ .../templates/columns2.mustache | 54 ++--- theme/boost_o365teams/templates/head.mustache | 46 ++++ .../boost_o365teams/templates/login.mustache | 9 +- 165 files changed, 1800 insertions(+), 1796 deletions(-) rename .github/workflows/{main.yml => ci.yml} (98%) delete mode 100644 blocks/microsoft/sass/styles.scss delete mode 100644 local/o365/sass/styles.scss create mode 100644 theme/boost_o365teams/amd/build/iframeChecker.min.js.map create mode 100644 theme/boost_o365teams/amd/build/teamsThemeChecker.min.js.map create mode 100644 theme/boost_o365teams/templates/head.mustache diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 98% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index f7be1a1b8..26d11d8d0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ # Title of the workflow -name: Moodle Office 365 Plugin CI +name: Moodle Plugin CI for Microsoft plugins # Run this workflow every time a new commit pushed to your repository or PR # created. @@ -7,7 +7,7 @@ on: [push, pull_request] jobs: check: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest services: postgres: diff --git a/blocks/microsoft/block_microsoft.php b/blocks/microsoft/block_microsoft.php index 59c1eca55..832f15afc 100644 --- a/blocks/microsoft/block_microsoft.php +++ b/blocks/microsoft/block_microsoft.php @@ -16,6 +16,7 @@ /** * Block Microsoft block + * * @package block_microsoft * @author James McQuillan * @author Lai Wei @@ -24,12 +25,13 @@ */ use local_o365\feature\coursesync\utils; +use local_onenote\api\base; defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot.'/blocks/microsoft/lib.php'); -require_once($CFG->dirroot.'/auth/oidc/lib.php'); -require_once($CFG->dirroot.'/local/o365/lib.php'); +require_once($CFG->dirroot . '/blocks/microsoft/lib.php'); +require_once($CFG->dirroot . '/auth/oidc/lib.php'); +require_once($CFG->dirroot . '/local/o365/lib.php'); /** * Microsoft Block. @@ -58,7 +60,7 @@ public function has_config() { /** * Get the content of the block. * - * @return stdClass|stdObject|null + * @return stdClass|null */ public function get_content() { global $USER, $DB; @@ -160,8 +162,7 @@ protected function get_course_content() { if ($iscoursecontext && $coursesyncenabled && $iscoursesyncenabled) { $canmanage = (has_capability('local/o365:managegroups', $this->page->context) === true) ? true : false; - $canview = (is_enrolled($this->page->context) && has_capability('local/o365:viewgroups', $this->page->context)) ? - true : false; + $canview = is_enrolled($this->page->context) && has_capability('local/o365:viewgroups', $this->page->context); if ($canmanage === true || $canview === true) { [$courseheader, $o365record] = $this->get_course_header_and_o365object($courseid); @@ -269,9 +270,9 @@ protected function get_user_content_connected() { $o365config = get_config('local_o365'); $html = ''; - $user = $DB->get_record('user', array('id' => $USER->id)); + $user = $DB->get_record('user', ['id' => $USER->id]); $langconnected = get_string('o365connected', 'block_microsoft', $user); - $html .= '
'.$langconnected.'
'; + $html .= '
' . $langconnected . '
'; $odburl = get_config('local_o365', 'odburl'); $o365object = $DB->get_record('local_o365_objects', ['type' => 'user', 'moodleid' => $USER->id]); @@ -284,13 +285,13 @@ protected function get_user_content_connected() { if (!empty($odburl) && !empty($this->globalconfig->settings_showmydelve)) { if (!empty($o365object)) { - $delveurl = 'https://'.$odburl.'/_layouts/15/me.aspx?u='.$o365object->objectid.'&v=work'; + $delveurl = 'https://' . $odburl . '/_layouts/15/me.aspx?u=' . $o365object->objectid . '&v=work'; } } if (!empty($user->picture)) { $html .= '
'; - $picturehtml = $OUTPUT->user_picture($user, array('size' => 100, 'class' => 'block_microsoft_profile')); + $picturehtml = $OUTPUT->user_picture($user, ['size' => 100, 'class' => 'block_microsoft_profile']); $profileurl = new moodle_url('/user/profile.php', ['id' => $USER->id]); if (!empty($delveurl)) { // If "My Delve" is enabled, clicking the user picture should take you to their Delve page. @@ -313,7 +314,7 @@ protected function get_user_content_connected() { if (!empty($coursespsite)) { $spsite = \local_o365\rest\sharepoint::get_tokenresource(); if (!empty($spsite)) { - $spurl = $spsite.'/'.$coursespsite->siteurl; + $spurl = $spsite . '/' . $coursespsite->siteurl; $spattrs = ['class' => 'servicelink block_microsoft_sharepoint', 'target' => '_blank']; $items[] = html_writer::link($spurl, $sharepointstr, $spattrs); $items[] = '
'; @@ -358,7 +359,7 @@ protected function get_user_content_connected() { ]; $stronedrive = get_string('linkonedrive', 'block_microsoft'); if (!empty($odburl)) { - $items[] = html_writer::link('https://'.$odburl, $stronedrive, $odbattrs); + $items[] = html_writer::link('https://' . $odburl, $stronedrive, $odbattrs); } } @@ -386,7 +387,7 @@ protected function get_user_content_connected() { // My Sways. if (!empty($this->globalconfig->settings_showsways) && !empty($userupn)) { - $swayurl = 'https://www.sway.com/my?auth_pvr=OrgId&auth_upn='.$userupn; + $swayurl = 'https://www.sway.com/my?auth_pvr=OrgId&auth_upn=' . $userupn; $swayattrs = ['target' => '_blank', 'class' => 'servicelink block_microsoft_sway']; $items[] = html_writer::link($swayurl, get_string('linksways', 'block_microsoft'), $swayattrs); } @@ -406,9 +407,9 @@ protected function get_user_content_connected() { } if (auth_oidc_connectioncapability($USER->id, 'connect') === true - || auth_oidc_connectioncapability($USER->id, 'disconnect') === true - || local_o365_connectioncapability($USER->id, 'link') - || local_o365_connectioncapability($USER->id, 'unlink')) { + || auth_oidc_connectioncapability($USER->id, 'disconnect') === true + || local_o365_connectioncapability($USER->id, 'link') + || local_o365_connectioncapability($USER->id, 'unlink')) { if (!empty($this->globalconfig->settings_showmanageo365conection)) { $connecturl = new moodle_url('/local/o365/ucp.php', ['action' => 'connection']); $connectstr = get_string('linkconnection', 'block_microsoft'); @@ -465,6 +466,7 @@ protected function get_user_content_not_connected() { } $html .= html_writer::alist($items); + return $html; } @@ -480,18 +482,20 @@ protected function get_content_o365download() { $url = get_config('block_microsoft', 'settings_geto365link'); $str = get_string('install_office', 'block_microsoft'); + return [ - html_writer::link($url, $str, ['class' => 'servicelink block_microsoft_downloado365', 'target' => '_blank']), + html_writer::link($url, $str, + ['class' => 'servicelink block_microsoft_downloado365', 'target' => '_blank']), ]; } /** * Get the user's Moodle OneNote Notebook. * - * @param \local_onenote\api\base $onenoteapi A constructed OneNote API to use. + * @param base $onenoteapi A constructed OneNote API to use. * @return array Array of information about the user's OneNote notebook used for Moodle. */ - protected function get_onenote_notebook(\local_onenote\api\base $onenoteapi) { + protected function get_onenote_notebook(base $onenoteapi) { $moodlenotebook = null; for ($i = 0; $i < 2; $i++) { $notebooks = $onenoteapi->get_items_list(''); @@ -510,6 +514,7 @@ protected function get_onenote_notebook(\local_onenote\api\base $onenoteapi) { break; } } + return $moodlenotebook; } @@ -532,21 +537,20 @@ protected function render_onenote() { 'onclick' => 'window.open(this.href,\'_blank\'); return false;', 'class' => 'servicelink block_microsoft_onenote', ]; + return html_writer::link($url->out(false), $stropennotebook, $linkattrs); } $action = optional_param('action', '', PARAM_TEXT); try { - $onenoteapi = \local_onenote\api\base::getinstance(); + $onenoteapi = base::getinstance(); $output = ''; if ($onenoteapi->is_logged_in()) { // Add the "save to onenote" button if we are on an assignment page. - $onassignpage = ($this->page->cm - && $this->page->cm->modname == 'assign' - && $action == 'editsubmission') ? true : false; + $onassignpage = $this->page->cm && $this->page->cm->modname == 'assign' && $action == 'editsubmission'; if ($onassignpage === true && $onenoteapi->is_student($this->page->cm->id, $USER->id)) { $workstr = get_string('workonthis', 'block_microsoft'); - $output .= $onenoteapi->render_action_button($workstr, $this->page->cm->id).'

'; + $output .= $onenoteapi->render_action_button($workstr, $this->page->cm->id) . '

'; } // Find moodle notebook, create if not found. $moodlenotebook = null; @@ -570,13 +574,16 @@ protected function render_onenote() { $output .= get_string('error_nomoodlenotebook', 'block_microsoft'); } } + return $output; } catch (moodle_exception $e) { if (class_exists('\local_o365\utils')) { \local_o365\utils::debug($e->getMessage(), __METHOD__, $e); } - return ''.get_string('linkonenote_unavailable', 'block_microsoft') - .'
'.get_string('contactadmin', 'block_microsoft').'
'; + + return '' . + get_string('linkonenote_unavailable', 'block_microsoft') . '
' . + get_string('contactadmin', 'block_microsoft') . '
'; } } } diff --git a/blocks/microsoft/db/access.php b/blocks/microsoft/db/access.php index ad5a180cf..56088ea73 100644 --- a/blocks/microsoft/db/access.php +++ b/blocks/microsoft/db/access.php @@ -22,6 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ + defined('MOODLE_INTERNAL') || die(); $capabilities = [ @@ -29,9 +30,9 @@ 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, 'archetypes' => [ - 'user' => CAP_ALLOW + 'user' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/my:manageblocks' + 'clonepermissionsfrom' => 'moodle/my:manageblocks', ], 'block/microsoft:addinstance' => [ 'riskbitmask' => RISK_SPAM | RISK_XSS, @@ -39,8 +40,8 @@ 'contextlevel' => CONTEXT_BLOCK, 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/site:manageblocks' + 'clonepermissionsfrom' => 'moodle/site:manageblocks', ], ]; diff --git a/blocks/microsoft/db/caches.php b/blocks/microsoft/db/caches.php index 9001e3f63..04e56e6ee 100644 --- a/blocks/microsoft/db/caches.php +++ b/blocks/microsoft/db/caches.php @@ -22,9 +22,11 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ + defined('MOODLE_INTERNAL') || die(); + $definitions = [ 'onenotenotebook' => [ - 'mode' => cache_store::MODE_SESSION + 'mode' => cache_store::MODE_SESSION, ], ]; diff --git a/blocks/microsoft/lang/en/block_microsoft.php b/blocks/microsoft/lang/en/block_microsoft.php index e2d30b88c..18f27e76f 100644 --- a/blocks/microsoft/lang/en/block_microsoft.php +++ b/blocks/microsoft/lang/en/block_microsoft.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder -- The strings are organised by features. +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment -- The strings are organised by features. + $string['pluginname'] = 'Microsoft block'; $string['contactadmin'] = 'Contact administrator for more information.'; $string['error_nomoodlenotebook'] = 'Could not find your Moodle notebook.'; @@ -140,7 +143,10 @@ $string['error_connected_team_missing'] = 'The course is configured to be synced, but the Team cannot be found.'; $string['error_course_sync_disabled'] = 'The course is not configured to be synced.'; -// Course request +// Course request. $string['linkcourserequest'] = 'Request course from Teams'; $string['settings_courserequest'] = 'Request course from Teams'; $string['settings_courserequest_desc'] = 'Request a new course from Microsoft Teams. After approval, the course will be created and connected to a Team. Microsoft Team members will be enrolled in the course.'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/blocks/microsoft/sass/styles.scss b/blocks/microsoft/sass/styles.scss deleted file mode 100644 index 0e195a8ad..000000000 --- a/blocks/microsoft/sass/styles.scss +++ /dev/null @@ -1,88 +0,0 @@ -.block_microsoft { - h5 { - font-size: 95%; - text-align: center; - } - ul { - list-style: none; - padding-left: 0; - margin-left: 0; - .servicelink { - background-position: 2px 0px; - background-size: 28px; - background-repeat: no-repeat; - background-color: transparent; - display: inline-block; - padding: 4px 4px 4px 40px; - margin: 0.2rem 0; - &:active, &:hover, &:visited { - text-decoration: none !important; - } - } - } - .block_microsoft_onedrive { - background-image: url([[pix:block_microsoft|onedriveicon]]); - } - .block_microsoft_sway { - background-image: url([[pix:block_microsoft|sway]]); - } - .block_microsoft_msstream { - background-image: url([[pix:block_microsoft|msstream]]); - } - .block_microsoft_msteams { - background-image: url([[pix:block_microsoft|msteams]]); - } - .block_microsoft_onenote { - background-image: url([[pix:block_microsoft|onenotecolor]]); - } - .block_microsoft_outlook { - background-image: url([[pix:block_microsoft|outlookcolor]]); - } - .block_microsoft_connection { - background-image: url([[pix:block_microsoft|o365color]]); - } - .block_microsoft_delve { - background-image: url([[pix:block_microsoft|delvecolor]]); - } - .block_microsoft_forms { - background-image: url([[pix:block_microsoft|formscolor]]); - } - .block_microsoft_sharepoint { - background-image: url([[pix:block_microsoft|sharepointcolor]]); - } - .block_microsoft_preferences { - background-image: url([[pix:moodle|i/settings]]); - } - .block_microsoft_msasignin { - background-image: url([[pix:block_microsoft|msftcolor]]); - } - .block_microsoft_downloado365 { - background-image: url([[pix:moodle|i/restore]]); - } - .block_microsoft_team { - background-image: url([[pix:block_microsoft|msteams]]); - } - .block_microsoft_conversations { - background-image: url([[pix:block_microsoft|outlookcolor]]); - } - .block_microsoft_calendar { - background-image: url([[pix:block_microsoft|calendar]]); - } - .block_microsoft_notebook { - background-image: url([[pix:block_microsoft|onenotecolor]]); - } - .block_microsoft_sync { - background-image: url([[pix:moodle|i/settings]]); - } - .block_microsoft_reset { - background-image: url([[pix:moodle|t/reset]]); - } - .block_microsoft_profile { - border-radius: 50%; - display: block; - margin: 1rem auto 2rem; - } - hr { - margin: 1rem 0 !important; - } -} diff --git a/blocks/microsoft/styles.css b/blocks/microsoft/styles.css index 27fcd7403..f9c2d90ab 100644 --- a/blocks/microsoft/styles.css +++ b/blocks/microsoft/styles.css @@ -1,14 +1,16 @@ .block_microsoft h5 { - font-size: 95%; - text-align: center; + font-size: 95%; + text-align: center; } + .block_microsoft ul { - list-style: none; - padding-left: 0; - margin-left: 0; + list-style: none; + padding-left: 0; + margin-left: 0; } + .block_microsoft ul .servicelink { - background-position: 2px 0px; + background-position: 2px 0; background-size: 28px; background-repeat: no-repeat; background-color: transparent; @@ -16,68 +18,93 @@ padding: 4px 4px 4px 40px; margin: 0.2rem 0; } -.block_microsoft ul .servicelink:active, .block_microsoft ul .servicelink:hover, .block_microsoft ul .servicelink:visited { - text-decoration: none !important; + +.block_microsoft ul .servicelink:active, +.block_microsoft ul .servicelink:hover, +.block_microsoft ul .servicelink:visited { + text-decoration: none; } + .block_microsoft .block_microsoft_onedrive { - background-image: url([[pix:block_microsoft|onedriveicon]]); + background-image: url([[pix:block_microsoft|onedriveicon]]); } + .block_microsoft .block_microsoft_sway { - background-image: url([[pix:block_microsoft|sway]]); + background-image: url([[pix:block_microsoft|sway]]); } + .block_microsoft .block_microsoft_msstream { - background-image: url([[pix:block_microsoft|msstream]]); + background-image: url([[pix:block_microsoft|msstream]]); } + .block_microsoft .block_microsoft_msteams { - background-image: url([[pix:block_microsoft|msteams]]); + background-image: url([[pix:block_microsoft|msteams]]); } + .block_microsoft .block_microsoft_onenote { - background-image: url([[pix:block_microsoft|onenotecolor]]); + background-image: url([[pix:block_microsoft|onenotecolor]]); } + .block_microsoft .block_microsoft_outlook { - background-image: url([[pix:block_microsoft|outlookcolor]]); + background-image: url([[pix:block_microsoft|outlookcolor]]); } + .block_microsoft .block_microsoft_connection { - background-image: url([[pix:block_microsoft|o365color]]); + background-image: url([[pix:block_microsoft|o365color]]); } + .block_microsoft .block_microsoft_delve { - background-image: url([[pix:block_microsoft|delvecolor]]); + background-image: url([[pix:block_microsoft|delvecolor]]); } + .block_microsoft .block_microsoft_forms { - background-image: url([[pix:block_microsoft|formscolor]]); + background-image: url([[pix:block_microsoft|formscolor]]); } + .block_microsoft .block_microsoft_sharepoint { - background-image: url([[pix:block_microsoft|sharepointcolor]]); + background-image: url([[pix:block_microsoft|sharepointcolor]]); } + .block_microsoft .block_microsoft_preferences { - background-image: url([[pix:moodle|i/settings]]); + background-image: url([[pix:moodle|i/settings]]); } + .block_microsoft .block_microsoft_msasignin { - background-image: url([[pix:block_microsoft|msftcolor]]); + background-image: url([[pix:block_microsoft|msftcolor]]); } + .block_microsoft .block_microsoft_downloado365 { - background-image: url([[pix:moodle|i/restore]]); + background-image: url([[pix:moodle|i/restore]]); } + .block_microsoft .block_microsoft_team { - background-image: url([[pix:block_microsoft|msteams]]); + background-image: url([[pix:block_microsoft|msteams]]); } + .block_microsoft .block_microsoft_conversations { - background-image: url([[pix:block_microsoft|outlookcolor]]); + background-image: url([[pix:block_microsoft|outlookcolor]]); } + .block_microsoft .block_microsoft_calendar { - background-image: url([[pix:block_microsoft|calendar]]); + background-image: url([[pix:block_microsoft|calendar]]); } + .block_microsoft .block_microsoft_notebook { - background-image: url([[pix:block_microsoft|onenotecolor]]); + background-image: url([[pix:block_microsoft|onenotecolor]]); } + .block_microsoft .block_microsoft_sync { - background-image: url([[pix:moodle|i/settings]]); + background-image: url([[pix:moodle|i/settings]]); } + .block_microsoft .block_microsoft_reset { - background-image: url([[pix:moodle|t/reset]]); + background-image: url([[pix:moodle|t/reset]]); } + .block_microsoft .block_microsoft_courserequest { - background-image: url([[pix:block_microsoft|courserequest]]); + background-image: url([[pix:block_microsoft|courserequest]]); } + .block_microsoft hr { - margin: 1rem 0 !important; } + margin: 1rem 0; +} diff --git a/local/o365/classes/adminsetting/tabs.php b/local/o365/classes/adminsetting/tabs.php index e2f72f69c..d4d6dabf9 100644 --- a/local/o365/classes/adminsetting/tabs.php +++ b/local/o365/classes/adminsetting/tabs.php @@ -30,8 +30,6 @@ use moodle_url; use tabobject; -defined('MOODLE_INTERNAL') || die(); - /** * A tab in the plugin configuration page. */ @@ -136,7 +134,7 @@ public function write_setting($data) { * @param moodle_url|null $url An explicit URL to use instead of settings page section. * @uses $CFG */ - public function addtab($id, $name, moodle_url $url = null) { + public function addtab($id, $name, ?moodle_url $url = null) { if (empty($url)) { $urlparams = [ 'section' => $this->section, diff --git a/local/o365/classes/adminsetting/usersynccreationrestriction.php b/local/o365/classes/adminsetting/usersynccreationrestriction.php index 27d3c591b..934738ef4 100644 --- a/local/o365/classes/adminsetting/usersynccreationrestriction.php +++ b/local/o365/classes/adminsetting/usersynccreationrestriction.php @@ -72,8 +72,8 @@ public function __construct($name, $visiblename, $description, $defaultsetting) ]; $order = 0; while ($order++ < 15) { - $this->remotefields['extensionAttribute' . $order] = get_string('settings_fieldmap_field_extensionattribute', 'auth_oidc', - $order); + $this->remotefields['extensionAttribute' . $order] = get_string('settings_fieldmap_field_extensionattribute', + 'auth_oidc', $order); } return parent::__construct($name, $visiblename, $description, $defaultsetting); diff --git a/local/o365/classes/adminsetting/usersyncoptions.php b/local/o365/classes/adminsetting/usersyncoptions.php index 9ba63fc90..1b1fb21a7 100644 --- a/local/o365/classes/adminsetting/usersyncoptions.php +++ b/local/o365/classes/adminsetting/usersyncoptions.php @@ -83,18 +83,18 @@ public function __construct($name, $visiblename, $description) { */ public function output_html($data, $query = '') { global $OUTPUT; - if (!$this->load_choices() or empty($this->choices)) { + if (!$this->load_choices() || empty($this->choices)) { return ''; } $default = $this->get_defaultsetting(); if (is_null($default)) { - $default = array(); + $default = []; } if (is_null($data)) { - $data = array(); + $data = []; } - $options = array(); - $defaults = array(); + $options = []; + $defaults = []; foreach ($this->choices as $key => $description) { if (!empty($data[$key])) { $checked = 'checked="checked"'; diff --git a/local/o365/classes/adminsetting/verifysetup.php b/local/o365/classes/adminsetting/verifysetup.php index d1647c52a..f97c35b4f 100644 --- a/local/o365/classes/adminsetting/verifysetup.php +++ b/local/o365/classes/adminsetting/verifysetup.php @@ -87,14 +87,10 @@ public function output_html($data, $query = '') { if (\local_o365\adminsetting\detectoidc::setup_step_complete() === true) { $existingsetting = $this->config_read($this->name); if (!empty($existingsetting)) { - $messageattrs = [ - 'class' => 'permmessage' - ]; + $messageattrs = ['class' => 'permmessage']; $message = \html_writer::tag('span', get_string('settings_detectperms_valid', 'local_o365'), $messageattrs); } else { - $messageattrs = [ - 'class' => 'permmessage' - ]; + $messageattrs = ['class' => 'permmessage']; $message = \html_writer::tag('span', get_string('settings_detectperms_invalid', 'local_o365'), $messageattrs); } } else { diff --git a/local/o365/classes/event/api_call_failed.php b/local/o365/classes/event/api_call_failed.php index e10096683..d26a60177 100644 --- a/local/o365/classes/event/api_call_failed.php +++ b/local/o365/classes/event/api_call_failed.php @@ -25,8 +25,6 @@ namespace local_o365\event; -defined('MOODLE_INTERNAL') || die(); - /** * Event fired whenever a user subscribes to a calendar. */ diff --git a/local/o365/classes/event/calendar_subscribed.php b/local/o365/classes/event/calendar_subscribed.php index 709ccaf88..7abb9d653 100644 --- a/local/o365/classes/event/calendar_subscribed.php +++ b/local/o365/classes/event/calendar_subscribed.php @@ -25,8 +25,6 @@ namespace local_o365\event; -defined('MOODLE_INTERNAL') || die(); - /** * Event fired whenever a user subscribes to a calendar. */ diff --git a/local/o365/classes/event/calendar_unsubscribed.php b/local/o365/classes/event/calendar_unsubscribed.php index 66b932b02..d44183225 100644 --- a/local/o365/classes/event/calendar_unsubscribed.php +++ b/local/o365/classes/event/calendar_unsubscribed.php @@ -25,8 +25,6 @@ namespace local_o365\event; -defined('MOODLE_INTERNAL') || die(); - /** * Event fired whenever a user unsubscribes from a calendar. */ diff --git a/local/o365/classes/feature/calsync/form/element/calendar.php b/local/o365/classes/feature/calsync/form/element/calendar.php index 747b6a856..dc08c7633 100644 --- a/local/o365/classes/feature/calsync/form/element/calendar.php +++ b/local/o365/classes/feature/calsync/form/element/calendar.php @@ -31,6 +31,9 @@ require_once("$CFG->libdir/form/advcheckbox.php"); +// phpcs:disable moodle.NamingConventions.ValidVariableName.VariableNameLowerCase -- Parent class uses uppercase variable names. +// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod -- Parent class uses uppercase method names. + /** * Calendar form element. Provides checkbox to enable/disable calendar and options for sync behavior. */ @@ -50,15 +53,15 @@ class calendar extends \HTML_QuickForm_advcheckbox { /** * Constructor, accessed through __call constructor workaround. * - * @param string $elementName The name of the element. - * @param string $elementLabel The label of the element. + * @param string $elementname The name of the element. + * @param string $elementlabel The label of the element. * @param string $text Text that appears after the checkbox. * @param array $attributes Array of checkbox attributes. * @param array $customdata Array of form custom data. */ - public function calendarconstruct($elementName = null, $elementLabel = null, $text = null, $attributes = null, + public function calendarconstruct($elementname = null, $elementlabel = null, $text = null, $attributes = null, $customdata = []) { - parent::__construct($elementName, $elementLabel, $text, $attributes, null); + parent::__construct($elementname, $elementlabel, $text, $attributes, null); $this->customdata = $customdata; $this->_type = 'advcheckbox'; } @@ -112,7 +115,7 @@ public function setValue($value) { * * @return string html for help button */ - function getHelpButton(){ + public function getHelpButton() { return $this->_helpbutton; } @@ -183,3 +186,6 @@ public function toHtml() { return $html; } } + +// phpcs:enable moodle.NamingConventions.ValidVariableName.VariableNameLowerCase +// phpcs:enable moodle.NamingConventions.ValidFunctionName.LowercaseMethod diff --git a/local/o365/classes/feature/calsync/form/subscriptions.php b/local/o365/classes/feature/calsync/form/subscriptions.php index 36b972871..fec28c5ec 100644 --- a/local/o365/classes/feature/calsync/form/subscriptions.php +++ b/local/o365/classes/feature/calsync/form/subscriptions.php @@ -112,11 +112,11 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate $newsetting = [ 'user_id' => $USER->id, 'o365calid' => $sitecalenderid, - 'timecreated' => time() + 'timecreated' => time(), ]; $newsetting['id'] = $DB->insert_record('local_o365_calsettings', (object)$newsetting); } else if (empty($fromform->settingcal) && !empty($usersetting)) { - $DB->delete_records('local_o365_calsettings', array('user_id' => $USER->id)); + $DB->delete_records('local_o365_calsettings', ['user_id' => $USER->id]); } // Determine and organize existing subscriptions. @@ -176,7 +176,7 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate $eventdata = [ 'objectid' => $currentcaldata[$caltype]['recid'], 'userid' => $USER->id, - 'other' => ['caltype' => $caltype] + 'other' => ['caltype' => $caltype], ]; $event = \local_o365\event\calendar_unsubscribed::create($eventdata); $event->trigger(); @@ -202,13 +202,13 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate 'o365calid' => $syncwith, 'syncbehav' => $syncbehav, 'isprimary' => ($syncwith == $primarycalid) ? '1' : '0', - 'timecreated' => time() + 'timecreated' => time(), ]; $newsub['id'] = $DB->insert_record('local_o365_calsub', (object)$newsub); $eventdata = [ 'objectid' => $newsub['id'], 'userid' => $USER->id, - 'other' => ['caltype' => $caltype] + 'other' => ['caltype' => $caltype], ]; } else { // Already subscribed, update behavior. @@ -222,7 +222,7 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate $eventdata = [ 'objectid' => $currentcaldata[$caltype]['recid'], 'userid' => $USER->id, - 'other' => ['caltype' => $caltype] + 'other' => ['caltype' => $caltype], ]; } $event = \local_o365\event\calendar_subscribed::create($eventdata); @@ -241,13 +241,13 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate } } $todelete = (empty($fromform->settingcal)) ? $existingcoursesubs : array_diff_key($existingcoursesubs, $newcoursesubs); - $toadd = (empty($fromform->settingcal)) ? array() : array_diff_key($newcoursesubs, $existingcoursesubs); + $toadd = (empty($fromform->settingcal)) ? [] : array_diff_key($newcoursesubs, $existingcoursesubs); foreach ($todelete as $courseid => $unused) { $DB->delete_records('local_o365_calsub', ['user_id' => $USER->id, 'caltype' => 'course', 'caltypeid' => $courseid]); $eventdata = [ 'objectid' => $USER->id, 'userid' => $USER->id, - 'other' => ['caltype' => 'course', 'caltypeid' => $courseid] + 'other' => ['caltype' => 'course', 'caltypeid' => $courseid], ]; $event = \local_o365\event\calendar_unsubscribed::create($eventdata); $event->trigger(); @@ -273,7 +273,7 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate $eventdata = [ 'objectid' => $USER->id, 'userid' => $USER->id, - 'other' => ['caltype' => 'course', 'caltypeid' => $courseid] + 'other' => ['caltype' => 'course', 'caltypeid' => $courseid], ]; $event = \local_o365\event\calendar_subscribed::create($eventdata); $event->trigger(); @@ -297,7 +297,7 @@ public static function update_subscriptions($fromform, $primarycalid, $cancreate $eventdata = [ 'objectid' => $USER->id, 'userid' => $USER->id, - 'other' => ['caltype' => 'course', 'caltypeid' => $courseid] + 'other' => ['caltype' => 'course', 'caltypeid' => $courseid], ]; $event = \local_o365\event\calendar_subscribed::create($eventdata); $event->trigger(); diff --git a/local/o365/classes/feature/calsync/main.php b/local/o365/classes/feature/calsync/main.php index de9bc00ea..2dca5ef20 100644 --- a/local/o365/classes/feature/calsync/main.php +++ b/local/o365/classes/feature/calsync/main.php @@ -32,8 +32,6 @@ use local_o365\utils; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Calendar sync feature. */ @@ -54,7 +52,7 @@ class main { * @param httpclient|null $httpclient * @throws moodle_exception */ - public function __construct(clientdata $clientdata = null, httpclient $httpclient = null) { + public function __construct(?clientdata $clientdata = null, ?httpclient $httpclient = null) { $this->clientdata = (!empty($clientdata)) ? $clientdata : clientdata::instance_from_oidc(); $this->httpclient = (!empty($httpclient)) ? $httpclient : new httpclient(); } @@ -293,7 +291,7 @@ public function create_outlook_event_from_moodle_event($moodleventid) { 'emailAddress' => [ 'name' => $groupobject->o365name, 'address' => $outlookgroupemail, - ] + ], ], 'responseRequested' => false, 'isOrganizer' => true, @@ -313,6 +311,7 @@ public function create_outlook_event_from_moodle_event($moodleventid) { } } catch (moodle_exception $e) { // No token found, nothing to do. + debugging('Error creating group event. Details: ' . $e->getMessage()); } } } @@ -478,7 +477,7 @@ public function update_outlook_event($moodleeventid) { try { $apiclient->update_event($idmaprec->outlookeventid, $updated, $o365upn); } catch (moodle_exception $e) { - // Do nothing. + mtrace('Error updating event: '.$e->getMessage()); } } } @@ -539,30 +538,6 @@ protected function construct_outlook_group_email($courseid) { return $groupemail; } - /** - * Get group first and last name. - * @param string $groupname The o365 group name. - * @return array The first index is the first name and the second index is the last name. - */ - protected function group_first_last_name($groupname) { - $firstname = ''; - $lastname = ''; - if (empty($groupname)) { - return array($firstname, $lastname); - } - - $pos = strpos($groupname, ': '); - - if (false === $pos) { - return array($firstname, $lastname); - } - - $firstname = substr($groupname, 0, $pos + 1); - $lastname = substr($groupname, $pos + 1); - $lastname = trim($lastname); - return array($firstname, $lastname); - } - /** * Create a new calendar in the user's o365 calendars. * diff --git a/local/o365/classes/feature/calsync/observers.php b/local/o365/classes/feature/calsync/observers.php index d88e78f50..3d89ad2f0 100644 --- a/local/o365/classes/feature/calsync/observers.php +++ b/local/o365/classes/feature/calsync/observers.php @@ -75,8 +75,8 @@ public static function handle_user_enrolment_deleted(\core\event\user_enrolment_ 'userid' => $userid, 'other' => [ 'caltype' => 'course', - 'caltypeid' => $courseid - ] + 'caltypeid' => $courseid, + ], ]; $event = \local_o365\event\calendar_unsubscribed::create($eventdata); $event->trigger(); diff --git a/local/o365/classes/feature/calsync/task/importfromoutlook.php b/local/o365/classes/feature/calsync/task/importfromoutlook.php index 68f34d413..944d68879 100644 --- a/local/o365/classes/feature/calsync/task/importfromoutlook.php +++ b/local/o365/classes/feature/calsync/task/importfromoutlook.php @@ -28,8 +28,6 @@ use core_date; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Scheduled task to check for new o365 events and sync them into Moodle. */ @@ -111,7 +109,7 @@ public function execute() { // If all day event time is stored in Outlook only as UTC time and not in the local user time. if (isset($event['isAllDay']) && $event['isAllDay'] == '1') { // Need to make the time the same as the user preference so no time conversion. - $user = $DB->get_record('user', array('id' => $calsub->user_id)); + $user = $DB->get_record('user', ['id' => $calsub->user_id]); if ($user->timezone == 99) { $user->timezone = core_date::get_server_timezone(); } @@ -137,7 +135,7 @@ public function execute() { 'eventid' => $moodleevent->id, 'outlookeventid' => $event['id'], 'origin' => 'o365', - 'userid' => $calsub->user_id + 'userid' => $calsub->user_id, ]; $DB->insert_record('local_o365_calidmap', (object)$idmaprec); mtrace('Successfully imported event #'.$moodleevent->id); diff --git a/local/o365/classes/feature/calsync/task/syncoldevents.php b/local/o365/classes/feature/calsync/task/syncoldevents.php index ae1423929..2f276920f 100644 --- a/local/o365/classes/feature/calsync/task/syncoldevents.php +++ b/local/o365/classes/feature/calsync/task/syncoldevents.php @@ -28,8 +28,6 @@ use local_o365\utils; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * AdHoc task to sync existing Moodle calendar events with Microsoft 365. * @@ -125,7 +123,7 @@ protected function sync_siteevents($timecreated) { $calsync->update_event_raw($event->eventuserid, $event->outlookeventid, ['attendees' => $subscribersprimary]); } catch (moodle_exception $e) { - // Do nothing. + mtrace('ERROR: ' . $e->getMessage()); } } else { $calid = null; @@ -146,7 +144,7 @@ protected function sync_siteevents($timecreated) { $subscribersprimary, [], $calid); } } catch (moodle_exception $e) { - mtrace('ERROR: '.$e->getMessage()); + mtrace('ERROR: ' . $e->getMessage()); } } @@ -269,6 +267,7 @@ protected function sync_courseevents($courseid, $timecreated) { ['attendees' => $eventattendees]); } catch (moodle_exception $e) { // Do nothing. + mtrace('Error updating event #' . $event->eventid . ': ' . $e->getMessage()); } } else { $calid = null; @@ -327,7 +326,7 @@ protected function sync_courseevents($courseid, $timecreated) { } } catch (moodle_exception $e) { // Could not sync this course event. Log and continue. - mtrace('Error syncing course event #'.$event->eventid.': '.$e->getMessage()); + mtrace('Error syncing course event #' . $event->eventid . ': ' . $e->getMessage()); } } $events->close(); diff --git a/local/o365/classes/feature/cohortsync/main.php b/local/o365/classes/feature/cohortsync/main.php index 6471e081f..2eaa5e881 100644 --- a/local/o365/classes/feature/cohortsync/main.php +++ b/local/o365/classes/feature/cohortsync/main.php @@ -58,9 +58,11 @@ class main { private $cohortlist; /** + * Return the list of groups. + * * @return array */ - public function get_grouplist() : array { + public function get_grouplist(): array { if (is_null($this->grouplist)) { $this->fetch_groups_from_cache(); } @@ -69,9 +71,11 @@ public function get_grouplist() : array { } /** + * Return the list of cohorts. + * * @return array */ - public function get_cohortlist() : array { + public function get_cohortlist(): array { if (is_null($this->cohortlist)) { $this->fetch_cohorts(); } @@ -97,7 +101,7 @@ public function __construct(unified $graphclient) { * @param int $cohortid * @return bool */ - public function add_mapping(string $groupoid, int $cohortid) : bool { + public function add_mapping(string $groupoid, int $cohortid): bool { global $DB; if (!$groupoid || !$cohortid) { @@ -136,7 +140,7 @@ public function add_mapping(string $groupoid, int $cohortid) : bool { * * @return array */ - public function get_mappings() : array { + public function get_mappings(): array { global $DB; $mappings = $DB->get_records('local_o365_objects', ['type' => 'group', 'subtype' => 'cohort']); @@ -151,7 +155,7 @@ public function get_mappings() : array { * @param int $cohortid * @return void */ - public function delete_mapping_by_group_oid_and_cohort_id(string $groupoid, int $cohortid) : void { + public function delete_mapping_by_group_oid_and_cohort_id(string $groupoid, int $cohortid): void { global $DB; $params = ['objectid' => $groupoid, 'moodleid' => $cohortid]; @@ -164,7 +168,7 @@ public function delete_mapping_by_group_oid_and_cohort_id(string $groupoid, int * @param int $id * @return void */ - public function delete_mapping_by_id(int $id) : void { + public function delete_mapping_by_id(int $id): void { global $DB; $params = ['id' => $id]; @@ -177,7 +181,7 @@ public function delete_mapping_by_id(int $id) : void { * This function populates the $this->grouplist with the groups fetched from * the local Moodle cache. */ - public function fetch_groups_from_cache() : void { + public function fetch_groups_from_cache(): void { global $DB; $sql = 'SELECT * @@ -197,7 +201,7 @@ public function fetch_groups_from_cache() : void { /** * Fetch cohorts from the local Moodle cache. */ - public function fetch_cohorts() : void { + public function fetch_cohorts(): void { $systemcontext = context_system::instance(); $systemcohorts = cohort_get_cohorts($systemcontext->id, 0, 0); $this->cohortlist = $systemcohorts['cohorts']; @@ -208,7 +212,7 @@ public function fetch_cohorts() : void { * * @return bool */ - public function update_groups_cache() : bool { + public function update_groups_cache(): bool { global $DB; if (utils::update_groups_cache($this->graphclient, 1)) { @@ -230,7 +234,7 @@ public function update_groups_cache() : bool { * @param int $cohortid * @return void */ - public function sync_members_by_group_oid_and_cohort_id(string $groupoid, int $cohortid) : void { + public function sync_members_by_group_oid_and_cohort_id(string $groupoid, int $cohortid): void { $groupownersandmembers = $this->get_group_owners_and_members($groupoid); if ($groupownersandmembers !== false) { @@ -289,7 +293,7 @@ public function get_group_owners_and_members(string $groupoid) { * @return void */ private function sync_cohort_members_by_cohort_id_and_microsoft_user_objects(int $cohortid, - array $microsoftuserobjects) : void { + array $microsoftuserobjects): void { global $DB; $microsoftuseroids = array_column($microsoftuserobjects, 'id'); @@ -322,7 +326,7 @@ private function sync_cohort_members_by_cohort_id_and_microsoft_user_objects(int * @param array $moodleuserids * @return array */ - private function get_all_potential_user_details(array $microsoftuseroids, array $moodleuserids) : array { + private function get_all_potential_user_details(array $microsoftuseroids, array $moodleuserids): array { global $DB; if (empty($microsoftuseroids) && empty($moodleuserids)) { @@ -366,7 +370,7 @@ private function get_all_potential_user_details(array $microsoftuseroids, array * @param string $groupoid * @return string */ - public function get_group_name_by_group_oid(string $groupoid) : string { + public function get_group_name_by_group_oid(string $groupoid): string { $groupname = ''; foreach ($this->grouplist as $group) { @@ -385,7 +389,7 @@ public function get_group_name_by_group_oid(string $groupoid) : string { * @param int $cohortid * @return string */ - public function get_cohort_name_by_cohort_id(int $cohortid) : string { + public function get_cohort_name_by_cohort_id(int $cohortid): string { $cohortname = ''; if (is_null($this->cohortlist)) { diff --git a/local/o365/classes/feature/courserequest/main.php b/local/o365/classes/feature/courserequest/main.php index d37968506..ebf4ef648 100644 --- a/local/o365/classes/feature/courserequest/main.php +++ b/local/o365/classes/feature/courserequest/main.php @@ -25,8 +25,6 @@ namespace local_o365\feature\courserequest; -defined('MOODLE_INTERNAL') || die(); - use context_course; use core_user; use course_request; @@ -36,9 +34,22 @@ use local_o365\utils; use moodle_exception; use stdClass; + +/** + * Main class for the course request from Microsoft Teams feature. + */ class main { + /** + * @var int The course request status: pending. + */ const COURSE_REQUEST_STATUS_PENDING = 0; + /** + * @var int The course request status: approved. + */ const COURSE_REQUEST_STATUS_APPROVED = 1; + /** + * @var int The course request status: rejected. + */ const COURSE_REQUEST_STATUS_REJECTED = 2; /** @@ -70,7 +81,7 @@ public function __construct(unified $graphclient, bool $debug = false) { * @param string $eol * @return void */ - protected function mtrace(string $msg, int $level = 0, string $eol = "\n") : void { + protected function mtrace(string $msg, int $level = 0, string $eol = "\n"): void { if ($this->debug === true) { if ($level) { $msg = str_repeat('...', $level) . ' ' . $msg; @@ -86,7 +97,7 @@ protected function mtrace(string $msg, int $level = 0, string $eol = "\n") : voi * @param array $teamdata * @return bool */ - public function save_custom_course_request_data(course_request $request, array $teamdata) : bool { + public function save_custom_course_request_data(course_request $request, array $teamdata): bool { global $DB; if (empty($request) || empty($teamdata)) { @@ -197,7 +208,7 @@ public function get_user_team_details_by_team_oid(string $teamoid) { * @param int $courseid * @return bool */ - public function enrol_team_owners_and_members_in_course_by_team_oid_and_course_id(string $teamoid, int $courseid) : bool { + public function enrol_team_owners_and_members_in_course_by_team_oid_and_course_id(string $teamoid, int $courseid): bool { global $DB; if (empty($teamoid) || empty($courseid)) { @@ -246,7 +257,7 @@ public function enrol_team_owners_and_members_in_course_by_team_oid_and_course_i } if ($moodleuser->suspended || $moodleuser->deleted) { mtrace('......... Moodle user matching Microsoft account ' . $teamowner['id'] . ' is suspended or deleted.'); - contrinue; + continue; } if (user_has_role_assignment($userconnectionrecord->moodleid, $ownerroleid, $context->id) && in_array($userconnectionrecord->moodleid, $enrolleduserids)) { @@ -276,7 +287,7 @@ public function enrol_team_owners_and_members_in_course_by_team_oid_and_course_i } if ($moodleuser->suspended || $moodleuser->deleted) { mtrace('......... Moodle user matching Microsoft account ' . $teammember['id'] . ' is suspended or deleted.'); - contrinue; + continue; } if (user_has_role_assignment($userconnectionrecord->moodleid, $memberroleid, $context->id) && in_array($userconnectionrecord->moodleid, $enrolleduserids)) { @@ -300,7 +311,7 @@ public function enrol_team_owners_and_members_in_course_by_team_oid_and_course_i * * @return array */ - private function get_team_owners_and_members_by_team_oid(string $teamoid) : array { + private function get_team_owners_and_members_by_team_oid(string $teamoid): array { $teamowners = []; $teammembers = []; diff --git a/local/o365/classes/feature/coursesync/main.php b/local/o365/classes/feature/coursesync/main.php index 596d674a2..58cb77d4f 100644 --- a/local/o365/classes/feature/coursesync/main.php +++ b/local/o365/classes/feature/coursesync/main.php @@ -33,8 +33,6 @@ use moodle_exception; use stdClass; -defined('MOODLE_INTERNAL') || die(); - define('API_CALL_RETRY_LIMIT', 5); /** @@ -112,14 +110,14 @@ protected function mtrace(string $msg, int $level = 0, string $eol = "\n") { * * @return bool */ - public function has_education_license() : bool { + public function has_education_license(): bool { return $this->haseducationlicense; } /** * Create teams and populate membership for all courses that don't have an associated team recorded. */ - public function sync_courses() : bool { + public function sync_courses(): bool { global $DB; $this->mtrace('Start syncing courses.'); @@ -254,7 +252,7 @@ private function create_education_group(stdClass $course, int $baselevel = 3) { * @param int $baselevel * @return bool */ - public function set_lti_properties_in_education_group(string $groupobjectid, stdClass $course, int $baselevel = 3) : bool { + public function set_lti_properties_in_education_group(string $groupobjectid, stdClass $course, int $baselevel = 3): bool { $this->mtrace('Set LMS attributes in group ' . $groupobjectid . ' for course #' . $course->id, $baselevel); $lmsattributes = [ @@ -346,7 +344,7 @@ private function create_standard_group(stdClass $course, int $baselevel = 3) { * @return bool whether at least one owner was added. */ private function add_group_owners_and_members_to_group(string $groupobjectid, array $owners, array $members, - int $baselevel = 3) : bool { + int $baselevel = 3): bool { global $SESSION; if (empty($owners) && empty($members)) { $this->mtrace('Skip adding owners / members to the group. Reason: No users to add.', $baselevel); @@ -441,7 +439,7 @@ private function add_group_owners_and_members_to_group(string $groupobjectid, ar sleep(10); } try { - $this->mtrace('Chunk ' . $key + 1 . ', adding ' . count($users) . ' users as ' . $role, $baselevel + 1); + $this->mtrace('Chunk ' . ($key + 1) . ', adding ' . count($users) . ' users as ' . $role, $baselevel + 1); if (isset($SESSION->o365_groups_not_exist)) { if (in_array($groupobjectid, $SESSION->o365_groups_not_exist)) { @@ -498,7 +496,7 @@ private function add_group_owners_and_members_to_group(string $groupobjectid, ar * @param string $exceptionmessage * @return bool */ - private static function is_resource_not_exist_exception(string $exceptionmessage) : bool { + private static function is_resource_not_exist_exception(string $exceptionmessage): bool { return (strpos($exceptionmessage, \local_o365\utils::RESOURCE_NOT_EXIST_ERROR) !== false); } @@ -754,7 +752,7 @@ public function install_moodle_app_in_team(string $groupobjectid, int $courseid, * @return string */ private function add_moodle_tab_to_channel(string $groupobjectid, string $channelid, string $appid, - int $moodlecourseid) : string { + int $moodlecourseid): string { global $CFG; $tabconfiguration = [ @@ -837,7 +835,7 @@ private function process_courses_without_groups(int $baselevel = 1) { * @param int $baselevel * @return bool True if group creation succeeds, or False if it fails. */ - public function create_group_for_course(stdClass $course, int $baselevel = 2) : bool { + public function create_group_for_course(stdClass $course, int $baselevel = 2): bool { global $SESSION; $this->mtrace('Process course #' . $course->id, $baselevel); @@ -999,7 +997,7 @@ private function process_courses_without_teams() { * @param array $objectrecmetadata The metadata of the object database record. * @return bool */ - private function restore_group(int $objectrecid, string $objectid, array $objectrecmetadata) : bool { + private function restore_group(int $objectrecid, string $objectid, array $objectrecmetadata): bool { global $DB; $deletedgroups = $this->graphclient->list_deleted_groups(); @@ -1028,7 +1026,7 @@ private function restore_group(int $objectrecid, string $objectid, array $object * * @return bool */ - public function update_teams_cache() : bool { + public function update_teams_cache(): bool { global $DB; $this->mtrace('Update teams cache...'); @@ -1184,7 +1182,7 @@ public function cleanup_course_connection_records() { * * @return bool */ - public function update_team_name(int $courseid) : bool { + public function update_team_name(int $courseid): bool { global $DB; if (!$course = $DB->get_record('course', ['id' => $courseid])) { @@ -1238,7 +1236,7 @@ public function update_team_name(int $courseid) : bool { * @return bool */ public function process_course_reset(stdClass $course, stdClass $o365object, bool $teamexists = false, - bool $createafterreset = true) : bool { + bool $createafterreset = true): bool { global $DB; // Rename existing group. @@ -1477,7 +1475,7 @@ public function process_course_team_user_sync_from_moodle_to_microsoft(int $cour * @return array * @throws moodle_exception */ - public function get_group_members(string $groupobjectid) : array { + public function get_group_members(string $groupobjectid): array { $groupmembers = []; $memberrecords = $this->graphclient->get_group_members($groupobjectid); @@ -1495,7 +1493,7 @@ public function get_group_members(string $groupobjectid) : array { * @return array * @throws moodle_exception */ - public function get_group_owners(string $groupobjectid) : array { + public function get_group_owners(string $groupobjectid): array { $groupowners = []; $ownerresults = $this->graphclient->get_group_owners($groupobjectid); @@ -1511,7 +1509,7 @@ public function get_group_owners(string $groupobjectid) : array { * * @return array An array of group IDs. */ - public function get_all_group_ids() : array { + public function get_all_group_ids(): array { $groupids = []; $groups = $this->graphclient->get_groups(); @@ -1636,6 +1634,7 @@ public function remove_member_from_group(string $groupobjectid, string $userobje $this->graphclient->get_aad_user_conversation_member_id($groupobjectid, $userobjectid); } catch (moodle_exception $e) { // Do nothing. + $removed = false; } if ($aaduserconversationmemberid) { try { @@ -1644,6 +1643,7 @@ public function remove_member_from_group(string $groupobjectid, string $userobje $removed = true; } catch (moodle_exception $e) { // Do nothing. + $removed = false; } } } @@ -1669,6 +1669,7 @@ public function remove_owner_from_group(string $groupobjectid, string $userobjec $this->graphclient->get_aad_user_conversation_member_id($groupobjectid, $userobjectid); } catch (moodle_exception $e) { // Do nothing. + $removed = false; } if ($aaduserconversationmemberid) { try { @@ -1677,6 +1678,7 @@ public function remove_owner_from_group(string $groupobjectid, string $userobjec $removed = true; } catch (moodle_exception $e) { // Do nothing. + $removed = false; } } } @@ -1695,7 +1697,7 @@ public function remove_owner_from_group(string $groupobjectid, string $userobjec * @return bool */ public function process_course_team_user_sync_from_microsoft_to_moodle(int $courseid, string $groupobjectid = '', - array $connectedusers = null) : bool { + ?array $connectedusers = null): bool { global $DB; $coursecontext = context_course::instance($courseid, IGNORE_MISSING); @@ -1785,8 +1787,8 @@ public function process_course_team_user_sync_from_microsoft_to_moodle(int $cour array_keys($moodletomicrosoftusermappings)); // Sync teachers. - // - $connectedcurrentcourseteachers contains the current teachers in the course. - // - $connectedintendedcourseteachers contains the teachers that should be in the course. + // - $connectedcurrentcourseteachers contains the current teachers in the course. + // - $connectedintendedcourseteachers contains the teachers that should be in the course. $teacherstoenrol = array_diff($connectedintendedcourseteachers, $connectedcurrentcourseteachers); if ($teacherstoenrol) { $this->mtrace('Add teacher role to ' . count($teacherstoenrol) . ' users...', 2); @@ -1809,8 +1811,8 @@ public function process_course_team_user_sync_from_microsoft_to_moodle(int $cour } // Sync students. - // - $connectedcurrentcoursestudents contains the current students in the course. - // - $connectedintendedcoursestudents contains the students that should be in the course. + // - $connectedcurrentcoursestudents contains the current students in the course. + // - $connectedintendedcoursestudents contains the students that should be in the course. $studentstoenrol = array_diff($connectedintendedcoursestudents, $connectedcurrentcoursestudents); if ($studentstoenrol) { $this->mtrace('Add student role to ' . count($studentstoenrol) . ' users...', 2); @@ -1842,7 +1844,7 @@ public function process_course_team_user_sync_from_microsoft_to_moodle(int $cour * @param int $roleid The ID of the role. * @param context_course $context The context of the course. */ - private function assign_role_by_user_id_role_id_and_course_context(int $userid, int $roleid, context_course $context) : void { + private function assign_role_by_user_id_role_id_and_course_context(int $userid, int $roleid, context_course $context): void { enrol_try_internal_enrol($context->instanceid, $userid, $roleid); $this->mtrace('Assigned role #' . $roleid . ' to user #' . $userid . '.', 3); } @@ -1857,7 +1859,7 @@ private function assign_role_by_user_id_role_id_and_course_context(int $userid, * @param bool $hasotherrole Whether the user has other role. */ private function unassign_role_by_user_id_role_id_and_course_context(int $userid, int $roleid, context_course $context, - bool $hasotherrole) : void { + bool $hasotherrole): void { role_unassign($roleid, $userid, $context->id); $this->mtrace('Removed role #' . $roleid . ' from user #' . $userid . '.', 3); @@ -1875,7 +1877,7 @@ private function unassign_role_by_user_id_role_id_and_course_context(int $userid * @param int $courseid The ID of the course. * @return bool */ - private function unenrol_user_by_user_id_and_course_id(int $userid, int $courseid) : bool { + private function unenrol_user_by_user_id_and_course_id(int $userid, int $courseid): bool { global $DB; $sql = "SELECT * @@ -1919,7 +1921,7 @@ private function unenrol_user_by_user_id_and_course_id(int $userid, int $coursei * @param int $courseid The ID of the course. * @param string $groupobjectid The object ID of the Microsoft 365 group. */ - public function process_initial_course_team_user_sync(int $courseid, string $groupobjectid) : void { + public function process_initial_course_team_user_sync(int $courseid, string $groupobjectid): void { $coursecontext = context_course::instance($courseid); $this->mtrace('Perform initial Moodle course and Microsoft Teams user sync between course #' . $courseid . @@ -1980,8 +1982,8 @@ public function process_initial_course_team_user_sync(int $courseid, string $gro } // Sync teachers from Microsoft Teams to Moodle course. - // - $connectedcurrentcourseteachers contains the current teachers in the course. - // - $connectedintendedcourseteachers contains the teachers that should be in the course. + // - $connectedcurrentcourseteachers contains the current teachers in the course. + // - $connectedintendedcourseteachers contains the teachers that should be in the course. $teacherstoenrol = array_diff($connectedintendedcourseteachers, $connectedcurrentcourseteachers); if ($teacherstoenrol) { $this->mtrace('Add teacher role to ' . count($teacherstoenrol) . ' users...', 2); @@ -1993,8 +1995,8 @@ public function process_initial_course_team_user_sync(int $courseid, string $gro } // Sync students from Microsoft Teams to Moodle course. - // - $connectedcurrentcoursestudents contains the current students in the course. - // - $connectedintendedcoursestudents contains the students that should be in the course. + // - $connectedcurrentcoursestudents contains the current students in the course. + // - $connectedintendedcoursestudents contains the students that should be in the course. $studentstoenrol = array_diff($connectedintendedcoursestudents, $connectedcurrentcoursestudents); if ($studentstoenrol) { $this->mtrace('Add student role to ' . count($studentstoenrol) . ' users...', 2); @@ -2025,7 +2027,7 @@ public function process_initial_course_team_user_sync(int $courseid, string $gro * * @return void */ - public function save_not_found_groups() : void { + public function save_not_found_groups(): void { global $DB, $SESSION; $this->mtrace('Save non-existing groups to groups cache...'); diff --git a/local/o365/classes/feature/coursesync/observers.php b/local/o365/classes/feature/coursesync/observers.php index 3f2b110a8..ba2d38568 100644 --- a/local/o365/classes/feature/coursesync/observers.php +++ b/local/o365/classes/feature/coursesync/observers.php @@ -46,7 +46,7 @@ class observers { * @param course_reset_started $event * @return bool */ - public static function handle_course_reset_started(course_reset_started $event) : bool { + public static function handle_course_reset_started(course_reset_started $event): bool { global $CFG, $DB; if (!\local_o365\utils::is_connected()) { @@ -88,6 +88,7 @@ public static function handle_course_reset_started(course_reset_started $event) } } catch (moodle_exception $e) { // Do nothing. + $connectedtoteam = false; } } } else { diff --git a/local/o365/classes/feature/coursesync/utils.php b/local/o365/classes/feature/coursesync/utils.php index 1478ae10e..59d58a157 100644 --- a/local/o365/classes/feature/coursesync/utils.php +++ b/local/o365/classes/feature/coursesync/utils.php @@ -46,7 +46,7 @@ class utils { * * @return bool True if group creation is enabled. False otherwise. */ - public static function is_enabled() : bool { + public static function is_enabled(): bool { $coursesyncsetting = get_config('local_o365', 'coursesync'); return $coursesyncsetting === 'oncustom' || $coursesyncsetting === 'onall'; } @@ -103,7 +103,7 @@ public static function get_enabled_courses(bool $returnallids = false) { * @param int $courseid The Moodle course ID to check. * @return bool Whether the course is enabled for sync. */ - public static function is_course_sync_enabled(int $courseid) : bool { + public static function is_course_sync_enabled(int $courseid): bool { $coursesyncsetting = get_config('local_o365', 'coursesync'); if ($coursesyncsetting === 'onall') { return true; @@ -170,7 +170,7 @@ public static function get_o365_object(int $courseid) { * @param int $courseid * @return string[]|null */ - public static function get_course_microsoft_365_urls(int $courseid) : ?array { + public static function get_course_microsoft_365_urls(int $courseid): ?array { $object = static::get_o365_object($courseid); if (empty($object->objectid)) { return null; @@ -267,7 +267,7 @@ public static function set_course_sync_enabled(int $courseid, bool $enabled = tr * @param string $currentoid * @return array */ - public static function get_matching_team_options(string $currentoid = '') : array { + public static function get_matching_team_options(string $currentoid = ''): array { global $DB; $teamsoptions = []; @@ -316,11 +316,11 @@ public static function get_matching_team_options(string $currentoid = '') : arra * * @param stdClass $course * @param string $forcedprefix - * @param stdClass $group + * @param stdClass|null $group * * @return string */ - public static function get_team_display_name(stdClass $course, string $forcedprefix = '', stdClass $group = null) { + public static function get_team_display_name(stdClass $course, string $forcedprefix = '', ?stdClass $group = null) { if ($forcedprefix) { $teamdisplayname = $forcedprefix; } else { @@ -367,7 +367,7 @@ public static function get_team_display_name(stdClass $course, string $forcedpre * * @return array */ - public static function get_sample_team_group_names() : array { + public static function get_sample_team_group_names(): array { $teamgroupamesamplecourse = static::get_team_group_name_sample_course(); return [static::get_team_display_name($teamgroupamesamplecourse), static::get_group_mail_alias($teamgroupamesamplecourse)]; @@ -380,7 +380,7 @@ public static function get_sample_team_group_names() : array { * * @return string */ - public static function get_group_mail_alias(stdClass $course) : string { + public static function get_group_mail_alias(stdClass $course): string { $groupmailaliasprefix = get_config('local_o365', 'group_mail_alias_prefix'); if ($groupmailaliasprefix) { $groupmailaliasprefix = static::clean_up_group_mail_alias($groupmailaliasprefix); @@ -428,7 +428,7 @@ public static function get_group_mail_alias(stdClass $course) : string { public static function clean_up_group_mail_alias(string $mailalias) { $notallowedbasicchars = ['@', '(', ')', "\\", '[', ']', '"', ';', ':', '.', '<', '>', ' ']; $chars = preg_split( '//u', $mailalias, -1, PREG_SPLIT_NO_EMPTY); - foreach($chars as $key => $char){ + foreach ($chars as $key => $char) { $charorder = ord($char); if ($charorder < 0 || $charorder > 127 || in_array($char, $notallowedbasicchars)) { unset($chars[$key]); @@ -443,7 +443,7 @@ public static function clean_up_group_mail_alias(string $mailalias) { * * @return stdClass */ - public static function get_team_group_name_sample_course() : stdClass { + public static function get_team_group_name_sample_course(): stdClass { $samplecourse = new stdClass(); $samplecourse->fullname = 'Sample course 15'; $samplecourse->shortname = 'sample 15'; @@ -459,7 +459,7 @@ public static function get_team_group_name_sample_course() : stdClass { * @param array $userids * @return array */ - public static function get_user_object_ids_by_user_ids(array $userids) : array { + public static function get_user_object_ids_by_user_ids(array $userids): array { global $DB; if ($userids) { @@ -540,7 +540,7 @@ public static function get_user_object_record_id_by_user_id(int $userid) { * @param int $courseid * @return array */ - public static function get_team_owner_object_ids_by_course_id(int $courseid) : array { + public static function get_team_owner_object_ids_by_course_id(int $courseid): array { $teamownerobjectids = []; $teamowneruserids = static::get_team_owner_user_ids_by_course_id($courseid); if ($teamowneruserids) { @@ -556,7 +556,7 @@ public static function get_team_owner_object_ids_by_course_id(int $courseid) : a * @param int $courseid ID of Moodle course * @return array array containing IDs of teachers. */ - public static function get_team_owner_user_ids_by_course_id(int $courseid) : array { + public static function get_team_owner_user_ids_by_course_id(int $courseid): array { $context = context_course::instance($courseid); $teamownerusers = get_enrolled_users($context, 'local/o365:teamowner', 0, 'u.*', null, 0, 0, true); $teamowneruserids = []; @@ -576,7 +576,7 @@ public static function get_team_owner_user_ids_by_course_id(int $courseid) : arr * @param array $teamownerobjectids * @return array */ - public static function get_team_member_object_ids_by_course_id(int $courseid, array $teamownerobjectids = []) : array { + public static function get_team_member_object_ids_by_course_id(int $courseid, array $teamownerobjectids = []): array { $teammemberobjectids = []; $teammemberuserids = static::get_team_member_user_ids_by_course_id($courseid); if ($teammemberuserids) { @@ -594,7 +594,7 @@ public static function get_team_member_object_ids_by_course_id(int $courseid, ar * @param int $courseid ID of the Moodle course * @return array */ - public static function get_team_member_user_ids_by_course_id(int $courseid) : array { + public static function get_team_member_user_ids_by_course_id(int $courseid): array { $context = context_course::instance($courseid); $teammemberusers = get_enrolled_users($context, 'local/o365:teammember', 0, 'u.*', null, 0, 0, true); $teammemberuserids = []; @@ -614,7 +614,7 @@ public static function get_team_member_user_ids_by_course_id(int $courseid) : ar * @param array $members * @return array */ - public static function arrange_group_users_in_chunks(array $owners, array $members) : array { + public static function arrange_group_users_in_chunks(array $owners, array $members): array { $userchunks = []; $ownerchunks = array_chunk($owners, 20); @@ -686,6 +686,7 @@ public static function migrate_existing_groups() { } } catch (moodle_exception $e) { // Cannot get graph client, nothing to do. + return; } } @@ -698,7 +699,7 @@ public static function migrate_existing_groups() { * @param int $excluderoleid * @return string */ - public static function get_user_group_role_by_moodle_ids(int $userid, int $courseid, int $excluderoleid = 0) : string { + public static function get_user_group_role_by_moodle_ids(int $userid, int $courseid, int $excluderoleid = 0): string { $grouprole = ''; $coursecontext = context_course::instance($courseid); @@ -737,7 +738,7 @@ public static function get_user_group_role_by_moodle_ids(int $userid, int $cours * @return bool */ public static function sync_user_role_in_course_group(int $userid, int $courseid, int $userobjectrecordid = 0, - int $coursegroupobjectrecordid = 0, bool $sdscoursechecked = false, int $excluderoleid = 0) : bool { + int $coursegroupobjectrecordid = 0, bool $sdscoursechecked = false, int $excluderoleid = 0): bool { global $DB; if (empty($userid) || empty($courseid)) { @@ -777,8 +778,8 @@ public static function sync_user_role_in_course_group(int $userid, int $courseid $grouprole = static::get_user_group_role_by_moodle_ids($userid, $courseid, $excluderoleid); // Get group and user object IDs. - $groupobjectid = utils::get_object_id_by_record_id($coursegroupobjectrecordid); - $userobjectid = utils::get_object_id_by_record_id($userobjectrecordid); + $groupobjectid = static::get_object_id_by_record_id($coursegroupobjectrecordid); + $userobjectid = static::get_object_id_by_record_id($userobjectrecordid); // If the user doesn't have any group role, remove the user from the connected group. if (!$grouprole) { @@ -835,7 +836,7 @@ public static function sync_user_role_in_course_group(int $userid, int $courseid * @param string $groupobjectid * @return bool */ - public static function is_team_created_from_group(string $groupobjectid) : bool { + public static function is_team_created_from_group(string $groupobjectid): bool { global $DB; return $DB->record_exists('local_o365_objects', diff --git a/local/o365/classes/feature/sds/task/sync.php b/local/o365/classes/feature/sds/task/sync.php index bc37ef7dc..d90d4bfb5 100644 --- a/local/o365/classes/feature/sds/task/sync.php +++ b/local/o365/classes/feature/sds/task/sync.php @@ -33,8 +33,6 @@ use local_o365\utils; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Scheduled task to run SDS sync. */ @@ -44,7 +42,7 @@ class sync extends scheduled_task { * * @return string */ - public function get_name() : string { + public function get_name(): string { return get_string('task_sds_sync', 'local_o365'); } @@ -54,7 +52,7 @@ public function get_name() : string { * @param unified $apiclient The unified API client. * @return bool */ - public static function runsync(unified $apiclient) : bool { + public static function runsync(unified $apiclient): bool { global $DB, $CFG; require_once($CFG->dirroot . '/user/lib.php'); @@ -438,7 +436,7 @@ public static function mtrace(string $str, int $level = 0) { * @return object The course object. */ public static function get_or_create_class_course(string $classobjectid, string $shortname, string $fullname, - int $categoryid = 0) : object { + int $categoryid = 0): object { global $DB, $CFG; require_once($CFG->dirroot . '/course/lib.php'); @@ -458,12 +456,12 @@ public static function get_or_create_class_course(string $classobjectid, string } // Create new course category and object record. - $data = ['category' => $categoryid, 'shortname' => $shortname, 'fullname' => $fullname, 'idnumber' => $classobjectid,]; + $data = ['category' => $categoryid, 'shortname' => $shortname, 'fullname' => $fullname, 'idnumber' => $classobjectid]; $course = create_course((object) $data); $now = time(); $objectrec = ['type' => 'sdssection', 'subtype' => 'course', 'objectid' => $classobjectid, 'moodleid' => $course->id, - 'o365name' => $shortname, 'tenant' => '', 'timecreated' => $now, 'timemodified' => $now,]; + 'o365name' => $shortname, 'tenant' => '', 'timecreated' => $now, 'timemodified' => $now]; $DB->insert_record('local_o365_objects', $objectrec); return $course; @@ -476,7 +474,7 @@ public static function get_or_create_class_course(string $classobjectid, string * @param string $schoolname The name of the school. * @return core_course_category A course category object for the retrieved or created course category. */ - public static function get_or_create_school_coursecategory(string $schoolobjectid, string $schoolname) : core_course_category { + public static function get_or_create_school_coursecategory(string $schoolobjectid, string $schoolname): core_course_category { global $DB; // Look for existing category. @@ -494,7 +492,7 @@ public static function get_or_create_school_coursecategory(string $schoolobjecti } // Create new course category and object record. - $data = ['visible' => 1, 'name' => $schoolname, 'idnumber' => $schoolobjectid,]; + $data = ['visible' => 1, 'name' => $schoolname, 'idnumber' => $schoolobjectid]; if (strlen($data['name']) > 255) { static::mtrace('School name was over 255 chars when creating course category, truncating to 255.'); $data['name'] = substr($data['name'], 0, 255); @@ -504,7 +502,7 @@ public static function get_or_create_school_coursecategory(string $schoolobjecti $now = time(); $objectrec = ['type' => 'sdsschool', 'subtype' => 'coursecat', 'objectid' => $schoolobjectid, 'moodleid' => $coursecat->id, - 'o365name' => $schoolname, 'tenant' => '', 'timecreated' => $now, 'timemodified' => $now,]; + 'o365name' => $schoolname, 'tenant' => '', 'timecreated' => $now, 'timemodified' => $now]; $DB->insert_record('local_o365_objects', $objectrec); return $coursecat; @@ -515,7 +513,7 @@ public static function get_or_create_school_coursecategory(string $schoolobjecti * * @return bool */ - public function execute() : bool { + public function execute(): bool { if (utils::is_connected() !== true) { static::mtrace('local_o365 reported unconfigured during SDS sync task, so exiting.'); return false; @@ -573,6 +571,7 @@ public static function clean_up_sds_sync_records() { $sectionsinenabledschools = array_merge($sectionsinenabledschools, $schoolclasses); } catch (moodle_exception $e) { // Do nothing. + static::mtrace('Error getting school classes. Details: ' . $e->getMessage(), 2); } } foreach ($sectionsinenabledschools as $sectionsinenabledschool) { diff --git a/local/o365/classes/feature/sds/utils.php b/local/o365/classes/feature/sds/utils.php index 9a4bfd22a..da20c9472 100644 --- a/local/o365/classes/feature/sds/utils.php +++ b/local/o365/classes/feature/sds/utils.php @@ -43,7 +43,7 @@ class utils { * * @return unified|null The SDS API client. */ - public static function get_apiclient() : ?unified { + public static function get_apiclient(): ?unified { $httpclient = new httpclient(); try { $clientdata = clientdata::instance_from_oidc(); @@ -69,7 +69,7 @@ public static function get_apiclient() : ?unified { * @param unified|null $apiclient * @return array */ - public static function get_profile_sync_status_with_id_name(unified $apiclient = null) : array { + public static function get_profile_sync_status_with_id_name(?unified $apiclient = null): array { $profilesyncenabled = false; $schoolid = ''; $schoolname = ''; @@ -112,7 +112,7 @@ public static function get_profile_sync_status_with_id_name(unified $apiclient = * * @return array[] */ - public static function get_sds_profile_sync_api_requirements() : array { + public static function get_sds_profile_sync_api_requirements(): array { $idandnamemappings = []; $additionalprofilemappings = []; diff --git a/local/o365/classes/feature/userconnections/filtering.php b/local/o365/classes/feature/userconnections/filtering.php index 8c2f31cc0..c5af3ae5b 100644 --- a/local/o365/classes/feature/userconnections/filtering.php +++ b/local/o365/classes/feature/userconnections/filtering.php @@ -80,13 +80,13 @@ public function get_field($fieldname, $advanced) { * Returns sql where statement based on active user filters. * * @param string $extra sql - * @param array $params named params (recommended prefix ex) + * @param array|null $params named params (recommended prefix ex) * @return array sql string and $params */ - public function get_sql_filter($extra='', array $params=null) { + public function get_sql_filter($extra='', ?array $params=null) { global $SESSION; - $sqls = array(); + $sqls = []; if ($extra != '') { $sqls[] = $extra; } @@ -102,7 +102,7 @@ public function get_sql_filter($extra='', array $params=null) { } $field = $this->_fields[$fname]; foreach ($datas as $i => $data) { - list($s, $p) = $field->get_sql_filter($data); + [$s, $p] = $field->get_sql_filter($data); $sqls[] = $s; $params = $params + $p; } @@ -131,7 +131,7 @@ public function get_filter_o365username() { $datas = $SESSION->user_filtering[$fname]; $field = $this->_fields[$fname]; foreach ($datas as $i => $data) { - list($s, $p) = $field->get_sql_filter($data); + [$s, $p] = $field->get_sql_filter($data); $sqls[] = $s; $params = $params + $p; } diff --git a/local/o365/classes/feature/usersync/main.php b/local/o365/classes/feature/usersync/main.php index 3abe97929..5a0826569 100644 --- a/local/o365/classes/feature/usersync/main.php +++ b/local/o365/classes/feature/usersync/main.php @@ -68,7 +68,7 @@ class main { * * @throws moodle_exception */ - public function __construct(clientdata $clientdata = null, httpclient $httpclient = null) { + public function __construct(?clientdata $clientdata = null, ?httpclient $httpclient = null) { if (!PHPUNIT_TEST && !defined('BEHAT_SITE_RUNNING')) { $this->clientdata = (!empty($clientdata)) ? $clientdata @@ -190,7 +190,7 @@ public function assign_photo(int $muserid) { // User has no photo. Deleting previous profile photo. $fs = \get_file_storage(); $fs->delete_area_files($context->id, 'user', 'icon'); - $DB->set_field('user', 'picture', 0, array('id' => $muser->id)); + $DB->set_field('user', 'picture', 0, ['id' => $muser->id]); } $result = false; } else { @@ -234,7 +234,7 @@ public function assign_photo(int $muserid) { // User has no photo. Deleting previous profile photo. $fs = \get_file_storage(); $fs->delete_area_files($context->id, 'user', 'icon'); - $DB->set_field('user', 'picture', 0, array('id' => $muser->id)); + $DB->set_field('user', 'picture', 0, ['id' => $muser->id]); } } } @@ -563,7 +563,8 @@ public static function apply_configured_fieldmap(array $entraiduserdata, stdClas if (isset($countrymap[$incoming])) { $countrycode = $incoming; } else { - $countrycode = array_search($entraiduserdata[$remotefield], get_string_manager()->get_list_of_countries()); + $countrycode = array_search($entraiduserdata[$remotefield], + get_string_manager()->get_list_of_countries()); } $user->$localfield = (!empty($countrycode)) ? $countrycode : ''; break; @@ -803,7 +804,7 @@ protected function check_usercreationrestriction($entraiduserdata) { return false; } else { - utils:debug('Invalid extension attribute ID', __METHOD__); + utils::debug('Invalid extension attribute ID', __METHOD__); return false; } } else { @@ -1012,7 +1013,7 @@ public static function sync_option_enabled($option) { * @param string $bindingusernameclaim * @return bool Success/Failure */ - public function sync_users(array $entraidusers = array(), string $bindingusernameclaim = 'userPrincipalName') { + public function sync_users(array $entraidusers = [], string $bindingusernameclaim = 'userPrincipalName') { global $DB, $CFG; $usersyncsettings = $this->get_sync_options(); @@ -1158,7 +1159,8 @@ public function sync_users(array $entraidusers = array(), string $bindingusernam LEFT JOIN {local_o365_connections} conn ON conn.muserid = u.id LEFT JOIN {local_o365_appassign} assign ON assign.muserid = u.id LEFT JOIN {local_o365_objects} obj ON obj.type = ? AND obj.moodleid = u.id - WHERE tok.oidcusername '.$useridentifiersql.' AND u.username '.$usernamesql.' AND u.mnethostid = ? AND u.deleted = ? '; + WHERE tok.oidcusername ' . $useridentifiersql . ' AND u.username ' . $usernamesql . ' AND u.mnethostid = ? + AND u.deleted = ? '; $params = array_merge(['user'], $useridentifierparams, $usernameparams, [$CFG->mnet_localhost_id, '0']); $linkedexistingusers = $DB->get_records_sql($sql, $params); @@ -1258,7 +1260,8 @@ public function sync_users(array $entraidusers = array(), string $bindingusernam $existinguserrecord->suspended = $renamedmoodleuser->suspended; $existinguserrecord->auth = $renamedmoodleuser->auth; - $connected = $this->sync_existing_user($usersyncsettings, $entraiduser, $existinguserrecord, $exactmatch); + $connected = $this->sync_existing_user($usersyncsettings, $entraiduser, $existinguserrecord, + $exactmatch); $existinguser = $renamedmoodleuser; } } else { @@ -1281,7 +1284,8 @@ public function sync_users(array $entraidusers = array(), string $bindingusernam if (isset($entraiduser['id']) && $entraiduser['id'] && $existingusermatching = $DB->get_record('local_o365_objects', ['type' => 'user', 'objectid' => $entraiduser['id']])) { - $possibleo365names = [$entraiduser['useridentifierlower'], $entraiduser['convertedidentifier'], $entraiduser['useridentifier']]; + $possibleo365names = [$entraiduser['useridentifierlower'], $entraiduser['convertedidentifier'], + $entraiduser['useridentifier']]; if (isset($entraiduser['upnsplit0'])) { $possibleo365names[] = $entraiduser['upnsplit0']; } @@ -1321,7 +1325,8 @@ public function sync_users(array $entraidusers = array(), string $bindingusernam $DB->update_record('local_o365_objects', $existingusermatching); // Update token record. - if ($existingtoken = $DB->get_record('auth_oidc_token', ['userid' => $renamedmoodleuser->id])) { + if ($existingtoken = $DB->get_record('auth_oidc_token', + ['userid' => $renamedmoodleuser->id])) { $existingtoken->useridentifier = $entraiduser['useridentifier']; $existingtoken->username = $username; $DB->update_record('auth_oidc_token', $existingtoken); @@ -1607,7 +1612,8 @@ protected function sync_existing_user($syncoptions, $entraiduserdata, $existingu // Match user if needed. if ($existinguser->auth !== 'oidc') { $this->mtrace('Found a user in Microsoft Entra ID that seems to match a user in Moodle'); - $this->mtrace(sprintf('moodle username: %s, Entra ID user identifier: %s', $existinguser->username, $entraiduserdata['useridentifierlower'])); + $this->mtrace(sprintf('moodle username: %s, Entra ID user identifier: %s', $existinguser->username, + $entraiduserdata['useridentifierlower'])); return $this->sync_users_matchuser($syncoptions, $entraiduserdata, $existinguser, $exactmatch); } else { $this->mtrace('The user is already using OIDC for authentication.'); diff --git a/local/o365/classes/form/cohortsync.php b/local/o365/classes/form/cohortsync.php index feb0d7c61..47be34d53 100644 --- a/local/o365/classes/form/cohortsync.php +++ b/local/o365/classes/form/cohortsync.php @@ -43,7 +43,7 @@ class cohortsync extends moodleform { /** * Define the form elements. */ - public function definition() : void { + public function definition(): void { $mform = $this->_form; $cohortsyncmain = $this->_customdata['cohortsyncmain']; diff --git a/local/o365/classes/form/courserequestform.php b/local/o365/classes/form/courserequestform.php index 2e3767f89..6a823e8b6 100644 --- a/local/o365/classes/form/courserequestform.php +++ b/local/o365/classes/form/courserequestform.php @@ -44,7 +44,7 @@ class courserequestform extends course_request_form { * * @return void */ - function definition() { + public function definition() { global $CFG, $DB, $USER; $mform =& $this->_form; @@ -108,7 +108,7 @@ function definition() { $select = $mform->addElement('select', 'team', get_string('courserequest_teams', 'local_o365'), []); $mform->addHelpButton('team', 'courserequest_teams', 'local_o365'); - // Populate the select element based on the availability of unmatched teams + // Populate the select element based on the availability of unmatched teams. if (!empty($unmatchedteams)) { foreach ($unmatchedteams as $unmatchedteam) { $select->addOption($unmatchedteam['displayName'], $unmatchedteam['id']); @@ -118,7 +118,7 @@ function definition() { $mform->disabledIf('team', '', 'eq', ''); } - // Add client-side validation + // Add client-side validation. $mform->addRule('team', get_string('courserequest_emptyteams', 'local_o365'), 'required', null, 'client'); } } @@ -144,11 +144,11 @@ function definition() { /** * Custom validation function. * - * @param $data - * @param $files + * @param array $data + * @param array $files * @return array */ - public function validation($data, $files) : array { + public function validation($data, $files): array { global $DB; $errors = parent::validation($data, $files); diff --git a/local/o365/classes/form/teamstabconfiguration.php b/local/o365/classes/form/teamstabconfiguration.php index edf876021..0083f5b6b 100644 --- a/local/o365/classes/form/teamstabconfiguration.php +++ b/local/o365/classes/form/teamstabconfiguration.php @@ -52,7 +52,7 @@ public function definition() { if ($courseoptions) { // User can access at least one course, show tab name field and course selector. $mform->addElement('text', 'local_o365_teams_tab_name', get_string('tab_name', 'local_o365'), - array('onchange' => 'onTabNameChange()')); + ['onchange' => 'onTabNameChange()']); $mform->setType('local_o365_teams_tab_name', PARAM_TEXT); $tabname = get_config('local_o365', 'teams_moodle_tab_name'); if (!$tabname) { @@ -62,7 +62,7 @@ public function definition() { $courseselector = $mform->createElement('select', 'local_o365_teams_course', get_string('course_selector_label', 'local_o365'), - $courseoptions, array('onchange' => 'onCourseChange()')); + $courseoptions, ['onchange' => 'onCourseChange()']); $courseselector->setSize(100); $courseselector->setMultiple(true); @@ -84,7 +84,7 @@ public function definition() { private function get_course_options() { global $DB, $USER; - $courseoptions = array(); + $courseoptions = []; if (is_siteadmin($USER->id)) { $courses = $DB->get_records('course', ['visible' => 1]); diff --git a/local/o365/classes/healthcheck/healthcheckinterface.php b/local/o365/classes/healthcheck/healthcheckinterface.php index d23e8d028..67696189c 100644 --- a/local/o365/classes/healthcheck/healthcheckinterface.php +++ b/local/o365/classes/healthcheck/healthcheckinterface.php @@ -25,15 +25,25 @@ namespace local_o365\healthcheck; -defined('MOODLE_INTERNAL') || die(); - /** * Interface for all health checks. */ interface healthcheckinterface { + /** + * @var int SEVERITY_OK + */ const SEVERITY_OK = 0; + /** + * @var int SEVERITY_TRIVIAL + */ const SEVERITY_TRIVIAL = 1; + /** + * @var int SEVERITY_WARNING + */ const SEVERITY_WARNING = 2; + /** + * @var int SEVERITY_FATAL + */ const SEVERITY_FATAL = 3; /** diff --git a/local/o365/classes/healthcheck/ratelimit.php b/local/o365/classes/healthcheck/ratelimit.php index d56cf56e7..df8ba941c 100644 --- a/local/o365/classes/healthcheck/ratelimit.php +++ b/local/o365/classes/healthcheck/ratelimit.php @@ -25,8 +25,6 @@ namespace local_o365\healthcheck; -defined('MOODLE_INTERNAL') || die(); - /** * Checks current recorded rate limit */ diff --git a/local/o365/classes/httpclient.php b/local/o365/classes/httpclient.php index e67ab1535..4780cd53c 100644 --- a/local/o365/classes/httpclient.php +++ b/local/o365/classes/httpclient.php @@ -26,24 +26,26 @@ namespace local_o365; +use curl; use moodle_exception; +use stdClass; defined('MOODLE_INTERNAL') || die(); global $CFG; -require_once($CFG->dirroot.'/lib/filelib.php'); +require_once($CFG->dirroot . '/lib/filelib.php'); /** * An httpclientinterface implementation, using curl class as backend and adding patch and merge methods. */ -class httpclient extends \curl implements \local_o365\httpclientinterface { +class httpclient extends curl implements httpclientinterface { /** - * Generate a client tag. + * Generate client tag headers. * - * @return string A client tag. + * @return string[] */ - protected function get_clienttag_headers() { + protected function get_clienttag_headers(): array { global $CFG; $iid = sha1($CFG->wwwroot); @@ -55,9 +57,10 @@ protected function get_clienttag_headers() { $params = "lang=PHP; os={$ostype}; os_version={$osver}; arch={$arch}; version={$ver}; MoodleInstallId={$iid}"; $clienttag = "Moodle/{$mdlver} ({$params})"; + return [ - 'User-Agent: '.$clienttag, - 'X-ClientService-ClientTag: '.$clienttag, + 'User-Agent: ' . $clienttag, + 'X-ClientService-ClientTag: ' . $clienttag, ]; } @@ -66,10 +69,12 @@ protected function get_clienttag_headers() { * * @return string The current plugin version. */ - protected function get_plugin_version() { + protected function get_plugin_version(): string { global $CFG; - $plugin = new \stdClass; - require_once($CFG->dirroot.'/local/o365/version.php'); + + $plugin = new stdClass; + require_once($CFG->dirroot . '/local/o365/version.php'); + return $plugin->release; } @@ -78,8 +83,9 @@ protected function get_plugin_version() { * * @return string The current Moodle version. */ - protected function get_moodle_version() { + protected function get_moodle_version(): string { global $CFG; + return $CFG->release; } @@ -91,11 +97,11 @@ protected function get_moodle_version() { * @param array $options * @return bool */ - public function patch($url, $params = '', $options = array()) { + public function patch($url, $params = '', $options = []): bool { $options['CURLOPT_CUSTOMREQUEST'] = 'PATCH'; if (is_array($params)) { - $this->_tmp_file_post_params = array(); + $this->_tmp_file_post_params = []; foreach ($params as $key => $value) { if ($value instanceof stored_file) { $value->add_to_curl_request($this, $key); @@ -109,6 +115,7 @@ public function patch($url, $params = '', $options = array()) { // Var $params is the raw post data. $options['CURLOPT_POSTFIELDS'] = $params; } + return $this->request($url, $options); } @@ -120,11 +127,11 @@ public function patch($url, $params = '', $options = array()) { * @param array $options * @return bool */ - public function merge($url, $params = '', $options = array()) { + public function merge($url, $params = '', $options = []): bool { $options['CURLOPT_CUSTOMREQUEST'] = 'MERGE'; if (is_array($params)) { - $this->_tmp_file_post_params = array(); + $this->_tmp_file_post_params = []; foreach ($params as $key => $value) { if ($value instanceof stored_file) { $value->add_to_curl_request($this, $key); @@ -138,6 +145,7 @@ public function merge($url, $params = '', $options = array()) { // Var $params is the raw post data. $options['CURLOPT_POSTFIELDS'] = $params; } + return $this->request($url, $options); } @@ -149,7 +157,7 @@ public function merge($url, $params = '', $options = array()) { * @param array $options * @return bool */ - public function put($url, $params = array(), $options = array()) { + public function put($url, $params = [], $options = []): bool { if (!isset($params['file'])) { throw new moodle_exception('errorhttpclientnofileinput', 'local_o365'); } @@ -168,12 +176,10 @@ public function put($url, $params = array(), $options = array()) { $options['CURLOPT_PUT'] = 1; $options['CURLOPT_INFILESIZE'] = $size; $options['CURLOPT_INFILE'] = $fp; - if (!isset($this->options['CURLOPT_USERPWD'])) { - $this->setopt(array('CURLOPT_USERPWD' => 'anonymous: noreply@moodle.org')); - } $ret = $this->request($url, $options); fclose($fp); + return $ret; } @@ -184,8 +190,9 @@ public function put($url, $params = array(), $options = array()) { * @param array $options * @return bool */ - public function download_file($url, $options = array()) { - $url = str_replace(array('+', ' '), '%20', $url); + public function download_file($url, $options = []): bool { + $url = str_replace(['+', ' '], '%20', $url); + return $this->request($url, $options); } } diff --git a/local/o365/classes/httpclientinterface.php b/local/o365/classes/httpclientinterface.php index 0037bb511..aa5b186bf 100644 --- a/local/o365/classes/httpclientinterface.php +++ b/local/o365/classes/httpclientinterface.php @@ -25,41 +25,39 @@ namespace local_o365; -defined('MOODLE_INTERNAL') || die(); - /** * HTTP Client Interface. */ interface httpclientinterface { - /** - * HTTP POST method - * - * @param string $url - * @param array|string $params - * @param array $options - * @return bool - */ - public function post($url, $params = '', $options = array()); + /** + * HTTP POST method + * + * @param string $url + * @param array|string $params + * @param array $options + * @return bool + */ + public function post($url, $params = '', $options = []); - /** - * HTTP GET method - * - * @param string $url - * @param array $params - * @param array $options - * @return bool - */ - public function get($url, $params = array(), $options = array()); + /** + * HTTP GET method + * + * @param string $url + * @param array $params + * @param array $options + * @return bool + */ + public function get($url, $params = [], $options = []); - /** - * HTTP PATCH method - * - * @param string $url - * @param array|string $params - * @param array $options - * @return bool - */ - public function patch($url, $params = '', $options = array()); + /** + * HTTP PATCH method + * + * @param string $url + * @param array|string $params + * @param array $options + * @return bool + */ + public function patch($url, $params = '', $options = []); /** * HTTP DELETE method @@ -69,7 +67,7 @@ public function patch($url, $params = '', $options = array()); * @param array $options * @return bool */ - public function delete($url, $param = array(), $options = array()); + public function delete($url, $param = [], $options = []); /** * Set HTTP Request Header @@ -78,8 +76,8 @@ public function delete($url, $param = array(), $options = array()); */ public function setheader($header); - /** - * Resets the HTTP Request headers (to prepare for the new request) - */ + /** + * Resets the HTTP Request headers (to prepare for the new request) + */ public function resetheader(); } diff --git a/local/o365/classes/oauth2/apptoken.php b/local/o365/classes/oauth2/apptoken.php index 0e29e25cb..32fdd531f 100644 --- a/local/o365/classes/oauth2/apptoken.php +++ b/local/o365/classes/oauth2/apptoken.php @@ -111,7 +111,7 @@ public static function get_app_token($tokenresource, \local_o365\oauth2\clientda $params = http_build_query($params, '', '&'); $header = [ 'Content-Type: application/x-www-form-urlencoded', - 'Content-Length: '.strlen($params) + 'Content-Length: ' . strlen($params), ]; $httpclient->resetheader(); $httpclient->setheader($header); @@ -133,7 +133,7 @@ public static function get_app_token($tokenresource, \local_o365\oauth2\clientda } $debuginfo = [ 'tokenresult' => $tokenresult, - 'resource' => $tokenresource + 'resource' => $tokenresource, ]; \local_o365\utils::debug($errmsg, __METHOD__, $debuginfo); return false; @@ -168,7 +168,7 @@ public function refresh() { 'scope' => $this->scope, 'token' => $this->token, 'expiry' => $this->expiry, - 'tokenresource' => $this->tokenresource + 'tokenresource' => $this->tokenresource, ]; $this->update_stored_token($existingtoken, $newtoken); } else { diff --git a/local/o365/classes/oauth2/clientdata.php b/local/o365/classes/oauth2/clientdata.php index c9721f760..4fe54a2cc 100644 --- a/local/o365/classes/oauth2/clientdata.php +++ b/local/o365/classes/oauth2/clientdata.php @@ -47,7 +47,7 @@ class clientdata { /** @var string The token endpoint URI. */ protected $tokenendpoint; - /** @var boolean The app-only token endpoint URI. */ + /** @var bool The app-only token endpoint URI. */ protected $apptokenendpoint = false; /** diff --git a/local/o365/classes/oauth2/token.php b/local/o365/classes/oauth2/token.php index 1d6b98b0f..961b9a81a 100644 --- a/local/o365/classes/oauth2/token.php +++ b/local/o365/classes/oauth2/token.php @@ -27,8 +27,6 @@ use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Represents an oauth2 token. */ @@ -207,7 +205,7 @@ public static function jump_tokenresource(\local_o365\oauth2\token $token, $newt $header = [ 'Content-Type: application/x-www-form-urlencoded', - 'Content-Length: '.strlen($params) + 'Content-Length: ' . strlen($params), ]; $httpclient->resetheader(); $httpclient->setheader($header); @@ -260,7 +258,7 @@ public static function get_for_new_resource($userid, $tokenresource, \local_o365 $header = [ 'Content-Type: application/x-www-form-urlencoded', - 'Content-Length: '.strlen($params) + 'Content-Length: ' . strlen($params), ]; $httpclient->resetheader(); $httpclient->setheader($header); @@ -282,7 +280,7 @@ public static function get_for_new_resource($userid, $tokenresource, \local_o365 } $debuginfo = [ 'tokenresult' => $tokenresult, - 'resource' => $tokenresource + 'resource' => $tokenresource, ]; \local_o365\utils::debug($errmsg, __METHOD__, $debuginfo); } @@ -412,7 +410,7 @@ public function refresh() { $header = [ 'Content-Type: application/x-www-form-urlencoded', - 'Content-Length: '.strlen($params) + 'Content-Length: ' . strlen($params), ]; $this->httpclient->resetheader(); $this->httpclient->setheader($header); @@ -436,7 +434,7 @@ public function refresh() { 'token' => $this->token, 'expiry' => $this->expiry, 'refreshtoken' => $this->refreshtoken, - 'tokenresource' => $this->tokenresource + 'tokenresource' => $this->tokenresource, ]; $this->update_stored_token($existingtoken, $newtoken); } diff --git a/local/o365/classes/obj/o365user.php b/local/o365/classes/obj/o365user.php index f6f1ac829..5fe1b9eb6 100644 --- a/local/o365/classes/obj/o365user.php +++ b/local/o365/classes/obj/o365user.php @@ -25,10 +25,6 @@ namespace local_o365\obj; -use local_o365\utils; - -defined('MOODLE_INTERNAL') || die(); - /** * Class representing Microsoft 365 user information. */ diff --git a/local/o365/classes/observers.php b/local/o365/classes/observers.php index 9ac6a9d85..5b1f23915 100644 --- a/local/o365/classes/observers.php +++ b/local/o365/classes/observers.php @@ -81,7 +81,7 @@ class observers { * @param user_authed $event The triggered event. * @return bool Success/Failure. */ - public static function handle_oidc_user_authed(user_authed $event) : bool { + public static function handle_oidc_user_authed(user_authed $event): bool { require_login(); require_capability('moodle/site:config', context_system::instance()); @@ -146,6 +146,7 @@ public static function handle_oidc_user_authed(user_authed $event) : bool { } } catch (moodle_exception $e) { // Do nothing. + $domainsfetched = false; } if (!$domainsfetched) { @@ -172,7 +173,7 @@ public static function handle_oidc_user_authed(user_authed $event) : bool { * @param user_connected $event The triggered event. * @return bool Success/Failure. */ - public static function handle_oidc_user_connected(user_connected $event) : bool { + public static function handle_oidc_user_connected(user_connected $event): bool { global $DB; if (utils::is_connected() !== true) { @@ -269,7 +270,7 @@ public static function handle_oidc_user_connected(user_connected $event) : bool * @param user_created $event The triggered event. * @return bool Success/Failure. */ - public static function handle_user_created(user_created $event) : bool { + public static function handle_user_created(user_created $event): bool { global $DB; if (utils::is_connected() !== true) { @@ -297,7 +298,7 @@ public static function handle_user_created(user_created $event) : bool { * @param user_disconnected $event The triggered event. * @return bool Success/Failure. */ - public static function handle_oidc_user_disconnected(user_disconnected $event) : bool { + public static function handle_oidc_user_disconnected(user_disconnected $event): bool { global $DB; $eventdata = $event->get_data(); @@ -321,7 +322,7 @@ public static function handle_oidc_user_disconnected(user_disconnected $event) : * @param user_loggedin $event The triggered event. * @return bool Success/Failure. */ - public static function handle_oidc_user_loggedin(user_loggedin $event) : bool { + public static function handle_oidc_user_loggedin(user_loggedin $event): bool { if (utils::is_connected() !== true) { return false; } @@ -341,7 +342,7 @@ public static function handle_oidc_user_loggedin(user_loggedin $event) : bool { * @param int $userid The ID of the user we want more information about. * @return bool Success/Failure. */ - public static function get_additional_user_info(int $userid) : bool { + public static function get_additional_user_info(int $userid): bool { global $DB; try { @@ -417,7 +418,7 @@ public static function get_additional_user_info(int $userid) : bool { * @param user_enrolment_updated $event The triggered event. * @return bool Success/Failure. */ - public static function handle_user_enrolment_updated(user_enrolment_updated $event) : bool { + public static function handle_user_enrolment_updated(user_enrolment_updated $event): bool { // Do nothing if sync direction is Teams to Moodle. $courseusersyncdirection = get_config('local_o365', 'courseusersyncdirection'); if ($courseusersyncdirection == COURSE_USER_SYNC_DIRECTION_TEAMS_TO_MOODLE) { @@ -442,7 +443,7 @@ public static function handle_user_enrolment_updated(user_enrolment_updated $eve * @param enrol_instance_updated $event * @return bool */ - public static function handle_enrol_instance_updated(enrol_instance_updated $event) : bool { + public static function handle_enrol_instance_updated(enrol_instance_updated $event): bool { global $DB; // Do nothing if sync direction is Teams to Moodle. @@ -505,16 +506,16 @@ public static function handle_course_created(course_created $event): bool { $coursecreatedfromcustomcourserequest = false; - // Process course request approval + // Process course request approval. $courseid = $event->objectid; $course = get_course($courseid); $shortnametocheck = $course->shortname; - // First, try to get a record with an exact match on shortname + // First, try to get a record with an exact match on shortname. $customrequest = $DB->get_record('local_o365_course_request', ['courseshortname' => $shortnametocheck, 'requeststatus' => feature\courserequest\main::COURSE_REQUEST_STATUS_PENDING]); - // If no exact match, try removing the suffix _(number) + // If no exact match, try removing the suffix _(number). if (!$customrequest && preg_match('/^(.+)_(\d+)$/', $course->shortname, $matches)) { $shortnametocheck = $matches[1]; $customrequest = $DB->get_record('local_o365_course_request', ['courseshortname' => $shortnametocheck, @@ -551,7 +552,7 @@ public static function handle_course_created(course_created $event): bool { * * @return bool */ - public static function handle_course_restored(course_restored $event) : bool { + public static function handle_course_restored(course_restored $event): bool { if (utils::is_connected() !== true) { return false; } @@ -580,7 +581,7 @@ public static function handle_course_restored(course_restored $event) : bool { * @param course_updated $event The triggered event. * @return bool Success/Failure. */ - public static function handle_course_updated(course_updated $event) : bool { + public static function handle_course_updated(course_updated $event): bool { if (utils::is_connected() !== true) { return false; } @@ -614,7 +615,7 @@ public static function handle_course_updated(course_updated $event) : bool { * @param course_deleted $event The triggered event. * @return bool Success/Failure. */ - public static function handle_course_deleted(course_deleted $event) : bool { + public static function handle_course_deleted(course_deleted $event): bool { global $DB; if (utils::is_connected() !== true) { @@ -647,7 +648,7 @@ public static function handle_course_deleted(course_deleted $event) : bool { * @param role_assigned $event The triggered event. * @return bool Success/Failure. */ - public static function handle_role_assigned(role_assigned $event) : bool { + public static function handle_role_assigned(role_assigned $event): bool { // Do nothing if sync direction is Teams to Moodle. $courseusersyncdirection = get_config('local_o365', 'courseusersyncdirection'); if ($courseusersyncdirection == COURSE_USER_SYNC_DIRECTION_TEAMS_TO_MOODLE) { @@ -676,7 +677,7 @@ public static function handle_role_assigned(role_assigned $event) : bool { * @param role_unassigned $event The triggered event. * @return bool Success/Failure. */ - public static function handle_role_unassigned(role_unassigned $event) : bool { + public static function handle_role_unassigned(role_unassigned $event): bool { // Do nothing if sync direction is Teams to Moodle. $courseusersyncdirection = get_config('local_o365', 'courseusersyncdirection'); if ($courseusersyncdirection == COURSE_USER_SYNC_DIRECTION_TEAMS_TO_MOODLE) { @@ -705,7 +706,7 @@ public static function handle_role_unassigned(role_unassigned $event) : bool { * @param capability_assigned|capability_unassigned $event * @return bool */ - public static function handle_capability_change($event) { + public static function handle_capability_change($event): bool { $roleid = $event->objectid; // Resync owners and members in the groups connected to enabled Moodle courses. @@ -734,7 +735,7 @@ public static function handle_capability_change($event) { * @param role_deleted $event The triggered event. * @return bool Success/Failure. */ - public static function handle_role_deleted(role_deleted $event) : bool { + public static function handle_role_deleted(role_deleted $event): bool { if (utils::is_connected() !== true) { return false; } @@ -757,7 +758,7 @@ public static function handle_role_deleted(role_deleted $event) : bool { * @param user_deleted $event The triggered event. * @return bool Success/Failure. */ - public static function handle_user_deleted(user_deleted $event) : bool { + public static function handle_user_deleted(user_deleted $event): bool { global $DB; $userid = $event->objectid; $DB->delete_records('local_o365_token', ['user_id' => $userid]); @@ -774,7 +775,7 @@ public static function handle_user_deleted(user_deleted $event) : bool { * * @return bool */ - public static function handle_config_log_created(config_log_created $event) : bool { + public static function handle_config_log_created(config_log_created $event): bool { global $DB; $eventdata = $event->get_data(); @@ -843,7 +844,7 @@ public static function handle_config_log_created(config_log_created $event) : bo * * @return bool */ - public static function handle_cohort_deleted(cohort_deleted $event) : bool { + public static function handle_cohort_deleted(cohort_deleted $event): bool { global $DB; $cohortid = $event->objectid; diff --git a/local/o365/classes/page/acp.php b/local/o365/classes/page/acp.php index 1327618ac..7d41d1f20 100644 --- a/local/o365/classes/page/acp.php +++ b/local/o365/classes/page/acp.php @@ -120,7 +120,7 @@ public function mode_adminconsent() { $auth = new authcode; $auth->set_httpclient(new httpclient()); $stateparams = ['redirect' => '/admin/settings.php?section=local_o365', 'justauth' => true, 'forceflow' => 'authcode', - 'action' => 'adminconsent',]; + 'action' => 'adminconsent']; $idptype = get_config('auth_oidc', 'idptype'); if ($idptype == AUTH_OIDC_IDP_TYPE_MICROSOFT_IDENTITY_PLATFORM) { $auth->initiateadminconsentrequest($stateparams); @@ -135,7 +135,7 @@ public function mode_adminconsent() { * * @return bool */ - public function checktenantsetup() : bool { + public function checktenantsetup(): bool { $config = get_config('local_o365'); if (empty($config->entratenant)) { return false; @@ -304,7 +304,7 @@ public function mode_tenantsaddgo() { $auth = new authcode; $auth->set_httpclient(new httpclient()); $stateparams = ['redirect' => '/local/o365/acp.php?mode=tenantsadd', 'justauth' => true, 'forceflow' => 'authcode', - 'action' => 'addtenant', 'ignorerestrictions' => true,]; + 'action' => 'addtenant', 'ignorerestrictions' => true]; $idptype = get_config('auth_oidc', 'idptype'); if ($idptype == AUTH_OIDC_IDP_TYPE_MICROSOFT_IDENTITY_PLATFORM) { $auth->initiateadminconsentrequest($stateparams); @@ -598,7 +598,7 @@ public function mode_coursesynccustom() { $search = optional_param('search', '', PARAM_TEXT); $sortdir = strtolower(optional_param('sortdir', 'asc', PARAM_ALPHA)); - $headers = ['fullname' => get_string('fullnamecourse'), 'shortname' => get_string('shortnamecourse'),]; + $headers = ['fullname' => get_string('fullnamecourse'), 'shortname' => get_string('shortnamecourse')]; if (empty($sort) || !isset($headers[$sort])) { $sort = 'fullname'; } @@ -627,7 +627,7 @@ public function mode_coursesynccustom() { if ($sortdir == 'desc') { $sortdir = -1; } - $options = ['recursive' => true, 'sort' => [$sort => $sortdir], 'offset' => $limitfrom, 'limit' => $perpage,]; + $options = ['recursive' => true, 'sort' => [$sort => $sortdir], 'offset' => $limitfrom, 'limit' => $perpage]; $topcat = core_course_category::get(0); $courses = $topcat->get_courses($options); $totalcount = $topcat->get_courses_count($options); @@ -707,7 +707,7 @@ public function mode_coursesynccustom() { var local_o365_coursesync_all_set_feature = function(state) { if (confirm("' . get_string('acp_coursesynccustom_confirm_all_action', 'local_o365') . '")) { var enabled = (state == 1) ? true : false; - + // Send data to server $.ajax({ url: \'' . $allchangeendpoint->out(false) . '\', @@ -879,7 +879,7 @@ public function mode_teamconnections() { $search = optional_param('search', '', PARAM_TEXT); $sortdir = strtolower(optional_param('sortdir', 'asc', PARAM_ALPHA)); - $headers = ['fullname' => get_string('fullnamecourse'), 'shortname' => get_string('shortnamecourse'),]; + $headers = ['fullname' => get_string('fullnamecourse'), 'shortname' => get_string('shortnamecourse')]; if (empty($sort) || !isset($headers[$sort])) { $sort = 'fullname'; } @@ -908,7 +908,7 @@ public function mode_teamconnections() { if ($sortdir == 'desc') { $sortdir = -1; } - $options = ['recursive' => true, 'sort' => [$sort => $sortdir], 'offset' => $limitfrom, 'limit' => $perpage,]; + $options = ['recursive' => true, 'sort' => [$sort => $sortdir], 'offset' => $limitfrom, 'limit' => $perpage]; $topcat = core_course_category::get(0); $courses = $topcat->get_courses($options); $totalcount = $topcat->get_courses_count($options); @@ -1013,7 +1013,7 @@ public function mode_teamconnections() { $courseurl = new moodle_url('/course/view.php', ['id' => $course->id]); - $rowdata = [html_writer::link($courseurl, $course->fullname), $course->shortname, $existingconnection, $actionsfield,]; + $rowdata = [html_writer::link($courseurl, $course->fullname), $course->shortname, $existingconnection, $actionsfield]; $table->data[] = $rowdata; } @@ -1728,7 +1728,7 @@ public function mode_userconnections() { $searchurl = new moodle_url('/local/o365/acp.php', ['mode' => 'userconnections']); $filterfields = ['o365username' => 0, 'realname' => 0, 'username' => 0, 'idnumber' => 1, 'firstname' => 1, 'lastname' => 1, - 'email' => 1,]; + 'email' => 1]; $ufiltering = new filtering($filterfields, $searchurl); [$extrasql, $params] = $ufiltering->get_sql_filter(); [$o365usernamesql, $o365usernameparams] = $ufiltering->get_filter_o365username(); @@ -1751,7 +1751,7 @@ public function mode_userconnections() { * @return bool * @throws moodle_exception */ - public function mode_userconnections_resync() : bool { + public function mode_userconnections_resync(): bool { global $DB; $userid = required_param('userid', PARAM_INT); confirm_sesskey(); @@ -1829,14 +1829,14 @@ public function mode_userconnections_manualmatch() { } // Check if a o365 user object record already exists. - $params = ['moodleid' => $userid, 'type' => 'user',]; + $params = ['moodleid' => $userid, 'type' => 'user']; $existingobject = $DB->get_record('local_o365_objects', $params); if (!empty($existingobject) && $existingobject->o365name === $o365username) { throw new moodle_exception('acp_userconnections_manualmatch_error_muserconnected2', 'local_o365'); } $uselogin = (!empty($fromform->uselogin)) ? 1 : 0; - $matchrec = (object) ['muserid' => $userid, 'entraidupn' => $o365username, 'uselogin' => $uselogin,]; + $matchrec = (object) ['muserid' => $userid, 'entraidupn' => $o365username, 'uselogin' => $uselogin]; $DB->insert_record('local_o365_connections', $matchrec); redirect(new moodle_url('/local/o365/acp.php', ['mode' => 'userconnections'])); die(); @@ -1871,7 +1871,7 @@ public function mode_userconnections_unmatch() { $this->standard_header(); $message = get_string('acp_userconnections_table_unmatch_confirmmsg', 'local_o365', $user->username); $message .= '

'; - $urlparams = ['mode' => 'userconnections_unmatch', 'userid' => $userid, 'confirmed' => 1, 'sesskey' => sesskey(),]; + $urlparams = ['mode' => 'userconnections_unmatch', 'userid' => $userid, 'confirmed' => 1, 'sesskey' => sesskey()]; $url = new moodle_url('/local/o365/acp.php', $urlparams); $label = get_string('acp_userconnections_table_unmatch', 'local_o365'); $message .= html_writer::link($url, $label); @@ -1907,7 +1907,7 @@ public function mode_userconnections_disconnect() { $this->standard_header(); $message = get_string('acp_userconnections_table_disconnect_confirmmsg', 'local_o365', $user->username); $message .= '

'; - $urlparams = ['mode' => 'userconnections_disconnect', 'userid' => $userid, 'confirmed' => 1, 'sesskey' => sesskey(),]; + $urlparams = ['mode' => 'userconnections_disconnect', 'userid' => $userid, 'confirmed' => 1, 'sesskey' => sesskey()]; $url = new moodle_url('/local/o365/acp.php', $urlparams); $label = get_string('acp_userconnections_table_disconnect', 'local_o365'); $message .= html_writer::link($url, $label); diff --git a/local/o365/classes/page/ajax.php b/local/o365/classes/page/ajax.php index 1f94f79b0..c9ffc624f 100644 --- a/local/o365/classes/page/ajax.php +++ b/local/o365/classes/page/ajax.php @@ -36,8 +36,6 @@ use stdClass; use webservice; -defined('MOODLE_INTERNAL') || die(); - /** * Ajax page. */ @@ -361,7 +359,7 @@ public function mode_checkteamsmoodlesetup() { // Enable REST protocol. $webservice = 'rest'; $availablewebservices = core_component::get_plugin_list('webservice'); - $activewebservices = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols); + $activewebservices = empty($CFG->webserviceprotocols) ? [] : explode(',', $CFG->webserviceprotocols); foreach ($activewebservices as $key => $active) { if (empty($availablewebservices[$active])) { unset($activewebservices[$key]); @@ -386,9 +384,7 @@ public function mode_checkteamsmoodlesetup() { if (!$o365service->enabled) { $o365service->enabled = 1; $webservicemanager->update_external_service($o365service); - $params = array( - 'objectid' => $o365service->id - ); + $params = ['objectid' => $o365service->id]; $event = \core\event\webservice_service_updated::create($params); $event->trigger(); $data->success[] = get_string('settings_notice_o365serviceenabled', 'local_o365'); diff --git a/local/o365/classes/page/base.php b/local/o365/classes/page/base.php index 5a1acf74c..1536022fa 100644 --- a/local/o365/classes/page/base.php +++ b/local/o365/classes/page/base.php @@ -25,8 +25,6 @@ namespace local_o365\page; -defined('MOODLE_INTERNAL') || die(); - /** * Basic page-style class handling page setup and page modes. */ diff --git a/local/o365/classes/privacy/provider.php b/local/o365/classes/privacy/provider.php index 9518ff996..ee9f7d42a 100644 --- a/local/o365/classes/privacy/provider.php +++ b/local/o365/classes/privacy/provider.php @@ -25,14 +25,22 @@ namespace local_o365\privacy; -use \core_privacy\local\metadata\collection; -use \core_privacy\local\request\contextlist; -use \core_privacy\local\request\approved_contextlist; -use \core_privacy\local\request\writer; +use context; +use core_privacy\local\metadata\collection; +use core_privacy\local\request\approved_userlist; +use core_privacy\local\request\contextlist; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\core_userlist_provider; +use core_privacy\local\request\userlist; +use core_privacy\local\request\writer; +use stdClass; defined('MOODLE_INTERNAL') || die(); -interface local_o365_userlist extends \core_privacy\local\request\core_userlist_provider { +/** + * Local userlist provider for local_o365. + */ +interface local_o365_userlist extends core_userlist_provider { }; /** @@ -44,12 +52,12 @@ class provider implements local_o365_userlist { /** - * Returns meta data about this system. + * Returns metadata about this system. * * @param collection $collection The initialised collection to add items to. * @return collection A listing of user data stored through this system. */ - public static function get_metadata(collection $collection) : collection { + public static function get_metadata(collection $collection): collection { $tables = [ 'local_o365_calidmap' => [ @@ -132,8 +140,8 @@ public static function get_metadata(collection $collection) : collection { * @param int $userid The user to search. * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin. */ - public static function get_contexts_for_userid(int $userid) : contextlist { - $contextlist = new \core_privacy\local\request\contextlist(); + public static function get_contexts_for_userid(int $userid): contextlist { + $contextlist = new contextlist(); if (self::user_has_o365_data($userid)) { $contextlist->add_user_context($userid); } @@ -143,10 +151,9 @@ public static function get_contexts_for_userid(int $userid) : contextlist { /** * Get the list of users who have data within a context. * - * @param \core_privacy\local\request\userlist $userlist The userlist containing the list of users who have data in this - * context/plugin combination. + * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination. */ - public static function get_users_in_context(\core_privacy\local\request\userlist $userlist) { + public static function get_users_in_context(userlist $userlist) { $context = $userlist->get_context(); if (!$context instanceof \context_user) { return; @@ -173,7 +180,7 @@ public static function export_user_data(approved_contextlist $contextlist) { foreach ($records as $record) { writer::with_context($context)->export_data([ get_string('privacy:metadata:local_o365', 'local_o365'), - get_string('privacy:metadata:'.$table, 'local_o365') + get_string('privacy:metadata:'.$table, 'local_o365'), ], $record); } } @@ -184,7 +191,7 @@ public static function export_user_data(approved_contextlist $contextlist) { * * @param context $context The specific context to delete data for. */ - public static function delete_data_for_all_users_in_context(\context $context) { + public static function delete_data_for_all_users_in_context(context $context) { if ($context->contextlevel == CONTEXT_USER) { self::delete_user_data($context->instanceid); } @@ -209,10 +216,9 @@ public static function delete_data_for_user(approved_contextlist $contextlist) { /** * Delete multiple users within a single context. * - * @param \core_privacy\local\request\approved_userlist $userlist The approved context and user information to delete - * information for. + * @param approved_userlist $userlist The approved context and user information to delete information for. */ - public static function delete_data_for_users(\core_privacy\local\request\approved_userlist $userlist) { + public static function delete_data_for_users(approved_userlist $userlist) { $context = $userlist->get_context(); if ($context instanceof \context_user) { self::delete_user_data($context->instanceid); @@ -228,7 +234,7 @@ public static function delete_data_for_users(\core_privacy\local\request\approve private static function user_has_o365_data(int $userid) { global $DB; - $userdata = new \stdClass; + $userdata = new stdClass; $userdata->id = $userid; $user = $DB->get_record('user', ['id' => $userid]); if (!empty($user)) { @@ -252,7 +258,7 @@ private static function user_has_o365_data(int $userid) { private static function delete_user_data(int $userid) { global $DB; - $userdata = new \stdClass; + $userdata = new stdClass; $userdata->id = $userid; $user = $DB->get_record('user', ['id' => $userid]); if (!empty($user)) { @@ -267,10 +273,10 @@ private static function delete_user_data(int $userid) { /** * Get a map of database tables that contain user data, and the filters to get records for a user. * - * @param \stdClass $user The user to get the map for. + * @param stdClass $user The user to get the map for. * @return array The table user map. */ - protected static function get_table_user_map(\stdClass $user) : array { + protected static function get_table_user_map(stdClass $user): array { $tables = [ 'local_o365_calidmap' => ['userid' => $user->id], 'local_o365_calsub' => ['user_id' => $user->id], diff --git a/local/o365/classes/rest/o365api.php b/local/o365/classes/rest/o365api.php index 27b875f8f..38e5822bb 100644 --- a/local/o365/classes/rest/o365api.php +++ b/local/o365/classes/rest/o365api.php @@ -27,8 +27,6 @@ use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Abstract base class for all o365 REST api classes. */ @@ -345,7 +343,7 @@ public function geturl($url, $options = []) { if ($tokenvalid !== true) { throw new moodle_exception('erroro365apiinvalidtoken', 'local_o365'); } - $header = ['Authorization: Bearer ' . $this->token->get_token(),]; + $header = ['Authorization: Bearer ' . $this->token->get_token()]; $this->httpclient->resetheader(); $this->httpclient->setheader($header); return $this->httpclient->get($url, '', $options); diff --git a/local/o365/classes/rest/unified.php b/local/o365/classes/rest/unified.php index aeb6643cd..7a42d20b2 100644 --- a/local/o365/classes/rest/unified.php +++ b/local/o365/classes/rest/unified.php @@ -53,7 +53,7 @@ class unified extends o365api { * * @return bool Whether the API client is configured. */ - public static function is_configured() : bool { + public static function is_configured(): bool { // Since legacy APIs are removed, unified is always configured. return true; } @@ -63,7 +63,7 @@ public static function is_configured() : bool { * * @return string The resource for oauth2 tokens. */ - public static function get_tokenresource() : string { + public static function get_tokenresource(): string { $oidcresource = get_config('auth_oidc', 'oidcresource'); if (!empty($oidcresource)) { return $oidcresource; @@ -92,7 +92,7 @@ public function get_apiuri() { * @param string $apimethod The API method being called. * @return string a simplified api area string. */ - protected function generate_apiarea(string $apimethod) : string { + protected function generate_apiarea(string $apimethod): string { $apimethod = explode('/', $apimethod); foreach ($apimethod as $apicomponent) { $validareas = ['applications', 'groups', 'calendars', 'events', 'trendingaround', 'users']; @@ -205,7 +205,7 @@ public function paginatedapicall($httpmethod, $apimethod, $odataqueries = [], $e if (!empty($result['value']) && is_array($result['value'])) { $content = array_merge($content, $result['value']); } - + if (isset($result['odata.nextLink'])) { $skiptoken = $this->extract_param_from_link($result['odata.nextLink'], $skipparam); } else if (isset($result['@odata.nextLink'])) { @@ -236,7 +236,7 @@ public function paginatedapicall($httpmethod, $apimethod, $odataqueries = [], $e * @return bool True if tenant succeeded, false if not. * @throws moodle_exception */ - public function test_tenant(string $tenant) : bool { + public function test_tenant(string $tenant): bool { if (!is_string($tenant)) { throw new moodle_exception('errortenantvaluenotstring', 'local_o365'); } @@ -254,7 +254,7 @@ public function test_tenant(string $tenant) : bool { * @return string * @throws moodle_exception */ - public function get_default_domain_name_in_tenant() : string { + public function get_default_domain_name_in_tenant(): string { $response = $this->apicall('get', '/domains'); $response = $this->process_apicall_response($response, ['value' => null]); foreach ($response['value'] as $domain) { @@ -301,7 +301,7 @@ public function get_all_domain_names_in_tenant() { * @return string The OneDrive URL string. * @throws moodle_exception */ - public function get_odburl() : string { + public function get_odburl(): string { $tenant = $this->get_default_domain_name_in_tenant(); $suffix = '.onmicrosoft.com'; $sufflen = strlen($suffix); @@ -319,7 +319,7 @@ public function get_odburl() : string { * @param clientdata $clientdata oAuth2 Credentials * @return bool Whether the received resource is valid or not. */ - public function validate_resource(string $tokenresource, clientdata $clientdata) : bool { + public function validate_resource(string $tokenresource, clientdata $clientdata): bool { $cleanresource = clean_param($tokenresource, PARAM_URL); if ($cleanresource !== $tokenresource) { return false; @@ -337,13 +337,13 @@ public function validate_resource(string $tokenresource, clientdata $clientdata) * @param string $appobjectid * @return string|null */ - public function assign_user(int $muserid, string $userobjectid, string $appobjectid) : ?string { + public function assign_user(int $muserid, string $userobjectid, string $appobjectid): ?string { global $DB; $record = $DB->get_record('local_o365_appassign', ['muserid' => $muserid]); if (empty($record) || $record->assigned == 0) { $roleid = '00000000-0000-0000-0000-000000000000'; $endpoint = '/users/' . $userobjectid . '/appRoleAssignments/'; - $params = ['id' => $roleid, 'resourceId' => $appobjectid, 'principalId' => $userobjectid,]; + $params = ['id' => $roleid, 'resourceId' => $appobjectid, 'principalId' => $userobjectid]; $response = $this->betaapicall('post', $endpoint, json_encode($params)); if (empty($record)) { $record = new stdClass(); @@ -365,7 +365,7 @@ public function assign_user(int $muserid, string $userobjectid, string $appobjec * @return array List of groups. * @throws moodle_exception */ - public function get_groups() : array { + public function get_groups(): array { $endpoint = '/groups'; return $this->paginatedapicall('get', $endpoint); @@ -380,7 +380,7 @@ public function get_groups() : array { * @return array|null * @throws moodle_exception */ - public function create_group(string $name, string $mailnickname = null, array $extra = null) : ?array { + public function create_group(string $name, ?string $mailnickname = null, ?array $extra = null): ?array { if (empty($mailnickname)) { $mailnickname = $name; } @@ -443,7 +443,7 @@ public function create_group(string $name, string $mailnickname = null, array $e * @return string Null string on success, json string on failure. * @throws moodle_exception */ - public function update_group(array $groupdata) : string { + public function update_group(array $groupdata): string { // Check for required parameters. if (empty($groupdata['id'])) { throw new moodle_exception('invalidgroupdata', 'local_o365'); @@ -474,7 +474,7 @@ public function update_group(array $groupdata) : string { * @return array Array of returned o365 group data. * @throws moodle_exception */ - public function get_group(string $objectid) : array { + public function get_group(string $objectid): array { $response = $this->apicall('get', '/groups/' . $objectid); $expectedparams = ['id' => null]; return $this->process_apicall_response($response, $expectedparams); @@ -484,10 +484,11 @@ public function get_group(string $objectid) : array { * Get group urls. * * @param string $objectid The object ID of the group. - * @return array Array of returned o365 group urls, null on no group data found. + * @return array|null Array of returned o365 group urls, null on no group data found. + * @throws \dml_exception * @throws moodle_exception */ - public function get_group_urls(string $objectid) : ?array { + public function get_group_urls(string $objectid): ?array { $group = $this->get_group($objectid); if (empty($group['mailNickname'])) { return null; @@ -508,12 +509,13 @@ public function get_group_urls(string $objectid) : ?array { ]; try { [$rawteam, $teamurl, $lockstatus] = $this->get_team($objectid); - if ($teamurl) { - $o365urls['team'] = $teamurl; - } } catch (moodle_exception $e) { - // Do nothing. + $teamurl = null; + } + if ($teamurl) { + $o365urls['team'] = $teamurl; } + return $o365urls; } @@ -550,10 +552,10 @@ public function get_team(string $objectid) { * Get a group by its displayName * * @param string $name The group name, - * @return array Array of group information, or null if group not found. + * @return array|null Array of group information, or null if group not found. * @throws moodle_exception */ - public function get_group_by_name(string $name) : ?array { + public function get_group_by_name(string $name): ?array { $response = $this->apicall('get', '/groups?$filter=displayName' . rawurlencode(' eq \'' . $name . '\'')); $expectedparams = ['value' => null]; $groups = $this->process_apicall_response($response, $expectedparams); @@ -580,7 +582,7 @@ public function delete_group(string $objectid) { * @return array Array of returned information. * @throws moodle_exception */ - public function list_deleted_groups() : array { + public function list_deleted_groups(): array { $endpoint = '/directory/deleteditems/Microsoft.Graph.Group'; return $this->paginatedapicall('get', $endpoint, [], ['value' => null], true); @@ -593,7 +595,7 @@ public function list_deleted_groups() : array { * @return array Array of returned information. * @throws moodle_exception */ - public function restore_deleted_group(string $objectid) : array { + public function restore_deleted_group(string $objectid): array { $response = $this->betaapicall('post', '/directory/deleteditems/' . $objectid . '/restore'); return $this->process_apicall_response($response); } @@ -605,7 +607,7 @@ public function restore_deleted_group(string $objectid) : array { * @return array Array of returned members. * @throws moodle_exception */ - public function get_group_members(string $groupobjectid) : array { + public function get_group_members(string $groupobjectid): array { $endpoint = '/groups/' . $groupobjectid . '/members'; return $this->paginatedapicall('get', $endpoint); @@ -615,10 +617,10 @@ public function get_group_members(string $groupobjectid) : array { * Get a list of group owners. * * @param string $groupobjectid The object ID of the group. - * @return array Array of returned owners. + * @return array|null Array of returned owners. * @throws moodle_exception */ - public function get_group_owners(string $groupobjectid) : ?array { + public function get_group_owners(string $groupobjectid): ?array { $endpoint = '/groups/' . $groupobjectid . '/owners'; return $this->paginatedapicall('get', $endpoint); @@ -633,7 +635,7 @@ public function get_group_owners(string $groupobjectid) : ?array { * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function get_group_files(string $groupid, string $parentid = '', string $skiptoken = '') : ?array { + public function get_group_files(string $groupid, string $parentid = '', string $skiptoken = ''): ?array { if (!empty($parentid) && $parentid !== '/') { $endpoint = "/groups/$groupid/drive/items/$parentid/children"; } else { @@ -664,7 +666,7 @@ public function get_group_files(string $groupid, string $parentid = '', string $ * @return array|null The file's content. * @throws moodle_exception */ - public function get_group_file_metadata(string $groupid, string $fileid) : ?array { + public function get_group_file_metadata(string $groupid, string $fileid): ?array { $response = $this->apicall('get', "/groups/$groupid/drive/items/$fileid"); $expectedparams = ['id' => null]; return $this->process_apicall_response($response, $expectedparams); @@ -678,7 +680,7 @@ public function get_group_file_metadata(string $groupid, string $fileid) : ?arra * @return string Sharing link url. * @throws moodle_exception */ - public function get_group_file_sharing_link(string $groupid, string $fileid) : string { + public function get_group_file_sharing_link(string $groupid, string $fileid): string { $params = ['type' => 'view', 'scope' => 'organization']; $apiresponse = $this->apicall('post', "/groups/$groupid/drive/items/$fileid/createLink", json_encode($params)); $response = $this->process_apicall_response($apiresponse); @@ -686,13 +688,13 @@ public function get_group_file_sharing_link(string $groupid, string $fileid) : s } /** - * Get a file's content by it's file id. + * Get a file's content by its file id. * * @param string $groupid * @param string $fileid The file's ID. * @return string The file's content. */ - public function get_group_file_by_id(string $groupid, string $fileid) : string { + public function get_group_file_by_id(string $groupid, string $fileid): string { return $this->apicall('get', "/groups/$groupid/drive/items/$fileid/content"); } @@ -733,7 +735,7 @@ public function add_owner_to_group_using_group_api(string $groupobjectid, string * @param string $memberobjectid The object ID of the item to remove (can be group object id or user object id). * @return bool */ - public function remove_member_from_group_using_group_api(string $groupobjectid, string $memberobjectid) : bool { + public function remove_member_from_group_using_group_api(string $groupobjectid, string $memberobjectid): bool { $endpoint = '/groups/' . $groupobjectid . '/members/' . $memberobjectid . '/$ref'; $this->betaapicall('delete', $endpoint); if ($this->check_expected_http_code(['204'])) { @@ -750,7 +752,7 @@ public function remove_member_from_group_using_group_api(string $groupobjectid, * @param string $ownerobjectid The object ID of the item to remove (can be group object id or user object id). * @return bool */ - public function remove_owner_from_group_using_group_api(string $groupobjectid, string $ownerobjectid) : bool { + public function remove_owner_from_group_using_group_api(string $groupobjectid, string $ownerobjectid): bool { $endpoint = '/groups/' . $groupobjectid . '/owners/' . $ownerobjectid . '/$ref'; $this->betaapicall('delete', $endpoint); if ($this->check_expected_http_code(['204'])) { @@ -768,7 +770,7 @@ public function remove_owner_from_group_using_group_api(string $groupobjectid, s * @return array|null * @throws moodle_exception */ - public function add_member_to_group_using_teams_api(string $groupobjectid, string $userobjectid) : ?array { + public function add_member_to_group_using_teams_api(string $groupobjectid, string $userobjectid): ?array { $endpoint = '/teams/' . $groupobjectid . '/members'; $data = [ '@odata.type' => '#microsoft.graph.aadUserConversationMember', @@ -788,7 +790,7 @@ public function add_member_to_group_using_teams_api(string $groupobjectid, strin * @return array|null * @throws moodle_exception */ - public function add_owner_to_group_using_teams_api(string $groupobjectid, string $userobjectid) : ?array { + public function add_owner_to_group_using_teams_api(string $groupobjectid, string $userobjectid): ?array { $endpoint = '/teams/' . $groupobjectid . '/members'; $data = [ '@odata.type' => '#microsoft.graph.aadUserConversationMember', @@ -808,7 +810,7 @@ public function add_owner_to_group_using_teams_api(string $groupobjectid, string * @return string * @throws moodle_exception */ - public function get_aad_user_conversation_member_id(string $groupobjectid, string $userobjectid) : string { + public function get_aad_user_conversation_member_id(string $groupobjectid, string $userobjectid): string { $endpoint = '/teams/' . $groupobjectid . '/members/?$filter=microsoft.graph.aadUserConversationMember/userId%20in%20("' . $userobjectid . '")'; @@ -832,7 +834,7 @@ public function get_aad_user_conversation_member_id(string $groupobjectid, strin * @throws moodle_exception */ public function remove_owner_and_member_from_group_using_teams_api(string $groupobjectid, - string $aaduserconversationmemberid) : ?array { + string $aaduserconversationmemberid): ?array { $endpoint = '/teams/' . $groupobjectid . '/members/' . $aaduserconversationmemberid; $response = $this->apicall('delete', $endpoint); @@ -850,7 +852,7 @@ public function remove_owner_and_member_from_group_using_teams_api(string $group * @throws moodle_exception */ public function create_group_file(string $groupid, string $filename, string $content, - string $contenttype = 'text/plain') : ?array { + string $contenttype = 'text/plain'): ?array { $filename = rawurlencode($filename); $endpoint = "/groups/$groupid/drive/root:/$filename:/content"; $fileresponse = $this->apicall('put', $endpoint, ['file' => $content], ['contenttype' => $contenttype]); @@ -864,12 +866,12 @@ public function create_group_file(string $groupid, string $filename, string $con * @param bool $guestuser if the fields are for a guest user. * @return array Array of user fields. */ - protected function get_default_user_fields(bool $guestuser = false) : array { + protected function get_default_user_fields(bool $guestuser = false): array { $defaultfields = ['id', 'userPrincipalName', 'displayName', 'givenName', 'surname', 'mail', 'streetAddress', 'city', 'postalCode', 'state', 'country', 'jobTitle', 'department', 'companyName', 'preferredLanguage', 'employeeId', 'businessPhones', 'faxNumber', 'mobilePhone', 'officeLocation', 'manager', 'teams', 'roles', 'groups', 'accountEnabled', - 'onPremisesExtensionAttributes', 'onPremisesSamAccountName',]; + 'onPremisesExtensionAttributes', 'onPremisesSamAccountName']; if (!$guestuser) { $defaultfields[] = 'preferredName'; } @@ -884,7 +886,7 @@ protected function get_default_user_fields(bool $guestuser = false) : array { * @return array|null Array of user information, or null if failure. * @throws moodle_exception */ - public function get_users($params = 'default') : ?array { + public function get_users($params = 'default'): ?array { $endpoint = "/users"; $odataqueries = []; @@ -912,7 +914,7 @@ public function get_users($params = 'default') : ?array { * @param string|null $deltatoken * @return array */ - public function get_users_delta($params, string $deltatoken = null) : array { + public function get_users_delta($params, ?string $deltatoken = null): array { $endpoint = "/users/delta"; $odataqueries = []; @@ -961,7 +963,7 @@ public function get_users_delta($params, string $deltatoken = null) : array { * @param string $userobjectid - user AD id * @return array|null */ - public function get_user_manager(string $userobjectid) : ?array { + public function get_user_manager(string $userobjectid): ?array { $endpoint = "users/$userobjectid/manager"; $response = $this->apicall('get', $endpoint); try { @@ -980,7 +982,7 @@ public function get_user_manager(string $userobjectid) : ?array { * @return array * @throws moodle_exception */ - public function get_user_groups(string $userobjectid) : array { + public function get_user_groups(string $userobjectid): array { $endpoint = "users/$userobjectid/transitiveMemberOf/microsoft.graph.group"; return $this->paginatedapicall('get', $endpoint); } @@ -992,7 +994,7 @@ public function get_user_groups(string $userobjectid) : array { * @return array * @throws moodle_exception */ - public function get_user_transitive_groups(string $userobjectid) : ?array { + public function get_user_transitive_groups(string $userobjectid): ?array { $endpoint = "users/$userobjectid/getMemberGroups"; return $this->paginatedapicall('post', $endpoint, [], ['value' => null], false, json_encode(['securityEnabledOnly' => false])); @@ -1005,7 +1007,7 @@ public function get_user_transitive_groups(string $userobjectid) : ?array { * @return array * @throws moodle_exception */ - public function get_user_teams(string $userobjectid) : array { + public function get_user_teams(string $userobjectid): array { $endpoint = "users/$userobjectid/joinedTeams"; return $this->paginatedapicall('get', $endpoint); } @@ -1018,7 +1020,7 @@ public function get_user_teams(string $userobjectid) : array { * @return array * @throws moodle_exception */ - public function get_user_objects(string $userobjectid, bool $securityenabledonly = true) : array { + public function get_user_objects(string $userobjectid, bool $securityenabledonly = true): array { $endpoint = "users/$userobjectid/getMemberObjects"; $data = ['securityEnabledOnly' => $securityenabledonly]; return $this->paginatedapicall('post', $endpoint, [], ['value' => null], false, json_encode($data)); @@ -1032,7 +1034,7 @@ public function get_user_objects(string $userobjectid, bool $securityenabledonly * @return array|null * @throws moodle_exception */ - public function get_directory_objects(array $ids, string $types = null) : ?array { + public function get_directory_objects(array $ids, ?string $types = null): ?array { $endpoint = "directoryObjects/getByIds"; $data = ['ids' => $ids]; if (!empty($types)) { @@ -1050,7 +1052,7 @@ public function get_directory_objects(array $ids, string $types = null) : ?array * @param string $param Parameter name. * @return string|null The extracted deltalink value, or null if none found. */ - protected function extract_param_from_link(string $link, string $param) : ?string { + protected function extract_param_from_link(string $link, string $param): ?string { $link = parse_url($link); if (isset($link['query'])) { $output = []; @@ -1068,7 +1070,7 @@ protected function extract_param_from_link(string $link, string $param) : ?strin * @return array Array of returned information. * @throws moodle_exception */ - public function list_deleted_users() : array { + public function list_deleted_users(): array { $endpoint = '/directory/deleteditems/Microsoft.Graph.User'; return $this->paginatedapicall('get', $endpoint, [], ['value' => null], true); @@ -1081,7 +1083,7 @@ public function list_deleted_users() : array { * @return array Array of user data. * @throws moodle_exception */ - public function get_user_by_upn(string $upn) : array { + public function get_user_by_upn(string $upn): array { $endpoint = '/users/' . rawurlencode($upn); $response = $this->apicall('get', $endpoint); $expectedparams = ['id' => null, 'userPrincipalName' => null]; @@ -1092,10 +1094,10 @@ public function get_user_by_upn(string $upn) : array { * Get a list of the user's o365 calendars. * * @param string $upn The user's userPrincipalName - * @return array Returned response + * @return array|null Returned response * @throws moodle_exception */ - public function get_calendars(string $upn) : ?array { + public function get_calendars(string $upn): ?array { $endpoint = '/users/' . $upn . '/calendars'; return $this->paginatedapicall('get', $endpoint, [], ['value' => null], false, '', [], '$skip'); @@ -1109,7 +1111,7 @@ public function get_calendars(string $upn) : ?array { * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function create_calendar(string $name, string $upn) : ?array { + public function create_calendar(string $name, string $upn): ?array { $calendardata = json_encode(['name' => $name]); $response = $this->apicall('post', '/users/' . $upn . '/calendars', $calendardata); $expectedparams = ['id' => null]; @@ -1132,7 +1134,7 @@ public function create_calendar(string $name, string $upn) : ?array { * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function update_calendar(string $calendearid, array $updated, string $upn) : ?array { + public function update_calendar(string $calendearid, array $updated, string $upn): ?array { if (empty($calendearid) || empty($updated)) { return []; } @@ -1161,7 +1163,7 @@ public function update_calendar(string $calendearid, array $updated, string $upn * @throws moodle_exception */ public function create_event(string $subject, string $body, int $starttime, int $endtime, array $attendees, array $other, - ?string $calendarid, string $upn) : ?array { + ?string $calendarid, string $upn): ?array { $eventdata = [ 'subject' => $subject, 'body' => [ @@ -1185,7 +1187,7 @@ public function create_event(string $subject, string $body, int $starttime, int 'Address' => $attendee->email, 'Name' => $attendee->firstname.' '.$attendee->lastname, ], - 'type' => 'Resource' + 'type' => 'Resource', ]; } $eventdata = array_merge($eventdata, $other); @@ -1238,7 +1240,7 @@ public function create_group_event(string $subject, string $body, int $starttime 'Address' => $attendee->email, 'Name' => $attendee->firstname.' '.$attendee->lastname, ], - 'type' => 'Resource' + 'type' => 'Resource', ]; } $eventdata = array_merge($eventdata, $other); @@ -1262,7 +1264,7 @@ public function create_group_event(string $subject, string $body, int $starttime * @return array Array of events. * @throws moodle_exception */ - public function get_events(string $calendarid, string $since, string $upn) : array { + public function get_events(string $calendarid, string $since, string $upn): array { core_date::set_default_server_timezone(); $endpoint = (!empty($calendarid)) ? '/users/' . $upn . '/calendars/' . $calendarid . '/events' : '/users/' . $upn . '/calendar/events'; @@ -1287,7 +1289,7 @@ public function get_events(string $calendarid, string $since, string $upn) : arr * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function update_event(string $outlookeventid, array $updated, string $upn) : ?array { + public function update_event(string $outlookeventid, array $updated, string $upn): ?array { if (empty($outlookeventid) || empty($updated)) { return []; } @@ -1300,10 +1302,10 @@ public function update_event(string $outlookeventid, array $updated, string $upn } if (!empty($updated['starttime'])) { $updateddata['start'] = - ['dateTime' => date('c', $updated['starttime']), 'timeZone' => date('T', $updated['starttime']),]; + ['dateTime' => date('c', $updated['starttime']), 'timeZone' => date('T', $updated['starttime'])]; } if (!empty($updated['endtime'])) { - $updateddata['end'] = ['dateTime' => date('c', $updated['endtime']), 'timeZone' => date('T', $updated['endtime']),]; + $updateddata['end'] = ['dateTime' => date('c', $updated['endtime']), 'timeZone' => date('T', $updated['endtime'])]; } if (!empty($updated['responseRequested'])) { $updateddata['responseRequested'] = $updated['responseRequested']; @@ -1312,7 +1314,7 @@ public function update_event(string $outlookeventid, array $updated, string $upn $updateddata['attendees'] = []; foreach ($updated['attendees'] as $attendee) { $updateddata['attendees'][] = - ['emailAddress' => ['address' => $attendee->email, 'name' => $attendee->firstname . ' ' . $attendee->lastname,], + ['emailAddress' => ['address' => $attendee->email, 'name' => $attendee->firstname . ' ' . $attendee->lastname], 'type' => 'resource']; } } @@ -1329,7 +1331,7 @@ public function update_event(string $outlookeventid, array $updated, string $upn * @param string $upn user's userPrincipalName * @return bool Success/Failure. */ - public function delete_event(string $outlookeventid, string $upn) : bool { + public function delete_event(string $outlookeventid, string $upn): bool { if (!empty($outlookeventid)) { $this->apicall('delete', '/users/' . $upn . '/events/' . $outlookeventid); } @@ -1348,7 +1350,7 @@ public function delete_event(string $outlookeventid, string $upn) : bool { * @throws moodle_exception */ public function create_file(string $parentid, string $filename, string $content, string $contenttype, - string $o365userid) : ?array { + string $o365userid): ?array { $filename = rawurlencode($filename); if (!empty($parentid)) { $endpoint = "/users/$o365userid/drive/items/$parentid:/$filename:/content"; @@ -1369,7 +1371,7 @@ public function create_file(string $parentid, string $filename, string $content, * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function get_user_files(string $parentid, string $o365userid, string $skiptoken = '') : ?array { + public function get_user_files(string $parentid, string $o365userid, string $skiptoken = ''): ?array { if (!empty($parentid) && $parentid !== '/') { $endpoint = "/users/$o365userid/drive/items/$parentid/children"; } else { @@ -1401,7 +1403,7 @@ public function get_user_files(string $parentid, string $o365userid, string $ski * @return array|null Returned response, or null if error. * @throws moodle_exception */ - public function get_trending_files(string $upn, string $skiptoken = '') : ?array { + public function get_trending_files(string $upn, string $skiptoken = ''): ?array { $endpoint = '/users/' . $upn . '/trendingAround'; $odataqueries = []; @@ -1428,7 +1430,7 @@ public function get_trending_files(string $upn, string $skiptoken = '') : ?array * @return array|null The file's content. * @throws moodle_exception */ - public function get_file_data(string $fileinfo) : ?array { + public function get_file_data(string $fileinfo): ?array { $response = $this->apicall('get', "/$fileinfo"); $expectedparams = ['id' => null]; return $this->process_apicall_response($response, $expectedparams); @@ -1440,7 +1442,7 @@ public function get_file_data(string $fileinfo) : ?array { * @param string $url The file's URL. * @return string The file's content. */ - public function get_file_by_url(string $url) : string { + public function get_file_by_url(string $url): string { return $this->httpclient->download_file($url); } @@ -1452,20 +1454,20 @@ public function get_file_by_url(string $url) : string { * @return array|null The file's metadata. * @throws moodle_exception */ - public function get_file_metadata(string $fileid, string $o365userid) : ?array { + public function get_file_metadata(string $fileid, string $o365userid): ?array { $response = $this->apicall('get', "/users/$o365userid/drive/items/$fileid"); $expectedparams = ['id' => null]; return $this->process_apicall_response($response, $expectedparams); } /** - * Get a file's content by it's file id. + * Get a file's content by its file id. * * @param string $fileid The file's ID. * @param string $o365userid user's Microsoft 365 account object ID * @return string The file's content. */ - public function get_file_by_id(string $fileid, string $o365userid) : string { + public function get_file_by_id(string $fileid, string $o365userid): string { return $this->apicall('get', "/users/$o365userid/drive/items/$fileid/content"); } @@ -1475,7 +1477,7 @@ public function get_file_by_id(string $fileid, string $o365userid) : string { * @return array|null Array of application information, or null if failure. * @throws moodle_exception */ - public function get_application_info() : ?array { + public function get_application_info(): ?array { $oidcconfig = get_config('auth_oidc'); $endpoint = '/applications/?$filter=appId%20eq%20\'' . $oidcconfig->clientid . '\''; $response = $this->betaapicall('get', $endpoint); @@ -1489,7 +1491,7 @@ public function get_application_info() : ?array { * @return array|null Array of application information, or null if failure. * @throws moodle_exception */ - public function get_application_serviceprincipal_info() : ?array { + public function get_application_serviceprincipal_info(): ?array { $oidcconfig = get_config('auth_oidc'); $endpoint = '/servicePrincipals/?$filter=appId%20eq%20\'' . $oidcconfig->clientid . '\''; $response = $this->betaapicall('get', $endpoint); @@ -1500,10 +1502,10 @@ public function get_application_serviceprincipal_info() : ?array { /** * Get the service principal object for the Microsoft Graph API. * - * @return array Array representing service principal object. + * @return array|null Array representing service principal object. * @throws moodle_exception */ - public function get_unified_api_serviceprincipal_info() : ?array { + public function get_unified_api_serviceprincipal_info(): ?array { static $response = null; if (empty($response)) { $graphperms = $this->get_required_permissions('graph'); @@ -1518,9 +1520,9 @@ public function get_unified_api_serviceprincipal_info() : ?array { /** * Get all available permissions for the Microsoft Graph API. * - * @return array Array of available permissions, include descriptions and keys. + * @return array|null Array of available permissions, include descriptions and keys. */ - public function get_available_permissions() : ?array { + public function get_available_permissions(): ?array { $svc = $this->get_unified_api_serviceprincipal_info(); if (empty($svc) || !is_array($svc)) { return null; @@ -1542,7 +1544,7 @@ public function get_available_permissions() : ?array { * * @return array Array of available app-only permissions, indexed by permission name. */ - public function get_graph_available_apponly_permissions() : array { + public function get_graph_available_apponly_permissions(): array { // Get list of permissions and associated IDs. $graphsp = $this->get_unified_api_serviceprincipal_info(); $graphsp = $graphsp['value'][0]; @@ -1559,7 +1561,7 @@ public function get_graph_available_apponly_permissions() : array { * @return array Array of current app-only permissions, indexed by permission name. * @throws moodle_exception */ - public function get_graph_current_apponly_permissions() : array { + public function get_graph_current_apponly_permissions(): array { // Get available permissions. $graphsp = $this->get_unified_api_serviceprincipal_info(); $graphsp = $graphsp['value'][0]; @@ -1603,7 +1605,7 @@ public function get_graph_current_apponly_permissions() : array { * @return array|null Array of application information, or null if failure. * @throws moodle_exception */ - public function get_permission_grants(string $resourceid = '') : ?array { + public function get_permission_grants(string $resourceid = ''): ?array { $appinfo = $this->get_application_serviceprincipal_info(); if (empty($appinfo) || !is_array($appinfo)) { return null; @@ -1623,9 +1625,9 @@ public function get_permission_grants(string $resourceid = '') : ?array { /** * Get currently assigned permissions for the Microsoft Graph API. * - * @return array Array of permission keys. + * @return array|null Array of permission keys. */ - public function get_unified_api_permissions() : ?array { + public function get_unified_api_permissions(): ?array { $apiinfo = $this->get_unified_api_serviceprincipal_info(); if (empty($apiinfo) || !is_array($apiinfo)) { return null; @@ -1649,7 +1651,7 @@ public function get_unified_api_permissions() : ?array { * * @return array Array of required delegated permissions. */ - public function get_graph_required_permissions() : array { + public function get_graph_required_permissions(): array { $allperms = $this->get_required_permissions(); if (isset($allperms['graph'])) { return $allperms['graph']['requiredDelegatedPermissionsUsingAppPermissions']; @@ -1663,7 +1665,7 @@ public function get_graph_required_permissions() : array { * * @return array Array of required application permissions. */ - public function get_graph_required_apponly_permissions() : array { + public function get_graph_required_apponly_permissions(): array { $allperms = $this->get_required_permissions(); if (isset($allperms['graph'])) { return $allperms['graph']['requiredAppPermissions']; @@ -1677,7 +1679,7 @@ public function get_graph_required_apponly_permissions() : array { * * @return array */ - public function check_graph_apponly_permissions() : array { + public function check_graph_apponly_permissions(): array { $this->token->refresh(); $requiredperms = $this->get_graph_required_apponly_permissions(); $currentperms = $this->get_graph_current_apponly_permissions(); @@ -1727,9 +1729,9 @@ public function check_graph_apponly_permissions() : array { /** * Check whether all required permissions are present. * - * @return array Array of missing permissions, permission key as array key, human-readable name as values. + * @return array|null Array of missing permissions, permission key as array key, human-readable name as values. */ - public function check_graph_delegated_permissions() : ?array { + public function check_graph_delegated_permissions(): ?array { $this->token->refresh(); $currentperms = $this->get_unified_api_permissions(); $requiredperms = $this->get_graph_required_permissions(); @@ -1821,7 +1823,7 @@ public function get_photo(string $user) { * @return string Readonly file url. * @throws moodle_exception */ - public function get_sharing_link(string $fileid, string $o365userid) : string { + public function get_sharing_link(string $fileid, string $o365userid): string { $params = ['type' => 'view', 'scope' => 'organization']; $apiresponse = $this->apicall('post', "/users/$o365userid/drive/items/$fileid/createLink", json_encode($params)); $response = $this->process_apicall_response($apiresponse); @@ -1836,7 +1838,7 @@ public function get_sharing_link(string $fileid, string $o365userid) : string { * @return array|null Array of user information, or null if failure. * @throws moodle_exception */ - public function get_user(string $oid, bool $guestuser = false) : ?array { + public function get_user(string $oid, bool $guestuser = false): ?array { $endpoint = "/users/$oid"; $odataqueries = []; @@ -1851,7 +1853,7 @@ public function get_user(string $oid, bool $guestuser = false) : ?array { try { $response = $this->apicall('get', $endpoint); - $expectedparams = ['@odata.context' => $context, 'id' => null, 'userPrincipalName' => null,]; + $expectedparams = ['@odata.context' => $context, 'id' => null, 'userPrincipalName' => null]; $result = $this->process_apicall_response($response, $expectedparams); if (!empty($result['id'])) { @@ -1871,9 +1873,9 @@ public function get_user(string $oid, bool $guestuser = false) : ?array { * @return bool * @throws moodle_exception */ - public function provision_app(string $groupobjectid, string $appid) : bool { + public function provision_app(string $groupobjectid, string $appid): bool { $endpoint = '/teams/' . $groupobjectid . '/installedApps'; - $data = ['teamsApp@odata.bind' => $this->get_apiuri() . '/beta/appCatalogs/teamsApps/' . $appid,]; + $data = ['teamsApp@odata.bind' => $this->get_apiuri() . '/beta/appCatalogs/teamsApps/' . $appid]; $this->betaapicall('post', $endpoint, json_encode($data)); // If the request was successful, it would return 201; otherwise, if the request failed with "duplicate", @@ -1892,7 +1894,7 @@ public function provision_app(string $groupobjectid, string $appid) : bool { * @return string|null * @throws moodle_exception */ - public function get_catalog_app_id(string $externalappid) : ?string { + public function get_catalog_app_id(string $externalappid): ?string { $moodleappid = null; $endpoint = '/appCatalogs/teamsApps?$filter=externalId' . rawurlencode(' eq \'' . $externalappid . '\''); @@ -1914,7 +1916,7 @@ public function get_catalog_app_id(string $externalappid) : ?string { * @return string|null * @throws moodle_exception */ - public function get_general_channel_id(string $groupobjectid) : ?string { + public function get_general_channel_id(string $groupobjectid): ?string { $generalchannelid = null; $endpoint = '/teams/' . $groupobjectid . '/channels?$filter=displayName' . rawurlencode(' eq \'General\''); @@ -1938,7 +1940,7 @@ public function get_general_channel_id(string $groupobjectid) : ?string { * @param array $tabconfiguration * @return string */ - public function add_tab_to_channel(string $groupobjectid, string $channelid, string $appid, array $tabconfiguration) : string { + public function add_tab_to_channel(string $groupobjectid, string $channelid, string $appid, array $tabconfiguration): string { $endpoint = '/teams/' . $groupobjectid . '/channels/' . $channelid . '/tabs'; $tabname = get_config('local_o365', 'teams_moodle_tab_name'); if (!$tabname) { @@ -1946,7 +1948,8 @@ public function add_tab_to_channel(string $groupobjectid, string $channelid, str } $requestparams = ['displayName' => $tabname, 'teamsApp@odata.bind' => $this->get_apiuri() . '/beta/appCatalogs/teamsApps/' . $appid, - 'configuration' => $tabconfiguration,]; + 'configuration' => $tabconfiguration, + ]; return $this->betaapicall('post', $endpoint, json_encode($requestparams)); } @@ -1958,10 +1961,10 @@ public function add_tab_to_channel(string $groupobjectid, string $channelid, str * @param string $displayname * @return string */ - public function update_team_name(string $objectid, string $displayname) : string { + public function update_team_name(string $objectid, string $displayname): string { $endpoint = '/teams/' . $objectid; - $teamdata = ['displayName' => $displayname,]; + $teamdata = ['displayName' => $displayname]; return $this->betaapicall('patch', $endpoint, json_encode($teamdata)); } @@ -2007,7 +2010,7 @@ public function get_timezone(string $upn) { * @return array|null * @throws moodle_exception */ - public function get_teams() : ?array { + public function get_teams(): ?array { $endpoint = '/groups'; $odataqueries = [ '$filter' => 'resourceProvisioningOptions/Any(x:x%20eq%20\'Team\')', @@ -2022,7 +2025,7 @@ public function get_teams() : ?array { * @return array * @throws moodle_exception */ - public function get_schools() : ?array { + public function get_schools(): ?array { $endpoint = '/education/schools'; return $this->paginatedapicall('get', $endpoint); @@ -2035,7 +2038,7 @@ public function get_schools() : ?array { * @return array * @throws moodle_exception */ - public function get_school_classes(string $schoolobjectid) : ?array { + public function get_school_classes(string $schoolobjectid): ?array { $endpoint = '/education/schools/' . $schoolobjectid . '/classes'; return $this->paginatedapicall('get', $endpoint); @@ -2048,7 +2051,7 @@ public function get_school_classes(string $schoolobjectid) : ?array { * @return array * @throws moodle_exception */ - public function get_school_class_teachers(string $classobjectid) : ?array { + public function get_school_class_teachers(string $classobjectid): ?array { $endpoint = '/education/classes/' . $classobjectid . '/teachers'; return $this->paginatedapicall('get', $endpoint); @@ -2061,7 +2064,7 @@ public function get_school_class_teachers(string $classobjectid) : ?array { * @return array|null * @throws moodle_exception */ - public function get_school_class_members(string $classobjectid) : ?array { + public function get_school_class_members(string $classobjectid): ?array { $endpoint = '/education/classes/' . $classobjectid . '/members'; return $this->paginatedapicall('get', $endpoint); @@ -2074,7 +2077,7 @@ public function get_school_class_members(string $classobjectid) : ?array { * @return array * @throws moodle_exception */ - public function get_school_users(string $schoolobjectid) : ?array { + public function get_school_users(string $schoolobjectid): ?array { $endpoint = '/education/schools/' . $schoolobjectid . '/users'; return $this->paginatedapicall('get', $endpoint); @@ -2085,7 +2088,7 @@ public function get_school_users(string $schoolobjectid) : ?array { * * @return bool */ - public function has_education_license() : bool { + public function has_education_license(): bool { $endpoint = '/organization'; $odataqueries = []; $odataqueries[] = '$select=assignedPlans'; @@ -2123,7 +2126,7 @@ public function has_education_license() : bool { * @throws moodle_exception */ public function create_educationclass_group(string $displayname, string $mailnickname, string $description, string $externalid, - string $externalname) : ?array { + string $externalname): ?array { if (!empty($mailnickname)) { $mailnickname = core_text::strtolower($mailnickname); $mailnickname = preg_replace('/[^a-z0-9_]+/iu', '', $mailnickname); @@ -2198,7 +2201,7 @@ public function update_education_group_with_lms_data(string $groupobjectid, arra * @return bool * @throws moodle_exception */ - public function add_chunk_users_to_group(string $groupobjectid, string $role, array $userobjectids) : bool { + public function add_chunk_users_to_group(string $groupobjectid, string $role, array $userobjectids): bool { $endpoint = '/groups/' . $groupobjectid; if ($role == 'owner') { @@ -2279,7 +2282,7 @@ public function create_standard_team_from_group(string $groupobjectid) { * @param array $expectedhttpcodes * @return bool */ - private function check_expected_http_code(array $expectedhttpcodes) : bool { + private function check_expected_http_code(array $expectedhttpcodes): bool { $httpclientinfo = (array) $this->httpclient->info; return in_array($httpclientinfo['http_code'], $expectedhttpcodes); diff --git a/local/o365/classes/task/cohortsync.php b/local/o365/classes/task/cohortsync.php index 847f81d17..46faf5ae3 100644 --- a/local/o365/classes/task/cohortsync.php +++ b/local/o365/classes/task/cohortsync.php @@ -25,8 +25,6 @@ namespace local_o365\task; -defined('MOODLE_INTERNAL') || die(); - use core\task\scheduled_task; use local_o365\feature\cohortsync\main; use local_o365\utils; @@ -40,7 +38,7 @@ class cohortsync extends scheduled_task { * * @return string */ - public function get_name() : string { + public function get_name(): string { return get_string('cohortsync_taskname', 'local_o365'); } @@ -49,7 +47,7 @@ public function get_name() : string { * * @return bool */ - public function execute() : bool { + public function execute(): bool { $graphclient = main::get_unified_api(__METHOD__); if (empty($graphclient)) { utils::mtrace("Failed to get Graph API client. Exiting.", 1); @@ -69,7 +67,7 @@ public function execute() : bool { * @param main $cohortsync * @return void */ - private function execute_sync(main $cohortsync) : void { + private function execute_sync(main $cohortsync): void { if ($cohortsync->update_groups_cache()) { utils::clean_up_not_found_groups(); } else { diff --git a/local/o365/classes/task/coursemembershipsync.php b/local/o365/classes/task/coursemembershipsync.php index 3a4875b46..fd45990ab 100644 --- a/local/o365/classes/task/coursemembershipsync.php +++ b/local/o365/classes/task/coursemembershipsync.php @@ -45,7 +45,7 @@ class coursemembershipsync extends scheduled_task { * * @return string */ - public function get_name() : string { + public function get_name(): string { return get_string('task_coursemembershipsync', 'local_o365'); } @@ -54,7 +54,7 @@ public function get_name() : string { * * @return bool */ - public function execute() : bool { + public function execute(): bool { // If the sync direction is Moodle to Teams, we don't want to sync the course membership. $courseusersyncdirection = get_config('local_o365', 'courseusersyncdirection'); if ($courseusersyncdirection == COURSE_USER_SYNC_DIRECTION_MOODLE_TO_TEAMS) { diff --git a/local/o365/classes/task/coursesync.php b/local/o365/classes/task/coursesync.php index 59b50271a..9387c27a0 100644 --- a/local/o365/classes/task/coursesync.php +++ b/local/o365/classes/task/coursesync.php @@ -25,16 +25,15 @@ namespace local_o365\task; +use core\task\scheduled_task; use local_o365\feature\coursesync\main; use local_o365\utils; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Create any needed groups in Microsoft 365. */ -class coursesync extends \core\task\scheduled_task { +class coursesync extends scheduled_task { /** * Get a descriptive name for this task (shown to admins). * diff --git a/local/o365/classes/task/groupmembershipsync.php b/local/o365/classes/task/groupmembershipsync.php index 4908c94ad..df5e6bd7a 100644 --- a/local/o365/classes/task/groupmembershipsync.php +++ b/local/o365/classes/task/groupmembershipsync.php @@ -67,4 +67,4 @@ public function execute() { } } } -} \ No newline at end of file +} diff --git a/local/o365/classes/task/notifysecretexpiry.php b/local/o365/classes/task/notifysecretexpiry.php index e33d364bc..ebf4b8b79 100644 --- a/local/o365/classes/task/notifysecretexpiry.php +++ b/local/o365/classes/task/notifysecretexpiry.php @@ -34,13 +34,16 @@ require_once($CFG->dirroot . '/auth/oidc/lib.php'); +/** + * Notify secret expiry task. + */ class notifysecretexpiry extends scheduled_task { /** * Return a descriptive name of the task. * * @return string */ - public function get_name() : string { + public function get_name(): string { return get_string('task_notifysecretexpiry', 'local_o365'); } @@ -49,7 +52,7 @@ public function get_name() : string { * * @return bool */ - public function execute() : bool { + public function execute(): bool { if (utils::is_connected() !== true) { return false; } @@ -139,7 +142,7 @@ public function execute() : bool { * * @return array */ - private function get_notification_recipient_emails_from_configuration() : array { + private function get_notification_recipient_emails_from_configuration(): array { $recipientemails = []; $recipientssetting = get_config('auth_oidc', 'secretexpiryrecipients'); @@ -161,7 +164,7 @@ private function get_notification_recipient_emails_from_configuration() : array * * @return array */ - private function get_notification_recipients() : array { + private function get_notification_recipients(): array { $notificationrecipients = []; $recipientemails = $this->get_notification_recipient_emails_from_configuration(); diff --git a/local/o365/classes/task/processcourserequestapproval.php b/local/o365/classes/task/processcourserequestapproval.php index 13936f7e7..093a99466 100644 --- a/local/o365/classes/task/processcourserequestapproval.php +++ b/local/o365/classes/task/processcourserequestapproval.php @@ -25,8 +25,6 @@ namespace local_o365\task; -defined('MOODLE_INTERNAL') || die(); - use core\task\adhoc_task; use local_o365\feature\courserequest\main; use local_o365\feature\coursesync\utils; @@ -40,10 +38,9 @@ class processcourserequestapproval extends adhoc_task { /** * Execute the task. * - * @return void - * @throws moodle_exception + * @return bool */ - public function execute() : bool { + public function execute(): bool { global $DB; $coursedata = $this->get_custom_data(); diff --git a/local/o365/classes/task/processmatchqueue.php b/local/o365/classes/task/processmatchqueue.php index 0c97f403d..0a65d25c1 100644 --- a/local/o365/classes/task/processmatchqueue.php +++ b/local/o365/classes/task/processmatchqueue.php @@ -51,7 +51,7 @@ class processmatchqueue extends scheduled_task { * * @return string */ - public function get_name() : string { + public function get_name(): string { return get_string('task_processmatchqueue', 'local_o365'); } @@ -79,7 +79,7 @@ public function get_api() { /** * Do the job. */ - public function execute() : bool { + public function execute(): bool { global $DB; if (utils::is_connected() !== true) { diff --git a/local/o365/classes/task/updatecourserequeststatus.php b/local/o365/classes/task/updatecourserequeststatus.php index fc14af504..57337cbcd 100644 --- a/local/o365/classes/task/updatecourserequeststatus.php +++ b/local/o365/classes/task/updatecourserequeststatus.php @@ -25,8 +25,6 @@ namespace local_o365\task; -defined('MOODLE_INTERNAL') || die(); - use core\task\scheduled_task; use local_o365\feature\courserequest\main; diff --git a/local/o365/classes/task/usersync.php b/local/o365/classes/task/usersync.php index 019635834..6195dce5e 100644 --- a/local/o365/classes/task/usersync.php +++ b/local/o365/classes/task/usersync.php @@ -31,8 +31,6 @@ use local_o365\utils; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Scheduled task to sync users with Microsoft Entra ID. */ @@ -178,7 +176,7 @@ public function execute() { if (!$suspensiontaskhour) { $suspensiontaskhour = 0; } - if(!$suspensiontaskminute) { + if (!$suspensiontaskminute) { $suspensiontaskminute = 0; } $currenthour = date('H'); @@ -186,13 +184,15 @@ public function execute() { if ($currenthour > $suspensiontaskhour) { $existingtaskusersynclastdeletesetting = get_config('local_o365', 'task_usersync_lastdelete'); if ($existingtaskusersynclastdeletesetting != date('Ymd')) { - add_to_config_log('task_usersync_lastdelete', $existingtaskusersynclastdeletesetting, date('Ymd'), 'local_o365'); + add_to_config_log('task_usersync_lastdelete', $existingtaskusersynclastdeletesetting, date('Ymd'), + 'local_o365'); } set_config('task_usersync_lastdelete', date('Ymd'), 'local_o365'); } else if (($currenthour == $suspensiontaskhour) && ($currentminute >= $suspensiontaskminute)) { $existingtaskusersynclastdeletesetting = get_config('local_o365', 'task_usersync_lastdelete'); if ($existingtaskusersynclastdeletesetting != date('Ymd')) { - add_to_config_log('task_usersync_lastdelete', $existingtaskusersynclastdeletesetting, date('Ymd'), 'local_o365'); + add_to_config_log('task_usersync_lastdelete', $existingtaskusersynclastdeletesetting, date('Ymd'), + 'local_o365'); } set_config('task_usersync_lastdelete', date('Ymd'), 'local_o365'); } else { @@ -276,7 +276,8 @@ protected function sync_users($usersync, $users) { case 'sub': case 'preferred_username': default: - $this->mtrace('Unsupported binding username claim: ' . $bindingusernameclaim . '. Falls back to userPrincepalName.'); + $this->mtrace('Unsupported binding username claim: ' . $bindingusernameclaim . + '. Falls back to userPrincepalName.'); $bindingusernameclaim = 'userPrincipalName'; } diff --git a/local/o365/classes/tests/mockhttpclient.php b/local/o365/classes/tests/mockhttpclient.php index 1275de8a5..1f2f1943e 100644 --- a/local/o365/classes/tests/mockhttpclient.php +++ b/local/o365/classes/tests/mockhttpclient.php @@ -27,8 +27,6 @@ use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * A mock HTTP client allowing set responses. * @@ -84,7 +82,7 @@ public function set_responses(array $responses) { * @return string The set response. * @throws moodle_exception If no responses are available. */ - protected function request($url, $options = array()) { + protected function request($url, $options = []) { $this->requests[] = [ 'url' => $url, 'options' => $options, diff --git a/local/o365/classes/utils.php b/local/o365/classes/utils.php index 53f4c474f..6bfe854ef 100644 --- a/local/o365/classes/utils.php +++ b/local/o365/classes/utils.php @@ -45,6 +45,9 @@ * General purpose utility class. */ class utils { + /** + * @var string RESOURCE_NOT_EXIST_ERROR + */ const RESOURCE_NOT_EXIST_ERROR = 'does not exist or one of its queried reference-property objects are not present'; /** @@ -76,7 +79,7 @@ public static function is_connected() { $clientdata = clientdata::instance_from_oidc(); $graphresource = unified::get_tokenresource(); try { - $token = utils::get_application_token($graphresource, $clientdata, $httpclient); + $token = static::get_application_token($graphresource, $clientdata, $httpclient); if ($token) { return true; } @@ -158,7 +161,7 @@ public static function is_configured_apponlyaccess() { * * @return bool Whether app-only access is active. */ - public static function is_active_apponlyaccess() : bool { + public static function is_active_apponlyaccess(): bool { return static::is_configured_apponlyaccess() === true && unified::is_configured() === true; } @@ -250,9 +253,9 @@ public static function tostring($val) { $valinfo['errorcode'] = $val->errorcode; $valinfo['module'] = $val->module; } - return print_r($valinfo, true); + return json_encode($valinfo, JSON_PRETTY_PRINT); } else { - return print_r($val, true); + return json_encode($val, JSON_PRETTY_PRINT); } } @@ -287,7 +290,7 @@ public static function debug($message, $where = '', $debugdata = null) { * @return unified A constructed unified API client, or throw an error. * @throws moodle_exception */ - public static function get_api(int $userid = null) { + public static function get_api(?int $userid = null) { $tokenresource = unified::get_tokenresource(); $clientdata = clientdata::instance_from_oidc(); $httpclient = new httpclient(); @@ -466,10 +469,10 @@ public static function disableadditionaltenant(string $tenantid) { /** * Delete an additional tenant from the legacy additional tenant settings. * - * @param $tenant + * @param string $tenant * @return bool|void */ - public static function deletelegacyadditionaltenant($tenant) { + public static function deletelegacyadditionaltenant(string $tenant) { $o365config = get_config('local_o365'); if (empty($o365config->legacymultitenants)) { return true; @@ -493,7 +496,7 @@ public static function deletelegacyadditionaltenant($tenant) { * @param int $userid The ID of the user. * @return string The tenant for the user. Empty string unless different from the host tenant. */ - public static function get_tenant_for_user(int $userid) : string { + public static function get_tenant_for_user(int $userid): string { try { $clientdata = clientdata::instance_from_oidc(); $httpclient = new httpclient(); @@ -506,7 +509,7 @@ public static function get_tenant_for_user(int $userid) : string { return ($tenant != get_config('local_o365', 'entratenant')) ? $tenant : ''; } } catch (moodle_exception $e) { - // Do nothing. + return ''; } return ''; } @@ -530,7 +533,7 @@ public static function get_odburl_for_user($userid) { return ($tenant != get_config('local_o365', 'odburl')) ? $tenant : ''; } } catch (moodle_exception $e) { - // Do nothing. + return ''; } return ''; } @@ -554,7 +557,7 @@ public static function get_microsoft_account_oid_by_user_id(int $userid) { * * @return array */ - public static function get_connected_users() : array { + public static function get_connected_users(): array { global $DB; $connectedusers = []; @@ -574,7 +577,7 @@ public static function get_connected_users() : array { * @param int $baselevel * @return bool */ - public static function update_groups_cache(unified $graphclient, int $baselevel = 0) : bool { + public static function update_groups_cache(unified $graphclient, int $baselevel = 0): bool { global $DB; static::mtrace("Update groups cache.", $baselevel); @@ -646,7 +649,7 @@ public static function update_groups_cache(unified $graphclient, int $baselevel * @param int $baselevel * @return void */ - public static function clean_up_not_found_groups(int $baselevel = 1) : void { + public static function clean_up_not_found_groups(int $baselevel = 1): void { global $DB; static::mtrace('Clean up non-existing groups from database', $baselevel); @@ -677,7 +680,7 @@ public static function clean_up_not_found_groups(int $baselevel = 1) : void { * @param string $eol * @return void */ - public static function mtrace(string $message, int $level = 0, string $eol = "\n") { + public static function mtrace(string $message, int $level = 0, string $eol = "\n"): void { if ($level) { $message = str_repeat('...', $level) . ' ' . $message; } @@ -690,7 +693,7 @@ public static function mtrace(string $message, int $level = 0, string $eol = "\n * @param string $errormessage * @return string|null */ - public static function extract_guid_from_error_message(string $errormessage) : ?string { + public static function extract_guid_from_error_message(string $errormessage): ?string { $pattern = '/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/'; preg_match($pattern, $errormessage, $matches); return $matches[0] ?? null; diff --git a/local/o365/classes/webservices/create_onenoteassignment.php b/local/o365/classes/webservices/create_onenoteassignment.php index de1de3906..be208dca3 100644 --- a/local/o365/classes/webservices/create_onenoteassignment.php +++ b/local/o365/classes/webservices/create_onenoteassignment.php @@ -54,7 +54,7 @@ public static function assignment_create_parameters() { 'section' => new external_value(PARAM_INT, 'section', VALUE_DEFAULT, 0), 'visible' => new external_value(PARAM_BOOL, 'visible', VALUE_DEFAULT, false), 'duedate' => new external_value(PARAM_INT, 'duedate', VALUE_DEFAULT, 0), - ]) + ]), ]); } @@ -81,7 +81,6 @@ public static function assignment_create($data) { 'duedate' => 0, 'cutoffdate' => 0, 'allowsubmissionsfromdate' => 0, - 'grade' => 0, 'gradingduedate' => 0, 'completionsubmit' => 0, 'teamsubmission' => 0, diff --git a/local/o365/classes/webservices/delete_onenoteassignment.php b/local/o365/classes/webservices/delete_onenoteassignment.php index 7e7ebef6d..3c6546b5e 100644 --- a/local/o365/classes/webservices/delete_onenoteassignment.php +++ b/local/o365/classes/webservices/delete_onenoteassignment.php @@ -50,7 +50,7 @@ public static function assignment_delete_parameters() { 'data' => new external_single_structure([ 'coursemodule' => new external_value(PARAM_INT, 'course module id'), 'course' => new external_value(PARAM_INT, 'course id'), - ]) + ]), ]); } diff --git a/local/o365/classes/webservices/exception/assignnotfound.php b/local/o365/classes/webservices/exception/assignnotfound.php index 353ebf306..8237e3fa1 100644 --- a/local/o365/classes/webservices/exception/assignnotfound.php +++ b/local/o365/classes/webservices/exception/assignnotfound.php @@ -25,8 +25,6 @@ namespace local_o365\webservices\exception; -defined('MOODLE_INTERNAL') || die(); - /** * Exception thrown when an associated assignment record is not found for a given course module. */ diff --git a/local/o365/classes/webservices/exception/couldnotsavegrade.php b/local/o365/classes/webservices/exception/couldnotsavegrade.php index dd6ff24c4..16f85c17d 100644 --- a/local/o365/classes/webservices/exception/couldnotsavegrade.php +++ b/local/o365/classes/webservices/exception/couldnotsavegrade.php @@ -25,8 +25,6 @@ namespace local_o365\webservices\exception; -defined('MOODLE_INTERNAL') || die(); - /** * Exception thrown when a grade could not be saved in local_o365_update_grade. */ diff --git a/local/o365/classes/webservices/exception/invalidassignment.php b/local/o365/classes/webservices/exception/invalidassignment.php index 5864d35ff..83e938ef4 100644 --- a/local/o365/classes/webservices/exception/invalidassignment.php +++ b/local/o365/classes/webservices/exception/invalidassignment.php @@ -25,8 +25,6 @@ namespace local_o365\webservices\exception; -defined('MOODLE_INTERNAL') || die(); - /** * Exception thrown when a module is called that is not a OneNote assignment. */ diff --git a/local/o365/classes/webservices/exception/modulenotfound.php b/local/o365/classes/webservices/exception/modulenotfound.php index c6d9e045f..cbe6829ca 100644 --- a/local/o365/classes/webservices/exception/modulenotfound.php +++ b/local/o365/classes/webservices/exception/modulenotfound.php @@ -25,8 +25,6 @@ namespace local_o365\webservices\exception; -defined('MOODLE_INTERNAL') || die(); - /** * Exception thrown when a module that does not exist is called. */ diff --git a/local/o365/classes/webservices/exception/sectionnotfound.php b/local/o365/classes/webservices/exception/sectionnotfound.php index aa493ef69..10be9e256 100644 --- a/local/o365/classes/webservices/exception/sectionnotfound.php +++ b/local/o365/classes/webservices/exception/sectionnotfound.php @@ -25,8 +25,6 @@ namespace local_o365\webservices\exception; -defined('MOODLE_INTERNAL') || die(); - /** * Exception thrown when a course section that does not exist is used to update an assignment. */ diff --git a/local/o365/classes/webservices/read_assignments.php b/local/o365/classes/webservices/read_assignments.php index 0a546d028..9bbd154ab 100644 --- a/local/o365/classes/webservices/read_assignments.php +++ b/local/o365/classes/webservices/read_assignments.php @@ -80,7 +80,7 @@ public static function assignments_read_parameters() { 'courseids to not be empty.', VALUE_DEFAULT, false - ) + ), ]); } @@ -94,26 +94,26 @@ public static function assignments_read_parameters() { * @param array $capabilities An array of additional capability checks you wish to be made on the course context. * @param bool $includenotenrolledcourses Wheter to return courses that the user can see even if is not enroled in. * This requires the parameter $courseids to not be empty. - * @return An array of courses and warnings. + * @return array An array of courses and warnings. * @since Moodle 2.4 */ public static function assignments_read($courseids = [], $assignmentids = [], $capabilities = [], $includenotenrolledcourses = false) { - global $USER, $DB, $CFG; + global $USER, $DB; $params = self::validate_parameters( self::assignments_read_parameters(), - array( + [ 'courseids' => $courseids, 'assignmentids' => $assignmentids, 'capabilities' => $capabilities, - 'includenotenrolledcourses' => $includenotenrolledcourses - ) + 'includenotenrolledcourses' => $includenotenrolledcourses, + ] ); $assignmentids = array_flip($params['assignmentids']); - $warnings = array(); - $courses = array(); + $warnings = []; + $courses = []; $fields = 'sortorder,shortname,fullname,timemodified'; // If the courseids list is empty, we return only the courses where the user is enrolled in. @@ -131,12 +131,12 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c foreach ($params['courseids'] as $courseid) { if (!in_array($courseid, $mycourseids)) { unset($courses[$courseid]); - $warnings[] = array( + $warnings[] = [ 'item' => 'course', 'itemid' => $courseid, 'warningcode' => '2', - 'message' => 'User is not enrolled or does not have requested capability' - ); + 'message' => 'User is not enrolled or does not have requested capability', + ]; } else { $courses[$courseid] = $mycourses[$courseid]; } @@ -156,12 +156,12 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c } } catch (moodle_exception $e) { unset($courses[$cid]); - $warnings[] = array( + $warnings[] = [ 'item' => 'course', 'itemid' => $cid, 'warningcode' => '1', - 'message' => 'No access rights in course context ' . $e->getMessage() - ); + 'message' => 'No access rights in course context ' . $e->getMessage(), + ]; continue; } if (count($params['capabilities']) > 0 && !has_all_capabilities($params['capabilities'], $context)) { @@ -193,10 +193,10 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c 'm.requiresubmissionstatement, '. 'm.intro, '. 'm.introformat'; - $coursearray = array(); + $coursearray = []; foreach ($courses as $id => $course) { - $assignmentarray = array(); + $assignmentarray = []; // Get a list of assignments for the course. if ($modules = get_coursemodules_in_course('assign', $courses[$id]->id, $extrafields)) { foreach ($modules as $module) { @@ -211,29 +211,29 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c self::validate_context($context); require_capability('mod/assign:view', $context); } catch (moodle_exception $e) { - $warnings[] = array( + $warnings[] = [ 'item' => 'module', 'itemid' => $module->id, 'warningcode' => '1', - 'message' => 'No access rights in module context' - ); + 'message' => 'No access rights in module context', + ]; continue; } - $configrecords = $DB->get_recordset('assign_plugin_config', array('assignment' => $module->assignmentid)); - $configarray = array(); + $configrecords = $DB->get_recordset('assign_plugin_config', ['assignment' => $module->assignmentid]); + $configarray = []; foreach ($configrecords as $configrecord) { - $configarray[] = array( + $configarray[] = [ 'id' => $configrecord->id, 'assignment' => $configrecord->assignment, 'plugin' => $configrecord->plugin, 'subtype' => $configrecord->subtype, 'name' => $configrecord->name, - 'value' => $configrecord->value - ); + 'value' => $configrecord->value, + ]; } $configrecords->close(); - $assignment = array( + $assignment = [ 'id' => $module->assignmentid, 'cmid' => $module->id, 'course' => $module->course, @@ -259,8 +259,8 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c 'markingworkflow' => $module->markingworkflow, 'markingallocation' => $module->markingallocation, 'requiresubmissionstatement' => $module->requiresubmissionstatement, - 'configs' => $configarray - ); + 'configs' => $configarray, + ]; // Return or not intro and file attachments depending on the plugin settings. $assign = new \assign($context, null, null); @@ -272,18 +272,18 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c $fs = get_file_storage(); if ($files = $fs->get_area_files($context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, - 0, 'timemodified', false)) { + 0, 'timemodified', false)) { - $assignment['introattachments'] = array(); + $assignment['introattachments'] = []; foreach ($files as $file) { $filename = $file->get_filename(); - $assignment['introattachments'][] = array( + $assignment['introattachments'][] = [ 'filename' => $filename, 'mimetype' => $file->get_mimetype(), - 'fileurl' => \moodle_url::make_webservice_pluginfile_url( - $context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, '/', $filename)->out(false) - ); + 'fileurl' => \moodle_url::make_webservice_pluginfile_url( + $context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, '/', $filename)->out(false), + ]; } } } @@ -291,19 +291,20 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c $assignmentarray[] = $assignment; } } - $coursearray[] = array( + $coursearray[] = [ 'id' => $courses[$id]->id, 'fullname' => $courses[$id]->fullname, 'shortname' => $courses[$id]->shortname, 'timemodified' => $courses[$id]->timemodified, - 'assignments' => $assignmentarray - ); + 'assignments' => $assignmentarray, + ]; } - $result = array( + $result = [ 'courses' => $coursearray, - 'warnings' => $warnings - ); + 'warnings' => $warnings, + ]; + return $result; } @@ -315,7 +316,7 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c */ private static function get_assignments_assignment_structure() { return new external_single_structure( - array( + [ 'id' => new external_value(PARAM_INT, 'assignment id'), 'cmid' => new external_value(PARAM_INT, 'course module id'), 'course' => new external_value(PARAM_INT, 'course id'), @@ -347,14 +348,14 @@ private static function get_assignments_assignment_structure() { 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), 'introattachments' => new external_multiple_structure( new external_single_structure( - array ( + [ 'filename' => new external_value(PARAM_FILE, 'file name'), 'mimetype' => new external_value(PARAM_RAW, 'mime type'), - 'fileurl' => new external_value(PARAM_URL, 'file download url') - ) + 'fileurl' => new external_value(PARAM_URL, 'file download url'), + ] ), 'intro attachments files', VALUE_OPTIONAL - ) - ), 'assignment information object'); + ), + ], 'assignment information object'); } /** @@ -365,14 +366,14 @@ private static function get_assignments_assignment_structure() { */ private static function get_assignments_config_structure() { return new external_single_structure( - array( + [ 'id' => new external_value(PARAM_INT, 'assign_plugin_config id'), 'assignment' => new external_value(PARAM_INT, 'assignment id'), 'plugin' => new external_value(PARAM_TEXT, 'plugin'), 'subtype' => new external_value(PARAM_TEXT, 'subtype'), 'name' => new external_value(PARAM_TEXT, 'name'), - 'value' => new external_value(PARAM_TEXT, 'value') - ), 'assignment configuration object' + 'value' => new external_value(PARAM_TEXT, 'value'), + ], 'assignment configuration object' ); } @@ -384,13 +385,13 @@ private static function get_assignments_config_structure() { */ private static function get_assignments_course_structure() { return new external_single_structure( - array( + [ 'id' => new external_value(PARAM_INT, 'course id'), 'fullname' => new external_value(PARAM_TEXT, 'course full name'), 'shortname' => new external_value(PARAM_TEXT, 'course short name'), 'timemodified' => new external_value(PARAM_INT, 'last time modified'), - 'assignments' => new external_multiple_structure(self::get_assignments_assignment_structure(), 'assignment info') - ), 'course information object' + 'assignments' => new external_multiple_structure(self::get_assignments_assignment_structure(), 'assignment info'), + ], 'course information object' ); } @@ -402,12 +403,12 @@ private static function get_assignments_course_structure() { */ public static function assignments_read_returns() { return new external_single_structure( - array( + [ 'courses' => new external_multiple_structure(self::get_assignments_course_structure(), 'list of courses'), - 'warnings' => new external_warnings('item can be \'course\' (errorcode 1 or 2) or \'module\' (errorcode 1)', + 'warnings' => new external_warnings('item can be \'course\' (errorcode 1 or 2) or \'module\' (errorcode 1)', 'When item is a course then itemid is a course id. When the item is a module then itemid is a module id', - 'errorcode can be 1 (no access rights) or 2 (not enrolled or no permissions)') - ) + 'errorcode can be 1 (no access rights) or 2 (not enrolled or no permissions)'), + ] ); } diff --git a/local/o365/classes/webservices/read_courseusers.php b/local/o365/classes/webservices/read_courseusers.php index 274b95588..3f39b0054 100644 --- a/local/o365/classes/webservices/read_courseusers.php +++ b/local/o365/classes/webservices/read_courseusers.php @@ -109,7 +109,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber $limitnumber = clean_param($limitnumber, PARAM_INT); if ($courseid == SITEID) { - // TODO exception. + return []; } $course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); $context = \context_course::instance($courseid); diff --git a/local/o365/classes/webservices/read_onenoteassignment.php b/local/o365/classes/webservices/read_onenoteassignment.php index d1d676979..6dfe02fb5 100644 --- a/local/o365/classes/webservices/read_onenoteassignment.php +++ b/local/o365/classes/webservices/read_onenoteassignment.php @@ -50,7 +50,7 @@ public static function assignment_read_parameters() { 'data' => new external_single_structure([ 'coursemodule' => new external_value(PARAM_INT, 'course module id'), 'course' => new external_value(PARAM_INT, 'course id'), - ]) + ]), ]); } diff --git a/local/o365/classes/webservices/read_teachercourses.php b/local/o365/classes/webservices/read_teachercourses.php index 5bc6dfa14..ea3437c8f 100644 --- a/local/o365/classes/webservices/read_teachercourses.php +++ b/local/o365/classes/webservices/read_teachercourses.php @@ -73,7 +73,7 @@ public static function teachercourses_read($courseids = []) { $params = self::validate_parameters( self::teachercourses_read_parameters(), [ - 'courseids' => $courseids + 'courseids' => $courseids, ] ); @@ -114,7 +114,7 @@ public static function teachercourses_read($courseids = []) { 'format' => $course->format, 'showgrades' => $course->showgrades, 'lang' => $course->lang, - 'enablecompletion' => $course->enablecompletion + 'enablecompletion' => $course->enablecompletion, ]; } diff --git a/local/o365/classes/webservices/update_grade.php b/local/o365/classes/webservices/update_grade.php index 20c6cc0b6..695d8930f 100644 --- a/local/o365/classes/webservices/update_grade.php +++ b/local/o365/classes/webservices/update_grade.php @@ -53,7 +53,7 @@ public static function grade_update_parameters() { global $CFG; require_once("$CFG->dirroot/grade/grading/lib.php"); $instance = new \assign(null, null, null); - $pluginfeedbackparams = array(); + $pluginfeedbackparams = []; foreach ($instance->get_feedback_plugins() as $plugin) { if ($plugin->is_visible()) { @@ -64,21 +64,21 @@ public static function grade_update_parameters() { } } - $advancedgradingdata = array(); + $advancedgradingdata = []; $methods = array_keys(\grading_manager::available_methods(false)); foreach ($methods as $method) { - require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php'); - $details = call_user_func('gradingform_'.$method.'_controller::get_external_instance_filling_details'); + require_once($CFG->dirroot . '/grade/grading/form/' . $method . '/lib.php'); + $details = call_user_func('gradingform_' . $method . '_controller::get_external_instance_filling_details'); if (!empty($details)) { - $items = array(); + $items = []; foreach ($details as $key => $value) { $value->required = VALUE_OPTIONAL; unset($value->content->keys['id']); $items[$key] = new external_multiple_structure (new external_single_structure( - array( + [ 'criterionid' => new external_value(PARAM_INT, 'criterion id'), - 'fillings' => $value - ) + 'fillings' => $value, + ] )); } $advancedgradingdata[$method] = new external_single_structure($items, 'items', VALUE_OPTIONAL); @@ -86,20 +86,19 @@ public static function grade_update_parameters() { } return new external_function_parameters( - array( + [ 'assignmentid' => new external_value(PARAM_INT, 'The assignment id to operate on'), 'userid' => new external_value(PARAM_INT, 'The student id to operate on'), 'grade' => new external_value(PARAM_FLOAT, 'The new grade for this user. Ignored if advanced grading used'), 'attemptnumber' => new external_value(PARAM_INT, 'The attempt number (-1 means latest attempt)'), 'addattempt' => new external_value(PARAM_BOOL, 'Allow another attempt if the attempt reopen method is manual'), 'workflowstate' => new external_value(PARAM_ALPHA, 'The next marking workflow state'), - 'applytoall' => new external_value(PARAM_BOOL, 'If true, this grade will be applied ' . - 'to all members ' . - 'of the group (for group assignments).'), - 'plugindata' => new external_single_structure($pluginfeedbackparams, 'plugin data', VALUE_DEFAULT, array()), + 'applytoall' => new external_value(PARAM_BOOL, 'If true, this grade will be applied to all members ' . + 'of the group (for group assignments).'), + 'plugindata' => new external_single_structure($pluginfeedbackparams, 'plugin data', VALUE_DEFAULT, []), 'advancedgradingdata' => new external_single_structure($advancedgradingdata, 'advanced grading data', - VALUE_DEFAULT, array()) - ) + VALUE_DEFAULT, []), + ] ); } @@ -119,27 +118,14 @@ public static function grade_update_parameters() { * @throws exception\couldnotsavegrade * @since Moodle 2.6 */ - public static function grade_update($assignmentid, - $userid, - $grade, - $attemptnumber, - $addattempt, - $workflowstate, - $applytoall, - $plugindata = array(), - $advancedgradingdata = array()) { - global $CFG, $USER, $DB; - - $params = self::validate_parameters(self::grade_update_parameters(), - array('assignmentid' => $assignmentid, - 'userid' => $userid, - 'grade' => $grade, - 'attemptnumber' => $attemptnumber, - 'workflowstate' => $workflowstate, - 'addattempt' => $addattempt, - 'applytoall' => $applytoall, - 'plugindata' => $plugindata, - 'advancedgradingdata' => $advancedgradingdata)); + public static function grade_update($assignmentid, $userid, $grade, $attemptnumber, $addattempt, $workflowstate, $applytoall, + $plugindata = [], $advancedgradingdata = []) { + global $DB; + + $params = self::validate_parameters(self::grade_update_parameters(), ['assignmentid' => $assignmentid, + 'userid' => $userid, 'grade' => $grade, 'attemptnumber' => $attemptnumber, 'workflowstate' => $workflowstate, + 'addattempt' => $addattempt, 'applytoall' => $applytoall, 'plugindata' => $plugindata, + 'advancedgradingdata' => $advancedgradingdata]); $cm = get_coursemodule_from_instance('assign', $params['assignmentid'], 0, false, MUST_EXIST); $context = \context_module::instance($cm->id); @@ -156,10 +142,10 @@ public static function grade_update($assignmentid, $gradedata->grade = $params['grade']; if (!empty($params['advancedgradingdata'])) { - $advancedgrading = array(); + $advancedgrading = []; $criteria = reset($params['advancedgradingdata']); foreach ($criteria as $key => $criterion) { - $details = array(); + $details = []; foreach ($criterion as $value) { foreach ($value['fillings'] as $filling) { $details[$value['criterionid']] = $filling; @@ -186,7 +172,7 @@ public static function grade_update($assignmentid, return [ 'id' => $graderec->id, - 'itemid' => $graderec->itemid + 'itemid' => $graderec->itemid, ]; } diff --git a/local/o365/classes/webservices/update_onenoteassignment.php b/local/o365/classes/webservices/update_onenoteassignment.php index 0b322996d..d44bd0f62 100644 --- a/local/o365/classes/webservices/update_onenoteassignment.php +++ b/local/o365/classes/webservices/update_onenoteassignment.php @@ -55,7 +55,7 @@ public static function assignment_update_parameters() { 'intro' => new external_value(PARAM_TEXT, 'intro', VALUE_DEFAULT, null), 'section' => new external_value(PARAM_INT, 'section', VALUE_DEFAULT, null), 'visible' => new external_value(PARAM_BOOL, 'visible', VALUE_DEFAULT, null), - ]) + ]), ]); } diff --git a/local/o365/classes/webservices/utils.php b/local/o365/classes/webservices/utils.php index 7eb061611..f9f2333c9 100644 --- a/local/o365/classes/webservices/utils.php +++ b/local/o365/classes/webservices/utils.php @@ -28,11 +28,9 @@ use core_external\external_multiple_structure; use core_external\external_single_structure; use core_external\external_value; -use \local_o365\webservices\exception as exception; +use local_o365\webservices\exception as exception; use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * Webservices utilities. */ diff --git a/local/o365/db/access.php b/local/o365/db/access.php index 2363818ec..92b7cb7a7 100644 --- a/local/o365/db/access.php +++ b/local/o365/db/access.php @@ -32,7 +32,7 @@ 'contextlevel' => CONTEXT_COURSE, 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ], ], 'local/o365:viewgroups' => [ diff --git a/local/o365/db/caches.php b/local/o365/db/caches.php index 22f161420..e22d27bb1 100644 --- a/local/o365/db/caches.php +++ b/local/o365/db/caches.php @@ -27,6 +27,6 @@ $definitions = [ 'groups' => [ - 'mode' => cache_store::MODE_SESSION + 'mode' => cache_store::MODE_SESSION, ], ]; diff --git a/local/o365/db/services.php b/local/o365/db/services.php index 4aad3b421..4836c2b84 100644 --- a/local/o365/db/services.php +++ b/local/o365/db/services.php @@ -103,5 +103,5 @@ 'restrictedusers' => 0, 'enabled' => 0, 'shortname' => 'o365_webservices', - ] + ], ]; diff --git a/local/o365/db/tasks.php b/local/o365/db/tasks.php index 57e4bb2eb..5714a487c 100644 --- a/local/o365/db/tasks.php +++ b/local/o365/db/tasks.php @@ -33,7 +33,7 @@ 'hour' => '1', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\task\coursesync', @@ -42,7 +42,7 @@ 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\feature\calsync\task\importfromoutlook', @@ -51,7 +51,7 @@ 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\task\processmatchqueue', @@ -60,7 +60,7 @@ 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\feature\sds\task\sync', @@ -69,7 +69,7 @@ 'hour' => '3', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\task\notifysecretexpiry', @@ -87,7 +87,7 @@ 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\task\updatecourserequeststatus', @@ -96,7 +96,7 @@ 'hour' => '*', 'day' => '*', 'dayofweek' => '*', - 'month' => '*' + 'month' => '*', ], [ 'classname' => 'local_o365\task\coursemembershipsync', diff --git a/local/o365/db/upgrade.php b/local/o365/db/upgrade.php index 312287442..939e1697c 100644 --- a/local/o365/db/upgrade.php +++ b/local/o365/db/upgrade.php @@ -46,7 +46,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->table_exists('local_o365_token')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_token'); } - upgrade_plugin_savepoint(true, '2014111700', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111700, 'local', 'o365'); } if ($oldversion < 2014111702) { @@ -56,21 +56,21 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->table_exists('local_o365_calidmap')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_calidmap'); } - upgrade_plugin_savepoint(true, '2014111702', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111702, 'local', 'o365'); } if ($oldversion < 2014111703) { $table = new xmldb_table('local_o365_calidmap'); $field = new xmldb_field('outlookeventid', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, 'eventid'); $dbman->change_field_type($table, $field); - upgrade_plugin_savepoint(true, '2014111703', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111703, 'local', 'o365'); } if ($oldversion < 2014111707) { if (!$dbman->table_exists('local_o365_cronqueue')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_cronqueue'); } - upgrade_plugin_savepoint(true, '2014111707', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111707, 'local', 'o365'); } if ($oldversion < 2014111710) { @@ -83,7 +83,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->table_exists('local_o365_aaduserdata')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_aaduserdata'); } - upgrade_plugin_savepoint(true, '2014111710', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111710, 'local', 'o365'); } if ($oldversion < 2014111711) { @@ -92,14 +92,14 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - upgrade_plugin_savepoint(true, '2014111711', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111711, 'local', 'o365'); } if ($oldversion < 2014111715) { if (!$dbman->table_exists('local_o365_spgroupassign')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_spgroupassign'); } - upgrade_plugin_savepoint(true, '2014111715', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111715, 'local', 'o365'); } if ($oldversion < 2014111716) { @@ -122,7 +122,7 @@ function xmldb_local_o365_upgrade($oldversion) { $dbman->add_index($table, $index); } - upgrade_plugin_savepoint(true, '2014111716', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2014111716, 'local', 'o365'); } if ($oldversion < 2015012702) { @@ -133,7 +133,7 @@ function xmldb_local_o365_upgrade($oldversion) { add_to_config_log('sharepointlink', '', $sharepointlink, 'local_o365'); set_config('sharepointlink', $sharepointlink, 'local_o365'); } - upgrade_plugin_savepoint(true, '2015012702', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012702, 'local', 'o365'); } if ($oldversion < 2015012704) { @@ -150,7 +150,7 @@ function xmldb_local_o365_upgrade($oldversion) { } set_config('odburl', $config->tenant.'-my.sharepoint.com', 'local_o365'); } - upgrade_plugin_savepoint(true, '2015012704', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012704, 'local', 'o365'); } if ($oldversion < 2015012707) { @@ -163,7 +163,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - upgrade_plugin_savepoint(true, '2015012707', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012707, 'local', 'o365'); } if ($oldversion < 2015012708) { @@ -184,7 +184,7 @@ function xmldb_local_o365_upgrade($oldversion) { } $idmaps->close(); - upgrade_plugin_savepoint(true, '2015012708', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012708, 'local', 'o365'); } if ($oldversion < 2015012709) { @@ -217,7 +217,7 @@ function xmldb_local_o365_upgrade($oldversion) { } $idmaps->close(); - upgrade_plugin_savepoint(true, '2015012709', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012709, 'local', 'o365'); } if ($oldversion < 2015012710) { @@ -231,7 +231,7 @@ function xmldb_local_o365_upgrade($oldversion) { } } $calsubs->close(); - upgrade_plugin_savepoint(true, '2015012710', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012710, 'local', 'o365'); } if ($oldversion < 2015012712) { @@ -239,14 +239,14 @@ function xmldb_local_o365_upgrade($oldversion) { $table = new xmldb_table('local_o365_token'); $field = new xmldb_field('scope', XMLDB_TYPE_TEXT, null, null, null, null, null, 'user_id'); $dbman->change_field_type($table, $field); - upgrade_plugin_savepoint(true, '2015012712', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012712, 'local', 'o365'); } if ($oldversion < 2015012713) { if (!$dbman->table_exists('local_o365_objects')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_objects'); } - upgrade_plugin_savepoint(true, '2015012713', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012713, 'local', 'o365'); } if ($oldversion < 2015012714) { @@ -255,7 +255,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - upgrade_plugin_savepoint(true, '2015012714', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012714, 'local', 'o365'); } if ($oldversion < 2015012715) { @@ -263,7 +263,7 @@ function xmldb_local_o365_upgrade($oldversion) { $table = new xmldb_table('local_o365_token'); $field = new xmldb_field('scope', XMLDB_TYPE_TEXT, null, null, null, null, null, 'user_id'); $dbman->change_field_type($table, $field); - upgrade_plugin_savepoint(true, '2015012715', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015012715, 'local', 'o365'); } if ($oldversion < 2015060102) { @@ -272,14 +272,14 @@ function xmldb_local_o365_upgrade($oldversion) { add_to_config_log('aadsync', '1', 'create', 'local_o365'); set_config('aadsync', 'create', 'local_o365'); } - upgrade_plugin_savepoint(true, '2015060102', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015060102, 'local', 'o365'); } if ($oldversion < 2015060103) { if (!$dbman->table_exists('local_o365_connections')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_connections'); } - upgrade_plugin_savepoint(true, '2015060103', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015060103, 'local', 'o365'); } if ($oldversion < 2015060104) { @@ -288,7 +288,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - upgrade_plugin_savepoint(true, '2015060104', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015060104, 'local', 'o365'); } if ($oldversion < 2015060109) { @@ -311,14 +311,14 @@ function xmldb_local_o365_upgrade($oldversion) { } } } - upgrade_plugin_savepoint(true, '2015060109', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015060109, 'local', 'o365'); } if ($oldversion < 2015060111) { // Clean up old "calendarsyncin" task record, if present. Replaced by \local_o365\feature\calsync\task\importfromoutlook. $conditions = ['component' => 'local_o365', 'classname' => '\local_o365\task\calendarsyncin']; $DB->delete_records('task_scheduled', $conditions); - upgrade_plugin_savepoint(true, '2015060111', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015060111, 'local', 'o365'); } if ($oldversion < 2015111900.01) { @@ -343,7 +343,7 @@ function xmldb_local_o365_upgrade($oldversion) { } } - upgrade_plugin_savepoint(true, '2015111900.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111900.01, 'local', 'o365'); } if ($oldversion < 2015111900.02) { @@ -351,7 +351,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->table_exists($table)) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_appassign'); } - upgrade_plugin_savepoint(true, '2015111900.02', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111900.02, 'local', 'o365'); } if ($oldversion < 2015111901.01) { @@ -359,7 +359,7 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->table_exists($table)) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_matchqueue'); } - upgrade_plugin_savepoint(true, '2015111901.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111901.01, 'local', 'o365'); } if ($oldversion < 2015111901.03) { @@ -378,12 +378,12 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->index_exists($table, $index)) { $dbman->add_index($table, $index); } - upgrade_plugin_savepoint(true, '2015111901.03', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111901.03, 'local', 'o365'); } if ($oldversion < 2015111903) { $table = new xmldb_table('local_o365_appassign'); - $index = new xmldb_index('userobjectid', XMLDB_INDEX_UNIQUE, array('userobjectid')); + $index = new xmldb_index('userobjectid', XMLDB_INDEX_UNIQUE, ['userobjectid']); if ($dbman->index_exists($table, $index)) { $dbman->drop_index($table, $index); } @@ -399,17 +399,17 @@ function xmldb_local_o365_upgrade($oldversion) { if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); } - upgrade_plugin_savepoint(true, '2015111903', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111903, 'local', 'o365'); } if ($oldversion < 2015111905) { // Delete custom profile fields for data type o365 and oidc which are no longer used. $fields = $DB->get_records_sql("SELECT * FROM {user_info_field} WHERE datatype IN ('o365', 'oidc')"); foreach ($fields as $field) { - $DB->delete_records('user_info_data', array('fieldid' => $field->id)); - $DB->delete_records('user_info_field', array('id' => $field->id)); + $DB->delete_records('user_info_data', ['fieldid' => $field->id]); + $DB->delete_records('user_info_field', ['id' => $field->id]); } - upgrade_plugin_savepoint(true, '2015111905', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111905, 'local', 'o365'); } if ($oldversion < 2015111911.01) { @@ -419,14 +419,14 @@ function xmldb_local_o365_upgrade($oldversion) { $field->setNotNull(false); $dbman->change_field_notnull($table, $field); } - upgrade_plugin_savepoint(true, '2015111911.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111911.01, 'local', 'o365'); } if ($oldversion < 2015111913) { if (!$dbman->table_exists('local_o365_coursegroupdata')) { $dbman->install_one_table_from_xmldb_file(__DIR__.'/install.xml', 'local_o365_coursegroupdata'); } - upgrade_plugin_savepoint(true, '2015111913', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111913, 'local', 'o365'); } if ($oldversion < 2015111913.02) { @@ -438,7 +438,7 @@ function xmldb_local_o365_upgrade($oldversion) { } set_config('creategroups', 'onall', 'local_o365'); } - upgrade_plugin_savepoint(true, '2015111913.02', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111913.02, 'local', 'o365'); } if ($oldversion < 2015111914.02) { @@ -452,7 +452,7 @@ function xmldb_local_o365_upgrade($oldversion) { } // O365 savepoint reached. - upgrade_plugin_savepoint(true, '2015111914.02', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111914.02, 'local', 'o365'); } if ($oldversion < 2015111914.03) { @@ -469,7 +469,7 @@ function xmldb_local_o365_upgrade($oldversion) { $dbman->drop_index($table, $index); } - upgrade_plugin_savepoint(true, '2015111914.03', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111914.03, 'local', 'o365'); } if ($oldversion < 2015111916.01) { @@ -483,7 +483,7 @@ function xmldb_local_o365_upgrade($oldversion) { $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_o365_calsettings. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally launch create table for local_o365_calsettings. if (!$dbman->table_exists($table)) { @@ -502,13 +502,13 @@ function xmldb_local_o365_upgrade($oldversion) { $newsetting = [ 'user_id' => $USER->id, 'o365calid' => $sitecalendar['Id'], - 'timecreated' => time() + 'timecreated' => time(), ]; $newsetting['id'] = $DB->insert_record('local_o365_calsettings', (object)$newsetting); } } - upgrade_plugin_savepoint(true, '2015111916.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2015111916.01, 'local', 'o365'); } if ($oldversion < 2016062000.01) { @@ -517,7 +517,7 @@ function xmldb_local_o365_upgrade($oldversion) { add_to_config_log('sharepointcourseselect', $existingsharepointcourseselectsetting, 'off', 'local_o365'); } set_config('sharepointcourseselect', 'off', 'local_o365'); - upgrade_plugin_savepoint(true, '2016062000.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016062000.01, 'local', 'o365'); } if ($oldversion < 2016062000.02) { @@ -528,7 +528,7 @@ function xmldb_local_o365_upgrade($oldversion) { $caps = [ 'auth/oidc:manageconnection' => ['local/o365:manageconnectionlink', 'local/o365:manageconnectionunlink'], 'auth/oidc:manageconnectionconnect' => ['local/o365:manageconnectionlink'], - 'auth/oidc:manageconnectiondisconnect' => ['local/o365:manageconnectionunlink'] + 'auth/oidc:manageconnectiondisconnect' => ['local/o365:manageconnectionunlink'], ]; foreach ($caps as $cap => $addcaps) { $roles = get_roles_with_capability($cap, CAP_ALLOW); @@ -538,8 +538,8 @@ function xmldb_local_o365_upgrade($oldversion) { $newrolecap = $rolecap; unset($newrolecap->id); foreach ($addcaps as $addcap) { - if (!$DB->record_exists('role_capabilities', ['roleid' => $role->id, - 'capability' => $addcap, 'contextid' => $newrolecap->contextid])) { + if (!$DB->record_exists('role_capabilities', + ['roleid' => $role->id, 'capability' => $addcap, 'contextid' => $newrolecap->contextid])) { $newrolecap->capability = $addcap; $DB->insert_record('role_capabilities', $newrolecap); } @@ -560,7 +560,7 @@ function xmldb_local_o365_upgrade($oldversion) { $dbman->add_field($table, $field); } } - upgrade_plugin_savepoint(true, '2016062000.03', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016062000.03, 'local', 'o365'); } if ($oldversion < 2016062001.01) { @@ -573,7 +573,7 @@ function xmldb_local_o365_upgrade($oldversion) { add_to_config_log('sharepointcourseselect', $sharepointcourseselect, 'none', 'local_o365'); set_config('sharepointcourseselect', 'none', 'local_o365'); } - upgrade_plugin_savepoint(true, '2016062001.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016062001.01, 'local', 'o365'); } if ($oldversion < 2016062004.01) { @@ -590,7 +590,7 @@ function xmldb_local_o365_upgrade($oldversion) { } set_config('disablegraphapi', 0, 'local_o365'); } - upgrade_plugin_savepoint(true, '2016062004.01', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016062004.01, 'local', 'o365'); } if ($oldversion < 2016120500.05) { @@ -601,7 +601,7 @@ function xmldb_local_o365_upgrade($oldversion) { $dbman->add_field($table, $field); } } - upgrade_plugin_savepoint(true, '2016120500.05', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016120500.05, 'local', 'o365'); } if ($oldversion < 2016120500.06) { @@ -612,12 +612,12 @@ function xmldb_local_o365_upgrade($oldversion) { $dbman->add_field($table, $field); } } - upgrade_plugin_savepoint(true, '2016120500.06', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2016120500.06, 'local', 'o365'); } if ($oldversion < 2017111301) { mtrace('Warning! This version removes the legacy Microsoft 365 API.'); - upgrade_plugin_savepoint(true, '2017111301', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2017111301, 'local', 'o365'); } if ($oldversion < 2018051702) { @@ -627,39 +627,7 @@ function xmldb_local_o365_upgrade($oldversion) { add_to_config_log('createteams', $existingcreateteamssetting, $coursesyncsetting, 'local_o365'); } set_config('createteams', $coursesyncsetting, 'local_o365'); - upgrade_plugin_savepoint(true, '2018051702', 'local', 'o365'); - } - - if ($oldversion < 2018051703) { - // Commented out since the bot feature has been removed. - /* - if (!$dbman->table_exists('local_o365_notif')) { - $dbman->install_one_table_from_xmldb_file(__DIR__ . '/install.xml', 'local_o365_notif'); - } - */ - - upgrade_plugin_savepoint(true, '2018051703', 'local', 'o365'); - } - - if ($oldversion < 2018051704) { - // Commented out since the bot feature has been removed. - /* - $botappid = get_config('local_o365', 'bot_app_id'); - $botapppassword = get_config('local_o365', 'bot_app_password'); - $botwebhookendpoint = get_config('local_o365', 'bot_webhook_endpoint'); - if ($botappid && $botapppassword && $botwebhookendpoint) { - set_config('bot_feature_enabled', '1', 'local_o365'); - } else { - set_config('bot_feature_enabled', '0', 'local_o365'); - } - */ - upgrade_plugin_savepoint(true, '2018051704', 'local', 'o365'); - } - - if ($oldversion < 2018051705) { - // Commented out since the bot feature has been removed. - // local_o365_check_sharedsecret(); - upgrade_plugin_savepoint(true, '2018051705', 'local', 'o365'); + upgrade_plugin_savepoint(true, 2018051702, 'local', 'o365'); } if ($oldversion < 2020020302) { @@ -1066,6 +1034,7 @@ function xmldb_local_o365_upgrade($oldversion) { } } catch (moodle_exception $e) { // Do nothing. + debugging('Error updating groups cache: ' . $e->getMessage()); } // O365 savepoint reached. @@ -1214,7 +1183,6 @@ function xmldb_local_o365_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2023100905, 'local', 'o365'); } - if ($oldversion < 2023100907) { // Unset "systemtokens" config. unset_config('systemtokens', 'local_o365'); diff --git a/local/o365/export_manifest.php b/local/o365/export_manifest.php index 4414aaf3e..e8209e9b8 100644 --- a/local/o365/export_manifest.php +++ b/local/o365/export_manifest.php @@ -27,6 +27,8 @@ require_once($CFG->libdir . '/filestorage/zip_archive.php'); require_once($CFG->dirroot . '/local/o365/lib.php'); +require_admin(); + // Mark manifest file as downloaded. $existingmanifestdownloadedsetting = get_config('local_o365', 'manifest_downloaded'); if (!$existingmanifestdownloadedsetting) { diff --git a/local/o365/lang/cs/local_o365.php b/local/o365/lang/cs/local_o365.php index fa31c26b6..2c4cafc17 100644 --- a/local/o365/lang/cs/local_o365.php +++ b/local/o365/lang/cs/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integrace Microsoft 365'; $string['acp_title'] = 'Ovládací panel správy Microsoft 365'; $string['acp_healthcheck'] = 'Kontrola stavu'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Aktualizovat Outlook i Moodle'; $string['ucp_title'] = 'Ovládací panel Microsoft 365 / Moodle'; $string['ucp_options'] = 'Možnosti'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/de/local_o365.php b/local/o365/lang/de/local_o365.php index 379adb147..9ba4f3551 100644 --- a/local/o365/lang/de/local_o365.php +++ b/local/o365/lang/de/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Microsoft 365-Integration'; $string['acp_title'] = 'Microsoft 365-Systemsteuerung'; $string['acp_healthcheck'] = 'Health Check'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Sowohl Outlook als auch Moodle aktualisieren'; $string['ucp_title'] = 'Microsoft 365/Moodle-Systemsteuerung'; $string['ucp_options'] = 'Optionen'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/en/local_o365.php b/local/o365/lang/en/local_o365.php index 39905ff16..fe9bd2ce6 100644 --- a/local/o365/lang/en/local_o365.php +++ b/local/o365/lang/en/local_o365.php @@ -26,6 +26,9 @@ defined('MOODLE_INTERNAL') || die(); +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder -- The strings are organised by features. +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment -- The strings are organised by features. + $string['pluginname'] = 'Microsoft 365 Integration'; // Settings - tabs. @@ -167,7 +170,7 @@
  1. Rename the Moodle user.
  2. auth_oidc_token updated with both new values for both "username" and "oidcusername" fields.
  3. -
  4. local_o365_objects user connection record "o365name" field updated to new value.
  5. +
  6. local_o365_objects user connection record "o365name" field updated to new value.
@@ -180,7 +183,7 @@
  1. Rename the Moodle user.
  2. local_o365_objects user connection record is updated.
  3. -
  4. auth_oidc_token updated.
  5. +
  6. auth_oidc_token updated.
@@ -193,7 +196,7 @@
  1. Rename the Moodle user.
  2. local_o365_objects user connection record is updated.
  3. -
  4. auth_oidc_token updated.
  5. +
  6. auth_oidc_token updated.
@@ -205,7 +208,7 @@
  1. Rename the Moodle user.
  2. -
  3. local_o365_objects user connection record is updated.
  4. +
  5. local_o365_objects user connection record is updated.
@@ -1000,8 +1003,11 @@ $string['notification_subject_invalid_secret'] = 'Action required: invalid Azure app secret found'; $string['notification_content_invalid_secret'] = 'Dear site administrator, -The Azure app secret used in your Moodle and Microsoft 365 integration seems to be invalid. This can either be caused by the secret expired, or it has been deleted. +The Azure app secret used in your Moodle and Microsoft 365 integration seems to be invalid. This can either be caused by the secret expired, or it has been deleted. Please review the secret to ensure the integration works as expected.'; // Misc. $string['spsite_group_contributors_desc'] = 'All users who have access to manage files for course {$a}'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/es/local_o365.php b/local/o365/lang/es/local_o365.php index 1682b7e04..5f3b654b3 100644 --- a/local/o365/lang/es/local_o365.php +++ b/local/o365/lang/es/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integración de Microsoft 365'; $string['acp_title'] = 'Panel de control de administración de Microsoft 365'; $string['acp_healthcheck'] = 'Comprobación de estado'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Actualizar Outlook y Moodle'; $string['ucp_title'] = 'Panel de control de Microsoft 365/Moodle'; $string['ucp_options'] = 'Opciones'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/fi/local_o365.php b/local/o365/lang/fi/local_o365.php index e3df73140..7e9214a6d 100644 --- a/local/o365/lang/fi/local_o365.php +++ b/local/o365/lang/fi/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Microsoft 365 -integrointi'; $string['acp_title'] = 'Microsoft 365 -järjestelmänvalvojan ohjauspaneeli'; $string['acp_healthcheck'] = 'Kuntotarkistus'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Päivitä Outlook ja Moodle'; $string['ucp_title'] = 'Microsoft 365 / Moodle -ohjauspaneeli'; $string['ucp_options'] = 'Asetukset'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/fr/local_o365.php b/local/o365/lang/fr/local_o365.php index 4a9722647..57d77488e 100644 --- a/local/o365/lang/fr/local_o365.php +++ b/local/o365/lang/fr/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Intégration de Microsoft 365'; $string['acp_title'] = 'Panneau de configuration d\'administration Microsoft 365'; $string['acp_healthcheck'] = 'Contrôle de l\'état'; @@ -46,7 +49,7 @@ $string['erroro365apinoparentinfo'] = 'Informations du dossier parent introuvables'; $string['erroro365apinotimplemented'] = 'Ces données doivent être remplacées.'; $string['erroro365apinotoken'] = 'Jeton inexistant pour l\'utilisateur et la ressource donnés. Impossible d\'en obtenir un. Le jeton actualisé de l\'utilisateur a-t-il expiré ?'; -$string['erroro365apisiteexistsnolocal'] = 'Le site existe déjà, mais registre local introuvable.';; +$string['erroro365apisiteexistsnolocal'] = 'Le site existe déjà, mais registre local introuvable.'; $string['eventapifail'] = 'Échec de l\'API'; $string['eventcalendarsubscribed'] = 'Utilisateur abonné à un calendrier'; $string['eventcalendarunsubscribed'] = 'Utilisateur désabonné d\'un calendrier'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Mettre à jour Outlook et Moodle'; $string['ucp_title'] = 'Panneau de configuration Microsoft 365/Moodle'; $string['ucp_options'] = 'Options'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/it/local_o365.php b/local/o365/lang/it/local_o365.php index dbb708429..f288201a7 100644 --- a/local/o365/lang/it/local_o365.php +++ b/local/o365/lang/it/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integrazione Microsoft 365'; $string['acp_title'] = 'Pannello di controllo per amministrare Microsoft 365'; $string['acp_healthcheck'] = 'Controllo stato'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Aggiorna Outlook e Moodle'; $string['ucp_title'] = 'Pannello di controllo di Microsoft 365/Moodle'; $string['ucp_options'] = 'Opzioni'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/ja/local_o365.php b/local/o365/lang/ja/local_o365.php index ffc92edaf..288a66b46 100644 --- a/local/o365/lang/ja/local_o365.php +++ b/local/o365/lang/ja/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Microsoft 365の統合'; $string['acp_title'] = 'Microsoft 365管理コントロールパネル'; $string['acp_healthcheck'] = '状態チェック'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'OutlookとMoodleを両方更新する'; $string['ucp_title'] = 'Microsoft 365 / Moodleコントロールパネル'; $string['ucp_options'] = 'オプション'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/nl/local_o365.php b/local/o365/lang/nl/local_o365.php index 67d1a6a4d..4936fdf77 100644 --- a/local/o365/lang/nl/local_o365.php +++ b/local/o365/lang/nl/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integratie met Microsoft 365'; $string['acp_title'] = 'Configuratiescherm voor Microsoft 365-beheer'; $string['acp_healthcheck'] = 'Statuscontrole'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Zowel Outlook als Moodle bijwerken'; $string['ucp_title'] = 'Microsoft 365-/Moodle-configuratiescherm'; $string['ucp_options'] = 'Opties'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/pl/local_o365.php b/local/o365/lang/pl/local_o365.php index f2e0ed25d..4d0306e90 100644 --- a/local/o365/lang/pl/local_o365.php +++ b/local/o365/lang/pl/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integracja pakietu Microsoft 365'; $string['acp_title'] = 'Panel sterowania administratora pakietu Microsoft 365'; $string['acp_healthcheck'] = 'Sprawdzanie kondycji'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Zaktualizuj dane w programie Outlook i na platformie Moodle'; $string['ucp_title'] = 'Panel sterowania pakietu Microsoft 365 / platformy Moodle'; $string['ucp_options'] = 'Opcje'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lang/pt_br/local_o365.php b/local/o365/lang/pt_br/local_o365.php index 9bf145cac..6ca999212 100644 --- a/local/o365/lang/pt_br/local_o365.php +++ b/local/o365/lang/pt_br/local_o365.php @@ -24,6 +24,9 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:disable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:disable moodle.Files.LangFilesOrdering.UnexpectedComment + $string['pluginname'] = 'Integração ao Microsoft 365'; $string['acp_title'] = 'Painel de controle de administração do Microsoft 365'; $string['acp_healthcheck'] = 'Verificação de integridade'; @@ -141,3 +144,6 @@ $string['ucp_syncdir_both'] = 'Atualizar tanto o Outlook quanto o Moodle'; $string['ucp_title'] = 'Painel de controle do Microsoft 365/Moodle'; $string['ucp_options'] = 'Opções'; + +// phpcs:enable moodle.Files.LangFilesOrdering.IncorrectOrder +// phpcs:enable moodle.Files.LangFilesOrdering.UnexpectedComment diff --git a/local/o365/lib.php b/local/o365/lib.php index d7d634d2c..565c3dec6 100644 --- a/local/o365/lib.php +++ b/local/o365/lib.php @@ -30,50 +30,76 @@ /** * TEAMS_MOODLE_APP_EXTERNAL_ID - app ID used to create Teams Moodle app. */ +/** @var string default teams Moodle app external ID. */ const TEAMS_MOODLE_APP_EXTERNAL_ID = '2e43119b-fcfe-44f8-b3e5-996ffcb7fb95'; // Teams/group course reset site settings. +/** @var int course reset site action Do nothing. */ const COURSE_SYNC_RESET_SITE_SETTING_DO_NOTHING = '1'; +/** @var int course reset site action allow configuration per course. */ const COURSE_SYNC_RESET_SITE_SETTING_PER_COURSE = '2'; +/** @var int course reset site action disconnect and create new. */ const COURSE_SYNC_RESET_SITE_SETTING_DISCONNECT_AND_CREATE_NEW = '3'; +/** @var int course reset site action disconnect only. */ const COURSE_SYNC_RESET_SITE_SETTING_DISCONNECT_ONLY = '4'; // Course reset course settings. +/** @var int course reset action do nothing. */ const COURSE_SYNC_RESET_COURSE_SETTING_DO_NOTHING = '1'; +/** @var int course reset course action disconnect and create new. */ const COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_AND_CREATE_NEW = '2'; +/** @var int course reset course action disconnect only. */ const COURSE_SYNC_RESET_COURSE_SETTING_DISCONNECT_ONLY = '3'; // Course sync options. +/** @var int course sync disabled. */ const MICROSOFT365_COURSE_SYNC_DISABLED = 0; +/** @var int course sync enabled. */ const MICROSOFT365_COURSE_SYNC_ENABLED = 1; // Configuration tabs. -const LOCAL_O365_TAB_SETUP = 0; // Setup settings. -const LOCAL_O365_TAB_SYNC = 1; // Sync settings. -const LOCAL_O365_TAB_ADVANCED = 2; // Admin tools + advanced settings. -const LOCAL_O365_TAB_SDS = 3; // School data sync. -const LOCAL_O365_TAB_TEAMS = 5; // Teams integration settings. -const LOCAL_O365_TAB_MOODLE_APP = 6; // Teams Moodle app. +/** @var int configuration tab "Setup settings". */ +const LOCAL_O365_TAB_SETUP = 0; +/** @var int configuration tab "Sync settings". */ +const LOCAL_O365_TAB_SYNC = 1; +/** @var int configuration tab "Admin tools + advanced settings.". */ +const LOCAL_O365_TAB_ADVANCED = 2; +/** @var int configuration tab "School data sync". */ +const LOCAL_O365_TAB_SDS = 3; +/** @var int configuration tab "Teams integration settings". */ +const LOCAL_O365_TAB_TEAMS = 5; +/** @var int configuration tab "Teams Moodle app". */ +const LOCAL_O365_TAB_MOODLE_APP = 6; // Group roles. +/** @var int group role owner */ const MICROSOFT365_GROUP_ROLE_OWNER = 'owner'; +/** @var int group role member */ const MICROSOFT365_GROUP_ROLE_MEMBER = 'member'; // Team lock status. +/** @var int team locking status unknown */ const TEAM_LOCKED_STATUS_UNKNOWN = 0; +/** @var int team locking status locked */ const TEAM_LOCKED = 1; +/** @var int team locking status unlocked */ const TEAM_UNLOCKED = 2; -// Education license. +/** @var array education license */ const EDUCATION_LICENSE_IDS = ['c33802dd-1b50-4b9a-8bb9-f13d2cdeadac', '500b6a2a-7a50-4f40-b5f9-160e5b8c2f48']; // SDS sync school disabled actions. +/** @var int SDS school disabled action keep connected */ const SDS_SCHOOL_DISABLED_ACTION_KEEP_CONNECTED = 1; +/** @var int SDS school disabled action disconnect */ const SDS_SCHOOL_DISABLED_ACTION_DISCONNECT = 2; // Course user sync directions. +/** @var int course user sync direction from Moodle to teams */ const COURSE_USER_SYNC_DIRECTION_MOODLE_TO_TEAMS = 1; +/** @var int course user sync direction from teams to Moodle */ const COURSE_USER_SYNC_DIRECTION_TEAMS_TO_MOODLE = 2; +/** @var int course user sync direction both */ const COURSE_USER_SYNC_DIRECTION_BOTH = 3; /** @@ -120,7 +146,7 @@ function local_o365_rmdir($path) { * * @return string[] */ -function local_o365_create_manifest_file() : array { +function local_o365_create_manifest_file(): array { global $CFG; // Task 1: prepare manifest folder. @@ -283,11 +309,12 @@ function local_o365_set_default_user_sync_suspension_feature_schedule() { */ function local_o365_get_duplicate_emails() { global $DB; - + $sql = 'SELECT LOWER(email) FROM {user} WHERE deleted = 0 and suspended = 0 GROUP BY LOWER(email) HAVING COUNT(*) > 1'; $records = $DB->get_records_sql($sql); + return array_keys($records); } diff --git a/local/o365/sass/styles.scss b/local/o365/sass/styles.scss deleted file mode 100644 index 41831ed7c..000000000 --- a/local/o365/sass/styles.scss +++ /dev/null @@ -1,129 +0,0 @@ -.local_o365_statusmessage { - &.alert { - margin-bottom: 0.25rem; - } - img { - margin-right: 0.25rem; - } - span, a { - vertical-align: middle; - } -} - -#local_o365_admin-verifysetup { - button.refreshperms { - margin: 0 0 0.75rem; - } -} - -.local_o365_adminsetting_verifysetup_results { - section { - margin-bottom: 1rem; - h5 { - margin: 0 0 0.25rem; - } - } -} - -.local_o365_ucp_index { - .connectionstatus { - float: right; - width: 14rem; - padding: 0.5rem; - img { - float: left; - padding: 0.25rem; - } - small { - font-weight: bold; - font-size: 0.8rem; - } - img.smallicon { - width: 12px; - height: 12px; - } - } - .local_o365_features { - margin-right: 16rem; - > div { - margin-bottom: 1rem; - a, b { - background-position: 2px 0px; - background-size: 28px; - background-repeat: no-repeat; - background-color: transparent; - display: inline-block; - padding: 4px 4px 4px 40px; - } - } - .local_o365_feature_connection { - a, b { - background-image: url([[pix:local_o365|o365color]]); - } - } - .local_o365_feature_calendar a, .local_o365_feature_calendar b { - background-image: url([[pix:local_o365|outlookcolor]]); - } - .local_o365_feature_onenote a, .local_o365_feature_onenote b { - background-image: url([[pix:local_o365|onenotecolor]]); - } - } -} - -.local_o365_ucp_featurepage { - h3.local_o365_featureheader { - background-position: center left; - background-size: 28px; - background-repeat: no-repeat; - background-color: transparent; - padding: 4px 4px 4px 35px; - &.local_o365_feature_calendar { - background-image: url([[pix:local_o365|outlookcolor]]); - } - &.local_o365_feature_onenote { - background-image: url([[pix:local_o365|onenotecolor]]); - } - } - &.local_o365_feature_connection { - h3.local_o365_featureheader { - background-image: url([[pix:local_o365|o365color]]); - } - div.connectionstatus { - margin: 2rem 0; - } - div.local_o365_connectionoption { - margin: 0 0 1rem; - padding: 1rem; - h4 { - margin-top: 0; - } - } - } -} - -.local_o365_o365toollink { - margin-bottom: 1rem; -} - -.local_o365_matchqueuetoolbar { - margin: 0.75rem 0 0.5rem 0; -} - -table.local_o365_matchqueue { - width: 100%; - td, th { - padding: 0.25rem 0.5rem; - vertical-align: top; - &:first-child { - width: 1.5rem; - text-align: center; - } - } - -} - -/* Display spinner while course data is syncing. */ -.local_o365_spinner { - margin: 0 0 1em 1em; - display: none; -} diff --git a/local/o365/settings.php b/local/o365/settings.php index 93fd3840b..33ab9fd2f 100644 --- a/local/o365/settings.php +++ b/local/o365/settings.php @@ -297,7 +297,7 @@ get_string('settings_team_name_sync_desc', 'local_o365'), 0)); - // Cohort Sync section + // Cohort Sync section. $label = new lang_string('settings_secthead_cohortsync', 'local_o365'); $desc = new lang_string('settings_secthead_cohortsync_desc', 'local_o365'); $settings->add(new admin_setting_heading('local_o365_section_cohortsync', $label, $desc)); diff --git a/local/o365/sso_end.php b/local/o365/sso_end.php index b50f2765b..bce43ee6f 100644 --- a/local/o365/sso_end.php +++ b/local/o365/sso_end.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); echo ""; diff --git a/local/o365/sso_login.php b/local/o365/sso_login.php index 34614234f..04a306dde 100644 --- a/local/o365/sso_login.php +++ b/local/o365/sso_login.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); require_once($CFG->dirroot . '/local/o365/lib.php'); diff --git a/local/o365/sso_start.php b/local/o365/sso_start.php index 4bce93923..9affbf8e3 100644 --- a/local/o365/sso_start.php +++ b/local/o365/sso_start.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); echo ""; diff --git a/local/o365/styles.css b/local/o365/styles.css index b55feca12..be654a889 100644 --- a/local/o365/styles.css +++ b/local/o365/styles.css @@ -6,7 +6,8 @@ margin-right: 0.25rem; } -.local_o365_statusmessage span, .local_o365_statusmessage a { +.local_o365_statusmessage span, +.local_o365_statusmessage a { vertical-align: middle; } @@ -51,8 +52,9 @@ margin-bottom: 1rem; } -.local_o365_ucp_index .local_o365_features > div a, .local_o365_ucp_index .local_o365_features > div b { - background-position: 2px 0px; +.local_o365_ucp_index .local_o365_features > div a, +.local_o365_ucp_index .local_o365_features > div b { + background-position: 2px 0; background-size: 28px; background-repeat: no-repeat; background-color: transparent; @@ -60,15 +62,18 @@ padding: 4px 4px 4px 40px; } -.local_o365_ucp_index .local_o365_features .local_o365_feature_connection a, .local_o365_ucp_index .local_o365_features .local_o365_feature_connection b { +.local_o365_ucp_index .local_o365_features .local_o365_feature_connection a, +.local_o365_ucp_index .local_o365_features .local_o365_feature_connection b { background-image: url([[pix:local_o365|o365color]]); } -.local_o365_ucp_index .local_o365_features .local_o365_feature_calendar a, .local_o365_ucp_index .local_o365_features .local_o365_feature_calendar b { +.local_o365_ucp_index .local_o365_features .local_o365_feature_calendar a, +.local_o365_ucp_index .local_o365_features .local_o365_feature_calendar b { background-image: url([[pix:local_o365|outlookcolor]]); } -.local_o365_ucp_index .local_o365_features .local_o365_feature_onenote a, .local_o365_ucp_index .local_o365_features .local_o365_feature_onenote b { +.local_o365_ucp_index .local_o365_features .local_o365_feature_onenote a, +.local_o365_ucp_index .local_o365_features .local_o365_feature_onenote b { background-image: url([[pix:local_o365|onenotecolor]]); } @@ -117,12 +122,14 @@ table.local_o365_matchqueue { width: 100%; } -table.local_o365_matchqueue td, table.local_o365_matchqueue th { +table.local_o365_matchqueue td, +table.local_o365_matchqueue th { padding: 0.25rem 0.5rem; vertical-align: top; } -table.local_o365_matchqueue td:first-child, table.local_o365_matchqueue th:first-child { +table.local_o365_matchqueue td:first-child, +table.local_o365_matchqueue th:first-child { width: 1.5rem; text-align: center; } @@ -139,8 +146,8 @@ select#id_local_o365_teams_course select::-webkit-scrollbar { } select#id_local_o365_teams_course::-webkit-scrollbar-track { - box-shadow: inset 0 0 0px grey; - border-radius: 0px; + box-shadow: inset 0 0 0 grey; + border-radius: 0; } select#id_local_o365_teams_course::-webkit-scrollbar-thumb { @@ -172,8 +179,8 @@ select#id_local_o365_teams_course { } select#id_local_o365_teams_course:focus { - outline-offset: 0px !important; - outline: none !important; + outline-offset: 0; + outline: none; } select#id_local_o365_teams_course option { @@ -194,7 +201,7 @@ form#local_o365_course_list { /* Teams tab page. */ #id_local_o365_teams_tab_name { background-color: #f0f2f4; - border: 0px; + border: 0; padding: 8px 8px 8px 12px; width: 100%; margin-bottom: 20px; @@ -215,7 +222,7 @@ div.local_o365_manual_login { } button.local_o365_manual_login_button { - font-family: "Segoe UI", "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Helvetica, Arial, sans-serif !important; + font-family: "Segoe UI", "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Helvetica, Arial, sans-serif; display: block; width: 200px; background: #6264a7; @@ -228,9 +235,9 @@ button.local_o365_manual_login_button { min-width: 6rem; padding: 0.25rem; white-space: nowrap; - -webkit-box-shadow: unset !important; - box-shadow: unset !important; - color: #FFF; + -webkit-box-shadow: unset; + box-shadow: unset; + color: #fff; margin: 5px; } @@ -240,13 +247,11 @@ button.local_o365_manual_login_button:not(:disabled):not(.disabled):active { color: #201f1f; } -button.local_o365_manual_login_button:hover, button.local_o365_manual_login_button.enabled { +button.local_o365_manual_login_button:hover, +button.local_o365_manual_login_button.enabled { background: #464775; border-color: transparent; - color: #FFF; -} - -button.local_o365_manual_login_button:focus, button.local_o365_manual_login_button:focus:enabled { + color: #fff; } .local_o365_acp_option { @@ -255,11 +260,11 @@ button.local_o365_manual_login_button:focus, button.local_o365_manual_login_butt } .local_o365_settings_manifest_container { - margin: 40px 0px 20px 0px; + margin: 40px 0 20px 0; } .local_o365_settings_teams_banner_part_1 { - margin: 30px 40px 0px 40px; + margin: 30px 40px 0 40px; text-align: center; } @@ -283,7 +288,7 @@ button.local_o365_manual_login_button:focus, button.local_o365_manual_login_butt } .local_o365_settings_teams_h4_spacer { - margin: 20px 0px 30px 0px; + margin: 20px 0 30px 0; border-top: 1px solid #e9ecef; padding-top: 10px; } diff --git a/local/o365/teams_tab.php b/local/o365/teams_tab.php index ddf686038..fb9789943 100644 --- a/local/o365/teams_tab.php +++ b/local/o365/teams_tab.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); // Force theme. @@ -58,10 +59,10 @@ echo html_writer::start_div('local_o365_manual_login'); // Microsoft Entra ID login box. echo html_writer::tag('button', get_string('sso_login', 'local_o365'), - array('onclick' => 'login()', 'class' => 'local_o365_manual_login_button')); + ['onclick' => 'login()', 'class' => 'local_o365_manual_login_button']); // Manual login link. echo html_writer::tag('button', get_string('other_login', 'local_o365'), - array('onclick' => 'otherLogin()', 'class' => 'local_o365_manual_login_button')); + ['onclick' => 'otherLogin()', 'class' => 'local_o365_manual_login_button']); echo html_writer::end_div(); $SESSION->wantsurl = $coursepageurl; diff --git a/local/o365/teams_tab_configuration.php b/local/o365/teams_tab_configuration.php index cea7ae27d..3ac35e101 100644 --- a/local/o365/teams_tab_configuration.php +++ b/local/o365/teams_tab_configuration.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); $url = new moodle_url('/local/o365/teams_tab_configuration.php'); diff --git a/local/o365/teams_tab_redirect.php b/local/o365/teams_tab_redirect.php index 6a13e8005..35bd5404d 100644 --- a/local/o365/teams_tab_redirect.php +++ b/local/o365/teams_tab_redirect.php @@ -23,6 +23,7 @@ * @copyright (C) 2018 onwards Microsoft, Inc. (http://microsoft.com/) */ +// phpcs:ignore moodle.Files.RequireLogin.Missing -- This file is called from Microsoft Teams tab. require_once(__DIR__ . '/../../config.php'); unset($SESSION->theme); diff --git a/local/o365/tests/coursesyncutils_test.php b/local/o365/tests/coursesyncutils_test.php index 5aac422e0..b6a864b7c 100644 --- a/local/o365/tests/coursesyncutils_test.php +++ b/local/o365/tests/coursesyncutils_test.php @@ -24,108 +24,120 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ +namespace local_o365; + +use externallib_advanced_testcase; +use local_o365\feature\coursesync\utils; + defined('MOODLE_INTERNAL') || die(); global $CFG; -require_once($CFG->dirroot.'/webservice/tests/helpers.php'); +require_once($CFG->dirroot . '/webservice/tests/helpers.php'); /** * Tests \local_o365\feature\coursesync\utils. * * @group local_o365 */ -class local_o365_coursesyncutils_testcase extends \externallib_advanced_testcase { +final class coursesyncutils_test extends externallib_advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } /** * Test is_enabled() method. + * + * @covers \local_o365\feature\coursesync\utils::is_enabled */ - public function test_is_enabled() { + public function test_is_enabled(): void { global $DB; $DB->delete_records('config_plugins', ['name' => 'coursesync', 'plugin' => 'local_o365']); - $this->assertFalse(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertFalse(utils::is_enabled()); set_config('coursesync', '', 'local_o365'); - $this->assertFalse(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertFalse(utils::is_enabled()); set_config('coursesync', 'onall', 'local_o365'); - $this->assertTrue(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertTrue(utils::is_enabled()); set_config('coursesync', 'off', 'local_o365'); - $this->assertFalse(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertFalse(utils::is_enabled()); set_config('coursesync', 'oncustom', 'local_o365'); - $this->assertTrue(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertTrue(utils::is_enabled()); set_config('coursesync', 'off', 'local_o365'); - $this->assertFalse(\local_o365\feature\coursesync\utils::is_enabled()); + $this->assertFalse(utils::is_enabled()); } /** * Test get_enabled_courses() method. + * + * @covers \local_o365\feature\coursesync\utils::get_enabled_courses */ - public function test_get_enabled_courses() { + public function test_get_enabled_courses(): void { global $DB; $DB->delete_records('config_plugins', ['name' => 'coursesync', 'plugin' => 'local_o365']); - $actual = \local_o365\feature\coursesync\utils::get_enabled_courses(); + $actual = utils::get_enabled_courses(); $this->assertIsArray($actual); $this->assertEmpty($actual); set_config('coursesync', 'off', 'local_o365'); set_config('coursesynccustom', json_encode([1 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::get_enabled_courses(); + $actual = utils::get_enabled_courses(); $this->assertIsArray($actual); $this->assertEmpty($actual); set_config('coursesync', 'onall', 'local_o365'); set_config('coursesynccustom', json_encode([1 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::get_enabled_courses(); + $actual = utils::get_enabled_courses(); $this->assertTrue($actual); set_config('coursesync', 'oncustom', 'local_o365'); set_config('coursesynccustom', json_encode([1 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::get_enabled_courses(); + $actual = utils::get_enabled_courses(); $this->assertIsArray($actual); $this->assertEquals([1], $actual); } /** * Test course_is_group_enabled() method. + * + * @covers \local_o365\feature\coursesync\utils::is_course_sync_enabled */ - public function test_course_is_group_enabled() { + public function test_course_is_group_enabled(): void { global $DB; + $DB->delete_records('config_plugins', ['name' => 'coursesync', 'plugin' => 'local_o365']); $DB->delete_records('config_plugins', ['name' => 'coursesynccustom', 'plugin' => 'local_o365']); - $actual = \local_o365\feature\coursesync\utils::is_course_sync_enabled(3); + $actual = utils::is_course_sync_enabled(3); $this->assertFalse($actual); set_config('coursesync', 'off', 'local_o365'); set_config('coursesynccustom', json_encode([1 => 1, 3 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::is_course_sync_enabled(3); + $actual = utils::is_course_sync_enabled(3); $this->assertFalse($actual); set_config('coursesync', 'onall', 'local_o365'); set_config('coursesynccustom', json_encode([2 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::is_course_sync_enabled(3); + $actual = utils::is_course_sync_enabled(3); $this->assertTrue($actual); set_config('coursesync', 'oncustom', 'local_o365'); set_config('coursesynccustom', json_encode([2 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::is_course_sync_enabled(3); + $actual = utils::is_course_sync_enabled(3); $this->assertFalse($actual); set_config('coursesync', 'oncustom', 'local_o365'); set_config('coursesynccustom', json_encode([2 => 1, 3 => 1]), 'local_o365'); - $actual = \local_o365\feature\coursesync\utils::is_course_sync_enabled(3); + $actual = utils::is_course_sync_enabled(3); $this->assertTrue($actual); } } diff --git a/local/o365/tests/observers_test.php b/local/o365/tests/observers_test.php index 9bd5e7200..fa345e29c 100644 --- a/local/o365/tests/observers_test.php +++ b/local/o365/tests/observers_test.php @@ -23,29 +23,31 @@ * @copyright (C) 2016 onwards Microsoft, Inc. (http://microsoft.com/) */ -defined('MOODLE_INTERNAL') || die(); +namespace local_o365; + +use advanced_testcase; /** * Tests event observers. * * @group local_o365 * @group office365 - * @codeCoverageIgnore */ -class local_o365_observers_testcase extends \advanced_testcase { +final class observers_test extends advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } /** * Test users disconnect method. + * + * @covers \local_o365\observers::handle_oidc_user_disconnected */ - public function test_user_disconnected() { - global $DB; + public function test_user_disconnected(): void { $user = $this->getDataGenerator()->create_user(['auth' => 'oidc']); $this->create_member_entities($user->id); $this->assertTrue($this->has_member_entities($user->id)); @@ -57,9 +59,10 @@ public function test_user_disconnected() { /** * Test users deleted method. + * + * @covers \local_o365\observers::handle_user_deleted */ - public function test_user_deleted() { - global $DB; + public function test_user_deleted(): void { $user = $this->getDataGenerator()->create_user(['auth' => 'oidc']); $this->create_member_entities($user->id); $this->assertTrue($this->has_member_entities($user->id)); @@ -74,7 +77,7 @@ public function test_user_deleted() { */ public function create_member_entities($userid) { global $DB; - $token = (object)[ + $token = (object) [ 'user_id' => $userid, 'scope' => 'scope', 'tokenresource' => 'resource', @@ -83,7 +86,7 @@ public function create_member_entities($userid) { 'refreshtoken' => time() + 100000, ]; $DB->insert_record('local_o365_token', $token); - $entraiduserdata = (object)[ + $entraiduserdata = (object) [ 'type' => 'user', 'subtype' => '', 'objectid' => '', @@ -94,7 +97,7 @@ public function create_member_entities($userid) { ]; $DB->insert_record('local_o365_objects', $entraiduserdata); $DB->insert_record('local_o365_connections', ['muserid' => $userid]); - $object = (object)[ + $object = (object) [ 'muserid' => $userid, 'assigned' => 1, 'photoid' => 'abc', @@ -114,6 +117,7 @@ public function has_member_entities($userid) { $result = $DB->count_records('local_o365_token', ['user_id' => $userid]); $result = $result || $DB->count_records('local_o365_objects', ['type' => 'user', 'moodleid' => $userid]); $result = $result || $DB->count_records('local_o365_connections', ['muserid' => $userid]); + return $result || $DB->count_records('local_o365_appassign', ['muserid' => $userid]); } } diff --git a/local/o365/tests/privacy_provider_test.php b/local/o365/tests/privacy_provider_test.php index bbf3914ed..d076e382a 100644 --- a/local/o365/tests/privacy_provider_test.php +++ b/local/o365/tests/privacy_provider_test.php @@ -23,9 +23,16 @@ * @copyright (C) 2019 Remote Learner.net Inc http://www.remote-learner.net */ -defined('MOODLE_INTERNAL') || die(); +namespace local_o365; -use \local_o365\privacy\provider; +use context_system; +use context_user; +use core_privacy\local\request\approved_contextlist; +use core_privacy\local\request\userlist; +use core_privacy\local\request\writer; +use core_privacy\tests\provider_testcase; +use local_o365\privacy\provider; +use stdClass; /** * Privacy test for the local_o365 @@ -35,19 +42,21 @@ * @group office365 * @group office365_privacy */ -class local_o365_privacy_testcase extends \core_privacy\tests\provider_testcase { +final class privacy_provider_test extends provider_testcase { /** * Tests set up. */ - protected function setUp() : void { + protected function setUp(): void { $this->resetAfterTest(); $this->setAdminUser(); } /** * Check that a user context is returned if there is any user data for this user. + * + * @covers \local_o365\privacy\provider::get_contexts_for_userid */ - public function test_get_contexts_for_userid() { + public function test_get_contexts_for_userid(): void { $user = $this->getDataGenerator()->create_user(); $this->assertEmpty(provider::get_contexts_for_userid($user->id)); @@ -59,14 +68,16 @@ public function test_get_contexts_for_userid() { $this->assertCount(1, $contextlist); // Check that a context is returned and is the expected context. - $usercontext = \context_user::instance($user->id); + $usercontext = context_user::instance($user->id); $this->assertEquals($usercontext->id, $contextlist->get_contextids()[0]); } /** * Test that only users with a user context are fetched. + * + * @covers \local_o365\privacy\provider::get_users_in_context */ - public function test_get_users_in_context() { + public function test_get_users_in_context(): void { $this->resetAfterTest(); $component = 'local_o365'; @@ -75,7 +86,7 @@ public function test_get_users_in_context() { $usercontext = context_user::instance($user->id); // The list of users should not return anything yet (related data still haven't been created). - $userlist = new \core_privacy\local\request\userlist($usercontext, $component); + $userlist = new userlist($usercontext, $component); provider::get_users_in_context($userlist); $this->assertCount(0, $userlist); @@ -90,49 +101,53 @@ public function test_get_users_in_context() { $this->assertEquals($expected, $actual); // The list of users for system context should not return any users. - $userlist = new \core_privacy\local\request\userlist(context_system::instance(), $component); + $userlist = new userlist(context_system::instance(), $component); provider::get_users_in_context($userlist); $this->assertCount(0, $userlist); } /** * Test that user data is exported correctly. + * + * @covers \local_o365\privacy\provider::export_user_data */ - public function test_export_user_data() { + public function test_export_user_data(): void { // Create a user record. $user = $this->getDataGenerator()->create_user(); // Create user records. $userrecords = self::create_userdata($user->id); - $usercontext = \context_user::instance($user->id); + $usercontext = context_user::instance($user->id); - $writer = \core_privacy\local\request\writer::with_context($usercontext); + $writer = writer::with_context($usercontext); $this->assertFalse($writer->has_any_data()); - $approvedlist = new core_privacy\local\request\approved_contextlist($user, 'local_o365', [$usercontext->id]); + $approvedlist = new approved_contextlist($user, 'local_o365', [$usercontext->id]); provider::export_user_data($approvedlist); foreach ($userrecords as $table => $record) { $data = $writer->get_data([ get_string('privacy:metadata:local_o365', 'local_o365'), - get_string('privacy:metadata:'.$table, 'local_o365') + get_string('privacy:metadata:' . $table, 'local_o365'), ]); foreach ($record as $k => $v) { - $this->assertEquals((string)$v, $data->$k); + $this->assertEquals((string) $v, $data->$k); } } } /** * Test deleting all user data for a specific context. + * + * @covers \local_o365\privacy\provider::delete_data_for_all_users_in_context */ - public function test_delete_data_for_all_users_in_context() { + public function test_delete_data_for_all_users_in_context(): void { global $DB; // Create user data. $user1 = $this->getDataGenerator()->create_user(); $user1records = self::create_userdata($user1->id); - $user1context = \context_user::instance($user1->id); + $user1context = context_user::instance($user1->id); $user2 = $this->getDataGenerator()->create_user(); $user2records = self::create_userdata($user2->id); @@ -162,14 +177,16 @@ public function test_delete_data_for_all_users_in_context() { /** * This should work identical to the above test. + * + * @covers \local_o365\privacy\provider::delete_data_for_all_users_in_context */ - public function test_delete_data_for_user() { + public function test_delete_data_for_user(): void { global $DB; // Create a user record. $user1 = $this->getDataGenerator()->create_user(); $user1records = self::create_userdata($user1->id); - $user1context = \context_user::instance($user1->id); + $user1context = context_user::instance($user1->id); $user2 = $this->getDataGenerator()->create_user(); $user2records = self::create_userdata($user2->id); @@ -180,7 +197,7 @@ public function test_delete_data_for_user() { } // Delete everything for the first user. - $approvedlist = new \core_privacy\local\request\approved_contextlist($user1, 'local_o365', [$user1context->id]); + $approvedlist = new approved_contextlist($user1, 'local_o365', [$user1context->id]); provider::delete_data_for_user($approvedlist); $this->assertCount(0, $DB->get_records('local_o365_calidmap', ['userid' => $user1->id])); @@ -200,8 +217,10 @@ public function test_delete_data_for_user() { /** * Test that data for users in approved userlist is deleted. + * + * @covers \local_o365\privacy\provider::delete_data_for_users */ - public function test_delete_data_for_users() { + public function test_delete_data_for_users(): void { $this->resetAfterTest(); $component = 'local_o365'; @@ -216,7 +235,7 @@ public function test_delete_data_for_users() { $usercontext2 = context_user::instance($user2->id); // The list of users for usercontext1 should return user1. - $userlist1 = new \core_privacy\local\request\userlist($usercontext1, $component); + $userlist1 = new userlist($usercontext1, $component); provider::get_users_in_context($userlist1); $this->assertCount(1, $userlist1); $expected = [$user1->id]; @@ -224,7 +243,7 @@ public function test_delete_data_for_users() { $this->assertEquals($expected, $actual); // The list of users for usercontext2 should return user2. - $userlist2 = new \core_privacy\local\request\userlist($usercontext2, $component); + $userlist2 = new userlist($usercontext2, $component); provider::get_users_in_context($userlist2); $this->assertCount(1, $userlist2); $expected = [$user2->id]; @@ -238,11 +257,11 @@ public function test_delete_data_for_users() { provider::delete_data_for_users($approvedlist); // Re-fetch users in usercontext1 - The user list should now be empty. - $userlist1 = new \core_privacy\local\request\userlist($usercontext1, $component); + $userlist1 = new userlist($usercontext1, $component); provider::get_users_in_context($userlist1); $this->assertCount(0, $userlist1); // Re-fetch users in usercontext2 - The user list should not be empty (user2). - $userlist2 = new \core_privacy\local\request\userlist($usercontext2, $component); + $userlist2 = new userlist($usercontext2, $component); provider::get_users_in_context($userlist2); $this->assertCount(1, $userlist2); @@ -253,7 +272,7 @@ public function test_delete_data_for_users() { // Delete user1 data using delete_data_for_user. provider::delete_data_for_users($approvedlist); // Re-fetch users in usercontext2 - The user list should not be empty (user2). - $userlist2 = new \core_privacy\local\request\userlist($usercontext2, $component); + $userlist2 = new userlist($usercontext2, $component); provider::get_users_in_context($userlist2); $this->assertCount(1, $userlist2); } @@ -275,6 +294,7 @@ private static function create_userdata(int $userid) { 'local_o365_matchqueue' => self::create_matchqueue($userid), 'local_o365_calsettings' => self::create_calsettings($userid), ]; + return $records; } @@ -292,6 +312,7 @@ private static function create_calidmap(int $userid): stdClass { $record->origin = 'moodle'; $record->userid = $userid; $record->id = $DB->insert_record('local_o365_calidmap', $record); + return $record; } @@ -312,6 +333,7 @@ private static function create_calsub(int $userid): stdClass { $record->syncbehav = "out"; $record->timecreated = 123456; $record->id = $DB->insert_record('local_o365_calsub', $record); + return $record; } @@ -325,9 +347,10 @@ private static function create_connections(int $userid): stdClass { global $DB; $record = new stdClass(); $record->muserid = $userid; - $record->entraidupn = "user".$userid."@example.com"; + $record->entraidupn = "user" . $userid . "@example.com"; $record->uselogin = 1; $record->id = $DB->insert_record('local_o365_connections', $record); + return $record; } @@ -347,6 +370,7 @@ private static function create_token(int $userid): stdClass { $record->expiry = 123456; $record->refreshtoken = 'refreshtoken1234567'; $record->id = $DB->insert_record('local_o365_token', $record); + return $record; } @@ -369,6 +393,7 @@ private static function create_objects(int $userid): stdClass { $record->timecreated = 123456; $record->timemodified = 123457; $record->id = $DB->insert_record('local_o365_objects', $record); + return $record; } @@ -386,6 +411,7 @@ private static function create_appassign(int $userid): stdClass { $record->photoid = 'photoid123'; $record->photoupdated = 123457; $record->id = $DB->insert_record('local_o365_appassign', $record); + return $record; } @@ -405,6 +431,7 @@ private static function create_matchqueue(int $userid): stdClass { $record->completed = 1; $record->errormessage = 'some error message'; $record->id = $DB->insert_record('local_o365_matchqueue', $record); + return $record; } @@ -421,6 +448,7 @@ private static function create_calsettings(int $userid): stdClass { $record->o365calid = 'calid1234'; $record->timecreated = 1234567; $record->id = $DB->insert_record('local_o365_calsettings', $record); + return $record; } diff --git a/local/o365/tests/token_test.php b/local/o365/tests/token_test.php index c0bf50a0c..b77d29a6a 100644 --- a/local/o365/tests/token_test.php +++ b/local/o365/tests/token_test.php @@ -23,28 +23,31 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ -defined('MOODLE_INTERNAL') || die(); +namespace local_o365; + +use advanced_testcase; /** * Tests \local_o365\oauth2\token * * @group local_o365 * @group office365 - * @codeCoverageIgnore */ -class local_o365_oauth2_token_testcase extends \advanced_testcase { +final class token_test extends advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } /** * Test refresh method. + * + * @covers \local_o365\oauth2\token::refresh */ - public function test_refresh() { + public function test_refresh(): void { global $USER, $DB; $this->setAdminUser(); $now = time(); @@ -64,7 +67,7 @@ public function test_refresh() { 'clientid' => 'clientid', 'clientsecret' => 'clientsecret', 'authendpoint' => 'http://example.com/auth', - 'tokenendpoint' => 'http://example.com/token' + 'tokenendpoint' => 'http://example.com/token', ]; $tokenrec = (object)[ diff --git a/local/o365/tests/usersync_test.php b/local/o365/tests/usersync_test.php index 60780f997..f58a270c8 100644 --- a/local/o365/tests/usersync_test.php +++ b/local/o365/tests/usersync_test.php @@ -23,20 +23,25 @@ * @copyright (C) 2014 onwards Microsoft, Inc. (http://microsoft.com/) */ -defined('MOODLE_INTERNAL') || die(); +namespace local_o365; + +use advanced_testcase; +use local_o365\feature\usersync\main; +use local_o365\oauth2\token; +use local_o365\rest\unified; +use local_o365\tests\mockhttpclient; /** * Tests \local_o365\feature\usersync\main. * * @group local_o365 * @group office365 - * @codeCoverageIgnore */ -class local_o365_usersync_testcase extends \advanced_testcase { +final class usersync_test extends advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } @@ -44,30 +49,31 @@ protected function setUp() : void { /** * Get a mock token object to use when constructing the API client. * - * @return \local_o365\oauth2\token The mock token object. + * @return token The mock token object. */ protected function get_mock_clientdata() { - $oidcconfig = (object)[ + $oidcconfig = (object) [ 'clientid' => 'clientid', 'clientsecret' => 'clientsecret', 'authendpoint' => 'http://example.com/auth', - 'tokenendpoint' => 'http://example.com/token' + 'tokenendpoint' => 'http://example.com/token', ]; $clientdata = new \local_o365\oauth2\clientdata($oidcconfig->clientid, $oidcconfig->clientsecret, - $oidcconfig->authendpoint, $oidcconfig->tokenendpoint); + $oidcconfig->authendpoint, $oidcconfig->tokenendpoint); + return $clientdata; } /** * Get a mock token object to use when constructing the API client. * - * @return \local_o365\oauth2\token The mock token object. + * @return token The mock token object. */ protected function get_mock_token() { - $httpclient = new \local_o365\tests\mockhttpclient(); + $httpclient = new mockhttpclient(); - $tokenrec = (object)[ + $tokenrec = (object) [ 'token' => 'token', 'expiry' => time() + 1000, 'refreshtoken' => 'refreshtoken', @@ -77,8 +83,9 @@ protected function get_mock_token() { ]; $clientdata = $this->get_mock_clientdata(); - $token = new \local_o365\oauth2\token($tokenrec->token, $tokenrec->expiry, $tokenrec->refreshtoken, - $tokenrec->scope, $tokenrec->tokenresource, $tokenrec->user_id, $clientdata, $httpclient); + $token = new token($tokenrec->token, $tokenrec->expiry, $tokenrec->refreshtoken, + $tokenrec->scope, $tokenrec->tokenresource, $tokenrec->user_id, $clientdata, $httpclient); + return $token; } @@ -92,16 +99,16 @@ protected function get_entra_id_userinfo($i = 0) { return [ 'odata.type' => 'Microsoft.WindowsAzure.ActiveDirectory.User', 'objectType' => 'User', - 'objectId' => '00000000-0000-0000-0000-00000000000'.$i, - 'id' => '00000000-0000-0000-0000-00000000000'.$i, + 'objectId' => '00000000-0000-0000-0000-00000000000' . $i, + 'id' => '00000000-0000-0000-0000-00000000000' . $i, 'city' => 'Toronto', 'country' => ($i == 3) ? 'Canada' : 'CA', 'department' => 'Dev', 'givenName' => 'Test', - 'userPrincipalName' => 'testuser'.$i.'@example.onmicrosoft.com', - 'mail' => 'testuser'.$i.'@example.onmicrosoft.com', - 'surname' => 'User'.$i, + 'mail' => 'testuser' . $i . '@example.onmicrosoft.com', + 'surname' => 'User' . $i, 'preferredLanguage' => ($i == 3) ? 'sa-IN' : 'en-US', + 'userPrincipalName' => 'testuser' . $i . '@example.onmicrosoft.com', ]; } @@ -110,7 +117,7 @@ protected function get_entra_id_userinfo($i = 0) { * * @return array Array of test parameters. */ - public function dataprovider_create_user_from_entra_id_data() { + public static function dataprovider_create_user_from_entra_id_data(): array { global $CFG; $tests = []; @@ -124,9 +131,12 @@ public function dataprovider_create_user_from_entra_id_data() { 'country' => 'CA', 'department' => 'Dev', 'givenName' => 'Test', - 'userPrincipalName' => 'testuser1@example.onmicrosoft.com', 'mail' => 'testuser1@example.onmicrosoft.com', 'surname' => 'User1', + 'userPrincipalName' => 'testuser1@example.onmicrosoft.com', + 'useridentifier' => 'testuser1@example.onmicrosoft.com', + 'useridentifierlower' => 'testuser1@example.onmicrosoft.com', + 'upnsplit0' => 'testuser1', ], [ 'auth' => 'oidc', @@ -153,9 +163,12 @@ public function dataprovider_create_user_from_entra_id_data() { 'country' => 'CA', 'department' => 'Dev', 'givenName' => 'Test', - 'userPrincipalName' => 'testuser2@example.onmicrosoft.com', 'mail' => 'testuser2@example.onmicrosoft.com', 'surname' => 'User2', + 'userPrincipalName' => 'testuser2@example.onmicrosoft.com', + 'useridentifier' => 'testuser2@example.onmicrosoft.com', + 'useridentifierlower' => 'testuser2@example.onmicrosoft.com', + 'upnsplit0' => 'testuser2', ], [ 'auth' => 'oidc', @@ -181,9 +194,12 @@ public function dataprovider_create_user_from_entra_id_data() { 'id' => '00000000-0000-0000-0000-000000000003', 'department' => 'Dev', 'givenName' => 'Test', - 'userPrincipalName' => 'testuser3@example.onmicrosoft.com', 'mail' => 'testuser3@example.onmicrosoft.com', 'surname' => 'User3', + 'userPrincipalName' => 'testuser3@example.onmicrosoft.com', + 'useridentifier' => 'testuser3@example.onmicrosoft.com', + 'useridentifierlower' => 'testuser3@example.onmicrosoft.com', + 'upnsplit0' => 'testuser3', ], [ 'auth' => 'oidc', @@ -208,9 +224,12 @@ public function dataprovider_create_user_from_entra_id_data() { 'objectId' => '00000000-0000-0000-0000-000000000004', 'id' => '00000000-0000-0000-0000-000000000004', 'givenName' => 'Test', - 'userPrincipalName' => 'testuser4@example.onmicrosoft.com', 'mail' => 'testuser4@example.onmicrosoft.com', 'surname' => 'User4', + 'userPrincipalName' => 'testuser4@example.onmicrosoft.com', + 'useridentifier' => 'testuser4@example.onmicrosoft.com', + 'useridentifierlower' => 'testuser4@example.onmicrosoft.com', + 'upnsplit0' => 'testuser4', ], [ 'auth' => 'oidc', @@ -237,13 +256,15 @@ public function dataprovider_create_user_from_entra_id_data() { * @dataProvider dataprovider_create_user_from_entra_id_data * @param array $entraiddata The Microsoft Entra ID user data to create the user from. * @param array $expecteduser The expected user data to be created. + * @covers \local_o365\feature\usersync\main::create_user_from_entra_id_data */ - public function test_create_user_from_entra_id_data($entraiddata, $expecteduser) { + public function test_create_user_from_entra_id_data($entraiddata, $expecteduser): void { global $DB; - $httpclient = new \local_o365\tests\mockhttpclient(); + + $httpclient = new mockhttpclient(); $clientdata = $this->get_mock_clientdata(); - $apiclient = new \local_o365\feature\usersync\main($clientdata, $httpclient); - $apiclient->create_user_from_entra_id_data($entraiddata, []); + $usersync = new main($clientdata, $httpclient); + $usersync->create_user_from_entra_id_data($entraiddata, []); $userparams = ['auth' => 'oidc', 'username' => $entraiddata['mail'], 'firstname' => $entraiddata['givenName'], 'lastname' => $entraiddata['surname']]; @@ -257,36 +278,39 @@ public function test_create_user_from_entra_id_data($entraiddata, $expecteduser) /** * Test sync_users method when creating users. + * + * @covers \local_o365\feature\usersync\main::sync_users */ - public function test_sync_users_create() { + public function test_sync_users_create(): void { global $CFG, $DB; + set_config('usersync', 'create', 'local_o365'); for ($i = 1; $i <= 2; $i++) { $muser = [ 'auth' => 'oidc', 'deleted' => '0', 'mnethostid' => $CFG->mnet_localhost_id, - 'username' => 'testuser'.$i.'@example.onmicrosoft.com', + 'username' => 'testuser' . $i . '@example.onmicrosoft.com', 'firstname' => 'Test', - 'lastname' => 'User'.$i, - 'email' => 'testuser'.$i.'@example.onmicrosoft.com', - 'lang' => 'en' + 'lastname' => 'User' . $i, + 'email' => 'testuser' . $i . '@example.onmicrosoft.com', + 'lang' => 'en', ]; - $muser['id'] = $DB->insert_record('user', (object)$muser); + $muser['id'] = $DB->insert_record('user', (object) $muser); $token = [ - 'oidcuniqid' => '00000000-0000-0000-0000-00000000000'.$i, + 'oidcuniqid' => '00000000-0000-0000-0000-00000000000' . $i, 'authcode' => '000', - 'username' => 'testuser'.$i.'@example.onmicrosoft.com', + 'username' => 'testuser' . $i . '@example.onmicrosoft.com', 'userid' => $muser['id'], 'scope' => 'test', - 'tokenresource' => \local_o365\rest\unified::get_tokenresource(), + 'tokenresource' => unified::get_tokenresource(), 'token' => '000', 'expiry' => '9999999999', - 'refreshtoken' => 'fsdfsdf'.$i, - 'idtoken' => 'sdfsdfsdf'.$i, + 'refreshtoken' => 'fsdfsdf' . $i, + 'idtoken' => 'sdfsdfsdf' . $i, ]; - $DB->insert_record('auth_oidc_token', (object)$token); + $DB->insert_record('auth_oidc_token', (object) $token); } $response = [ @@ -297,11 +321,11 @@ public function test_sync_users_create() { ]; $response = json_encode($response); $clientdata = $this->get_mock_clientdata(); - $httpclient = new \local_o365\tests\mockhttpclient(); + $httpclient = new mockhttpclient(); $httpclient->set_response($response); - $apiclient = new \local_o365\rest\unified($this->get_mock_token(), $httpclient); - $usersync = new \local_o365\feature\usersync\main($clientdata, $httpclient); + $apiclient = new unified($this->get_mock_token(), $httpclient); + $usersync = new main($clientdata, $httpclient); $users = $apiclient->get_users(); $usersync->sync_users($users); @@ -310,6 +334,7 @@ public function test_sync_users_create() { $createduser = ['auth' => 'oidc', 'username' => 'testuser3@example.onmicrosoft.com']; $this->assertTrue($DB->record_exists('user', $createduser)); + $createduser = $DB->get_record('user', $createduser); $this->assertEquals('Test', $createduser->firstname); $this->assertEquals('User3', $createduser->lastname); diff --git a/local/o365/tests/webservices_onenoteassignment_test.php b/local/o365/tests/webservices_onenoteassignment_test.php index 95e0cc880..db0d5f88a 100644 --- a/local/o365/tests/webservices_onenoteassignment_test.php +++ b/local/o365/tests/webservices_onenoteassignment_test.php @@ -23,10 +23,16 @@ * @copyright (C) 2014 onwards Microsoft Open Technologies, Inc. (http://msopentech.com/) */ +namespace local_o365; + +use advanced_testcase; use core_external\external_function_parameters; use core_external\external_single_structure; - -defined('MOODLE_INTERNAL') || die(); +use lang_string; +use local_o365\webservices\create_onenoteassignment; +use local_o365\webservices\delete_onenoteassignment; +use local_o365\webservices\read_onenoteassignment; +use local_o365\webservices\update_onenoteassignment; /** * Tests \local_o365\webservices\utils @@ -34,27 +40,33 @@ * @group local_o365 * @group office365 */ -class local_o365_webservices_onenoteassignment_testcase extends \advanced_testcase { +final class webservices_onenoteassignment_test extends advanced_testcase { // Data structure elements of the array based on old Data Provider. + /** @var int */ const DBSTATE = 0; + /** @var int */ const PARAMS = 1; + /** @var int */ const EXPECTEDRETURN = 2; + /** @var int */ const EXPECTEDEXCEPTION = 3; /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } /** * Test assignment_create_parameters method. + * + * @covers \local_o365\webservices\create_onenoteassignment::assignment_create_parameters */ - public function test_assignment_create_parameters() { - $schema = \local_o365\webservices\create_onenoteassignment::assignment_create_parameters(); + public function test_assignment_create_parameters(): void { + $schema = create_onenoteassignment::assignment_create_parameters(); $this->assertTrue($schema instanceof external_function_parameters); $this->assertArrayHasKey('data', $schema->keys); } @@ -64,7 +76,7 @@ public function test_assignment_create_parameters() { * * @return array Array of test parameters. */ - public function dataprovider_create_assignment() { + public static function dataprovider_create_assignment(): array { return [ [ [ @@ -94,18 +106,19 @@ public function dataprovider_create_assignment() { * @dataProvider dataprovider_create_assignment * @param array $params Webservice parameters. * @param array $expectedreturn Expected return. + * @covers \local_o365\webservices\create_onenoteassignment::assignment_create */ - public function test_assignment_create($params, $expectedreturn) { + public function test_assignment_create($params, $expectedreturn): void { global $DB; $course = $this->getDataGenerator()->create_course(); if ($params['course'] === '[[courseid]]') { - $params['course'] = (int)$course->id; + $params['course'] = (int) $course->id; } $this->setAdminUser(); - $actualreturn = \local_o365\webservices\create_onenoteassignment::assignment_create($params); + $actualreturn = create_onenoteassignment::assignment_create($params); $this->assertNotEmpty($actualreturn); $this->assertArrayHasKey('data', $actualreturn); @@ -129,18 +142,22 @@ public function test_assignment_create($params, $expectedreturn) { /** * Test assignment_create_returns method. + * + * @covers \local_o365\webservices\create_onenoteassignment::assignment_create_returns */ - public function test_assignment_create_returns() { - $schema = \local_o365\webservices\create_onenoteassignment::assignment_create_returns(); + public function test_assignment_create_returns(): void { + $schema = create_onenoteassignment::assignment_create_returns(); $this->assertTrue($schema instanceof external_single_structure); $this->assertArrayHasKey('data', $schema->keys); } /** * Test assignment_read_parameters method. + * + * @covers \local_o365\webservices\read_onenoteassignment::assignment_read_parameters */ - public function test_assignment_read_parameters() { - $schema = \local_o365\webservices\read_onenoteassignment::assignment_read_parameters(); + public function test_assignment_read_parameters(): void { + $schema = read_onenoteassignment::assignment_read_parameters(); $this->assertTrue($schema instanceof external_function_parameters); $this->assertArrayHasKey('data', $schema->keys); } @@ -148,16 +165,16 @@ public function test_assignment_read_parameters() { /** * Returns a list of general data existence tests to run against any function that looks up assignment data. * - * @return [type] [description] + * @return array[] [type] [description] */ - public function get_general_assignment_data_tests() { + public static function get_general_assignment_data_tests() { global $DB; - $course = $this->getDataGenerator()->create_course(); - $assign = $this->getDataGenerator()->create_module('assign', array('course' => $course->id, - 'section' => 1, - 'name' => 'OneNote Assignment', - 'intro' => 'This is a test assignment')); + $course = static::getDataGenerator()->create_course(); + $assign = static::getDataGenerator()->create_module('assign', ['course' => $course->id, + 'section' => 1, + 'name' => 'OneNote Assignment', + 'intro' => 'This is a test assignment']); // Enable OneNote submission for this assignment. $pluginconfigparams = [ @@ -254,10 +271,10 @@ public function get_general_assignment_data_tests() { * * @return array Array of test parameters. */ - public function dataprovider_assignment_read() { + public static function dataprovider_assignment_read(): array { global $DB; - $generaltests = $this->get_general_assignment_data_tests(); + $generaltests = static::get_general_assignment_data_tests(); $return = []; foreach ($generaltests as $testkey => $parameters) { @@ -269,12 +286,12 @@ public function dataprovider_assignment_read() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => 'OneNote Assignment', 'intro' => 'This is a test assignment', 'section' => $DB->get_field('course_sections', 'id', - array('course' => $parameters['params']['course'], - 'section' => 1)), + ['course' => $parameters['params']['course'], + 'section' => 1]), 'visible' => '1', ], ], @@ -296,10 +313,11 @@ public function dataprovider_assignment_read() { /** * Test \local_o365\webservices\read_onenoteassignment::assignment_read(). + * + * @dataProvider dataprovider_assignment_read + * @covers \local_o365\webservices\read_onenoteassignment::assignment_read */ - public function test_assignment_read() { - global $DB; - + public function test_assignment_read(): void { $dataarr = $this->dataprovider_assignment_read(); foreach ($dataarr as $data) { if (!empty($data[self::DBSTATE])) { @@ -318,7 +336,7 @@ public function test_assignment_read() { $this->setAdminUser(); - $actualreturn = \local_o365\webservices\read_onenoteassignment::assignment_read($data[self::PARAMS]); + $actualreturn = read_onenoteassignment::assignment_read($data[self::PARAMS]); $this->assertEquals($data[self::EXPECTEDRETURN], $actualreturn); } @@ -326,18 +344,22 @@ public function test_assignment_read() { /** * Test assignment_read_returns method. + * + * @covers \local_o365\webservices\read_onenoteassignment::assignment_read_returns */ - public function test_assignment_read_returns() { - $schema = \local_o365\webservices\read_onenoteassignment::assignment_read_returns(); + public function test_assignment_read_returns(): void { + $schema = read_onenoteassignment::assignment_read_returns(); $this->assertTrue($schema instanceof external_single_structure); $this->assertArrayHasKey('data', $schema->keys); } /** * Test assignment_update_parameters method. + * + * @covers \local_o365\webservices\update_onenoteassignment::assignment_update_parameters */ - public function test_assignment_update_parameters() { - $schema = \local_o365\webservices\update_onenoteassignment::assignment_update_parameters(); + public function test_assignment_update_parameters(): void { + $schema = update_onenoteassignment::assignment_update_parameters(); $this->assertTrue($schema instanceof external_function_parameters); $this->assertArrayHasKey('data', $schema->keys); } @@ -347,26 +369,24 @@ public function test_assignment_update_parameters() { * * @return array Array of test parameters. */ - public function dataprovider_assignment_update() { + public static function dataprovider_assignment_update(): array { global $DB; - $generaltests = $this->get_general_assignment_data_tests(); + $generaltests = static::get_general_assignment_data_tests(); $return = []; foreach ($generaltests as $testkey => $parameters) { if ($testkey === 'All data correct, assignment is a OneNote assignment') { - $data = array( - 'name' => 'New OneNote Assignment', - 'intro' => 'This is a test assignment', - 'newintro' => 'This is a new test assignment', - 'section' => $DB->get_field('course_sections', 'id', - array('course' => $parameters['params']['course'], - 'section' => 1)), - 'newsection' => $DB->get_field('course_sections', 'id', - array('course' => $parameters['params']['course'], - 'section' => 0)), - 'visible' => 1, - 'newvisible' => 0, - ); + $data = [ + 'name' => 'New OneNote Assignment', + 'intro' => 'This is a test assignment', + 'newintro' => 'This is a new test assignment', + 'section' => $DB->get_field('course_sections', 'id', + ['course' => $parameters['params']['course'], 'section' => 1]), + 'newsection' => $DB->get_field('course_sections', 'id', + ['course' => $parameters['params']['course'], 'section' => 0]), + 'visible' => 1, + 'newvisible' => 0, + ]; $return['Update name'] = [ $parameters['dbstate'], @@ -375,7 +395,7 @@ public function dataprovider_assignment_update() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => $data['name'], 'intro' => $data['intro'], 'section' => $data['section'], @@ -393,7 +413,7 @@ public function dataprovider_assignment_update() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => $data['name'], 'intro' => $data['newintro'], 'section' => $data['section'], @@ -411,7 +431,7 @@ public function dataprovider_assignment_update() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => $data['name'], 'intro' => $data['newintro'], 'section' => $data['section'], @@ -429,7 +449,7 @@ public function dataprovider_assignment_update() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => $data['name'], 'intro' => $data['newintro'], 'section' => $data['newsection'], @@ -447,7 +467,7 @@ public function dataprovider_assignment_update() { 'data' => [ [ 'course' => $parameters['params']['course'], - 'coursemodule' => (string)$parameters['params']['coursemodule'], + 'coursemodule' => (string) $parameters['params']['coursemodule'], 'name' => $data['name'], 'intro' => $data['newintro'], 'section' => $data['newsection'], @@ -465,8 +485,11 @@ public function dataprovider_assignment_update() { /** * Test \local_o365\webservices\update_onenoteassignment::assignment_update(). + * + * @dataProvider dataprovider_assignment_update + * @covers \local_o365\webservices\update_onenoteassignment::assignment_update */ - public function test_assignment_update() { + public function test_assignment_update(): void { $dataarr = $this->dataprovider_assignment_update(); foreach ($dataarr as $data) { if (!empty($data[self::DBSTATE])) { @@ -485,7 +508,7 @@ public function test_assignment_update() { $this->setAdminUser(); - $actualreturn = \local_o365\webservices\update_onenoteassignment::assignment_update($data[self::PARAMS]); + $actualreturn = update_onenoteassignment::assignment_update($data[self::PARAMS]); $this->assertEquals($data[self::EXPECTEDRETURN]['data'][0]['name'], $actualreturn['data'][0]['name']); $this->assertEquals($data[self::EXPECTEDRETURN]['data'][0]['intro'], $actualreturn['data'][0]['intro']); @@ -496,18 +519,22 @@ public function test_assignment_update() { /** * Test assignment_update_returns method. + * + * @covers \local_o365\webservices\update_onenoteassignment::assignment_update_returns */ - public function test_assignment_update_returns() { - $schema = \local_o365\webservices\update_onenoteassignment::assignment_update_returns(); + public function test_assignment_update_returns(): void { + $schema = update_onenoteassignment::assignment_update_returns(); $this->assertTrue($schema instanceof external_single_structure); $this->assertArrayHasKey('data', $schema->keys); } /** * Test assignment_delete_parameters method. + * + * @covers \local_o365\webservices\delete_onenoteassignment::assignment_delete_parameters */ - public function test_assignment_delete_parameters() { - $schema = \local_o365\webservices\delete_onenoteassignment::assignment_delete_parameters(); + public function test_assignment_delete_parameters(): void { + $schema = delete_onenoteassignment::assignment_delete_parameters(); $this->assertTrue($schema instanceof external_function_parameters); $this->assertArrayHasKey('data', $schema->keys); } @@ -517,8 +544,8 @@ public function test_assignment_delete_parameters() { * * @return array Array of test parameters. */ - public function dataprovider_assignment_delete() { - $generaltests = $this->get_general_assignment_data_tests(); + public static function dataprovider_assignment_delete(): array { + $generaltests = static::get_general_assignment_data_tests(); $return = []; foreach ($generaltests as $testkey => $parameters) { @@ -538,8 +565,10 @@ public function dataprovider_assignment_delete() { /** * Test \local_o365\webservices\delete_onenoteassignment::assignment_delete(). + * + * @covers \local_o365\webservices\delete_onenoteassignment::assignment_delete */ - public function test_assignment_delete() { + public function test_assignment_delete(): void { $dataarr = $this->dataprovider_assignment_delete(); foreach ($dataarr as $data) { if (!empty($data[self::DBSTATE])) { @@ -558,7 +587,7 @@ public function test_assignment_delete() { $this->setAdminUser(); - $actualreturn = \local_o365\webservices\delete_onenoteassignment::assignment_delete($data[self::PARAMS]); + $actualreturn = delete_onenoteassignment::assignment_delete($data[self::PARAMS]); $this->assertEquals($data[self::EXPECTEDRETURN], $actualreturn); } @@ -566,9 +595,11 @@ public function test_assignment_delete() { /** * Test assignment_delete_returns method. + * + * @covers \local_o365\webservices\delete_onenoteassignment::assignment_delete_returns */ - public function test_assignment_delete_returns() { - $schema = \local_o365\webservices\delete_onenoteassignment::assignment_delete_returns(); + public function test_assignment_delete_returns(): void { + $schema = delete_onenoteassignment::assignment_delete_returns(); $this->assertTrue($schema instanceof external_single_structure); $this->assertArrayHasKey('result', $schema->keys); } diff --git a/local/o365/tests/webservices_utils_test.php b/local/o365/tests/webservices_utils_test.php index d2169a3a7..cd7dc6e96 100644 --- a/local/o365/tests/webservices_utils_test.php +++ b/local/o365/tests/webservices_utils_test.php @@ -23,9 +23,12 @@ * @copyright (C) 2014 onwards Microsoft Open Technologies, Inc. (http://msopentech.com/) */ -use core_external\external_single_structure; +namespace local_o365; -defined('MOODLE_INTERNAL') || die(); +use advanced_testcase; +use core_external\external_single_structure; +use lang_string; +use local_o365\webservices\utils; /** * Tests \local_o365\webservices\utils @@ -33,12 +36,12 @@ * @group local_o365 * @group office365 */ -class local_o365_webservices_utils_testcase extends \advanced_testcase { +final class webservices_utils_test extends advanced_testcase { /** * Perform setup before every test. This tells Moodle's phpunit to reset the database after every test. */ - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->resetAfterTest(true); } @@ -85,7 +88,7 @@ public function create_assignment_info_testdata($createcourse, $modulerecords) { * * @return array Array of test parameters. */ - public function dataprovider_assignment_info() { + public static function dataprovider_assignment_info(): array { // Notes: // [[coursemoduleid]] is replaced with the id of the *last* course_module record inserted. // [[courseid]] is replaced with the generated course ID. @@ -269,12 +272,14 @@ public function dataprovider_assignment_info() { * @param int $coursemoduleid The course module id to pass to the test method. * @param int $courseid The course id to pass to the test method. * @param array $expectedreturn The expected return of the test method. + * + * @covers \local_o365\webservices\utils::get_assignment_info */ public function test_get_assignment_info($createcourse, $modulerecords, $expectedexception, $coursemoduleid, $courseid, - $expectedreturn) { + $expectedreturn): void { global $DB; - list($course, $modulerecord) = $this->create_assignment_info_testdata($createcourse, $modulerecords); + [$course, $modulerecord] = $this->create_assignment_info_testdata($createcourse, $modulerecords); if (!empty($expectedexception)) { if (isset($expectedexception[1])) { @@ -288,7 +293,7 @@ public function test_get_assignment_info($createcourse, $modulerecords, $expecte $courseid = ($courseid === '[[courseid]]') ? $course->id : $courseid; $coursemoduleid = ($coursemoduleid === '[[coursemoduleid]]') ? $modulerecord['id'] : $coursemoduleid; - $actualreturn = \local_o365\webservices\utils::get_assignment_info($coursemoduleid, $courseid); + $actualreturn = utils::get_assignment_info($coursemoduleid, $courseid); if ($expectedreturn[0] === '[[course]]') { $expectedreturn[0] = $DB->get_record('course', ['id' => $course->id]); @@ -311,8 +316,8 @@ public function test_get_assignment_info($createcourse, $modulerecords, $expecte * * @return array Array of test parameters. */ - public function dataprovider_verify_assignment() { - $assignmentinfotests = $this->dataprovider_assignment_info(); + public static function dataprovider_verify_assignment(): array { + $assignmentinfotests = static::dataprovider_assignment_info(); $testcases = []; foreach ($assignmentinfotests as $testkey => $testparams) { @@ -364,12 +369,14 @@ public function dataprovider_verify_assignment() { * @param array $expectedreturn The expected return of the test method. * @param bool $grantcapability Whether to grant the test user the capability to work with the assignment. * @param bool $addonenotesubmission Whether to add the OneNote submission record to this assignment. + * + * @covers \local_o365\webservices\utils::verify_assignment */ public function test_verify_assignment($createcourse, $modulerecords, $expectedexception, $coursemoduleid, $courseid, - $expectedreturn, $grantcapability, $addonenotesubmission) { + $expectedreturn, $grantcapability, $addonenotesubmission): void { global $DB; - list($course, $modulerecord) = $this->create_assignment_info_testdata($createcourse, $modulerecords); + [$course, $modulerecord] = $this->create_assignment_info_testdata($createcourse, $modulerecords); if (!empty($expectedexception)) { if (isset($expectedexception[1])) { @@ -400,7 +407,7 @@ public function test_verify_assignment($createcourse, $modulerecords, $expectede $DB->insert_record('assign_plugin_config', $pluginconfigparams); } - $actualreturn = \local_o365\webservices\utils::verify_assignment($coursemoduleid, $courseid); + $actualreturn = utils::verify_assignment($coursemoduleid, $courseid); if ($expectedreturn[0] === '[[course]]') { $expectedreturn[0] = $DB->get_record('course', ['id' => $course->id]); @@ -417,9 +424,11 @@ public function test_verify_assignment($createcourse, $modulerecords, $expectede /** * Test get_assignment_return_info_schema method. + * + * @covers \local_o365\webservices\utils::get_assignment_return_info_schema */ - public function test_get_assignment_return_info_schema() { - $schema = \local_o365\webservices\utils::get_assignment_return_info_schema(); + public function test_get_assignment_return_info_schema(): void { + $schema = utils::get_assignment_return_info_schema(); $this->assertTrue($schema instanceof external_single_structure); $this->assertArrayHasKey('data', $schema->keys); } @@ -429,8 +438,8 @@ public function test_get_assignment_return_info_schema() { * * @return array Array of test parameters. */ - public function dataprovider_get_assignment_return_info() { - $assignmentinfotests = $this->dataprovider_assignment_info(); + public static function dataprovider_get_assignment_return_info(): array { + $assignmentinfotests = static::dataprovider_assignment_info(); $testcases = []; foreach ($assignmentinfotests as $testkey => $testparams) { @@ -449,6 +458,7 @@ public function dataprovider_get_assignment_return_info() { ]; } } + return $testcases; } @@ -464,10 +474,12 @@ public function dataprovider_get_assignment_return_info() { * @param int $coursemoduleid The course module id to pass to the test method. * @param int $courseid The course id to pass to the test method. * @param array $expectedreturn The expected return of the test method. + * + * @covers \local_o365\webservices\utils::get_assignment_return_info */ public function test_get_assignment_return_info($createcourse, $modulerecords, $expectedexception, $coursemoduleid, $courseid, - $expectedreturn) { - list($course, $modulerecord) = $this->create_assignment_info_testdata($createcourse, $modulerecords); + $expectedreturn): void { + [$course, $modulerecord] = $this->create_assignment_info_testdata($createcourse, $modulerecords); if (!empty($expectedexception)) { if (isset($expectedexception[1])) { @@ -481,16 +493,16 @@ public function test_get_assignment_return_info($createcourse, $modulerecords, $ $courseid = ($courseid === '[[courseid]]') ? $course->id : $courseid; $coursemoduleid = ($coursemoduleid === '[[coursemoduleid]]') ? $modulerecord['id'] : $coursemoduleid; - $actualreturn = \local_o365\webservices\utils::get_assignment_return_info($coursemoduleid, $courseid); + $actualreturn = utils::get_assignment_return_info($coursemoduleid, $courseid); if ($expectedreturn['course'] === '[[courseid]]') { $expectedreturn['course'] = $course->id; } if ($expectedreturn['coursemodule'] === '[[coursemoduleid]]') { - $expectedreturn['coursemodule'] = (string)$modulerecord['id']; + $expectedreturn['coursemodule'] = (string) $modulerecord['id']; } if ($expectedreturn['instance'] === '[[assignid]]') { - $expectedreturn['instance'] = (string)$modulerecord['instance']; + $expectedreturn['instance'] = (string) $modulerecord['instance']; } $this->assertEquals($expectedreturn, $actualreturn); diff --git a/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js b/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js index e52826984..48f6fc50b 100644 --- a/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js +++ b/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js @@ -1,2 +1,3 @@ -define ("assignfeedback_onenote/onenotedelete",["jquery","core/templates","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){return{init:function init(){var b=a("#deleteuserfeedback"),h=a(b).attr("gradeid"),i=a(b).attr("contextid"),j=a(b).attr("userid");f.create({type:f.types.SAVE_CANCEL,title:e.get_string("deletefeedbackconfirm","assignfeedback_onenote"),body:e.get_string("deletefeedbackconfirmdetail","assignfeedback_onenote")},b).done(function(a){a.getRoot().on(g.save,function(a){a.preventDefault();requests=c.call([{methodname:"mod_assign_feedback_onenote_delete",args:{contextid:i,gradeid:h,userid:j}}]);requests[0].done(function(){location.reload()}).fail(d.exception)})})}}}); -//# sourceMappingURL=onenotedelete.min.js.map +define("assignfeedback_onenote/onenotedelete",["jquery","core/templates","core/ajax","core/notification","core/str","core/modal_factory","core/modal_events"],(function($,templates,ajax,notification,Str,ModalFactory,ModalEvents){return{init:function(){var trigger=$("#deleteuserfeedback"),gradeid=$(trigger).attr("gradeid"),contextid=$(trigger).attr("contextid"),userid=$(trigger).attr("userid");ModalFactory.create({type:ModalFactory.types.SAVE_CANCEL,title:Str.get_string("deletefeedbackconfirm","assignfeedback_onenote"),body:Str.get_string("deletefeedbackconfirmdetail","assignfeedback_onenote")},trigger).done((function(modal){modal.getRoot().on(ModalEvents.save,(function(e){e.preventDefault(),ajax.call([{methodname:"mod_assign_feedback_onenote_delete",args:{contextid:contextid,gradeid:gradeid,userid:userid}}])[0].done((function(){location.reload()})).fail(notification.exception)}))}))}}})); + +//# sourceMappingURL=onenotedelete.min.js.map \ No newline at end of file diff --git a/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js.map b/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js.map index fbd88b017..4086e6c22 100644 --- a/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js.map +++ b/mod/assign/feedback/onenote/amd/build/onenotedelete.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/onenotedelete.js"],"names":["define","$","templates","ajax","notification","Str","ModalFactory","ModalEvents","init","trigger","gradeid","attr","contextid","userid","create","type","types","SAVE_CANCEL","title","get_string","body","done","modal","getRoot","on","save","e","preventDefault","requests","call","methodname","args","location","reload","fail","exception"],"mappings":"AAAAA,OAAM,wCAAC,CAAC,QAAD,CACD,gBADC,CAED,WAFC,CAGD,mBAHC,CAID,UAJC,CAKD,oBALC,CAMD,mBANC,CAAD,CAOF,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAA6BC,CAA7B,CAA2CC,CAA3C,CAAgDC,CAAhD,CAA8DC,CAA9D,CAA4E,CAC1E,MAAO,CACLC,IAAI,CAAE,eAAY,IACZC,CAAAA,CAAO,CAAGR,CAAC,CAAC,qBAAD,CADC,CAEZS,CAAO,CAAGT,CAAC,CAACQ,CAAD,CAAD,CAAWE,IAAX,CAAgB,SAAhB,CAFE,CAGZC,CAAS,CAAGX,CAAC,CAACQ,CAAD,CAAD,CAAWE,IAAX,CAAgB,WAAhB,CAHA,CAIZE,CAAM,CAAGZ,CAAC,CAACQ,CAAD,CAAD,CAAWE,IAAX,CAAgB,QAAhB,CAJG,CAKhBL,CAAY,CAACQ,MAAb,CAAoB,CAClBC,IAAI,CAAET,CAAY,CAACU,KAAb,CAAmBC,WADP,CAElBC,KAAK,CAAEb,CAAG,CAACc,UAAJ,CAAe,uBAAf,CAAwC,wBAAxC,CAFW,CAGlBC,IAAI,CAAEf,CAAG,CAACc,UAAJ,CAAe,6BAAf,CAA8C,wBAA9C,CAHY,CAApB,CAIGV,CAJH,EAKKY,IALL,CAKU,SAAUC,CAAV,CAAiB,CACrBA,CAAK,CAACC,OAAN,GAAgBC,EAAhB,CAAmBjB,CAAW,CAACkB,IAA/B,CAAqC,SAAUC,CAAV,CAAa,CAEhDA,CAAC,CAACC,cAAF,GACAC,QAAQ,CAAGzB,CAAI,CAAC0B,IAAL,CAAU,CAAC,CACpBC,UAAU,CAAE,oCADQ,CAEpBC,IAAI,CAAE,CAACnB,SAAS,CAAEA,CAAZ,CAAuBF,OAAO,CAAEA,CAAhC,CAA0CG,MAAM,CAAEA,CAAlD,CAFc,CAAD,CAAV,CAAX,CAKAe,QAAQ,CAAC,CAAD,CAAR,CAAYP,IAAZ,CAAiB,UAAgB,CAC/BW,QAAQ,CAACC,MAAT,EACD,CAFD,EAEGC,IAFH,CAEQ9B,CAAY,CAAC+B,SAFrB,CAGD,CAXD,CAYD,CAlBL,CAmBD,CAzBI,CA2BR,CAnCC,CAAN","sourcesContent":["define(['jquery',\n 'core/templates',\n 'core/ajax',\n 'core/notification',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'],\n function($, templates, ajax, notification, Str, ModalFactory, ModalEvents,) {\n return {\n init: function () {\n var trigger = $('#deleteuserfeedback');\n var gradeid = $(trigger).attr('gradeid');\n var contextid = $(trigger).attr('contextid');\n var userid = $(trigger).attr('userid');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: Str.get_string('deletefeedbackconfirm', 'assignfeedback_onenote'),\n body: Str.get_string('deletefeedbackconfirmdetail', 'assignfeedback_onenote'),\n }, trigger)\n .done(function (modal) {\n modal.getRoot().on(ModalEvents.save, function (e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n requests = ajax.call([{\n methodname: 'mod_assign_feedback_onenote_delete',\n args: {contextid: contextid, gradeid: gradeid , userid: userid }\n }]);\n\n requests[0].done(function (plan) {\n location.reload();\n }).fail(notification.exception);\n });\n });\n }\n }\n });\n"],"file":"onenotedelete.min.js"} \ No newline at end of file +{"version":3,"file":"onenotedelete.min.js","sources":["../src/onenotedelete.js"],"sourcesContent":["define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'core/modal_factory', 'core/modal_events'],\n function($, templates, ajax, notification, Str, ModalFactory, ModalEvents) {\n return {\n init: function() {\n var trigger = $('#deleteuserfeedback');\n var gradeid = $(trigger).attr('gradeid');\n var contextid = $(trigger).attr('contextid');\n var userid = $(trigger).attr('userid');\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: Str.get_string('deletefeedbackconfirm', 'assignfeedback_onenote'),\n body: Str.get_string('deletefeedbackconfirmdetail', 'assignfeedback_onenote'),\n }, trigger)\n .done(function(modal) {\n modal.getRoot().on(ModalEvents.save, function(e) {\n // Stop the default save button behaviour which is to close the modal.\n e.preventDefault();\n var requests = ajax.call([{\n methodname: 'mod_assign_feedback_onenote_delete',\n args: {contextid: contextid, gradeid: gradeid, userid: userid}\n }]);\n\n requests[0].done(function() {\n location.reload();\n }).fail(notification.exception);\n });\n });\n }\n };\n }\n);\n"],"names":["define","$","templates","ajax","notification","Str","ModalFactory","ModalEvents","init","trigger","gradeid","attr","contextid","userid","create","type","types","SAVE_CANCEL","title","get_string","body","done","modal","getRoot","on","save","e","preventDefault","call","methodname","args","location","reload","fail","exception"],"mappings":"AAAAA,8CAAO,CAAC,SAAU,iBAAkB,YAAa,oBAAqB,WAAY,qBAAsB,sBACpG,SAASC,EAAGC,UAAWC,KAAMC,aAAcC,IAAKC,aAAcC,mBACnD,CACHC,KAAM,eACEC,QAAUR,EAAE,uBACZS,QAAUT,EAAEQ,SAASE,KAAK,WAC1BC,UAAYX,EAAEQ,SAASE,KAAK,aAC5BE,OAASZ,EAAEQ,SAASE,KAAK,UAC7BL,aAAaQ,OAAO,CAChBC,KAAMT,aAAaU,MAAMC,YACzBC,MAAOb,IAAIc,WAAW,wBAAyB,0BAC/CC,KAAMf,IAAIc,WAAW,8BAA+B,2BACrDV,SACEY,MAAK,SAASC,OACXA,MAAMC,UAAUC,GAAGjB,YAAYkB,MAAM,SAASC,GAE1CA,EAAEC,iBACaxB,KAAKyB,KAAK,CAAC,CACtBC,WAAY,qCACZC,KAAM,CAAClB,UAAWA,UAAWF,QAASA,QAASG,OAAQA,WAGlD,GAAGQ,MAAK,WACbU,SAASC,YACVC,KAAK7B,aAAa8B"} \ No newline at end of file diff --git a/mod/assign/feedback/onenote/amd/src/onenotedelete.js b/mod/assign/feedback/onenote/amd/src/onenotedelete.js index 440bdb918..f2c36b2a9 100644 --- a/mod/assign/feedback/onenote/amd/src/onenotedelete.js +++ b/mod/assign/feedback/onenote/amd/src/onenotedelete.js @@ -1,36 +1,31 @@ -define(['jquery', - 'core/templates', - 'core/ajax', - 'core/notification', - 'core/str', - 'core/modal_factory', - 'core/modal_events'], - function($, templates, ajax, notification, Str, ModalFactory, ModalEvents,) { - return { - init: function () { - var trigger = $('#deleteuserfeedback'); - var gradeid = $(trigger).attr('gradeid'); - var contextid = $(trigger).attr('contextid'); - var userid = $(trigger).attr('userid'); - ModalFactory.create({ - type: ModalFactory.types.SAVE_CANCEL, - title: Str.get_string('deletefeedbackconfirm', 'assignfeedback_onenote'), - body: Str.get_string('deletefeedbackconfirmdetail', 'assignfeedback_onenote'), - }, trigger) - .done(function (modal) { - modal.getRoot().on(ModalEvents.save, function (e) { - // Stop the default save button behaviour which is to close the modal. - e.preventDefault(); - requests = ajax.call([{ - methodname: 'mod_assign_feedback_onenote_delete', - args: {contextid: contextid, gradeid: gradeid , userid: userid } - }]); +define(['jquery', 'core/templates', 'core/ajax', 'core/notification', 'core/str', 'core/modal_factory', 'core/modal_events'], + function($, templates, ajax, notification, Str, ModalFactory, ModalEvents) { + return { + init: function() { + var trigger = $('#deleteuserfeedback'); + var gradeid = $(trigger).attr('gradeid'); + var contextid = $(trigger).attr('contextid'); + var userid = $(trigger).attr('userid'); + ModalFactory.create({ + type: ModalFactory.types.SAVE_CANCEL, + title: Str.get_string('deletefeedbackconfirm', 'assignfeedback_onenote'), + body: Str.get_string('deletefeedbackconfirmdetail', 'assignfeedback_onenote'), + }, trigger) + .done(function(modal) { + modal.getRoot().on(ModalEvents.save, function(e) { + // Stop the default save button behaviour which is to close the modal. + e.preventDefault(); + var requests = ajax.call([{ + methodname: 'mod_assign_feedback_onenote_delete', + args: {contextid: contextid, gradeid: gradeid, userid: userid} + }]); - requests[0].done(function (plan) { - location.reload(); - }).fail(notification.exception); - }); - }); - } - }; - }); + requests[0].done(function() { + location.reload(); + }).fail(notification.exception); + }); + }); + } + }; + } +); diff --git a/mod/assign/feedback/onenote/backup/moodle2/backup_assignfeedback_onenote_subplugin.class.php b/mod/assign/feedback/onenote/backup/moodle2/backup_assignfeedback_onenote_subplugin.class.php index 8b13e11b4..bd91a203c 100644 --- a/mod/assign/feedback/onenote/backup/moodle2/backup_assignfeedback_onenote_subplugin.class.php +++ b/mod/assign/feedback/onenote/backup/moodle2/backup_assignfeedback_onenote_subplugin.class.php @@ -15,7 +15,9 @@ // along with Moodle. If not, see . /** - * Provides the information to backup feedback files. This just adds its filearea to the annotations and records the number of files. + * Provides the information to backup feedback files. + * This just adds its filearea to the annotations and records the number of files. + * * @package assignfeedback_onenote * @author Vinayak (Vin) Bhalerao (v-vibhal@microsoft.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -27,7 +29,6 @@ * * @package assignfeedback_onenote */ -defined('MOODLE_INTERNAL') || die(); /** * Restore subplugin class. @@ -41,6 +42,7 @@ class backup_assignfeedback_onenote_subplugin extends backup_subplugin { /** * Returns the subplugin information to attach to feedback element + * * @return backup_subplugin_element */ protected function define_grade_subplugin_structure() { @@ -48,16 +50,17 @@ protected function define_grade_subplugin_structure() { // Create XML elements. $subplugin = $this->get_subplugin_element(); $subpluginwrapper = new backup_nested_element($this->get_recommended_name()); - $subpluginelement = new backup_nested_element('feedback_onenote', null, array('numfiles', 'grade')); + $subpluginelement = new backup_nested_element('feedback_onenote', null, ['numfiles', 'grade']); // Connect XML elements into the tree. $subplugin->add_child($subpluginwrapper); $subpluginwrapper->add_child($subpluginelement); // Set source to populate the data. - $subpluginelement->set_source_table('assignfeedback_onenote', array('grade' => backup::VAR_PARENTID)); + $subpluginelement->set_source_table('assignfeedback_onenote', ['grade' => backup::VAR_PARENTID]); // The parent is the grade. $subpluginelement->annotate_files('assignfeedback_onenote', 'feedback_files', 'grade'); + return $subplugin; } diff --git a/mod/assign/feedback/onenote/backup/moodle2/restore_assignfeedback_onenote_subplugin.class.php b/mod/assign/feedback/onenote/backup/moodle2/restore_assignfeedback_onenote_subplugin.class.php index 346485d48..818466549 100644 --- a/mod/assign/feedback/onenote/backup/moodle2/restore_assignfeedback_onenote_subplugin.class.php +++ b/mod/assign/feedback/onenote/backup/moodle2/restore_assignfeedback_onenote_subplugin.class.php @@ -16,12 +16,12 @@ /** * This file contains the restore code for the feedback_file plugin. + * * @package assignfeedback_onenote * @author Vinayak (Vin) Bhalerao (v-vibhal@microsoft.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); /** * Restore subplugin class. @@ -35,11 +35,12 @@ class restore_assignfeedback_onenote_subplugin extends restore_subplugin { /** * Returns the paths to be handled by the subplugin at assignment level + * * @return array */ protected function define_grade_subplugin_structure() { - $paths = array(); + $paths = []; $elename = $this->get_namefor('grade'); // We used get_recommended_name() so this works. @@ -51,12 +52,13 @@ protected function define_grade_subplugin_structure() { /** * Processes one feedback_onenote element + * * @param mixed $data */ public function process_assignfeedback_onenote_grade($data) { global $DB; - $data = (object)$data; + $data = (object) $data; $data->assignment = $this->get_new_parentid('assign'); $oldgradeid = $data->grade; // The mapping is set in the restore for the core assign activity @@ -67,5 +69,4 @@ public function process_assignfeedback_onenote_grade($data) { $this->add_related_files('assignfeedback_onenote', 'feedback_files', 'grade', null, $oldgradeid); } - } diff --git a/mod/assign/feedback/onenote/classes/privacy/provider.php b/mod/assign/feedback/onenote/classes/privacy/provider.php index 8915484cf..c6c08cb2b 100644 --- a/mod/assign/feedback/onenote/classes/privacy/provider.php +++ b/mod/assign/feedback/onenote/classes/privacy/provider.php @@ -28,14 +28,14 @@ require_once($CFG->dirroot.'/mod/assign/locallib.php'); -use \core_privacy\local\metadata\collection; -use \core_privacy\local\metadata\provider as metadataprovider; -use \mod_assign\privacy\assignfeedback_provider; -use \mod_assign\privacy\assignfeedback_user_provider; -use \core_privacy\local\request\writer; -use \core_privacy\local\request\contextlist; -use \mod_assign\privacy\assign_plugin_request_data; -use \mod_assign\privacy\useridlist; +use core_privacy\local\metadata\collection; +use core_privacy\local\metadata\provider as metadataprovider; +use mod_assign\privacy\assignfeedback_provider; +use mod_assign\privacy\assignfeedback_user_provider; +use core_privacy\local\request\writer; +use core_privacy\local\request\contextlist; +use mod_assign\privacy\assign_plugin_request_data; +use mod_assign\privacy\useridlist; /** * Privacy class for requesting user data. * @@ -54,11 +54,11 @@ class provider implements * @param collection $collection A list of information to add to. * @return collection Return the collection after adding to it. */ - public static function get_metadata(collection $collection) : collection { + public static function get_metadata(collection $collection): collection { $detail = [ 'assignment' => 'privacy:metadata:assignmentid', 'grade' => 'privacy:metadata:gradepurpose', - 'numfiles' => 'privacy:metadata:numfiles' + 'numfiles' => 'privacy:metadata:numfiles', ]; $collection->add_database_table('assignfeedback_onenote', $detail, 'privacy:metadata:tablepurpose'); return $collection; @@ -143,7 +143,7 @@ public static function delete_feedback_for_grade(assign_plugin_request_data $req $filters = [ 'assignment' => $requestdata->get_assign()->get_instance()->id, - 'grade' => $requestdata->get_pluginobject()->id + 'grade' => $requestdata->get_pluginobject()->id, ]; $DB->delete_records('assignfeedback_onenote', $filters); } diff --git a/mod/assign/feedback/onenote/db/install.php b/mod/assign/feedback/onenote/db/install.php index 82dde3f40..e4db67ad3 100644 --- a/mod/assign/feedback/onenote/db/install.php +++ b/mod/assign/feedback/onenote/db/install.php @@ -22,8 +22,6 @@ * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); - /** * Code run after the assignfeedback_onenote module database tables have been created. * Moves the feedback onenote plugin down diff --git a/mod/assign/feedback/onenote/db/upgrade.php b/mod/assign/feedback/onenote/db/upgrade.php index f2d1cd5c2..e28e3023b 100644 --- a/mod/assign/feedback/onenote/db/upgrade.php +++ b/mod/assign/feedback/onenote/db/upgrade.php @@ -22,8 +22,6 @@ * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); - /** * Stub for upgrade code * @param int $oldversion diff --git a/mod/assign/feedback/onenote/externallib.php b/mod/assign/feedback/onenote/externallib.php index bbf81d16b..1547bc152 100644 --- a/mod/assign/feedback/onenote/externallib.php +++ b/mod/assign/feedback/onenote/externallib.php @@ -65,7 +65,7 @@ protected static function validate_feedback_onenote_delete_foruser($contextid, $ */ public static function feedback_onenote_delete_foruser_parameters() { return new external_function_parameters (['contextid' => new external_value(PARAM_INT, 'Context id'), - 'gradeid' => new external_value(PARAM_INT, 'Grade id'), 'userid' => new external_value(PARAM_INT, 'User id'),]); + 'gradeid' => new external_value(PARAM_INT, 'Grade id'), 'userid' => new external_value(PARAM_INT, 'User id')]); } /** @@ -82,7 +82,7 @@ public static function feedback_onenote_delete_foruser($contextid, $gradeid, $us $warnings = []; self::validate_parameters(self::feedback_onenote_delete_foruser_parameters(), - ['contextid' => $contextid, 'gradeid' => $gradeid, 'userid' => $userid,]); + ['contextid' => $contextid, 'gradeid' => $gradeid, 'userid' => $userid]); // This code removes the entry. $fs = get_file_storage(); @@ -111,6 +111,6 @@ public static function feedback_onenote_delete_foruser($contextid, $gradeid, $us */ public static function feedback_onenote_delete_foruser_returns() { return new external_single_structure(['status' => new external_value(PARAM_BOOL, 'status: true if success'), - 'warnings' => new external_warnings(),]); + 'warnings' => new external_warnings()]); } } diff --git a/mod/assign/feedback/onenote/lang/cs/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/cs/assignfeedback_onenote.php index 1a42de239..b64fe7c34 100644 --- a/mod/assign/feedback/onenote/lang/cs/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/cs/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Přidat zpětnou vazbu'; +$string['addfeedbackhelp'] = 'Pokud chcete přidat svou zpětnou vazbu pro příspěvky studentů ve OneNote, klikněte na tlačítko výše. Později se sem můžete vrátit a uložit svou práci zpět do Moodlu.'; $string['configmaxbytes'] = 'Maximální velikost OneNote'; $string['countfiles'] = 'Soubory OneNote: {$a}'; $string['default'] = 'Ve výchozím nastavení povoleno'; $string['default_help'] = 'Je-li nastaveno, tato metoda zpětné vazby bude ve výchozím nastavení povolena pro všechny nové úkoly.'; $string['enabled'] = 'Zpětná vazba OneNote'; $string['enabled_help'] = 'Pokud je povoleno, učitel může při klasifikaci úkolů nahrávat stránky OneNote se zpětnou vazbou. Učitelé mohou přidávat anotace ke studentským příspěvkům ve formě OneNote nebo nahrát zcela novou stránku OneNote.'; -$string['onenote'] = 'OneNote zpětné vazby'; +$string['feedbackdownloadfailed'] = 'Nelze stáhnout zpětnou vazbu z OneNote. Zkuste to znovu.'; +$string['feedbacklimitexceed'] = 'Vaše zpětná vazba překračuje povolený limit velikosti.'; +$string['feedbacknotstarted'] = 'Přidejte svou zpětnou vazbu pomocí OneNote a potom uložte změny.'; $string['filesadded'] = 'Přidané zpětné vazby OneNote: {$a}'; $string['maxbytes'] = 'Maximální velikost balíčku OneNote'; $string['maxfiles'] = 'Maximální počet nahraných OneNote'; $string['maximumsize'] = 'Maximální velikost balíčku OneNote'; $string['moreusers'] = '{$a} více…'; $string['nochanges'] = 'Žádné změny'; +$string['notsignedin'] = 'Před pokusem o uložení změn se nejprve přihlaste do OneNote.'; +$string['onenote'] = 'OneNote zpětné vazby'; $string['pluginname'] = 'Zpětná vazba OneNote'; -$string['addfeedback'] = 'Přidat zpětnou vazbu'; -$string['addfeedbackhelp'] = 'Pokud chcete přidat svou zpětnou vazbu pro příspěvky studentů ve OneNote, klikněte na tlačítko výše. Později se sem můžete vrátit a uložit svou práci zpět do Moodlu.'; $string['signinhelp1'] = 'Klikněte na tlačítko výše a přihlaste se do OneNote, abyste ve OneNote mohli přidat zpětnou vazbu k příspěvkům studentů.'; $string['signinhelp2'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, pokud chcete zpětnou vazbu zobrazit tam.'; $string['viewfeedback'] = 'Zobrazit zpětnou vazbu'; -$string['feedbackdownloadfailed'] = 'Nelze stáhnout zpětnou vazbu z OneNote. Zkuste to znovu.'; -$string['notsignedin'] = 'Před pokusem o uložení změn se nejprve přihlaste do OneNote.'; -$string['feedbacknotstarted'] = 'Přidejte svou zpětnou vazbu pomocí OneNote a potom uložte změny.'; -$string['feedbacklimitexceed'] = 'Vaše zpětná vazba překračuje povolený limit velikosti.'; diff --git a/mod/assign/feedback/onenote/lang/de/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/de/assignfeedback_onenote.php index 987b40212..0e213588e 100644 --- a/mod/assign/feedback/onenote/lang/de/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/de/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Feedback hinzufügen'; +$string['addfeedbackhelp'] = 'Klicken Sie auf die Schaltfläche oben, um Ihr Feedback für die abgegebene Seite des Studenten in OneNote hinzuzufügen. Sie können später hierher zurückkehren, um Ihre Arbeit wieder in Moodle zu speichern.'; $string['configmaxbytes'] = 'Maximale OneNote-Größe'; $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Standardmäßig aktiviert'; $string['default_help'] = 'Mit dieser Einstellung wird die gewählte Feedback-Methode für alle neuen Aufgaben voreingestellt.'; $string['enabled'] = 'OneNote-Feedback'; $string['enabled_help'] = 'Ist diese Einstellung aktiviert, kann der Trainer bei der Benotung der Zuweisungen OneNote-Seiten mit Feedback hochladen. Trainer können die abgegebene OneNote-Seite des Studenten mit Anmerkungen versehen oder eine ganz neue OneNote-Seite hochladen.'; -$string['onenote'] = 'Feedback-OneNote'; +$string['feedbackdownloadfailed'] = 'Feedback konnte nicht von OneNote heruntergeladen werden. Versuchen Sie es noch einmal.'; +$string['feedbacklimitexceed'] = 'Die Größe Ihres Feedbacks übersteigt den zulässigen Grenzwert.'; +$string['feedbacknotstarted'] = 'Fügen Sie Ihr Feedback mit OneNote hinzu und speichern Sie anschließend Ihre Änderungen.'; $string['filesadded'] = 'Feedback-OneNote hinzugefügt: {$a}'; $string['maxbytes'] = 'Maximale Größe von OneNote-Paketen'; $string['maxfiles'] = 'Maximale Anzahl der hochgeladenen OneNote'; $string['maximumsize'] = 'Maximale Größe von OneNote-Paketen'; $string['moreusers'] = '{$a} weitere'; $string['nochanges'] = 'Keine Änderungen'; +$string['notsignedin'] = 'Melden Sie sich bei OneNote an, bevor Sie versuchen, Ihre Änderungen zu speichern.'; +$string['onenote'] = 'Feedback-OneNote'; $string['pluginname'] = 'OneNote-Feedback'; -$string['addfeedback'] = 'Feedback hinzufügen'; -$string['addfeedbackhelp'] = 'Klicken Sie auf die Schaltfläche oben, um Ihr Feedback für die abgegebene Seite des Studenten in OneNote hinzuzufügen. Sie können später hierher zurückkehren, um Ihre Arbeit wieder in Moodle zu speichern.'; $string['signinhelp1'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden und dort Feedback zur abgegebenen Arbeit des Studenten hinzuzufügen.'; $string['signinhelp2'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden, wenn Sie das Feedback dort anzeigen möchten.'; $string['viewfeedback'] = 'Feedback anzeigen'; -$string['feedbackdownloadfailed'] = 'Feedback konnte nicht von OneNote heruntergeladen werden. Versuchen Sie es noch einmal.'; -$string['notsignedin'] = 'Melden Sie sich bei OneNote an, bevor Sie versuchen, Ihre Änderungen zu speichern.'; -$string['feedbacknotstarted'] = 'Fügen Sie Ihr Feedback mit OneNote hinzu und speichern Sie anschließend Ihre Änderungen.'; -$string['feedbacklimitexceed'] = 'Die Größe Ihres Feedbacks übersteigt den zulässigen Grenzwert.'; diff --git a/mod/assign/feedback/onenote/lang/en/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/en/assignfeedback_onenote.php index 501def0d7..0e4fc29af 100644 --- a/mod/assign/feedback/onenote/lang/en/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/en/assignfeedback_onenote.php @@ -25,36 +25,36 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Add feedback'; +$string['addfeedbackhelp'] = 'Click on the button above to add your feedback for the student\'s submission in OneNote. You can come back here later on to save your work back into Moodle.'; $string['configmaxbytes'] = 'Maximum OneNote size'; $string['countfiles'] = 'OneNote: {$a}'; +$string['default'] = 'Enabled by default'; +$string['default_help'] = 'When set, this feedback method is enabled by default for all new assignments.'; $string['deletefeedback'] = 'Delete feedback for user'; $string['deletefeedbackconfirm'] = 'Confirmation of onenote feedback removal'; $string['deletefeedbackconfirmdetail'] = 'This will remove the saved onenote feedback for the user, details will still be in onenote'; $string['deletefeedbackforuser'] = 'Delete onenote feedback for user'; -$string['default'] = 'Enabled by default'; -$string['default_help'] = 'When set, this feedback method is enabled by default for all new assignments.'; $string['enabled'] = 'OneNote feedback'; $string['enabled_help'] = 'If enabled, the teacher will be able to upload OneNote pages with feedback when marking the assignments. Teachers may choose to annotate the student\'s OneNote submission or upload a completely new OneNote page.'; -$string['onenote'] = 'Feedback OneNote'; +$string['feedbackdownloadfailed'] = 'Could not download the feedback from OneNote. Please try again.'; +$string['feedbacklimitexceed'] = 'Your feedback size exceeds the acceptable limit.'; +$string['feedbacknotstarted'] = 'Please add your feedback using OneNote and then save your changes.'; $string['filesadded'] = 'Feedback OneNote added: {$a}'; $string['maxbytes'] = 'Maximum OneNote package size'; $string['maxfiles'] = 'Maximum number of uploaded OneNote'; $string['maximumsize'] = 'Maximum OneNote package size'; $string['moreusers'] = '{$a} more...'; $string['nochanges'] = 'No changes'; -$string['pluginname'] = 'OneNote feedback'; -$string['addfeedback'] = 'Add feedback'; -$string['addfeedbackhelp'] = 'Click on the button above to add your feedback for the student\'s submission in OneNote. You can come back here later on to save your work back into Moodle.'; -$string['signinhelp1'] = 'Click on the button above to sign in to OneNote so you can add your feedback to the student\'s submission there.'; -$string['signinhelp2'] = 'Click on the button above to sign in to OneNote if you want to view the feedback there.'; -$string['viewfeedback'] = 'View feedback'; -$string['feedbackdownloadfailed'] = 'Could not download the feedback from OneNote. Please try again.'; $string['notsignedin'] = 'Please sign in to OneNote before attempting to save your changes.'; -$string['feedbacknotstarted'] = 'Please add your feedback using OneNote and then save your changes.'; -$string['feedbacklimitexceed'] = 'Your feedback size exceeds the acceptable limit.'; +$string['onenote'] = 'Feedback OneNote'; $string['onenoteactions'] = 'OneNote Actions:'; -$string['privacy:path'] = 'Number of files'; +$string['pluginname'] = 'OneNote feedback'; $string['privacy:metadata:assignmentid'] = 'Assignment identifier'; $string['privacy:metadata:gradepurpose'] = 'The grade ID associated with the record'; $string['privacy:metadata:numfiles'] = 'Number of files'; $string['privacy:metadata:tablepurpose'] = 'Stores the number of files used for the feedback.'; +$string['privacy:path'] = 'Number of files'; +$string['signinhelp1'] = 'Click on the button above to sign in to OneNote so you can add your feedback to the student\'s submission there.'; +$string['signinhelp2'] = 'Click on the button above to sign in to OneNote if you want to view the feedback there.'; +$string['viewfeedback'] = 'View feedback'; diff --git a/mod/assign/feedback/onenote/lang/es/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/es/assignfeedback_onenote.php index 8596ac8e6..c611477a8 100644 --- a/mod/assign/feedback/onenote/lang/es/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/es/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Agregar retroalimentación'; +$string['addfeedbackhelp'] = 'Haga clic en el botón de arriba para agregar sus comentarios para la entrega del alumno en OneNote. Puede volver aquí más tarde para guardar su trabajo en Moodle.'; $string['configmaxbytes'] = 'Tamaño máximo de OneNote'; $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Habilitado por defecto'; $string['default_help'] = 'Si se ajusta esta opción, este método de retroalimentación se habilitará por defecto para todas las tareas nuevas.'; $string['enabled'] = 'Comentario de OneNote'; $string['enabled_help'] = 'Si está habilitado, el profesor podrá cargar páginas de OneNote con comentarios cuando marque las tareas. Los profesores pueden optar por anotar en la entrega de OneNote del alumno o cargar una página de OneNote completamente nueva.'; -$string['onenote'] = 'OneNote de retroalimentación'; +$string['feedbackdownloadfailed'] = 'No se pudieron descargar los comentarios desde OneNote. Vuelva a intentarlo.'; +$string['feedbacklimitexceed'] = 'El tamaño de sus comentarios excede el límite aceptable.'; +$string['feedbacknotstarted'] = 'Agregue sus comentarios utilizando OneNote y guarde los cambios.'; $string['filesadded'] = 'OneNote de retroalimentación agregados: {$a}'; $string['maxbytes'] = 'Tamaño de paquete máximo de OneNote'; $string['maxfiles'] = 'Número máximo de OneNote cargados'; $string['maximumsize'] = 'Tamaño de paquete máximo de OneNote'; $string['moreusers'] = '{$a} más...'; $string['nochanges'] = 'Sin cambios'; +$string['notsignedin'] = 'Inicie sesión en OneNote antes de intentar guardar los cambios.'; +$string['onenote'] = 'OneNote de retroalimentación'; $string['pluginname'] = 'Comentario de OneNote'; -$string['addfeedback'] = 'Agregar retroalimentación'; -$string['addfeedbackhelp'] = 'Haga clic en el botón de arriba para agregar sus comentarios para la entrega del alumno en OneNote. Puede volver aquí más tarde para guardar su trabajo en Moodle.'; $string['signinhelp1'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote para agregar sus comentarios en la entrega del estudiante desde allí.'; $string['signinhelp2'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote si desea ver los comentarios allí.'; $string['viewfeedback'] = 'Ver retroalimentación'; -$string['feedbackdownloadfailed'] = 'No se pudieron descargar los comentarios desde OneNote. Vuelva a intentarlo.'; -$string['notsignedin'] = 'Inicie sesión en OneNote antes de intentar guardar los cambios.'; -$string['feedbacknotstarted'] = 'Agregue sus comentarios utilizando OneNote y guarde los cambios.'; -$string['feedbacklimitexceed'] = 'El tamaño de sus comentarios excede el límite aceptable.'; diff --git a/mod/assign/feedback/onenote/lang/fi/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/fi/assignfeedback_onenote.php index b39ccb37b..8e9885fed 100644 --- a/mod/assign/feedback/onenote/lang/fi/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/fi/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Lisää palaute'; +$string['addfeedbackhelp'] = 'Lisää palaute opiskelijan palautukseen OneNote napsauttamalla yllä olevaa painiketta. Voit palata tähän myöhemmin ja tallentaa työn uudelleen Moodleen.'; $string['configmaxbytes'] = 'OneNoten enimmäiskoko'; $string['countfiles'] = 'OneNote-tiedostot: {$a}'; $string['default'] = 'Käytössä oletuksena'; $string['default_help'] = 'Jos asetus on käytössä, tämä palautetapa on oletusarvoisesti käytössä kaikissa uusissa tehtävissä.'; $string['enabled'] = 'OneNote-palaute'; $string['enabled_help'] = 'Jos asetus on käytössä, opettaja voi ladata palautetta sisältäviä OneNote-sivuja tehtävien arvioinnin yhteydessä. Opettajat voivat halutessaan merkitä palautteen opiskelijan OneNote-palautukseen tai täysin uudelle OneNote-sivulle.'; -$string['onenote'] = 'OneNote-palautteet'; +$string['feedbackdownloadfailed'] = 'Palautetta ei voitu ladata OneNote. Yritä uudelleen.'; +$string['feedbacklimitexceed'] = 'Palautteen koko ylittää määritetyn rajan.'; +$string['feedbacknotstarted'] = 'Lisää palaute OneNote ja tallenna sitten muutokset.'; $string['filesadded'] = 'OneNote-palautteet lisätty: {$a}'; $string['maxbytes'] = 'OneNote-paketin enimmäiskoko'; $string['maxfiles'] = 'Ladattavien OneNote-tiedostojen enimmäismäärä'; $string['maximumsize'] = 'OneNote-paketin enimmäiskoko'; $string['moreusers'] = '{$a} muuta...'; $string['nochanges'] = 'Ei muutoksia'; +$string['notsignedin'] = 'Kirjaudu OneNoteen, ennen kuin yrität tallentaa muutokset.'; +$string['onenote'] = 'OneNote-palautteet'; $string['pluginname'] = 'OneNote-palaute'; -$string['addfeedback'] = 'Lisää palaute'; -$string['addfeedbackhelp'] = 'Lisää palaute opiskelijan palautukseen OneNote napsauttamalla yllä olevaa painiketta. Voit palata tähän myöhemmin ja tallentaa työn uudelleen Moodleen.'; $string['signinhelp1'] = 'Kirjaudu OneNoteen yllä olevan painikkeen kautta, jotta voit lisätä palautteen opiskelijan palautukseen.'; $string['signinhelp2'] = 'Kirjaudu OneNoteen yllä olevan painikkeen kautta, jos haluat tarkistella palautetta siellä.'; $string['viewfeedback'] = 'Näytä palaute'; -$string['feedbackdownloadfailed'] = 'Palautetta ei voitu ladata OneNote. Yritä uudelleen.'; -$string['notsignedin'] = 'Kirjaudu OneNoteen, ennen kuin yrität tallentaa muutokset.'; -$string['feedbacknotstarted'] = 'Lisää palaute OneNote ja tallenna sitten muutokset.'; -$string['feedbacklimitexceed'] = 'Palautteen koko ylittää määritetyn rajan.'; diff --git a/mod/assign/feedback/onenote/lang/fr/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/fr/assignfeedback_onenote.php index 5696043cb..57f9a735f 100644 --- a/mod/assign/feedback/onenote/lang/fr/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/fr/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Ajouter feed-back'; +$string['addfeedbackhelp'] = 'Cliquez sur le bouton ci-dessus pour ajouter votre feed-back pour la remise de travaux de l\'étudiant dans OneNote. Vous pouvez revenir sur cette page ultérieurement pour enregistrer votre travail dans Moodle.'; $string['configmaxbytes'] = 'Taille maximale de OneNote'; -$string['countfiles'] = 'Pages OneNote : {$a}'; +$string['countfiles'] = 'Pages OneNote: {$a}'; $string['default'] = 'Activé par défaut'; $string['default_help'] = 'Si ce réglage est activé, cette méthode de feed-back sera activée par défaut pour tous les nouveaux devoirs.'; $string['enabled'] = 'Feed-back OneNote'; $string['enabled_help'] = 'Si ce réglage est activé, l\'enseignant pourra télécharger des pages OneNote avec un feed-back lors de l\'évaluation des devoirs. Les enseignants peuvent choisir d\'annoter la remise de travaux OneNote de l\'étudiant et de télécharger une toute nouvelle page OneNote.'; -$string['onenote'] = 'Fichiers OneNote de feed-back'; +$string['feedbackdownloadfailed'] = 'Impossible de télécharger le feed-back depuis OneNote. Veuillez réessayer.'; +$string['feedbacklimitexceed'] = 'La taille de votre feed-back dépasse la limite acceptable.'; +$string['feedbacknotstarted'] = 'Ajoutez votre feed-back à l\'aide de OneNote, puis enregistrez vos modifications.'; $string['filesadded'] = 'Fichiers OneNote de feed-back ajoutés : {$a}'; $string['maxbytes'] = 'Taille maximale du paquet OneNote'; $string['maxfiles'] = 'Nombre maximal de fichiers OneNote téléchargés'; $string['maximumsize'] = 'Taille maximale du paquet OneNote'; $string['moreusers'] = '{$a} de plus...'; $string['nochanges'] = 'Aucune modification'; +$string['notsignedin'] = 'Inscrivez-vous à OneNote avant d\'essayer d\'enregistrer vos modifications.'; +$string['onenote'] = 'Fichiers OneNote de feed-back'; $string['pluginname'] = 'Feed-back OneNote'; -$string['addfeedback'] = 'Ajouter feed-back'; -$string['addfeedbackhelp'] = 'Cliquez sur le bouton ci-dessus pour ajouter votre feed-back pour la remise de travaux de l\'étudiant dans OneNote. Vous pouvez revenir sur cette page ultérieurement pour enregistrer votre travail dans Moodle.'; $string['signinhelp1'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire sur OneNote de façon à ajouter votre feed-back dans la remise de travaux de l\'étudiant.'; $string['signinhelp2'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire sur OneNote si vous souhaitez y afficher le feed-back.'; $string['viewfeedback'] = 'Afficher le feed-back'; -$string['feedbackdownloadfailed'] = 'Impossible de télécharger le feed-back depuis OneNote. Veuillez réessayer.'; -$string['notsignedin'] = 'Inscrivez-vous à OneNote avant d\'essayer d\'enregistrer vos modifications.'; -$string['feedbacknotstarted'] = 'Ajoutez votre feed-back à l\'aide de OneNote, puis enregistrez vos modifications.'; -$string['feedbacklimitexceed'] = 'La taille de votre feed-back dépasse la limite acceptable.'; diff --git a/mod/assign/feedback/onenote/lang/it/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/it/assignfeedback_onenote.php index 968057132..bb3eeafde 100644 --- a/mod/assign/feedback/onenote/lang/it/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/it/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Aggiungi feedback'; +$string['addfeedbackhelp'] = 'Fai clic sul pulsante precedente per aggiungere il tuo feedback per il compito dello studente in OneNote. Puoi tornare qui in seguito per salvare nuovamente il lavoro in Moodle.'; $string['configmaxbytes'] = 'Dimensione massima OneNote'; $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Abilitato per default'; $string['default_help'] = 'Se impostato, questo metodo di feedback sarà abilitato per default per tutti i nuovi compiti.'; $string['enabled'] = 'Feedback OneNote'; $string['enabled_help'] = 'Il docente sarà in grado di caricare pagine OneNote con feedback durante la valutazione dei compiti. I docenti possono scegliere di annotare il compito OneNote dello studente o caricare una pagina OneNote completamente nuova.'; -$string['onenote'] = 'Blocchi note OneNote di feedback'; +$string['feedbackdownloadfailed'] = 'Impossibile scaricare il feedback da OneNote. Riprova.'; +$string['feedbacklimitexceed'] = 'La dimensione del feedback supera il limite accettabile.'; +$string['feedbacknotstarted'] = 'Aggiungere il feedback utilizzando OneNote, quindi salvare le modifiche.'; $string['filesadded'] = 'Blocchi note OneNote di feedback aggiunti: {$a}'; $string['maxbytes'] = 'Dimensione massima del pacchetto OneNote'; $string['maxfiles'] = 'Numero massimo di blocchi note OneNote'; $string['maximumsize'] = 'Dimensione massima del pacchetto OneNote'; $string['moreusers'] = '{$a} ulteriori...'; $string['nochanges'] = 'Nessuna modifica'; +$string['notsignedin'] = 'Accedere a OneNote prima di provare a salvare le modifiche.'; +$string['onenote'] = 'Blocchi note OneNote di feedback'; $string['pluginname'] = 'Feedback OneNote'; -$string['addfeedback'] = 'Aggiungi feedback'; -$string['addfeedbackhelp'] = 'Fai clic sul pulsante precedente per aggiungere il tuo feedback per il compito dello studente in OneNote. Puoi tornare qui in seguito per salvare nuovamente il lavoro in Moodle.'; $string['signinhelp1'] = 'Fai clic sul pulsante precedente per accedere a OneNote e aggiungere lì il tuo feedback al compito dello studente.'; $string['signinhelp2'] = 'Faci clic sul pulsante precedente per accedere a OneNote se desideri visualizzare lì il feedback.'; $string['viewfeedback'] = 'Visualizza feedback'; -$string['feedbackdownloadfailed'] = 'Impossibile scaricare il feedback da OneNote. Riprova.'; -$string['notsignedin'] = 'Accedere a OneNote prima di provare a salvare le modifiche.'; -$string['feedbacknotstarted'] = 'Aggiungere il feedback utilizzando OneNote, quindi salvare le modifiche.'; -$string['feedbacklimitexceed'] = 'La dimensione del feedback supera il limite accettabile.'; diff --git a/mod/assign/feedback/onenote/lang/ja/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/ja/assignfeedback_onenote.php index 49b02f32d..3604d14e8 100644 --- a/mod/assign/feedback/onenote/lang/ja/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/ja/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'フィードバックを追加する'; +$string['addfeedbackhelp'] = '学生のOneNoteの提出にフィードバックを追加するには、上のボタンをクリックします。Moodleに作業内容を保存するために、いつでもここに戻ることができます。'; $string['configmaxbytes'] = 'OneNoteの最大サイズ'; $string['countfiles'] = 'OneNote : {$a}'; $string['default'] = 'デフォルトで有効にする'; $string['default_help'] = '設定した場合、すべての新しい課題において、このフィードバック方法がデフォルトで有効になります。'; $string['enabled'] = 'OneNoteフィードバック'; $string['enabled_help'] = '有効にした場合、教師は課題の採点時にOneNoteページにフィードバックを付けてアップロードできるようになります。教師は学生のOneNote提出物にコメントを追加するか、完全に新しいOneNoteページをアップロードするか選択できます。'; -$string['onenote'] = 'フィードバックOneNote'; +$string['feedbackdownloadfailed'] = 'OneNoteからフィードバックをダウンロードできませんでした。もう一度お試しください。'; +$string['feedbacklimitexceed'] = 'フィードバックのサイズが上限を超えています。'; +$string['feedbacknotstarted'] = 'OneNoteを使用してフィードバックを追加してから、変更を保存してください。'; $string['filesadded'] = 'フィードバックOneNoteが追加されました : {$a}'; $string['maxbytes'] = 'OneNote最大パッケージサイズ'; $string['maxfiles'] = 'OneNote最大アップロード数'; $string['maximumsize'] = 'OneNote最大パッケージサイズ'; $string['moreusers'] = 'さらに {$a} 名 ...'; $string['nochanges'] = '変更なし'; +$string['notsignedin'] = '変更を保存する前に、OneNoteにサインインしてください。'; +$string['onenote'] = 'フィードバックOneNote'; $string['pluginname'] = 'OneNoteフィードバック'; -$string['addfeedback'] = 'フィードバックを追加する'; -$string['addfeedbackhelp'] = '学生のOneNoteの提出にフィードバックを追加するには、上のボタンをクリックします。Moodleに作業内容を保存するために、いつでもここに戻ることができます。'; $string['signinhelp1'] = '上のボタンをクリックしてOneNoteにサインインしてください。これにより、学生の提出にフィードバックを追加できます。'; $string['signinhelp2'] = 'OneNoteのフィードバックを表示するには、上のボタンをクリックしてOneNoteにサインインしてください。'; $string['viewfeedback'] = 'フィードバックを表示する'; -$string['feedbackdownloadfailed'] = 'OneNoteからフィードバックをダウンロードできませんでした。もう一度お試しください。'; -$string['notsignedin'] = '変更を保存する前に、OneNoteにサインインしてください。'; -$string['feedbacknotstarted'] = 'OneNoteを使用してフィードバックを追加してから、変更を保存してください。'; -$string['feedbacklimitexceed'] = 'フィードバックのサイズが上限を超えています。'; diff --git a/mod/assign/feedback/onenote/lang/nl/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/nl/assignfeedback_onenote.php index 2dac04026..e06efca78 100644 --- a/mod/assign/feedback/onenote/lang/nl/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/nl/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Feedback toevoegen'; +$string['addfeedbackhelp'] = 'Klik op de knop hierboven als je in OneNote je feedback wilt toevoegen voor de inzending van de student. Je kunt hier later terugkomen om je weer weer op te slaan in Moodle.'; $string['configmaxbytes'] = 'Maximum OneNote-formaat'; $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Standaard ingeschakeld'; $string['default_help'] = 'Als deze optie is ingeschakeld, is deze feedbackmethode standaard ingeschakeld voor alle nieuwe opdrachten.'; $string['enabled'] = 'OneNote-feedback'; $string['enabled_help'] = 'Als deze optie is ingeschakeld, kan de leraar OneNote-pagina\'s met feedback uploaden tijdens de beoordeling van de opdrachten. Leraren kunnen de OneNote-inzending van een student van aantekeningen voorzien of een geheel nieuwe OneNote-pagina uploaden.'; -$string['onenote'] = 'Feedback-OneNote'; +$string['feedbackdownloadfailed'] = 'Kan de feedback vanuit OneNote niet downloaden. Probeer het nog eens.'; +$string['feedbacklimitexceed'] = 'Je feedback overschrijdt de geaccepteerde limiet.'; +$string['feedbacknotstarted'] = 'Voeg je feedback toe met OneNote en sla daarna je wijzigingen op.'; $string['filesadded'] = 'Feedback-OneNote toegevoegd: {$a}'; $string['maxbytes'] = 'Maximale grootte OneNote-pakket'; $string['maxfiles'] = 'Maximaal aantal geüploade OneNote'; $string['maximumsize'] = 'Maximale grootte OneNote-pakket'; $string['moreusers'] = '{$a} meer ...'; $string['nochanges'] = 'Geen wijzigingen'; +$string['notsignedin'] = 'Meld je aan bij OneNote voordat je probeert je wijzigingen op te slaan.'; +$string['onenote'] = 'Feedback-OneNote'; $string['pluginname'] = 'OneNote-feedback'; -$string['addfeedback'] = 'Feedback toevoegen'; -$string['addfeedbackhelp'] = 'Klik op de knop hierboven als je in OneNote je feedback wilt toevoegen voor de inzending van de student. Je kunt hier later terugkomen om je weer weer op te slaan in Moodle.'; $string['signinhelp1'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote zodat je daar je feedback kunt toevoegen aan de inzending van de student.'; $string['signinhelp2'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote en daar de feedback wilt bekijken.'; $string['viewfeedback'] = 'Feedback bekijken'; -$string['feedbackdownloadfailed'] = 'Kan de feedback vanuit OneNote niet downloaden. Probeer het nog eens.'; -$string['notsignedin'] = 'Meld je aan bij OneNote voordat je probeert je wijzigingen op te slaan.'; -$string['feedbacknotstarted'] = 'Voeg je feedback toe met OneNote en sla daarna je wijzigingen op.'; -$string['feedbacklimitexceed'] = 'Je feedback overschrijdt de geaccepteerde limiet.'; diff --git a/mod/assign/feedback/onenote/lang/pl/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/pl/assignfeedback_onenote.php index 2959d6f5f..08f348d99 100644 --- a/mod/assign/feedback/onenote/lang/pl/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/pl/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Dodaj informację zwrotną'; +$string['addfeedbackhelp'] = 'Kliknij przycisk powyżej, aby dodać informację zwrotną do pracy przesłanej przez studenta w programie OneNote. Możesz powrócić do tej strony później, aby zapisać swoją prace w platformie Moodle.'; $string['configmaxbytes'] = 'Maksymalny rozmiar strony programu OneNote'; $string['countfiles'] = 'Notatki w programie OneNote: {$a}'; $string['default'] = 'Domyślnie włączone'; $string['default_help'] = 'Jeśli opcja jest włączona, ta metoda wysyłania informacji zwrotnej będzie włączona domyślnie dla wszystkich nowych zadań.'; $string['enabled'] = 'Informacje zwrotne w programie OneNote'; $string['enabled_help'] = 'Jeżeli opcja jest włączona, nauczyciel będzie mógł przesyłać strony programu OneNote z informacją zwrotną podczas oceniania zadań. Nauczyciele mogą dodawać uwagi na pracach przesłanych przez studentów w programie OneNote lub załadować zupełnie nową stronę programu OneNote.'; -$string['onenote'] = 'Informacje zwrotne w programie OneNote'; +$string['feedbackdownloadfailed'] = 'Nie udało się pobrać informacji zwrotnej z programu OneNote. Spróbuj ponownie.'; +$string['feedbacklimitexceed'] = 'Rozmiar informacji zwrotnej przekracza dopuszczalny limit.'; +$string['feedbacknotstarted'] = 'Dodaj informację zwrotną przy użyciu programu OneNote, a następnie zapisz zmiany.'; $string['filesadded'] = 'Dodane informacje zwrotne w programie OneNote:{$a}'; $string['maxbytes'] = 'Maksymalny rozmiar paczki programu OneNote'; $string['maxfiles'] = 'Maksymalna liczba przesłanych stron programu OneNote'; $string['maximumsize'] = 'Maksymalny rozmiar paczki programu OneNote'; $string['moreusers'] = '{$a} więcej...'; $string['nochanges'] = 'Bez zmian'; +$string['notsignedin'] = 'Zaloguj się do programu OneNote przed zapisaniem zmian.'; +$string['onenote'] = 'Informacje zwrotne w programie OneNote'; $string['pluginname'] = 'Informacje zwrotne w programie OneNote'; -$string['addfeedback'] = 'Dodaj informację zwrotną'; -$string['addfeedbackhelp'] = 'Kliknij przycisk powyżej, aby dodać informację zwrotną do pracy przesłanej przez studenta w programie OneNote. Możesz powrócić do tej strony później, aby zapisać swoją prace w platformie Moodle.'; $string['signinhelp1'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote i dodać w nim informację zwrotną do pracy przesłanej przez studenta.'; $string['signinhelp2'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote i wyświetlić w nim informację zwrotną.'; $string['viewfeedback'] = 'Wyświetl informację zwrotną'; -$string['feedbackdownloadfailed'] = 'Nie udało się pobrać informacji zwrotnej z programu OneNote. Spróbuj ponownie.'; -$string['notsignedin'] = 'Zaloguj się do programu OneNote przed zapisaniem zmian.'; -$string['feedbacknotstarted'] = 'Dodaj informację zwrotną przy użyciu programu OneNote, a następnie zapisz zmiany.'; -$string['feedbacklimitexceed'] = 'Rozmiar informacji zwrotnej przekracza dopuszczalny limit.'; diff --git a/mod/assign/feedback/onenote/lang/pt_br/assignfeedback_onenote.php b/mod/assign/feedback/onenote/lang/pt_br/assignfeedback_onenote.php index f21baa7ee..004d84bae 100644 --- a/mod/assign/feedback/onenote/lang/pt_br/assignfeedback_onenote.php +++ b/mod/assign/feedback/onenote/lang/pt_br/assignfeedback_onenote.php @@ -24,26 +24,26 @@ defined('MOODLE_INTERNAL') || die(); +$string['addfeedback'] = 'Adicionar feedback'; +$string['addfeedbackhelp'] = 'Clique no botão acima para adicionar seu feedback referente ao envio do aluno no OneNote. Você pode voltar aqui posteriormente para salvar seu trabalho de volta no Moodle.'; $string['configmaxbytes'] = 'Tamanho máximo do OneNote'; $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Ativado por padrão'; $string['default_help'] = 'Quando definido, esse método de feedback é ativado por padrão para todas as novas tarefas.'; $string['enabled'] = 'Feedback no OneNote'; $string['enabled_help'] = 'Se essa configuração estiver ativada, o professor poderá fazer o upload de páginas do OneNote com feedback ao corrigir suas tarefas. Os professores podem optar por fazer anotações no envio do aluno no OneNote ou fazer o upload de uma página totalmente nova do OneNote.'; -$string['onenote'] = 'OneNote de feedback'; +$string['feedbackdownloadfailed'] = 'Não foi possível fazer o download do feedback do OneNote. Tente novamente.'; +$string['feedbacklimitexceed'] = 'O tamanho do feedback ultrapassa o limite máximo.'; +$string['feedbacknotstarted'] = 'Adicione seu feedback usando o OneNote e depois salve suas alterações.'; $string['filesadded'] = 'OneNote de feedback adicionados: {$a}'; $string['maxbytes'] = 'Tamanho máximo de pacote do OneNote'; $string['maxfiles'] = 'Número máximo de uploads de OneNote'; $string['maximumsize'] = 'Tamanho máximo de pacote do OneNote'; $string['moreusers'] = 'Mais {$a}...'; $string['nochanges'] = 'Nenhuma alteração'; +$string['notsignedin'] = 'Faça login no OneNote antes de tentar salvar suas alterações.'; +$string['onenote'] = 'OneNote de feedback'; $string['pluginname'] = 'Feedback no OneNote'; -$string['addfeedback'] = 'Adicionar feedback'; -$string['addfeedbackhelp'] = 'Clique no botão acima para adicionar seu feedback referente ao envio do aluno no OneNote. Você pode voltar aqui posteriormente para salvar seu trabalho de volta no Moodle.'; $string['signinhelp1'] = 'Clique no botão acima para fazer login no OneNote e poder adicionar nele seu feedback referente ao envio do aluno.'; $string['signinhelp2'] = 'Clique no botão acima para fazer login no OneNote caso queira visualizar o feedback nele.'; $string['viewfeedback'] = 'Visualizar feedback'; -$string['feedbackdownloadfailed'] = 'Não foi possível fazer o download do feedback do OneNote. Tente novamente.'; -$string['notsignedin'] = 'Faça login no OneNote antes de tentar salvar suas alterações.'; -$string['feedbacknotstarted'] = 'Adicione seu feedback usando o OneNote e depois salve suas alterações.'; -$string['feedbacklimitexceed'] = 'O tamanho do feedback ultrapassa o limite máximo.'; diff --git a/mod/assign/feedback/onenote/lib.php b/mod/assign/feedback/onenote/lib.php index 39b93d575..29ddc163a 100644 --- a/mod/assign/feedback/onenote/lib.php +++ b/mod/assign/feedback/onenote/lib.php @@ -23,8 +23,6 @@ * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); - /** * Serves assignment feedback and other files. * @@ -57,7 +55,7 @@ function assignfeedback_onenote_pluginfile($course, $cm, context $context, $file } // Check is users feedback or has grading permission. - if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) { + if ($USER->id != $userid && !has_capability('mod/assign:grade', $context)) { return false; } @@ -66,7 +64,8 @@ function assignfeedback_onenote_pluginfile($course, $cm, context $context, $file $fullpath = "/{$context->id}/assignfeedback_onenote/$filearea/$itemid/$relativepath"; $fs = get_file_storage(); - if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { + $file = $fs->get_file_by_hash(sha1($fullpath)); + if (!$file || $file->is_directory()) { return false; } // Download MUST be forced - security! diff --git a/mod/assign/feedback/onenote/locallib.php b/mod/assign/feedback/onenote/locallib.php index 3a027d8fe..bf1ee2d20 100644 --- a/mod/assign/feedback/onenote/locallib.php +++ b/mod/assign/feedback/onenote/locallib.php @@ -25,8 +25,6 @@ use local_onenote\api\base; -defined('MOODLE_INTERNAL') || die(); - /** * Library class for ONENOTE feedback plugin extending feedback plugin base class. * @@ -91,7 +89,7 @@ private function copy_area_files(file_storage $fs, $fromcontextid, $fromcomponen if ($files = $fs->get_area_files($fromcontextid, $fromcomponent, $fromfilearea, $fromitemid)) { foreach ($files as $file) { - if ($file->is_directory() and $file->get_filepath() === '/') { + if ($file->is_directory() && $file->get_filepath() === '/') { // We need a way to mark the age of each draft area. // By not copying the root dir we force it to be created // automatically with current timestamp. diff --git a/mod/assign/feedback/onenote/tests/privacy/provider_test.php b/mod/assign/feedback/onenote/tests/privacy/provider_test.php index 9fca397d3..71bd0f223 100644 --- a/mod/assign/feedback/onenote/tests/privacy/provider_test.php +++ b/mod/assign/feedback/onenote/tests/privacy/provider_test.php @@ -1,5 +1,4 @@ assertNotEmpty($collection); @@ -87,8 +89,10 @@ public function test_get_metadata() { /** * Test that feedback comments are exported for a user. + * + * @covers \assignfeedback_onenote\privacy\provider::export_feedback_user_data */ - public function test_export_feedback_user_data() { + public function test_export_feedback_user_data(): void { $this->resetAfterTest(); // Create course, assignment, submission, and then a feedback onenote. @@ -134,8 +138,10 @@ public function test_export_feedback_user_data() { /** * Test that all feedback is deleted for a context. + * + * @covers \assignfeedback_onenote\privacy\provider::delete_feedback_for_context */ - public function test_delete_feedback_for_context() { + public function test_delete_feedback_for_context(): void { $this->resetAfterTest(); // Create course, assignment, submission, and then a feedback onenote. $course = $this->getDataGenerator()->create_course(); @@ -182,8 +188,10 @@ public function test_delete_feedback_for_context() { /** * Test that a grade item is deleted for a user. + * + * @covers \assignfeedback_onenote\privacy\provider::delete_feedback_for_grade */ - public function test_delete_feedback_for_grade() { + public function test_delete_feedback_for_grade(): void { $this->resetAfterTest(); // Create course, assignment, submission, and then a feedback onenote. $course = $this->getDataGenerator()->create_course(); @@ -239,8 +247,10 @@ public function test_delete_feedback_for_grade() { /** * Test that a grade item is deleted for a user. + * + * @covers \assignfeedback_onenote\privacy\provider::delete_feedback_for_grades */ - public function test_delete_feedback_for_grades() { + public function test_delete_feedback_for_grades(): void { $this->resetAfterTest(); // Create course, assignment, submission, and then a feedback onenote. $course = $this->getDataGenerator()->create_course(); diff --git a/mod/assign/submission/onenote/backup/moodle2/backup_assignsubmission_onenote_subplugin.class.php b/mod/assign/submission/onenote/backup/moodle2/backup_assignsubmission_onenote_subplugin.class.php index d50a53ec3..b2b187d1c 100644 --- a/mod/assign/submission/onenote/backup/moodle2/backup_assignsubmission_onenote_subplugin.class.php +++ b/mod/assign/submission/onenote/backup/moodle2/backup_assignsubmission_onenote_subplugin.class.php @@ -23,8 +23,6 @@ * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); - /** * Provides the information to backup submission files * This just adds its filearea to the annotations and records the number of files diff --git a/mod/assign/submission/onenote/classes/event/assessable_uploaded.php b/mod/assign/submission/onenote/classes/event/assessable_uploaded.php index 39181c7b5..9df8d8694 100644 --- a/mod/assign/submission/onenote/classes/event/assessable_uploaded.php +++ b/mod/assign/submission/onenote/classes/event/assessable_uploaded.php @@ -27,8 +27,6 @@ use stdClass; -defined('MOODLE_INTERNAL') || die(); - /** * The assignsubmission_onenote assessable uploaded event class. * diff --git a/mod/assign/submission/onenote/classes/event/submission_created.php b/mod/assign/submission/onenote/classes/event/submission_created.php index e1ffe3305..dee48d627 100644 --- a/mod/assign/submission/onenote/classes/event/submission_created.php +++ b/mod/assign/submission/onenote/classes/event/submission_created.php @@ -27,8 +27,6 @@ use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * The assignsubmission_onenote submission_created event class. * diff --git a/mod/assign/submission/onenote/classes/event/submission_updated.php b/mod/assign/submission/onenote/classes/event/submission_updated.php index d8e04d7be..47e8f9d15 100644 --- a/mod/assign/submission/onenote/classes/event/submission_updated.php +++ b/mod/assign/submission/onenote/classes/event/submission_updated.php @@ -27,8 +27,6 @@ use moodle_exception; -defined('MOODLE_INTERNAL') || die(); - /** * The assignsubmission_onenote submission_updated event class. * diff --git a/mod/assign/submission/onenote/classes/privacy/provider.php b/mod/assign/submission/onenote/classes/privacy/provider.php index c14ddabc4..74a5036a2 100644 --- a/mod/assign/submission/onenote/classes/privacy/provider.php +++ b/mod/assign/submission/onenote/classes/privacy/provider.php @@ -29,13 +29,13 @@ require_once($CFG->dirroot . '/mod/assign/locallib.php'); -use \core_privacy\local\metadata\collection; -use \core_privacy\local\metadata\provider as metadataprovider; +use core_privacy\local\metadata\collection; +use core_privacy\local\metadata\provider as metadataprovider; use core_privacy\local\request\userlist; -use \core_privacy\local\request\writer; -use \core_privacy\local\request\contextlist; +use core_privacy\local\request\writer; +use core_privacy\local\request\contextlist; use local_onenote\api\base; -use \mod_assign\privacy\assign_plugin_request_data; +use mod_assign\privacy\assign_plugin_request_data; use mod_assign\privacy\assignsubmission_provider; use mod_assign\privacy\assignsubmission_user_provider; use mod_assign\privacy\useridlist; @@ -57,11 +57,11 @@ class provider implements * @param collection $collection A list of information to add to. * @return collection Return the collection after adding to it. */ - public static function get_metadata(collection $collection) : collection { + public static function get_metadata(collection $collection): collection { $detail = [ 'assignment' => 'privacy:metadata:assignmentid', 'submission' => 'privacy:metadata:submissionpurpose', - 'numfiles' => 'privacy:metadata:numfiles' + 'numfiles' => 'privacy:metadata:numfiles', ]; $collection->add_database_table('assignsubmission_onenote', $detail, 'privacy:metadata:tablepurpose'); return $collection; diff --git a/mod/assign/submission/onenote/lang/cs/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/cs/assignsubmission_onenote.php index 1de702e4d..235e3349b 100644 --- a/mod/assign/submission/onenote/lang/cs/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/cs/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Příspěvky ve formě OneNote'; $string['enabled_help'] = 'Je-li povoleno, studenti mohou jako svůj příspěvek nahrát jednu či více stránek OneNote.'; $string['eventassessableuploaded'] = 'Byla nahrána stránka OneNote.'; -$string['onenote'] = 'Příspěvky ve formě OneNote'; $string['maxbytes'] = 'Maximální velikost stránky OneNote'; $string['maxfilessubmission'] = 'Maximální počet nahraných stránek OneNote'; $string['maxfilessubmission_help'] = 'Jsou-li povoleny příspěvky ve formě OneNote, každý student může jako svůj příspěvek nahrát maximálně tento počet stránek OneNote.'; $string['maximumsubmissionsize'] = 'Velikost stránky OneNote'; $string['maximumsubmissionsize_help'] = 'Nastavuje maximální velikost příspěvku stránek OneNote.'; +$string['notsignedin'] = 'Před pokusem o uložení změn se nejprve přihlaste do OneNote.'; +$string['onenote'] = 'Příspěvky ve formě OneNote'; +$string['onenoteactions'] = 'Akce OneNote: '; $string['pluginname'] = 'Příspěvky ve formě OneNote'; +$string['signinhelp1'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, pokud chcete na příspěvku pracovat tam.'; +$string['signinhelp2'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, pokud chcete příspěvek zobrazit tam.'; $string['siteuploadlimit'] = 'Limit pro nahrávání na těchto stránkách'; +$string['submissiondownloadfailed'] = 'Nelze stáhnout váš příspěvek z OneNote. Zkuste to znovu.'; $string['submissionfilearea'] = 'Nahrané stránky OneNote příspěvku'; -$string['onenoteactions'] = 'Akce OneNote: '; +$string['submissionlimitexceed'] = 'Váš příspěvek překračuje povolený limit velikosti.'; +$string['submissionnotstarted'] = 'Pracujte na úkolu ve OneNote a potom uložte změny.'; +$string['viewsubmission'] = 'Zobrazit příspěvek'; $string['workonthis'] = 'Pracovat na tomto'; $string['workonthishelp'] = 'Kliknutím na tlačítko výše začnete na úkolu pracovat ve OneNote. Pamatujte, že je třeba se vrátit na tuto stránku, abyste svou práci uložili zpět do Moodlu.'; -$string['signinhelp'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, abyste mohli na úkolu pracovat tam.'; -$string['submissiondownloadfailed'] = 'Nelze stáhnout váš příspěvek z OneNote. Zkuste to znovu.'; -$string['notsignedin'] = 'Před pokusem o uložení změn se nejprve přihlaste do OneNote.'; -$string['viewsubmission'] = 'Zobrazit příspěvek'; -$string['signinhelp1'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, pokud chcete na příspěvku pracovat tam.'; -$string['signinhelp2'] = 'Kliknutím na tlačítko výše se přihlásíte do OneNote, pokud chcete příspěvek zobrazit tam.'; -$string['submissionnotstarted'] = 'Pracujte na úkolu ve OneNote a potom uložte změny.'; -$string['submissionlimitexceed'] = 'Váš příspěvek překračuje povolený limit velikosti.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Počet stránek OneNote: {$a}'; diff --git a/mod/assign/submission/onenote/lang/de/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/de/assignsubmission_onenote.php index 3ab01461b..b59bec7f5 100644 --- a/mod/assign/submission/onenote/lang/de/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/de/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Abgabe von OneNote-Seiten'; $string['enabled_help'] = 'Teilnehmer/innen können eine oder mehrere OneNote-Seiten als Lösung der Aufgabe einreichen, wenn dies aktiviert wird.'; $string['eventassessableuploaded'] = 'Eine OneNote-Seite wurde hochgeladen.'; -$string['onenote'] = 'Abgabe von OneNote-Seiten'; $string['maxbytes'] = 'Maximale OneNote-Seitengröße'; $string['maxfilessubmission'] = 'Maximale Anzahl hochgeladener OneNote-Seiten'; $string['maxfilessubmission_help'] = 'Wenn die Abgabe von OneNote-Seiten als Lösung der Aufgabe gewählt wird, wird hier festgelegt, wie viele OneNote-Seiten je Teilnehmer/in hochgeladen werden können.'; $string['maximumsubmissionsize'] = 'OneNote-Seitengröße'; $string['maximumsubmissionsize_help'] = 'Legt die maximale Anzahl von OneNote-Seiten für die Abgabe fest.'; +$string['notsignedin'] = 'Melden Sie sich bei OneNote an, bevor Sie versuchen, Ihre Änderungen zu speichern.'; +$string['onenote'] = 'Abgabe von OneNote-Seiten'; +$string['onenoteactions'] = 'OneNote-Aktionen: '; $string['pluginname'] = 'Abgabe von OneNote-Seiten'; +$string['signinhelp1'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden, wenn Sie dort an Ihrer abgegebenen Aufgabe arbeiten möchten.'; +$string['signinhelp2'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden, wenn Sie die abgegebene Aufgabe dort anzeigen möchten.'; $string['siteuploadlimit'] = 'Uploadlimit der Website'; +$string['submissiondownloadfailed'] = 'Ihre Abgabe konnte nicht von OneNote heruntergeladen werden. Versuchen Sie es noch einmal.'; $string['submissionfilearea'] = 'Für die Abgabe hochgeladene OneNote-Seiten'; -$string['onenoteactions'] = 'OneNote-Aktionen: '; +$string['submissionlimitexceed'] = 'Die Größe Ihrer abgegebenen Aufgabe übersteigt den zulässigen Grenzwert.'; +$string['submissionnotstarted'] = 'Bearbeiten Sie die Zuweisung in OneNote und speichern Sie anschließend Ihre Änderungen.'; +$string['viewsubmission'] = 'Abgegebene Aufgabe anzeigen'; $string['workonthis'] = 'Hieran arbeiten'; $string['workonthishelp'] = 'Klicken Sie auf die Schaltfläche oben, um an der Zuweisung in OneNote zu arbeiten. Bedenken Sie, dass Sie hierher zurückkehren müssen, um Ihre Arbeit wieder in Moodle zu speichern.'; -$string['signinhelp'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden und hier an der Zuweisung arbeiten zu können.'; -$string['submissiondownloadfailed'] = 'Ihre Abgabe konnte nicht von OneNote heruntergeladen werden. Versuchen Sie es noch einmal.'; -$string['notsignedin'] = 'Melden Sie sich bei OneNote an, bevor Sie versuchen, Ihre Änderungen zu speichern.'; -$string['viewsubmission'] = 'Abgegebene Aufgabe anzeigen'; -$string['signinhelp1'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden, wenn Sie dort an Ihrer abgegebenen Aufgabe arbeiten möchten.'; -$string['signinhelp2'] = 'Klicken Sie auf die Schaltfläche oben, um sich bei OneNote anzumelden, wenn Sie die abgegebene Aufgabe dort anzeigen möchten.'; -$string['submissionnotstarted'] = 'Bearbeiten Sie die Zuweisung in OneNote und speichern Sie anschließend Ihre Änderungen.'; -$string['submissionlimitexceed'] = 'Die Größe Ihrer abgegebenen Aufgabe übersteigt den zulässigen Grenzwert.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Die Anzahl von OneNote-Seiten: {$a}'; diff --git a/mod/assign/submission/onenote/lang/en/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/en/assignsubmission_onenote.php index d74292b7d..68b929324 100644 --- a/mod/assign/submission/onenote/lang/en/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/en/assignsubmission_onenote.php @@ -29,37 +29,36 @@ $string['countfiles'] = 'OneNote: {$a}'; $string['default'] = 'Enabled by default'; $string['default_help'] = 'When set, this submission method is enabled by default for all new assignments.'; +$string['download'] = 'Download'; $string['enabled'] = 'OneNote submissions'; $string['enabled_help'] = 'If enabled, students are able to upload one or more OneNote pages as their submission.'; +$string['erroremptyothervalue'] = 'The \'filesubmissioncount\' value must be set in other.'; $string['eventassessableuploaded'] = 'A OneNote page has been uploaded.'; -$string['onenote'] = 'OneNote submissions'; $string['maxbytes'] = 'Maximum OneNote page size'; $string['maxfilessubmission'] = 'Maximum number of uploaded OneNote pages'; $string['maxfilessubmission_help'] = 'If OneNote submissions are enabled, each student will be able to upload up to this number of OneNote pages for their submission.'; $string['maximumsubmissionsize'] = 'OneNote page size'; $string['maximumsubmissionsize_help'] = 'Sets the maximum submission size of OneNote pages.'; -$string['pluginname'] = 'OneNote submissions'; -$string['siteuploadlimit'] = 'Site upload limit'; -$string['submissionfilearea'] = 'Uploaded submission OneNote pages'; -$string['onenoteactions'] = 'OneNote actions: '; -$string['workonthis'] = 'Work on this'; -$string['workonthishelp'] = 'Click on the button above to work on the assignment in OneNote. Remember that you will need to come back here to save your work back into Moodle.'; -$string['signinhelp'] = 'Click on the button above to sign in to OneNote so you can work on the assignment there.'; -$string['submissiondownloadfailed'] = 'Could not download your submission from OneNote. Please try again.'; $string['notsignedin'] = 'Please sign in to OneNote before attempting to save your changes.'; -$string['viewsubmission'] = 'View submission'; +$string['onenote'] = 'OneNote submissions'; +$string['onenoteactions'] = 'OneNote actions: '; +$string['pluginname'] = 'OneNote submissions'; +$string['privacy:metadata:assignmentid'] = 'Assignment identifier'; +$string['privacy:metadata:numfiles'] = 'Number of files'; +$string['privacy:metadata:submissionpurpose'] = 'The submission ID that links to submissions for the user'; +$string['privacy:metadata:tablepurpose'] = 'Stores the number of files used for the submission.'; +$string['privacy:path'] = 'Number of files'; $string['signinhelp1'] = 'Click on the button above to sign in to OneNote if you want to work on the submission there.'; $string['signinhelp2'] = 'Click on the button above to sign in to OneNote if you want to view the submission there.'; -$string['submissionnotstarted'] = 'Please work on the assignment in OneNote and then save your changes.'; +$string['siteuploadlimit'] = 'Site upload limit'; +$string['submissiondownloadfailed'] = 'Could not download your submission from OneNote. Please try again.'; +$string['submissionfilearea'] = 'Uploaded submission OneNote pages'; $string['submissionlimitexceed'] = 'Your submission size exceeds the acceptable limit.'; -$string['download'] = 'Download'; +$string['submissionnotstarted'] = 'Please work on the assignment in OneNote and then save your changes.'; +$string['viewsubmission'] = 'View submission'; $string['viewsubmissionwarning'] = 'Warning: View Submission will overwrite your OneNote page for this submission, with the learner\'s latest copy.'; -$string['privacy:path'] = 'Number of files'; -$string['privacy:metadata:assignmentid'] = 'Assignment identifier'; -$string['privacy:metadata:submissionpurpose'] = 'The submission ID that links to submissions for the user'; -$string['privacy:metadata:numfiles'] = 'Number of files'; -$string['privacy:metadata:tablepurpose'] = 'Stores the number of files used for the submission.'; -$string['erroremptyothervalue'] = 'The \'filesubmissioncount\' value must be set in other.'; +$string['workonthis'] = 'Work on this'; +$string['workonthishelp'] = 'Click on the button above to work on the assignment in OneNote. Remember that you will need to come back here to save your work back into Moodle.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'The number of OneNote page(s) : {$a}'; diff --git a/mod/assign/submission/onenote/lang/es/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/es/assignsubmission_onenote.php index e99e26826..d1ff5e90d 100644 --- a/mod/assign/submission/onenote/lang/es/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/es/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Entregas de OneNote'; $string['enabled_help'] = 'Si se habilita esta opción, los alumnos pueden subir una o más páginas de OneNote como parte de su entrega.'; $string['eventassessableuploaded'] = 'Se cargó una página de OneNote.'; -$string['onenote'] = 'Entregas de OneNote'; $string['maxbytes'] = 'Tamaño de página máximo de OneNote'; $string['maxfilessubmission'] = 'Cantidad máxima de páginas de OneNote cargadas'; $string['maxfilessubmission_help'] = 'Si las entregas de OneNote están habilitadas, cada estudiante será capaz de subir hasta este número de páginas de OneNote en su entrega.'; $string['maximumsubmissionsize'] = 'Tamaño de página de OneNote'; $string['maximumsubmissionsize_help'] = 'Establece el tamaño de entrega máximo de las páginas de OneNote.'; +$string['notsignedin'] = 'Inicie sesión en OneNote antes de intentar guardar los cambios.'; +$string['onenote'] = 'Entregas de OneNote'; +$string['onenoteactions'] = 'Acciones de OneNote: '; $string['pluginname'] = 'Entregas de OneNote'; +$string['signinhelp1'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote si desea trabajar en la tarea desde allí.'; +$string['signinhelp2'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote si desea ver la entrega allí.'; $string['siteuploadlimit'] = 'Límite de subida del sitio'; +$string['submissiondownloadfailed'] = 'No se pudo descargar la entrega desde OneNote. Vuelva a intentarlo.'; $string['submissionfilearea'] = 'Páginas de entregas de OneNote cargadas'; -$string['onenoteactions'] = 'Acciones de OneNote: '; +$string['submissionlimitexceed'] = 'El tamaño de la entrega excede el límite aceptable.'; +$string['submissionnotstarted'] = 'Trabaje en la tarea en OneNote y luego guarde los cambios.'; +$string['viewsubmission'] = 'Ver entrega'; $string['workonthis'] = 'Trabajar en esto'; $string['workonthishelp'] = 'Haga clic en el botón de arriba para trabajar en la tarea desde OneNote. Recuerde que deberá volver aquí para guardar su trabajo en Moodle.'; -$string['signinhelp'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote para poder trabajar en la tarea desde allí.'; -$string['submissiondownloadfailed'] = 'No se pudo descargar la entrega desde OneNote. Vuelva a intentarlo.'; -$string['notsignedin'] = 'Inicie sesión en OneNote antes de intentar guardar los cambios.'; -$string['viewsubmission'] = 'Ver entrega'; -$string['signinhelp1'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote si desea trabajar en la tarea desde allí.'; -$string['signinhelp2'] = 'Haga clic en el botón de arriba para iniciar sesión en OneNote si desea ver la entrega allí.'; -$string['submissionnotstarted'] = 'Trabaje en la tarea en OneNote y luego guarde los cambios.'; -$string['submissionlimitexceed'] = 'El tamaño de la entrega excede el límite aceptable.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'La cantidad de página(s) de OneNote: {$a}'; diff --git a/mod/assign/submission/onenote/lang/fi/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/fi/assignsubmission_onenote.php index a146c7974..90af5a092 100644 --- a/mod/assign/submission/onenote/lang/fi/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/fi/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'OneNote-palautukset'; $string['enabled_help'] = 'Jos tämä asetus on käytössä, opiskelijat voivat ladata palautukseensa yhden tai useamman OneNote-sivun.'; $string['eventassessableuploaded'] = 'OneNote-sivu on ladattu.'; -$string['onenote'] = 'OneNote-palautukset'; $string['maxbytes'] = 'OneNote-sivun enimmäiskoko'; $string['maxfilessubmission'] = 'Ladattavien OneNote-sivujen enimmäismäärä'; $string['maxfilessubmission_help'] = 'Jos tiedostojen palautus on käytössä, kukin opiskelija voi ladata palautukseensa enintään tähän lukumäärään asti tiedostoja.'; $string['maximumsubmissionsize'] = 'OneNote-sivun koko'; $string['maximumsubmissionsize_help'] = 'Määrittää palautettavien OneNote-sivujen enimmäiskoon.'; +$string['notsignedin'] = 'Kirjaudu OneNoteen, ennen kuin yrität tallentaa muutokset.'; +$string['onenote'] = 'OneNote-palautukset'; +$string['onenoteactions'] = 'OneNote-toiminnot: '; $string['pluginname'] = 'OneNote-palautukset'; +$string['signinhelp1'] = 'Kirjaudu OneNoteen napsauttamalla yllä olevaa painiketta, jos haluat käsitellä palautusta siellä.'; +$string['signinhelp2'] = 'Kirjaudu OneNoteen napsauttamalla yllä olevaa painiketta, jos haluat tarkastella palautusta siellä.'; $string['siteuploadlimit'] = 'Sivuston latausrajoitus'; +$string['submissiondownloadfailed'] = 'Palautusta ei voitu ladata OneNote. Yritä uudelleen.'; $string['submissionfilearea'] = 'Palautukseen ladatut OneNote-sivut'; -$string['onenoteactions'] = 'OneNote-toiminnot: '; +$string['submissionlimitexceed'] = 'Palautuksen koko ylittää määritetyn rajan.'; +$string['submissionnotstarted'] = 'Tee tehtävä OneNote ja tallenna sitten muutokset.'; +$string['viewsubmission'] = 'Näytä palautus'; $string['workonthis'] = 'Käsittele tätä'; $string['workonthishelp'] = 'Tee tehtävä OneNote napsauttamalla yllä olevaa painiketta. Muista palata tälle sivulle ja tallentaa työ Moodleen.'; -$string['signinhelp'] = 'Kirjaudu OneNoteen napsauttamalla yllä olevaa painiketta, jotta voit käsitellä tehtävää siellä.'; -$string['submissiondownloadfailed'] = 'Palautusta ei voitu ladata OneNote. Yritä uudelleen.'; -$string['notsignedin'] = 'Kirjaudu OneNoteen, ennen kuin yrität tallentaa muutokset.'; -$string['viewsubmission'] = 'Näytä palautus'; -$string['signinhelp1'] = 'Kirjaudu OneNoteen napsauttamalla yllä olevaa painiketta, jos haluat käsitellä palautusta siellä.'; -$string['signinhelp2'] = 'Kirjaudu OneNoteen napsauttamalla yllä olevaa painiketta, jos haluat tarkastella palautusta siellä.'; -$string['submissionnotstarted'] = 'Tee tehtävä OneNote ja tallenna sitten muutokset.'; -$string['submissionlimitexceed'] = 'Palautuksen koko ylittää määritetyn rajan.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'OneNote-sivujen määrä: {$a}'; diff --git a/mod/assign/submission/onenote/lang/fr/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/fr/assignsubmission_onenote.php index a443153ef..bd5f99b95 100644 --- a/mod/assign/submission/onenote/lang/fr/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/fr/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Remises OneNote'; $string['enabled_help'] = 'Si ce réglage est activé, les étudiants pourront télécharger une ou plusieurs pages OneNote pour leur devoir.'; $string['eventassessableuploaded'] = 'Une page OneNote a été téléchargée.'; -$string['onenote'] = 'Remises OneNote'; $string['maxbytes'] = 'Taille maximale de la page OneNote'; $string['maxfilessubmission'] = 'Nombre maximal de pages OneNote téléchargées'; $string['maxfilessubmission_help'] = 'Si la remise de travaux OneNote est activée, chaque étudiant pourra télécharger au maximum ce nombre de pages OneNote pour son travail.'; $string['maximumsubmissionsize'] = 'Taille de page OneNote'; $string['maximumsubmissionsize_help'] = 'Définit la taille maximale de la remise de pages OneNote.'; +$string['notsignedin'] = 'Inscrivez-vous à OneNote avant d\'essayer d\'enregistrer vos modifications.'; +$string['onenote'] = 'Remises OneNote'; +$string['onenoteactions'] = 'Actions OneNote : '; $string['pluginname'] = 'Remises OneNote'; +$string['signinhelp1'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire à OneNote si vous souhaitez travailler sur la remise de travaux à cet endroit.'; +$string['signinhelp2'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire à OneNote si vous souhaitez afficher la remise de travaux à cet endroit.'; $string['siteuploadlimit'] = 'Limite de téléchargement du site'; +$string['submissiondownloadfailed'] = 'Impossible de télécharger votre remise de travaux à partir de OneNote. Veuillez réessayer.'; $string['submissionfilearea'] = 'Pages de remise OneNote téléchargées'; -$string['onenoteactions'] = 'Actions OneNote : '; +$string['submissionlimitexceed'] = 'La taille de votre remise de travaux dépasse la limite acceptable.'; +$string['submissionnotstarted'] = 'Travaillez sur le devoir dans OneNote, puis enregistrez vos modifications.'; +$string['viewsubmission'] = 'Afficher le devoir remis'; $string['workonthis'] = 'Travailler sur cet élément'; $string['workonthishelp'] = 'Cliquez sur le bouton ci-dessus pour travailler sur le devoir dans OneNote. Sachez que vous devrez revenir sur cette page pour enregistrer votre travail dans Moodle.'; -$string['signinhelp'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire sur OneNote de façon à pouvoir travailler sur le devoir.'; -$string['submissiondownloadfailed'] = 'Impossible de télécharger votre remise de travaux à partir de OneNote. Veuillez réessayer.'; -$string['notsignedin'] = 'Inscrivez-vous à OneNote avant d\'essayer d\'enregistrer vos modifications.'; -$string['viewsubmission'] = 'Afficher le devoir remis'; -$string['signinhelp1'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire à OneNote si vous souhaitez travailler sur la remise de travaux à cet endroit.'; -$string['signinhelp2'] = 'Cliquez sur le bouton ci-dessus pour vous inscrire à OneNote si vous souhaitez afficher la remise de travaux à cet endroit.'; -$string['submissionnotstarted'] = 'Travaillez sur le devoir dans OneNote, puis enregistrez vos modifications.'; -$string['submissionlimitexceed'] = 'La taille de votre remise de travaux dépasse la limite acceptable.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Nombre de pages OneNote : {$a}'; diff --git a/mod/assign/submission/onenote/lang/it/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/it/assignsubmission_onenote.php index 51fbf5d46..08d459d2d 100644 --- a/mod/assign/submission/onenote/lang/it/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/it/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Consegne OneNote'; $string['enabled_help'] = 'Abilitando questa opzione, gli studenti saranno in grado di caricare una o più pagine OneNote come consegna.'; $string['eventassessableuploaded'] = 'Una pagina OneNote è stata caricata.'; -$string['onenote'] = 'Consegne OneNote'; $string['maxbytes'] = 'Dimensione massima pagina OneNote'; $string['maxfilessubmission'] = 'Numero massimo di pagine OneNote caricate'; $string['maxfilessubmission_help'] = 'Se le consegne OneNote sono abilitate, ogni studente sarà in grado di caricare fino a questo numero di pagine OneNote per la consegna.'; $string['maximumsubmissionsize'] = 'Dimensione pagina OneNote'; $string['maximumsubmissionsize_help'] = 'Imposta la dimensione massima di consegna di pagine OneNote.'; +$string['notsignedin'] = 'Accedi a OneNote prima di provare a salvare le modifiche.'; +$string['onenote'] = 'Consegne OneNote'; +$string['onenoteactions'] = 'Azioni OneNote: '; $string['pluginname'] = 'Consegne OneNote'; +$string['signinhelp1'] = 'Fai clic sul pulsante precedente per accedere a OneNote se desideri lavorare lì sulla consegna.'; +$string['signinhelp2'] = 'Fai clic sul pulsante precedente per accedere a OneNote se desideri visualizzare lì la consegna.'; $string['siteuploadlimit'] = 'Limite di caricamento del sito'; +$string['submissiondownloadfailed'] = 'Impossibile scaricare il compito da OneNote. Riprova.'; $string['submissionfilearea'] = 'Pagine OneNote di consegna caricate'; -$string['onenoteactions'] = 'Azioni OneNote: '; +$string['submissionlimitexceed'] = 'La dimensione della consegna supera il limite accettabile.'; +$string['submissionnotstarted'] = 'Lavora sul compito in OneNote e poi salva le modifiche.'; +$string['viewsubmission'] = 'Visualizza consegna'; $string['workonthis'] = 'Lavora su questo'; $string['workonthishelp'] = 'Fai clic sul pulsante precedente per lavorare sul compito in OneNote. Ricorda che devi tornare qui per salvare nuovamente il lavoro in Moodle.'; -$string['signinhelp'] = 'Fai clic sul pulsante precedente per accedere a OneNote e lavorare sul compito.'; -$string['submissiondownloadfailed'] = 'Impossibile scaricare il compito da OneNote. Riprova.'; -$string['notsignedin'] = 'Accedi a OneNote prima di provare a salvare le modifiche.'; -$string['viewsubmission'] = 'Visualizza consegna'; -$string['signinhelp1'] = 'Fai clic sul pulsante precedente per accedere a OneNote se desideri lavorare lì sulla consegna.'; -$string['signinhelp2'] = 'Fai clic sul pulsante precedente per accedere a OneNote se desideri visualizzare lì la consegna.'; -$string['submissionnotstarted'] = 'Lavora sul compito in OneNote e poi salva le modifiche.'; -$string['submissionlimitexceed'] = 'La dimensione della consegna supera il limite accettabile.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Il numero di pagine OneNote: {$a}'; diff --git a/mod/assign/submission/onenote/lang/ja/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/ja/assignsubmission_onenote.php index 00ad7332a..3411f2656 100644 --- a/mod/assign/submission/onenote/lang/ja/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/ja/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'OneNote提出'; $string['enabled_help'] = '有効にした場合、学生は1ページ以上のOneNoteページを提出物としてアップロードできます。'; $string['eventassessableuploaded'] = 'OneNoteページがアップロードされました。'; -$string['onenote'] = 'OneNote提出'; $string['maxbytes'] = 'OneNote最大ページサイズ'; $string['maxfilessubmission'] = 'アップロードできる最大OneNoteページ数'; $string['maxfilessubmission_help'] = 'OneNote提出を有効にした場合、学生はこの数を上限とするOneNoteページを提出物としてアップロードできます。'; $string['maximumsubmissionsize'] = 'OneNoteページサイズ'; $string['maximumsubmissionsize_help'] = 'OneNoteページの最大提出サイズを設定します。'; +$string['notsignedin'] = '変更を保存する前に、OneNoteにサインインしてください。'; +$string['onenote'] = 'OneNote提出'; +$string['onenoteactions'] = 'OneNoteアクション : '; $string['pluginname'] = 'OneNote提出'; +$string['signinhelp1'] = 'OneNoteで提出の作業を行う場合は、上のボタンをクリックしてOneNoteにサインインします。'; +$string['signinhelp2'] = 'OneNoteで提出を表示する場合は、上のボタンをクリックしてOneNoteにサインインします。'; $string['siteuploadlimit'] = 'サイトアップロード上限'; +$string['submissiondownloadfailed'] = 'OneNoteから提出をダウンロードできませんでした。もう一度お試しください。'; $string['submissionfilearea'] = '提出物としてアップロードされたOneNoteページ'; -$string['onenoteactions'] = 'OneNoteアクション : '; +$string['submissionlimitexceed'] = '提出サイズが上限を超えています。'; +$string['submissionnotstarted'] = 'OneNoteで課題の作業を行い、変更した内容を保存してください。'; +$string['viewsubmission'] = '提出を表示する'; $string['workonthis'] = 'これを作業'; $string['workonthishelp'] = 'OneNoteで課題の作業を行うには、上のボタンをクリックします。必ずここに戻り、Moodleに作業内容を保存してください。'; -$string['signinhelp'] = '上のボタンをクリックしてOneNoteにサインインしてください。これにより、OneNoteで課題の作業が行えます。'; -$string['submissiondownloadfailed'] = 'OneNoteから提出をダウンロードできませんでした。もう一度お試しください。'; -$string['notsignedin'] = '変更を保存する前に、OneNoteにサインインしてください。'; -$string['viewsubmission'] = '提出を表示する'; -$string['signinhelp1'] = 'OneNoteで提出の作業を行う場合は、上のボタンをクリックしてOneNoteにサインインします。'; -$string['signinhelp2'] = 'OneNoteで提出を表示する場合は、上のボタンをクリックしてOneNoteにサインインします。'; -$string['submissionnotstarted'] = 'OneNoteで課題の作業を行い、変更した内容を保存してください。'; -$string['submissionlimitexceed'] = '提出サイズが上限を超えています。'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'OneNoteページ数 : {$a}'; diff --git a/mod/assign/submission/onenote/lang/nl/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/nl/assignsubmission_onenote.php index 477b8e28a..5bd90c49e 100644 --- a/mod/assign/submission/onenote/lang/nl/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/nl/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'OneNote-inzendingen'; $string['enabled_help'] = 'Als deze optie is ingeschakeld, kunnen studenten een of meer OneNote-pagina\'s als inzending uploaden.'; $string['eventassessableuploaded'] = 'Er is een OneNote-pagina geüpload.'; -$string['onenote'] = 'OneNote-inzendingen'; $string['maxbytes'] = 'Maximale grootte OneNote-pagina'; $string['maxfilessubmission'] = 'Maximum aantal geüploade OneNote-pagina\'s'; $string['maxfilessubmission_help'] = 'Als bestanden insturen is ingeschakeld, kan elke student maximaal dit aantal OneNote-pagina\'s uploaden als inzending.'; $string['maximumsubmissionsize'] = 'Grootte OneNote-pagina'; $string['maximumsubmissionsize_help'] = 'Hiermee wordt de maximale inzendingsgrootte van OneNote-pagina\'s ingesteld.'; +$string['notsignedin'] = 'Meld je aan bij OneNote voordat je probeert je wijzigingen op te slaan.'; +$string['onenote'] = 'OneNote-inzendingen'; +$string['onenoteactions'] = 'OneNote-acties: '; $string['pluginname'] = 'OneNote-inzendingen'; +$string['signinhelp1'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote om daar aan de inzending te werken.'; +$string['signinhelp2'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote om daar aan de inzending weer te geven.'; $string['siteuploadlimit'] = 'Uploadlimiet site'; +$string['submissiondownloadfailed'] = 'Kan je inzending vanuit OneNote niet downloaden. Probeer het nog eens.'; $string['submissionfilearea'] = 'OneNote-pagina\'s geüploade inzending'; -$string['onenoteactions'] = 'OneNote-acties: '; +$string['submissionlimitexceed'] = 'Je inzending overschrijdt de geaccepteerde limiet.'; +$string['submissionnotstarted'] = 'Werk aan de opdracht in OneNote en sla je wijzigingen op.'; +$string['viewsubmission'] = 'Inzending bekijken'; $string['workonthis'] = 'Werk hieraan'; $string['workonthishelp'] = 'Klik op de knop hierboven om aan de opdracht in OneNote te werken. Denk eraan dat je hier terug moet komen om je werk weer op te slaan in Moodle.'; -$string['signinhelp'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote om daar aan de opdracht te werken.'; -$string['submissiondownloadfailed'] = 'Kan je inzending vanuit OneNote niet downloaden. Probeer het nog eens.'; -$string['notsignedin'] = 'Meld je aan bij OneNote voordat je probeert je wijzigingen op te slaan.'; -$string['viewsubmission'] = 'Inzending bekijken'; -$string['signinhelp1'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote om daar aan de inzending te werken.'; -$string['signinhelp2'] = 'Klik op de knop hierboven als je je wilt aanmelden bij OneNote om daar aan de inzending weer te geven.'; -$string['submissionnotstarted'] = 'Werk aan de opdracht in OneNote en sla je wijzigingen op.'; -$string['submissionlimitexceed'] = 'Je inzending overschrijdt de geaccepteerde limiet.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Het aantal OneNote-pagina\'s: {$a}'; diff --git a/mod/assign/submission/onenote/lang/pl/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/pl/assignsubmission_onenote.php index 005855e2a..dacf4178e 100644 --- a/mod/assign/submission/onenote/lang/pl/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/pl/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Przesłane prace w programie OneNote'; $string['enabled_help'] = 'Jeśli opcja jest włączona, studenci mogą przesłać jedną lub większą liczbę plików jako ich przesłaną pracę.'; $string['eventassessableuploaded'] = 'Przesłano stronę programu OneNote.'; -$string['onenote'] = 'Przesłane prace w programie OneNote'; $string['maxbytes'] = 'Maksymalny rozmiar strony w programie OneNote'; $string['maxfilessubmission'] = 'Maksymalna liczba przesłanych stron programu OneNote'; $string['maxfilessubmission_help'] = 'Jeżeli opcja przesyłania prac w programie OneNote jest włączona, każdy student będzie mógł przesłać maksymalnie tyle stron programu OneNote jako swoją przesłaną pracę.'; $string['maximumsubmissionsize'] = 'Rozmiar strony programu OneNote'; $string['maximumsubmissionsize_help'] = 'Umożliwia ustawienie maksymalnego rozmiaru przesyłanych stron programu OneNote.'; +$string['notsignedin'] = 'Zaloguj się do programu OneNote przed zapisaniem zmian.'; +$string['onenote'] = 'Przesłane prace w programie OneNote'; +$string['onenoteactions'] = 'Działania w programie OneNote: '; $string['pluginname'] = 'Przesłane prace w programie OneNote'; +$string['signinhelp1'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote, jeżeli chcesz w nim sporządzić pracę do przesłania.'; +$string['signinhelp2'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote, jeżeli chcesz w nim wyświetlić przesłaną pracę.'; $string['siteuploadlimit'] = 'Limit przesyłania'; +$string['submissiondownloadfailed'] = 'Nie udało się pobrać przesłanej pracy z programu OneNote. Spróbuj ponownie.'; $string['submissionfilearea'] = 'Przesłane strony programu OneNote jako praca'; -$string['onenoteactions'] = 'Działania w programie OneNote: '; +$string['submissionlimitexceed'] = 'Rozmiar przesłanej pracy przekracza dopuszczalny limit.'; +$string['submissionnotstarted'] = 'Pracuj nad zadaniem w programie OneNote, a następnie zapisz zmiany.'; +$string['viewsubmission'] = 'Wyświetl złożoną pracę'; $string['workonthis'] = 'Pracuj nad tym'; $string['workonthishelp'] = 'Kliknij przycisk powyżej, aby pracować nad zadaniem w programie OneNote. Pamiętaj, że musisz powrócić do tej strony, aby zapisać swoją pracę na platformie Moodle.'; -$string['signinhelp'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote i pracować w nim nad zadaniem.'; -$string['submissiondownloadfailed'] = 'Nie udało się pobrać przesłanej pracy z programu OneNote. Spróbuj ponownie.'; -$string['notsignedin'] = 'Zaloguj się do programu OneNote przed zapisaniem zmian.'; -$string['viewsubmission'] = 'Wyświetl złożoną pracę'; -$string['signinhelp1'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote, jeżeli chcesz w nim sporządzić pracę do przesłania.'; -$string['signinhelp2'] = 'Kliknij przycisk powyżej, aby zalogować się do programu OneNote, jeżeli chcesz w nim wyświetlić przesłaną pracę.'; -$string['submissionnotstarted'] = 'Pracuj nad zadaniem w programie OneNote, a następnie zapisz zmiany.'; -$string['submissionlimitexceed'] = 'Rozmiar przesłanej pracy przekracza dopuszczalny limit.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Liczba stron programu OneNote: {$a}'; diff --git a/mod/assign/submission/onenote/lang/pt_br/assignsubmission_onenote.php b/mod/assign/submission/onenote/lang/pt_br/assignsubmission_onenote.php index c6dba736a..611e059ba 100644 --- a/mod/assign/submission/onenote/lang/pt_br/assignsubmission_onenote.php +++ b/mod/assign/submission/onenote/lang/pt_br/assignsubmission_onenote.php @@ -31,26 +31,25 @@ $string['enabled'] = 'Envios do OneNote'; $string['enabled_help'] = 'Se essa configuração estiver ativada, os alunos poderão fazer o upload de uma ou mais páginas do OneNote como seu envio.'; $string['eventassessableuploaded'] = 'Uma página do OneNote foi enviada.'; -$string['onenote'] = 'Envios do OneNote'; $string['maxbytes'] = 'Tamanho máximo de página do OneNote'; $string['maxfilessubmission'] = 'Número máximo de uploads de páginas do OneNote'; $string['maxfilessubmission_help'] = 'Se os envios do OneNote forem ativados, cada aluno poderá fazer o upload desse número de páginas do OneNote em seu envio.'; $string['maximumsubmissionsize'] = 'Tamanho de página do OneNote'; $string['maximumsubmissionsize_help'] = 'Define o tamanho máximo para o envio de páginas do OneNote.'; +$string['notsignedin'] = 'Faça login no OneNote antes de tentar salvar suas alterações.'; +$string['onenote'] = 'Envios do OneNote'; +$string['onenoteactions'] = 'Ações do OneNote: '; $string['pluginname'] = 'Envios do OneNote'; +$string['signinhelp1'] = 'Clique no botão acima para fazer login no OneNote caso queira trabalhar no envio nele.'; +$string['signinhelp2'] = 'Clique no botão acima para fazer login no OneNote caso queira visualizar o envio nele.'; $string['siteuploadlimit'] = 'Limite de uploads do site'; +$string['submissiondownloadfailed'] = 'Não foi possível fazer o download de seu envio do OneNote. Tente novamente.'; $string['submissionfilearea'] = 'Uploads de páginas do OneNote para envio'; -$string['onenoteactions'] = 'Ações do OneNote: '; +$string['submissionlimitexceed'] = 'O tamanho do envio ultrapassa o limite máximo.'; +$string['submissionnotstarted'] = 'Trabalhe na tarefa no OneNote e depois salve suas alterações.'; +$string['viewsubmission'] = 'Visualizar envio'; $string['workonthis'] = 'Trabalhar nisso'; $string['workonthishelp'] = 'Clique no botão acima para trabalhar na tarefa no OneNote. Lembre-se de que você precisará voltar aqui para salvar seu trabalho de volta no Moodle.'; -$string['signinhelp'] = 'Clique no botão acima para fazer login no OneNote e poder trabalhar na tarefa nele.'; -$string['submissiondownloadfailed'] = 'Não foi possível fazer o download de seu envio do OneNote. Tente novamente.'; -$string['notsignedin'] = 'Faça login no OneNote antes de tentar salvar suas alterações.'; -$string['viewsubmission'] = 'Visualizar envio'; -$string['signinhelp1'] = 'Clique no botão acima para fazer login no OneNote caso queira trabalhar no envio nele.'; -$string['signinhelp2'] = 'Clique no botão acima para fazer login no OneNote caso queira visualizar o envio nele.'; -$string['submissionnotstarted'] = 'Trabalhe na tarefa no OneNote e depois salve suas alterações.'; -$string['submissionlimitexceed'] = 'O tamanho do envio ultrapassa o limite máximo.'; // Deprecated since Moodle 4.3. $string['numfilesforlog'] = 'Número de página(s) do OneNote: {$a}'; diff --git a/mod/assign/submission/onenote/lib.php b/mod/assign/submission/onenote/lib.php index d7bbe2695..c2ae51f5f 100644 --- a/mod/assign/submission/onenote/lib.php +++ b/mod/assign/submission/onenote/lib.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright Microsoft, Inc. (based on files by NetSpot {@link http://www.netspot.com.au}) */ -defined('MOODLE_INTERNAL') || die(); /** * Serves assignment submissions and other files. diff --git a/mod/assign/submission/onenote/locallib.php b/mod/assign/submission/onenote/locallib.php index b4687167a..0b268786b 100644 --- a/mod/assign/submission/onenote/locallib.php +++ b/mod/assign/submission/onenote/locallib.php @@ -29,8 +29,6 @@ use assignsubmission_onenote\event\submission_updated; use local_onenote\api\base; -defined('MOODLE_INTERNAL') || die(); - /** * Library class for OneNote submission plugin extending submission plugin base class * diff --git a/mod/assign/submission/onenote/tests/privacy/provider_test.php b/mod/assign/submission/onenote/tests/privacy/provider_test.php index 55c0db6a2..58732542d 100644 --- a/mod/assign/submission/onenote/tests/privacy/provider_test.php +++ b/mod/assign/submission/onenote/tests/privacy/provider_test.php @@ -41,21 +41,26 @@ * * @copyright Microsoft, Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \assignsubmission_onenote\privacy\provider */ -class provider_test extends \mod_assign\privacy\provider_test { +final class provider_test extends \mod_assign\privacy\provider_test { /** * Quick test to make sure that get_metadata returns something. + * + * @covers \assignsubmission_onenote\privacy\provider::get_metadata */ - public function test_get_metadata() { + public function test_get_metadata(): void { $collection = new collection('assignsubmission_onenote'); - $collection = \assignsubmission_onenote\privacy\provider::get_metadata($collection); + $collection = provider::get_metadata($collection); $this->assertNotEmpty($collection); } /** * Test that comments are exported for a user. + * + * @covers \assignsubmission_onenote\privacy\provider::export_submission_user_data */ - public function test_export_submission_user_data() { + public function test_export_submission_user_data(): void { $this->resetAfterTest(); // Create course, assignment, submission, and then a feedback comment. $course = $this->getDataGenerator()->create_course(); @@ -74,7 +79,7 @@ public function test_export_submission_user_data() { // The student should have some text submitted. $exportdata = new assign_plugin_request_data($context, $assign, $submission, ['Attempt 1']); - \assignsubmission_onenote\privacy\provider::export_submission_user_data($exportdata); + provider::export_submission_user_data($exportdata); $exporteddata = $writer->get_data(['Attempt 1', get_string('privacy:path', 'assignsubmission_onenote')]); $this->assertEquals($assign->get_instance()->id, $exporteddata->assignment); $this->assertEquals($submission->id, $exporteddata->submission); @@ -90,8 +95,10 @@ public function test_export_submission_user_data() { /** * Test that all comments are deleted for this context. + * + * @covers \assignsubmission_onenote\privacy\provider::delete_submission_for_context */ - public function test_delete_submission_for_context() { + public function test_delete_submission_for_context(): void { $this->resetAfterTest(); // Create course, assignment, submission. $course = $this->getDataGenerator()->create_course(); @@ -119,7 +126,7 @@ public function test_delete_submission_for_context() { // Only need the context and assign object in this plugin for this operation. $requestdata = new assign_plugin_request_data($context, $assign); - \assignsubmission_onenote\privacy\provider::delete_submission_for_context($requestdata); + provider::delete_submission_for_context($requestdata); // This checks that there is no content for these submissions. $this->assertTrue($plugin->is_empty($submission)); $this->assertTrue($plugin2->is_empty($submission2)); @@ -132,8 +139,9 @@ public function test_delete_submission_for_context() { /** * Test that the comments for a user are deleted. + * @covers \assignsubmission_onenote\privacy\provider::delete_submission_for_userid */ - public function test_delete_submission_for_userid() { + public function test_delete_submission_for_userid(): void { $this->resetAfterTest(); // Create course, assignment, submission. $course = $this->getDataGenerator()->create_course(); @@ -161,7 +169,7 @@ public function test_delete_submission_for_userid() { // Need more data for this operation. $requestdata = new assign_plugin_request_data($context, $assign, $submission, [], $user1); - \assignsubmission_onenote\privacy\provider::delete_submission_for_userid($requestdata); + provider::delete_submission_for_userid($requestdata); // This checks that there is no content for the first submission. $this->assertTrue($plugin->is_empty($submission)); // But there is for the second submission. @@ -176,8 +184,9 @@ public function test_delete_submission_for_userid() { /** * Test deletion of all submissions for a context works. + * @covers \assignsubmission_onenote\privacy\provider::delete_submissions */ - public function test_delete_submissions() { + public function test_delete_submissions(): void { global $DB; $this->resetAfterTest(); @@ -204,7 +213,7 @@ public function test_delete_submissions() { [$plugin1, $submission1] = $this->create_onenote_submission($assign1, $user1, $student1text); $student2text = 'Student two\'s text.'; [$plugin2, $submission2] = $this->create_onenote_submission($assign1, $user2, $student2text); - $student3text = 'Student two\'s text.'; + $student3text = 'Student three\'s text.'; [$plugin3, $submission3] = $this->create_onenote_submission($assign1, $user3, $student3text); // Now for submissions in assignment two. $student3text2 = 'Student two\'s text for the second assignment.'; @@ -226,7 +235,7 @@ public function test_delete_submissions() { $requestdata = new assign_plugin_request_data($context1, $assign1); $requestdata->set_userids([$user1->id, $user2->id]); $requestdata->populate_submissions_and_grades(); - \assignsubmission_onenote\privacy\provider::delete_submissions($requestdata); + provider::delete_submissions($requestdata); // There should only be one record left for assignment one. $data = $DB->get_records('assignsubmission_onenote', ['assignment' => $assign1->get_instance()->id]); @@ -268,7 +277,7 @@ protected function create_onenote_submission($assign, $student, $submissiontext) 'filearea' => base::ASSIGNSUBMISSION_ONENOTE_FILEAREA, 'itemid' => $submission->id, 'filepath' => '/', - 'filename' => 'OneNote_' . time() . '.zip' + 'filename' => 'OneNote_' . time() . '.zip', ]; // Save it. $fs->create_file_from_string($fileinfo, $submissiontext); diff --git a/theme/boost_o365teams/amd/build/iframeChecker.min.js b/theme/boost_o365teams/amd/build/iframeChecker.min.js index 3873a51c5..737a3bb99 100644 --- a/theme/boost_o365teams/amd/build/iframeChecker.min.js +++ b/theme/boost_o365teams/amd/build/iframeChecker.min.js @@ -1 +1,3 @@ -define(["jquery"],function(t){return{init:function(){window.location!=window.parent.location||/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(t("body.drawer-open-left").css("margin-left","0"),t("div#page").css("margin-top","0"),t("section#region-main.has-blocks").css("width","100%"),t("div#page-wrapper").css("margin-bottom","0"),t("div.context-header-settings-menu").remove(),t("div.region-main-settings-menu").remove(),t("div.region_main_settings_menu_proxy").remove(),t("div.action-menu-trigger").remove(),t("div.ml-auto").remove(),t("a.printicon").remove(),t("header#page-header").css("display","none"),t(".activityinstance a").click(function(){t(this).attr("target","_blank")}),t(".modtype_assign .activityinstance a").click(function(){t(this).attr("target","_self")}),t(".modtype_quiz .activityinstance a").click(function(){t(this).attr("target","_self")}),t("#page-mod-assign-view .submissionlinks a").click(function(){t(this).attr("target","_blank")}),t(".quizattempt .singlebutton form").click(function(){t(this).attr("target","_blank"),t(this).attr("method","get")})):(t("nav.navbar").show(),t("nav.navbar").css("display","flex"),t("div#nav-drawer").show(),t('section[data-region="blocks-column"]').show(),t("footer#page-footer").show(),t("div#course_page_title").css("display","none"),t(".popupicon").css("display","none")),t("body").fadeIn(150)}}}); \ No newline at end of file +define("theme_boost_o365teams/iframeChecker",["jquery"],(function($){return{init:function(){window.location!=window.parent.location||/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?($("body.drawer-open-left").css("margin-left","0"),$("div#page").css("margin-top","0"),$("section#region-main.has-blocks").css("width","100%"),$("div#page-wrapper").css("margin-bottom","0"),$("div.context-header-settings-menu").remove(),$("div.region-main-settings-menu").remove(),$("div.region_main_settings_menu_proxy").remove(),$("div.action-menu-trigger").remove(),$("div.ml-auto").remove(),$("a.printicon").remove(),$("header#page-header").css("display","none"),$(".activityinstance a").click((function(){$(this).attr("target","_blank")})),$(".modtype_assign .activityinstance a").click((function(){$(this).attr("target","_self")})),$(".modtype_quiz .activityinstance a").click((function(){$(this).attr("target","_self")})),$("#page-mod-assign-view .submissionlinks a").click((function(){$(this).attr("target","_blank")})),$(".quizattempt .singlebutton form").click((function(){$(this).attr("target","_blank"),$(this).attr("method","get")}))):($("nav.navbar").show(),$("nav.navbar").css("display","flex"),$("div#nav-drawer").show(),$('section[data-region="blocks-column"]').show(),$("footer#page-footer").show(),$("div#course_page_title").css("display","none"),$(".popupicon").css("display","none")),$("body").fadeIn(150)}}})); + +//# sourceMappingURL=iframeChecker.min.js.map \ No newline at end of file diff --git a/theme/boost_o365teams/amd/build/iframeChecker.min.js.map b/theme/boost_o365teams/amd/build/iframeChecker.min.js.map new file mode 100644 index 000000000..e08ca0a70 --- /dev/null +++ b/theme/boost_o365teams/amd/build/iframeChecker.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"iframeChecker.min.js","sources":["../src/iframeChecker.js"],"sourcesContent":["define(['jquery'], function($) {\n return {\n init: function() {\n if (inTeams()) {\n // In Teams, hide page elements.\n $('body.drawer-open-left').css('margin-left', '0');\n $('div#page').css('margin-top', '0');\n $('section#region-main.has-blocks').css('width', '100%');\n $('div#page-wrapper').css('margin-bottom', '0');\n $('div.context-header-settings-menu').remove();\n $('div.region-main-settings-menu').remove();\n $('div.region_main_settings_menu_proxy').remove();\n $('div.action-menu-trigger').remove();\n $('div.ml-auto').remove();\n $('a.printicon').remove();\n $('header#page-header').css('display', 'none');\n $('.activityinstance a').click(function() {\n $(this).attr('target', '_blank');\n });\n $('.modtype_assign .activityinstance a').click(function() {\n $(this).attr('target', '_self');\n });\n $('.modtype_quiz .activityinstance a').click(function() {\n $(this).attr('target', '_self');\n });\n $('#page-mod-assign-view .submissionlinks a').click(function() {\n $(this).attr('target', '_blank');\n });\n $('.quizattempt .singlebutton form').click(function() {\n $(this).attr('target', '_blank');\n $(this).attr('method', 'get');\n });\n } else {\n // Not in Teams, show page elements.\n $('nav.navbar').show();\n $('nav.navbar').css('display', 'flex');\n $('div#nav-drawer').show();\n $('section[data-region=\"blocks-column\"]').show();\n $('footer#page-footer').show();\n $('div#course_page_title').css('display', 'none');\n $('.popupicon').css('display', 'none');\n }\n $(\"body\").fadeIn(150);\n }\n };\n\n /**\n * Check if the page is being displayed in Microsoft Teams.\n *\n * @return {boolean} True if the page is being displayed in Microsoft Teams, false otherwise.\n */\n function inTeams() {\n return ((window.location != window.parent.location) || (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)));\n }\n});\n"],"names":["define","$","init","window","location","parent","test","navigator","userAgent","css","remove","click","this","attr","show","fadeIn"],"mappings":"AAAAA,6CAAO,CAAC,WAAW,SAASC,SACjB,CACHC,KAAM,WAkDGC,OAAOC,UAAYD,OAAOE,OAAOD,UAAc,4BAA4BE,KAAKC,UAAUC,YA/C3FP,EAAE,yBAAyBQ,IAAI,cAAe,KAC9CR,EAAE,YAAYQ,IAAI,aAAc,KAChCR,EAAE,kCAAkCQ,IAAI,QAAS,QACjDR,EAAE,oBAAoBQ,IAAI,gBAAiB,KAC3CR,EAAE,oCAAoCS,SACtCT,EAAE,iCAAiCS,SACnCT,EAAE,uCAAuCS,SACzCT,EAAE,2BAA2BS,SAC7BT,EAAE,eAAeS,SACjBT,EAAE,eAAeS,SACjBT,EAAE,sBAAsBQ,IAAI,UAAW,QACvCR,EAAE,uBAAuBU,OAAM,WAC3BV,EAAEW,MAAMC,KAAK,SAAU,aAE3BZ,EAAE,uCAAuCU,OAAM,WAC3CV,EAAEW,MAAMC,KAAK,SAAU,YAE3BZ,EAAE,qCAAqCU,OAAM,WACzCV,EAAEW,MAAMC,KAAK,SAAU,YAE3BZ,EAAE,4CAA4CU,OAAM,WAChDV,EAAEW,MAAMC,KAAK,SAAU,aAE3BZ,EAAE,mCAAmCU,OAAM,WACvCV,EAAEW,MAAMC,KAAK,SAAU,UACvBZ,EAAEW,MAAMC,KAAK,SAAU,YAI3BZ,EAAE,cAAca,OAChBb,EAAE,cAAcQ,IAAI,UAAW,QAC/BR,EAAE,kBAAkBa,OACpBb,EAAE,wCAAwCa,OAC1Cb,EAAE,sBAAsBa,OACxBb,EAAE,yBAAyBQ,IAAI,UAAW,QAC1CR,EAAE,cAAcQ,IAAI,UAAW,SAEnCR,EAAE,QAAQc,OAAO"} \ No newline at end of file diff --git a/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js b/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js index 2a043d934..d0f2ff6bf 100644 --- a/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js +++ b/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js @@ -1 +1,3 @@ -define(["jquery"],function(e){return{init:function(){microsoftTeams.initialize(),microsoftTeams.getContext(function(t){theme=t.theme,e("body").addClass("theme_"+theme)}),microsoftTeams.registerOnThemeChangeHandler(function(t){e("body").removeClass("theme_default"),e("body").removeClass("theme_dark"),e("body").removeClass("theme_contrast"),e("body").addClass("theme_"+t)})}}}); +define("theme_boost_o365teams/teamsThemeChecker",["jquery","microsoftTeams"],(function($,microsoftTeams){return{init:function(){microsoftTeams.initialize(),microsoftTeams.getContext((function(context){var theme=context.theme;$("body").addClass("theme_"+theme)})),microsoftTeams.registerOnThemeChangeHandler((function(theme){$("body").removeClass("theme_default theme_dark theme_contrast"),$("body").addClass("theme_"+theme)}))}}})); + +//# sourceMappingURL=teamsThemeChecker.min.js.map \ No newline at end of file diff --git a/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js.map b/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js.map new file mode 100644 index 000000000..6c5c5ad66 --- /dev/null +++ b/theme/boost_o365teams/amd/build/teamsThemeChecker.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"teamsThemeChecker.min.js","sources":["../src/teamsThemeChecker.js"],"sourcesContent":["define(['jquery', 'microsoftTeams'], function($, microsoftTeams) {\n return {\n init: function() {\n microsoftTeams.initialize();\n\n microsoftTeams.getContext(function(context) {\n var theme = context.theme;\n $(\"body\").addClass(\"theme_\" + theme);\n });\n\n microsoftTeams.registerOnThemeChangeHandler(function(theme) {\n $(\"body\").removeClass(\"theme_default theme_dark theme_contrast\");\n $(\"body\").addClass(\"theme_\" + theme);\n });\n }\n };\n});\n"],"names":["define","$","microsoftTeams","init","initialize","getContext","context","theme","addClass","registerOnThemeChangeHandler","removeClass"],"mappings":"AAAAA,iDAAO,CAAC,SAAU,mBAAmB,SAASC,EAAGC,sBACtC,CACHC,KAAM,WACFD,eAAeE,aAEfF,eAAeG,YAAW,SAASC,aAC3BC,MAAQD,QAAQC,MACpBN,EAAE,QAAQO,SAAS,SAAWD,UAGlCL,eAAeO,8BAA6B,SAASF,OACjDN,EAAE,QAAQS,YAAY,2CACtBT,EAAE,QAAQO,SAAS,SAAWD"} \ No newline at end of file diff --git a/theme/boost_o365teams/amd/src/iframeChecker.js b/theme/boost_o365teams/amd/src/iframeChecker.js index cb54e3288..d56b39d57 100644 --- a/theme/boost_o365teams/amd/src/iframeChecker.js +++ b/theme/boost_o365teams/amd/src/iframeChecker.js @@ -1,7 +1,7 @@ -define(['jquery'], function ($) { +define(['jquery'], function($) { return { init: function() { - if (in_teams()) { + if (inTeams()) { // In Teams, hide page elements. $('body.drawer-open-left').css('margin-left', '0'); $('div#page').css('margin-top', '0'); @@ -44,7 +44,12 @@ define(['jquery'], function ($) { } }; - function in_teams() { + /** + * Check if the page is being displayed in Microsoft Teams. + * + * @return {boolean} True if the page is being displayed in Microsoft Teams, false otherwise. + */ + function inTeams() { return ((window.location != window.parent.location) || (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent))); - }; + } }); diff --git a/theme/boost_o365teams/amd/src/teamsThemeChecker.js b/theme/boost_o365teams/amd/src/teamsThemeChecker.js index fdc16792e..69871edcb 100644 --- a/theme/boost_o365teams/amd/src/teamsThemeChecker.js +++ b/theme/boost_o365teams/amd/src/teamsThemeChecker.js @@ -1,17 +1,15 @@ -define(['jquery'], function($) { +define(['jquery', 'microsoftTeams'], function($, microsoftTeams) { return { init: function() { microsoftTeams.initialize(); microsoftTeams.getContext(function(context) { - theme = context.theme; + var theme = context.theme; $("body").addClass("theme_" + theme); }); microsoftTeams.registerOnThemeChangeHandler(function(theme) { - $("body").removeClass("theme_default"); - $("body").removeClass("theme_dark"); - $("body").removeClass("theme_contrast"); + $("body").removeClass("theme_default theme_dark theme_contrast"); $("body").addClass("theme_" + theme); }); } diff --git a/theme/boost_o365teams/classes/output/core_renderer.php b/theme/boost_o365teams/classes/output/core_renderer.php index ea2d82fb4..e866b8566 100644 --- a/theme/boost_o365teams/classes/output/core_renderer.php +++ b/theme/boost_o365teams/classes/output/core_renderer.php @@ -17,10 +17,9 @@ namespace theme_boost_o365teams\output; use html_writer; +use moodle_page; use moodle_url; -defined('MOODLE_INTERNAL') || die; - /** * Core Render. * @@ -29,6 +28,22 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class core_renderer extends \theme_boost\output\core_renderer { + /** + * @var \theme_boost\output\core_renderer + */ + protected $output; + + /** + * Constructor. + * + * @param moodle_page $page + * @param string $target + */ + public function __construct(moodle_page $page, $target) { + parent::__construct($page, $target); + $this->output = $this->page->get_renderer('core', null, $target); + } + /** * Return header html. * The header section includes custom content security policy setting, as well as reference to the Microsoft Teams JS lib. @@ -52,12 +67,11 @@ public function standard_head_html() { * @return string */ public function user_link() { - global $USER, $OUTPUT; + global $USER; if (!empty($USER->id)) { - $profilepagelink = new moodle_url('/user/profile.php', ['id' => $USER->id]); - $profilepic = $OUTPUT->user_picture($USER, ['size' => 26, 'link' => false]); + $profilepic = $this->output->user_picture($USER, ['size' => 26, 'link' => false]); $userfullname = fullname($USER); $piclink = html_writer::link($profilepagelink, $profilepic, ['target' => '_blank', 'class' => 'user_details']); $userprofile = html_writer::link($profilepagelink, $userfullname, ['target' => '_blank']); @@ -109,10 +123,10 @@ public function feedback_link() { * @return string */ public function get_footer_stamp() { - global $CFG, $OUTPUT, $PAGE; + global $CFG; - if (!empty($PAGE->theme->setting_file_url('footer_stamp', 'footer_stamp'))) { - $fileurl = $PAGE->theme->setting_file_url('footer_stamp', 'footer_stamp'); + if (!empty($this->page->theme->setting_file_url('footer_stamp', 'footer_stamp'))) { + $fileurl = $this->page->theme->setting_file_url('footer_stamp', 'footer_stamp'); // Get a URL suitable for moodle_url. $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot); $relativefileurl = str_replace($relativebaseurl, '', $fileurl); @@ -122,7 +136,7 @@ public function get_footer_stamp() { $coursepageurl = $this->page->url; $stamp = html_writer::link($coursepageurl, $img, ['target' => '_blank', 'class' => 'stamp']); } else { - $img = html_writer::empty_tag('img', ["src" => $OUTPUT->image_url('moodlelogo', 'theme')]); + $img = html_writer::empty_tag('img', ["src" => $this->output->image_url('moodlelogo', 'theme')]); $coursepageurl = $this->page->url; $stamp = html_writer::link($coursepageurl, $img, ['target' => '_blank', 'class' => 'stamp']); diff --git a/theme/boost_o365teams/classes/privacy/provider.php b/theme/boost_o365teams/classes/privacy/provider.php index d5d74a373..cb3ff8d64 100644 --- a/theme/boost_o365teams/classes/privacy/provider.php +++ b/theme/boost_o365teams/classes/privacy/provider.php @@ -24,7 +24,7 @@ namespace theme_boost_o365teams\privacy; -defined('MOODLE_INTERNAL') || die(); +use core_privacy\local\metadata\null_provider; /** * Privacy Subsystem for theme_boost_o365teams implementing null_provider. @@ -32,7 +32,7 @@ * @copyright 2020 Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class provider implements \core_privacy\local\metadata\null_provider { +class provider implements null_provider { /** * Get the language string identifier with the component's language @@ -40,7 +40,7 @@ class provider implements \core_privacy\local\metadata\null_provider { * * @return string */ - public static function get_reason() : string { + public static function get_reason(): string { return 'privacy:metadata'; } } diff --git a/theme/boost_o365teams/config.php b/theme/boost_o365teams/config.php index ce10e635b..1c0cb8ea3 100644 --- a/theme/boost_o365teams/config.php +++ b/theme/boost_o365teams/config.php @@ -31,7 +31,7 @@ $THEME->editor_sheets = []; $THEME->parents = ['boost']; $THEME->enable_dock = false; -$THEME->yuicssmodules = array(); +$THEME->yuicssmodules = []; $THEME->rendererfactory = 'theme_overridden_renderer_factory'; $THEME->requiredblocks = ''; $THEME->addblockposition = BLOCK_ADDBLOCK_POSITION_FLATNAV; @@ -39,111 +39,111 @@ $THEME->layouts = [ // Most backwards compatible layout without the blocks - this is the layout used by default. - 'base' => array( + 'base' => [ 'file' => 'columns1.php', - 'regions' => array(), - ), + 'regions' => [], + ], // Standard layout with blocks, this is recommended for most pages with general information. - 'standard' => array( + 'standard' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), + ], // Main course page. - 'course' => array( + 'course' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - 'options' => array('langmenu' => true), - ), - 'coursecategory' => array( + 'options' => ['langmenu' => true], + ], + 'coursecategory' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), + ], // Part of course, typical for modules - default page layout if $cm specified in require_login(). - 'incourse' => array( + 'incourse' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), + ], // The site home page. - 'frontpage' => array( + 'frontpage' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - 'options' => array('nonavbar' => true), - ), + 'options' => ['nonavbar' => true], + ], // Server administration scripts. - 'admin' => array( + 'admin' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), + ], // My dashboard page. - 'mydashboard' => array( + 'mydashboard' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - 'options' => array('nonavbar' => true, 'langmenu' => true), - ), + 'options' => ['nonavbar' => true, 'langmenu' => true], + ], // My public page. - 'mypublic' => array( + 'mypublic' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), - 'login' => array( + ], + 'login' => [ 'file' => 'login.php', - 'regions' => array(), - 'options' => array('langmenu' => true), - ), + 'regions' => [], + 'options' => ['langmenu' => true], + ], // Pages that appear in pop-up windows - no navigation, no blocks, no header. - 'popup' => array( + 'popup' => [ 'file' => 'columns1.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nonavbar' => true), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nonavbar' => true], + ], // No blocks and minimal footer - used for legacy frame layouts only! - 'frametop' => array( + 'frametop' => [ 'file' => 'columns1.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nocoursefooter' => true), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nocoursefooter' => true], + ], // Embeded pages, like iframe/object embeded in moodleform - it needs as much space as possible. - 'embedded' => array( + 'embedded' => [ 'file' => 'embedded.php', - 'regions' => array() - ), + 'regions' => [], + ], // Used during upgrade and install, and for the 'This site is undergoing maintenance' message. // This must not have any blocks, links, or API calls that would lead to database or cache interaction. // Please be extremely careful if you are modifying this layout. - 'maintenance' => array( + 'maintenance' => [ 'file' => 'maintenance.php', - 'regions' => array(), - ), + 'regions' => [], + ], // Should display the content and basic headers only. - 'print' => array( + 'print' => [ 'file' => 'columns1.php', - 'regions' => array(), - 'options' => array('nofooter' => true, 'nonavbar' => false), - ), + 'regions' => [], + 'options' => ['nofooter' => true, 'nonavbar' => false], + ], // The pagelayout used when a redirection is occuring. - 'redirect' => array( + 'redirect' => [ 'file' => 'embedded.php', - 'regions' => array(), - ), + 'regions' => [], + ], // The pagelayout used for reports. - 'report' => array( + 'report' => [ 'file' => 'columns2.php', - 'regions' => array('side-pre'), + 'regions' => ['side-pre'], 'defaultregion' => 'side-pre', - ), + ], // The pagelayout used for safebrowser and securewindow. - 'secure' => array( + 'secure' => [ 'file' => 'secure.php', - 'regions' => array('side-pre'), - 'defaultregion' => 'side-pre' - ) + 'regions' => ['side-pre'], + 'defaultregion' => 'side-pre', + ], ]; diff --git a/theme/boost_o365teams/lang/en/theme_boost_o365teams.php b/theme/boost_o365teams/lang/en/theme_boost_o365teams.php index d1b4e424a..4f3460ca0 100644 --- a/theme/boost_o365teams/lang/en/theme_boost_o365teams.php +++ b/theme/boost_o365teams/lang/en/theme_boost_o365teams.php @@ -24,25 +24,21 @@ defined('MOODLE_INTERNAL') || die(); +$string['advancedsettings'] = 'Advanced settings'; $string['choosereadme'] = 'Boost o365teams is a modern highly-customisable theme. This theme is intended to be used directly, or as a parent theme when creating new themes utilising Bootstrap 4.'; +$string['configtitle'] = 'Boost Office365 Teams'; +$string['edit_course'] = 'Edit course in browser window'; +$string['editcourse'] = 'Edit course'; +$string['feedback'] = 'Feedback'; +$string['footer_stamp_desc'] = 'Displays Image or logo at bottom right of tabs.
(Max-Height: 60px)'; +$string['footer_stamp_title'] = 'Tabs Footer Stamp'; +$string['generalsettings'] = 'General settings'; +$string['navigatereturn'] = 'Return to quiz menu'; +$string['open_course'] = 'Open course in browser window'; +$string['placementfrontpage'] = 'Front page'; $string['pluginname'] = 'Boost Office365 Teams'; $string['privacy:metadata'] = 'The Boost Office365 Teams plugin does not store any personal data.'; $string['region-side-pre'] = 'Right'; - -$string['placementfrontpage'] = 'Front page'; -$string['editcourse'] = 'Edit course'; - $string['share_feedback'] = 'Share feedback'; -$string['feedback'] = 'Feedback'; -$string['edit_course'] = 'Edit course in browser window'; -$string['open_course'] = 'Open course in browser window'; - -$string['navigatereturn'] = 'Return to quiz menu'; - -$string['configtitle'] = 'Boost Office365 Teams'; -$string['generalsettings'] = 'General settings'; $string['showteamfeedbacklink'] = 'Show feedback link'; $string['showteamfeedbacklink_desc'] = 'If enabled, a link to leave feedback to Moodle Microsoft 365 integration will be shown when a Moodle tab is opened in Teams.'; -$string['advancedsettings'] = 'Advanced settings'; -$string['footer_stamp_title'] = "Tabs Footer Stamp"; -$string['footer_stamp_desc'] = "Displays Image or logo at bottom right of tabs.
(Max-Height: 60px)"; diff --git a/theme/boost_o365teams/layout/login.php b/theme/boost_o365teams/layout/login.php index 5d7c82d19..b16cc5f00 100644 --- a/theme/boost_o365teams/layout/login.php +++ b/theme/boost_o365teams/layout/login.php @@ -29,7 +29,7 @@ $templatecontext = [ 'sitename' => format_string($SITE->shortname, true, ['context' => context_course::instance(SITEID), "escape" => false]), 'output' => $OUTPUT, - 'bodyattributes' => $bodyattributes + 'bodyattributes' => $bodyattributes, ]; echo $OUTPUT->render_from_template('theme_boost_o365teams/login', $templatecontext); diff --git a/theme/boost_o365teams/lib.php b/theme/boost_o365teams/lib.php index 09c1fce12..1c66dd971 100644 --- a/theme/boost_o365teams/lib.php +++ b/theme/boost_o365teams/lib.php @@ -22,8 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - use theme_boost_o365teams\css_processor; /** @@ -38,7 +36,7 @@ * @param array $options * @return bool */ -function theme_boost_o365teams_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { +function theme_boost_o365teams_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) { static $theme; if (empty($theme)) { diff --git a/theme/boost_o365teams/renderers.php b/theme/boost_o365teams/renderers.php index 912cdd653..c8d12836f 100644 --- a/theme/boost_o365teams/renderers.php +++ b/theme/boost_o365teams/renderers.php @@ -48,7 +48,7 @@ public function render_assign_header(mod_assign\output\assign_header $header) { $this->page->navbar->add($header->subpage, $header->subpageurl); } - $heading = format_string($header->assign->name, false, array('context' => $header->context)); + $heading = format_string($header->assign->name, false, ['context' => $header->context]); $this->page->set_title($heading); $this->page->set_heading($this->page->course->fullname); @@ -65,12 +65,13 @@ public function render_assign_header(mod_assign\output\assign_header $header) { $activityheader = $this->page->activityheader; $activityheader->set_attrs([ 'title' => $activityheader->is_title_allowed() ? $heading : '', - 'description' => $description + 'description' => $description, ]); return $this->output->header(); } } + /** * course * @@ -89,7 +90,7 @@ class theme_boost_o365teams_core_course_renderer extends core_course_renderer { * @param array $displayoptions * @return string */ - public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) { + public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = []) { $output = ''; // We return empty string (because course module will not be displayed at all) if // 1) The activity is not visible to users; and @@ -114,7 +115,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect $output .= course_get_cm_move($mod, $sectionreturn); } - $output .= html_writer::start_tag('div', array('class' => 'mod-indent-outer')); + $output .= html_writer::start_tag('div', ['class' => 'mod-indent-outer']); // This div is used to indent the content. $output .= html_writer::div('', $indentclasses); @@ -149,7 +150,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect if (!empty($cmname)) { // Start the div for the activity title, excluding the edit icons. - $output .= html_writer::start_tag('div', array('class' => 'activityinstance')); + $output .= html_writer::start_tag('div', ['class' => 'activityinstance']); $output .= $cmname; // Module can put text after the link (e.g. forum unread). @@ -176,8 +177,10 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); + return $output; } + /** * Get Section Name * @@ -185,7 +188,7 @@ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sect * @param array $displayoptions * @return string */ - public function course_section_cm_name_title(cm_info $mod, $displayoptions = array()) { + public function course_section_cm_name_title(cm_info $mod, $displayoptions = []) { $output = ''; $url = $mod->url; if (!$mod->is_visible_on_course_page() || !$url) { @@ -200,7 +203,7 @@ public function course_section_cm_name_title(cm_info $mod, $displayoptions = arr // includes the word forum (or Forum, etc) then it is unhelpful // to include that in the accessible description that is added. if (false !== strpos(core_text::strtolower($instancename), - core_text::strtolower($altname))) { + core_text::strtolower($altname))) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). @@ -208,27 +211,29 @@ public function course_section_cm_name_title(cm_info $mod, $displayoptions = arr $altname = get_accesshide(' ' . $altname); } - list($linkclasses, $textclasses) = $this->course_section_cm_classes($mod); + [$linkclasses, $textclasses] = $this->course_section_cm_classes($mod); // Get on-click attribute value if specified and decode the onclick - it // has already been encoded for display (puke). $onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES); // Display link itself. - $activitylink = html_writer::empty_tag('img', array('src' => $mod->get_icon_url(), - 'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) . - html_writer::tag('span', $instancename . $altname, array('class' => 'instancename')) . - html_writer::tag('span', '', array('class' => 'fa fa-external-link popupicon')); + $activitylink = html_writer::empty_tag('img', ['src' => $mod->get_icon_url(), + 'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation']) . + html_writer::tag('span', $instancename . $altname, ['class' => 'instancename']) . + html_writer::tag('span', '', ['class' => 'fa fa-external-link popupicon']); if ($mod->uservisible) { - $output .= html_writer::link($url, $activitylink, array('class' => $linkclasses, 'onclick' => $onclick)); + $output .= html_writer::link($url, $activitylink, ['class' => $linkclasses, 'onclick' => $onclick]); } else { // We may be displaying this just in order to show information // about visibility, without the actual link ($mod->is_visible_on_course_page()). - $output .= html_writer::tag('div', $activitylink, array('class' => $textclasses)); + $output .= html_writer::tag('div', $activitylink, ['class' => $textclasses]); } + return $output; } } + /** * mod_quiz * @@ -251,41 +256,41 @@ public function attempt_form($attemptobj, $page, $slots, $id, $nextpage) { // Start the form. $output .= html_writer::start_tag('form', - array('action' => new moodle_url($attemptobj->processattempt_url(), - array('cmid' => $attemptobj->get_cmid())), 'method' => 'post', - 'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8', - 'id' => 'responseform')); + ['action' => new moodle_url($attemptobj->processattempt_url(), + ['cmid' => $attemptobj->get_cmid()]), 'method' => 'post', + 'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8', + 'id' => 'responseform']); $output .= html_writer::start_tag('div'); // Print all the questions. foreach ($slots as $slot) { $output .= $attemptobj->render_question($slot, false, $this, - $attemptobj->attempt_url($slot, $page), $this); + $attemptobj->attempt_url($slot, $page), $this); } $navmethod = $attemptobj->get_quiz()->navmethod; $output .= $this->attempt_navigation_buttons_with_link($page, $attemptobj->is_last_page($page), $navmethod, - $attemptobj->view_url()); + $attemptobj->view_url()); // Some hidden fields to trach what is going on. - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'attempt', - 'value' => $attemptobj->get_attemptid())); - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'thispage', - 'value' => $page, 'id' => 'followingpage')); - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'nextpage', - 'value' => $nextpage)); - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'timeup', - 'value' => '0', 'id' => 'timeup')); - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', - 'value' => sesskey())); - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scrollpos', - 'value' => '', 'id' => 'scrollpos')); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'attempt', + 'value' => $attemptobj->get_attemptid()]); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'thispage', + 'value' => $page, 'id' => 'followingpage']); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'nextpage', + 'value' => $nextpage]); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'timeup', + 'value' => '0', 'id' => 'timeup']); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', + 'value' => sesskey()]); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'scrollpos', + 'value' => '', 'id' => 'scrollpos']); // Add a hidden field with questionids. Do this at the end of the form, so // if you navigate before the form has finished loading, it does not wipe all // the student's answers. - $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'slots', - 'value' => implode(',', $attemptobj->get_active_slots($page)))); + $output .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'slots', + 'value' => implode(',', $attemptobj->get_active_slots($page))]); // Finish the form. $output .= html_writer::end_tag('div'); @@ -311,27 +316,28 @@ public function attempt_form($attemptobj, $page, $slots, $id, $nextpage) { protected function attempt_navigation_buttons_with_link($page, $lastpage, $navmethod = 'free', $viewurl = null) { $output = ''; - $output .= html_writer::start_tag('div', array('class' => 'submitbtns submitbtns_with_return')); + $output .= html_writer::start_tag('div', ['class' => 'submitbtns submitbtns_with_return']); if ($page > 0 && $navmethod == 'free') { - $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'previous', - 'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary')); + $output .= html_writer::empty_tag('input', ['type' => 'submit', 'name' => 'previous', + 'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav btn btn-secondary']); } if ($lastpage) { $nextlabel = get_string('endtest', 'quiz'); } else { $nextlabel = get_string('navigatenext', 'quiz'); } - $output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next', - 'value' => $nextlabel, 'class' => 'mod_quiz-next-nav btn btn-primary')); + $output .= html_writer::empty_tag('input', ['type' => 'submit', 'name' => 'next', + 'value' => $nextlabel, 'class' => 'mod_quiz-next-nav btn btn-primary']); if ($viewurl) { // Return button. $output .= html_writer::link($viewurl, get_string('navigatereturn', 'theme_boost_o365teams'), - array('class' => 'btn btn-secondary mod_quiz-return-nav')); + ['class' => 'btn btn-secondary mod_quiz-return-nav']); } $output .= html_writer::end_tag('div'); return $output; } + /** * No Question message * @@ -343,7 +349,7 @@ public function no_questions_message($canedit, $editurl) { $output = ''; $output .= $this->notification(get_string('noquestions', 'quiz')); if ($canedit) { - $output .= $this->single_button($editurl, get_string('editquiz', 'quiz'), 'get', array("primary" => true)); + $output .= $this->single_button($editurl, get_string('editquiz', 'quiz'), 'get', ["primary" => true]); } return $output; diff --git a/theme/boost_o365teams/style/custom.css b/theme/boost_o365teams/style/custom.css index 557c64324..01478ac42 100644 --- a/theme/boost_o365teams/style/custom.css +++ b/theme/boost_o365teams/style/custom.css @@ -32,15 +32,19 @@ font-weight: 600; font-style: normal; } + body { - font-family: "Segoe UI","Helvetica Neue","Apple Color Emoji","Segoe UI Emoji",Helvetica,Arial,sans-serif; + font-family: "Segoe UI", "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Helvetica, Arial, sans-serif; } + div.felement select option { - font-family: "Segoe UI","Helvetica Neue","Apple Color Emoji","Segoe UI Emoji",Helvetica,Arial,sans-serif; + font-family: "Segoe UI", "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Helvetica, Arial, sans-serif; } + form .felement input { - font-family: "Segoe UI","Helvetica Neue","Apple Color Emoji","Segoe UI Emoji",Helvetica,Arial,sans-serif; + font-family: "Segoe UI", "Helvetica Neue", "Apple Color Emoji", "Segoe UI Emoji", Helvetica, Arial, sans-serif; } + /* topics format START */ .format-topics.path-course-view .completionprogress { float: left; @@ -69,7 +73,8 @@ form .felement input { .format-topics .availabilityinfo.ishidden { display: none; } -/*topics format END */ +/* topics format END */ + /* weeks format START */ .format-weeks.path-course-view .completionprogress { float: left; @@ -90,7 +95,7 @@ form .felement input { font-size: 1em; } .format-weeks .course-content .current::before { - border: 0px; + border: 0; } .format-weeks .section_availability .ishidden { padding-left: 32px; @@ -99,12 +104,13 @@ form .felement input { display: none; } /* weeks format END */ + /* collapsable topics format START */ .format-collapsibletopics.path-course-view .completionprogress { float: left; } .course-content ul.collapsibletopics li.section ul.section { - padding-left: 0px; + padding-left: 0; } .format-collapsibletopics .section .activity { background-color: #fff; @@ -140,26 +146,17 @@ form .felement input { .format-collapsibletopics .course-content ul.collapsibletopics .sectiontoggle.collapsed ~ .section-summary-activities { padding-left: 20px; } -/*.format-collapsibletopics .course-content ul.collapsibletopics .sectiontoggle ~ .section-summary-activities,*/ -/*.format-collapsibletopics .course-content ul.collapsibletopics .sectiontoggle.collapsed ~ .section-summary-activities{*/ - /*display: none;*/ -/*}*/ .format-collapsibletopics .availabilityinfo.ishidden { display: none; } -/*.format-collapsibletopics .expandall {*/ - /*display: none;*/ -/*}*/ -/*.format-collapsibletopics #completionprogressid {*/ - /*display: none;*/ -/*}*/ /* collapsable topics format END */ + /* collapsable weeks format START */ .format-collapsibleweeks.path-course-view .completionprogress { float: left; } .course-content ul.collapsibleweeks li.section ul.section { - padding-left: 0px; + padding-left: 0; } .format-collapsibleweeks .section .activity { background-color: #fff; @@ -199,20 +196,11 @@ form .felement input { .format-collapsibleweeks .course-content ul.collapsibleweeks .sectiontoggle.collapsed ~ .section-summary-activities { padding-left: 20px; } -/*.format-collapsibleweeks .course-content ul.collapsibleweeks .sectiontoggle ~ .section-summary-activities,*/ -/*.format-collapsibleweeks .course-content ul.collapsibleweeks .sectiontoggle.collapsed ~ .section-summary-activities{*/ -/*display: none;*/ -/*}*/ -/*.format-collapsibleweeks .expandall {*/ -/*display: none;*/ -/*}*/ -/*.format-collapsibleweeks #completionprogressid {*/ -/*display: none;*/ -/*}*/ .format-collapsibleweeks .availabilityinfo.ishidden { display: none; } /* collapsable weeks format END */ + /* multi-page topics format START */ /* main page */ .format-topics .course-content .section-summary { @@ -221,9 +209,6 @@ form .felement input { .format-topics .course-content .topics .section-summary .section-title { margin: 0; } -/*.format-topics .course-content ul.topics .section-summary-activities {*/ - /*display: none;*/ -/*}*/ /* section page */ .format-topics .single-section h3.sectionname { text-align: unset; @@ -244,10 +229,6 @@ form .felement input { .format-weeks .course-content .weeks .section-summary .section-title { margin: 0; } -/*.format-weeks .course-content ul.weeks .section-summary-activities {*/ -/*display: none;*/ -/*}*/ -/* section page */ .format-weeks .single-section h3.sectionname { text-align: unset; font-size: 1em; @@ -262,13 +243,6 @@ form .felement input { #page-course-view-weeks .navigationtitle .mdl-right { display: none; } -/*.format-weeks .course-content .single-section .section-navigation .mdl-right,*/ -/*.format-weeks .course-content .single-section .section-navigation .mdl-left {*/ -/*display:none;*/ -/*}*/ -/*.format-weeks #sectionmenu {*/ -/*display: none;*/ -/*}*/ .format-weeks .availabilityinfo.ishidden { display: none; } @@ -310,26 +284,25 @@ body .back_course_main { text-decoration: none; } -@media (max-width:800px) { +@media (max-width: 800px) { body #course_page_title { font-size: 21px; } } -@media (max-width:640px) { +@media (max-width: 640px) { body #course_page_title { font-size: 17px; } } -@media (max-width:550px) { +@media (max-width: 550px) { body #course_page_title { font-size: 16px; } } /* header END */ - /* Section page START */ .section-summary-activities { text-align: left; @@ -337,7 +310,6 @@ body .back_course_main { } /* Section page END */ - /*!* all course formats START *!*/ .card-body { background-color: #f3f2f1; @@ -400,7 +372,7 @@ body.theme_contrast { padding-right: 15px; } .form-group div[data-fieldtype="filemanager"] { - padding-right: 0px; + padding-right: 0; } .course-content ul li.section.main { @@ -411,8 +383,8 @@ body.theme_contrast { } .row { - margin-right: 0px; - margin-left: 0px; + margin-right: 0; + margin-left: 0; } a, @@ -423,7 +395,7 @@ a, color: #6264a7; } .theme_contrast a { - color: #ffff00; + color: #ff0; } /* course body END */ @@ -471,7 +443,7 @@ a, color: gold; height: 60px; position: fixed; - bottom: 0px; + bottom: 0; background-color: #f3f2f1; padding-top: 10px; padding-bottom: 10px; @@ -510,19 +482,19 @@ a.feedbacklink { color: #c8c6c4; } .theme_contrast a.feedbacklink { - color: #ffff00; + color: #ff0; } .fa-lightbulb-o { - font-family: "FontAwesome" !important; - font-size: 15px !important; - border-radius: 5px !important; + font-family: "FontAwesome"; + font-size: 15px; + border-radius: 5px; } .fa-lightbulb-o:before { padding: 5px; } /* footer END */ -/* popup icon START */ +/* popup icon START */ .modtype_assign .popupicon, .modtype_quiz .popupicon { display: none; @@ -540,11 +512,11 @@ button { letter-spacing: normal; word-spacing: normal; text-transform: none; - text-indent: 0px; + text-indent: 0; text-shadow: none; display: inline-block; text-align: start; - margin: 0em; + margin: 0; font: 400 13.3333px Arial; } @@ -563,8 +535,8 @@ button { min-width: 6rem; padding: 0.25rem; white-space: nowrap; - -webkit-box-shadow: unset !important; - box-shadow: unset !important; + -webkit-box-shadow: unset; + box-shadow: unset; } /* secondary button :active*/ .btn-secondary:not(:disabled):not(.disabled):active { @@ -575,7 +547,7 @@ button { /* secondary button :hover*/ .btn-secondary:hover, .btn-secondary:focus:enabled { - background: rgb(200,200,200); + background: rgb(200, 200, 200); border-color: transparent; color: #000; } @@ -619,8 +591,8 @@ div.disabled .btn-secondary { min-width: 6rem; padding: 0.25rem; white-space: nowrap; - -webkit-box-shadow: unset !important; - box-shadow: unset !important; + -webkit-box-shadow: unset; + box-shadow: unset; color: #fff; } /* primary button :active*/ @@ -631,17 +603,15 @@ div.disabled .btn-secondary { color: #201f1f; } /* primary button :hover*/ -.btn-primary:hover, .btn-primary:focus:enabled, -.btn-default:hover, .btn-default:focus:enabled { +.btn-primary:hover, +.btn-primary:focus:enabled, +.btn-default:hover, +.btn-default:focus:enabled { background: #464775; border-color: transparent; color: #fff; } /* primary button :focus*/ -.btn-primary:focus, .btn-primary:focus:enabled, -.btn-default:focus, .btn-default:focus:enabled { -} - body { display: none; } @@ -689,7 +659,7 @@ ul { content: none; } #page-wrapper { - margin-bottom: 50px !important; + margin-bottom: 50px; } /*!* modules START *!*/ @@ -701,9 +671,6 @@ ul { #prev-activity-link { margin-left: 33px; } -/*.editsubmissionform .col-md-3 {*/ -/*display: none;*/ -/*}*/ .editsubmissionform .form-group { margin-left: -15px; } @@ -752,7 +719,6 @@ table#permissions tbody tr:hover { } /* Assignment Module END */ - /* Quiz Module START */ #page-mod-quiz-attempt .card div[role="main"], #page-mod-quiz-view .card div[role="main"] { @@ -762,20 +728,9 @@ table#permissions tbody tr:hover { display: inline-block; margin-left: 3px; } -/* Quiz Module END */ -/*!* modules END *!*/ - - -.m-t-2, .m-b-1 { - padding-top: 25px; -} - -.section .activity .availabilityinfo, .section .activity .contentafterlink { - padding-right: 30px; -} .submitbtns_with_return { - text-align: center !important; + text-align: center; } .mod_quiz-prev-nav { @@ -785,3 +740,15 @@ table#permissions tbody tr:hover { .mod_quiz-return-nav { margin: 0 auto; } +/* Quiz Module END */ +/*!* modules END *!*/ + +.m-t-2, +.m-b-1 { + padding-top: 25px; +} + +.section .activity .availabilityinfo, +.section .activity .contentafterlink { + padding-right: 30px; +} diff --git a/theme/boost_o365teams/templates/columns2.mustache b/theme/boost_o365teams/templates/columns2.mustache index bdcbf43f8..8356133ae 100644 --- a/theme/boost_o365teams/templates/columns2.mustache +++ b/theme/boost_o365teams/templates/columns2.mustache @@ -50,7 +50,7 @@ "hasregionmainsettingsmenu": false } }} -{{> theme_boost/head }} +{{> theme_boost_o365teams/head }} @@ -65,9 +65,9 @@
{{#hasregionmainsettingsmenu}} -
-
{{{ output.region_main_settings_menu }}}
-
+
+
{{{ output.region_main_settings_menu }}}
+
{{/hasregionmainsettingsmenu}}
@@ -76,21 +76,21 @@
{{/hasregionmainsettingsmenu}} {{#is_course_overview}} - {{{ output.course_content_header }}} - - - + {{{ output.course_content_header }}} + {{/is_course_overview}} {{^is_course_overview}} - {{{ output.course_content_header }}} - - - + {{{ output.course_content_header }}} + {{/is_course_overview}} {{{ output.main_content }}} {{{ output.activity_navigation }}} @@ -99,9 +99,9 @@
{{#hasblocks}} -
- {{{ sidepreblocks }}} -
+
+ {{{ sidepreblocks }}} +
{{/hasblocks}}
@@ -124,14 +124,14 @@ {{#js}} -require(['theme_boost/loader']); -require(['theme_boost/drawer'], function(mod) { + require(['theme_boost/loader']); + require(['theme_boost/drawer'], function(mod) { mod.init(); -}); -require(['theme_boost_o365teams/iframeChecker'], function(iframeChecker) { + }); + require(['theme_boost_o365teams/iframeChecker'], function(iframeChecker) { iframeChecker.init(); -}); -require(['theme_boost_o365teams/teamsThemeChecker'], function(teamsThemeChecker) { + }); + require(['theme_boost_o365teams/teamsThemeChecker'], function(teamsThemeChecker) { teamsThemeChecker.init(); -}); + }); {{/js}} diff --git a/theme/boost_o365teams/templates/head.mustache b/theme/boost_o365teams/templates/head.mustache new file mode 100644 index 000000000..c6401dc85 --- /dev/null +++ b/theme/boost_o365teams/templates/head.mustache @@ -0,0 +1,46 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template theme_boost_o365teams/head + + Page header. + + Example context (json): + { + "output": { + "doctype": "", + "page_title": "Test page", + "favicon": "favicon.ico", + "standard_head_html": "" + } + } +}} +{{{ output.doctype }}} + + + {{{ output.page_title }}} + + {{{ output.standard_head_html }}} + + + + + \ No newline at end of file diff --git a/theme/boost_o365teams/templates/login.mustache b/theme/boost_o365teams/templates/login.mustache index 6c9fe6a30..ac821f1bb 100644 --- a/theme/boost_o365teams/templates/login.mustache +++ b/theme/boost_o365teams/templates/login.mustache @@ -29,14 +29,7 @@ } } }} -{{> theme_boost/head }} - - - +{{> theme_boost_o365teams/head }}