diff --git a/Readme.md b/Readme.md index 3344a2a..83d5c7f 100644 --- a/Readme.md +++ b/Readme.md @@ -27,7 +27,7 @@ It has the standard Moodle Capability-Checks built-in, so there are no extra cap * Log in as the selected user ## Prerequisites -* This version is tested on Moodle 4.0, 4.1, 4.2, 4.3 (branch master and moodle_4_dev, without a link in navigation), 3.10, 3.11 (branch 310) +* This version is tested on Moodle 4.0, 4.1, 4.2, 4.3, 4.4 (branch master and moodle_4_dev, without a link in navigation), 3.10, 3.11 (branch 310) * For Moodle 3.9 and older use v1.03 * It is highly recommended to activate compression to reduce transmitted data (e.g. from 4.36MB to 1.05 MB) * Add "zlib.output_compression = On" in php.ini diff --git a/classes/external.php b/classes/external.php index 69da7a0..be2c740 100644 --- a/classes/external.php +++ b/classes/external.php @@ -56,14 +56,14 @@ class external extends external_api { public static function create_new_course_parameters() { return new external_function_parameters( [ - 'shortname' => new external_value(PARAM_TEXT, 'The short name of the course to be created'), - 'fullname' => new external_value(PARAM_TEXT, 'The full name of the course to be created'), - 'visible' => new external_value(PARAM_BOOL, 'Toggles visibility of course'), - 'categoryid' => new external_value(PARAM_INT, 'ID of category the course should be created in'), - 'activateselfenrol' => new external_value(PARAM_BOOL, 'Toggles if self_enrolment should be activated'), - 'selfenrolpassword' => new external_value(PARAM_TEXT, 'Password of self enrolment'), - 'startdate' => new external_value(PARAM_TEXT, 'Course start date'), - 'enddate' => new external_value(PARAM_TEXT, 'Course end date'), + 'shortname' => new external_value(PARAM_TEXT, 'The short name of the course to be created'), + 'fullname' => new external_value(PARAM_TEXT, 'The full name of the course to be created'), + 'visible' => new external_value(PARAM_BOOL, 'Toggles visibility of course'), + 'categoryid' => new external_value(PARAM_INT, 'ID of category the course should be created in'), + 'activateselfenrol' => new external_value(PARAM_BOOL, 'Toggles if self_enrolment should be activated'), + 'selfenrolpassword' => new external_value(PARAM_TEXT, 'Password of self enrolment'), + 'startdate' => new external_value(PARAM_TEXT, 'Course start date'), + 'enddate' => new external_value(PARAM_TEXT, 'Course end date'), ] ); } @@ -418,7 +418,7 @@ public static function get_user_information($userid) { $context = \context_system::instance(); if (\has_capability('moodle/user:loginas', $context)) { $link = $CFG->wwwroot . "/course/loginas.php?id=1&user=" . $data['userinformation']['id'] . "&sesskey=" - . $USER->sesskey; + . $USER->sesskey; $data['loginaslink'] = $link; } else { $data['loginaslink'] = false; @@ -909,7 +909,7 @@ public static function get_course_info($courseid) { // Get information about the course. $select = "SELECT c.id, c.shortname, c.fullname, c.visible, c.timecreated, c.startdate, cat.path FROM {course} c, " . - "{course_categories} cat WHERE c.category = cat.id AND c.id = " . $courseid; + "{course_categories} cat WHERE c.category = cat.id AND c.id = " . $courseid; $coursedetails = $DB->get_record_sql($select); $coursedetails = (array)$coursedetails; if ($coursedetails['timecreated'] == 0) { @@ -1117,8 +1117,8 @@ public static function get_course_info_returns() { 'rolesincourse' => new external_multiple_structure(new external_value(PARAM_TEXT, 'array with roles used in course')), 'roles' => new external_multiple_structure( new external_single_structure([ - 'roleName' => new external_value(PARAM_RAW, 'name of one role in course'), - 'roleNumber' => new external_value(PARAM_INT, 'number of participants with role = roleName'), + 'roleName' => new external_value(PARAM_RAW, 'name of one role in course'), + 'roleNumber' => new external_value(PARAM_INT, 'number of participants with role = roleName'), ]) ), 'users' => new external_multiple_structure( @@ -1132,20 +1132,20 @@ public static function get_course_info_returns() { 'enrol_id' => new external_value(PARAM_INT, 'id of user enrolment to course'), ]) ), - 'activities' => new external_multiple_structure( - new external_single_structure([ + 'activities' => new external_multiple_structure( + new external_single_structure([ 'section' => new external_value(PARAM_RAW, 'Name of section, in which the activity appears'), 'activity' => new external_value(PARAM_RAW, 'kind of activity'), 'name' => new external_value(PARAM_RAW, 'Name of this activity'), 'visible' => new external_value(PARAM_INT, 'Is the activity visible? 1: yes, 0: no'), - ]) - ), - 'links' => new external_single_structure([ - 'settingslink' => new external_value(PARAM_RAW, 'link to the settings of the course'), - 'deletelink' => new external_value(PARAM_RAW, 'link to delete the course if allowed, ' - . 'additional affirmation needed afterwards', VALUE_OPTIONAL), - 'courselink' => new external_value(PARAM_RAW, 'link to the course'), - ]), + ]) + ), + 'links' => new external_single_structure([ + 'settingslink' => new external_value(PARAM_RAW, 'link to the settings of the course'), + 'deletelink' => new external_value(PARAM_RAW, 'link to delete the course if allowed, ' + . 'additional affirmation needed afterwards', VALUE_OPTIONAL), + 'courselink' => new external_value(PARAM_RAW, 'link to the course'), + ]), 'enrolmentMethods' => new external_multiple_structure( new external_single_structure([ 'methodname' => new external_value(PARAM_TEXT, 'Name of the enrolment method'), @@ -1154,8 +1154,8 @@ public static function get_course_info_returns() { 'password' => new external_value(PARAM_TEXT, 'Password for enrolment method'), ]) ), - 'isallowedtoupdatecourse' => new external_value(PARAM_BOOL, "Is the user allowed to update the course globally?"), - 'wwwroot' => new external_value(PARAM_TEXT, "Root URL of this moodle instance"), + 'isallowedtoupdatecourse' => new external_value(PARAM_BOOL, "Is the user allowed to update the course globally?"), + 'wwwroot' => new external_value(PARAM_TEXT, "Root URL of this moodle instance"), ]); } @@ -1222,7 +1222,7 @@ public static function get_assignable_roles($courseid) { } $data = [ - 'assignableRoles' => (array)$arrayofroles, + 'assignableRoles' => (array)$arrayofroles, ]; return $data; @@ -1376,7 +1376,6 @@ public static function duplicate_course_parameters() { * @throws invalid_parameter_exception */ public static function duplicate_course($courseid) { - // TODO // Check parameters. $params = self::validate_parameters(self::duplicate_course_parameters(), ['courseid' => $courseid]); $courseid = $params['courseid']; @@ -1394,15 +1393,15 @@ public static function duplicate_course($courseid) { $newshortname = $oldcourse["shortname"] . " - duplicated" . rand(0, 1000); // Add random number to avoid shortnametaken. $options = [ - ['name' => 'activities', 'value' => 1], - ['name' => 'blocks', 'value' => 1], - ['name' => 'filters', 'value' => 1], - ['name' => 'users', 'value' => 0], - ['name' => 'role_assignments', 'value' => 0], - ['name' => 'comments', 'value' => 0], - ['name' => 'userscompletion', 'value' => 0], - ['name' => 'logs', 'value' => 0], - ['name' => 'grade_histories', 'value' => 0], + ['name' => 'activities', 'value' => 1], + ['name' => 'blocks', 'value' => 1], + ['name' => 'filters', 'value' => 1], + ['name' => 'users', 'value' => 0], + ['name' => 'role_assignments', 'value' => 0], + ['name' => 'comments', 'value' => 0], + ['name' => 'userscompletion', 'value' => 0], + ['name' => 'logs', 'value' => 0], + ['name' => 'grade_histories', 'value' => 0], ]; $newcourse = \core_course_external::duplicate_course( diff --git a/lang/en/tool_supporter.php b/lang/en/tool_supporter.php index f782af6..3b9c086 100644 --- a/lang/en/tool_supporter.php +++ b/lang/en/tool_supporter.php @@ -21,52 +21,42 @@ * @copyright 2019 Benedikt Schneider, Klara Saary * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['toolsupporter'] = 'toolsupporter'; - +$string['beingduplicated'] = "The course is being duplicated. This may take a while."; +$string['enable_selfenrolment'] = 'Activate self enrolment and set password'; +$string['level'] = 'Level'; $string['pagetitle'] = 'Moodle-Supporter'; -$string['pluginname'] = 'Supporter'; $string['plugincategory'] = 'Supporter'; -$string['level'] = 'Level'; -$string['enable_selfenrolment'] = 'Activate self enrolment and set password'; - -$string['beingduplicated'] = "The course is being duplicated. This may take a while."; - -$string['searchcourses'] = 'Search'; +$string['pluginname'] = 'Supporter'; +$string['privacy:metadata'] = 'This plugin does not save user-specific data, only global settings.'; $string['refreshcourses'] = 'Refresh'; -$string['searchusers'] = 'Search'; $string['refreshusers'] = 'Refresh'; - -// Strings for setting page - settings.php. -$string['sett_title'] = 'Supporter configuration'; -$string['sett_levels'] = 'Labeling of course category levels'; +$string['searchcourses'] = 'Search'; +$string['searchusers'] = 'Search'; +$string['sett_course_detail_showrolesandamount'] = 'Show all roles and their amount'; +$string['sett_course_detail_showrolesandamount_desc'] = 'Explicitly shows all roles and their amounts in a seperate table row per role, i.e. amount of teachers, amount of students, etc.'; +$string['sett_course_details'] = 'Course details'; +$string['sett_course_details_desc'] = 'The course details are shown in the top left when a course is clicked.'; +$string['sett_course_table'] = 'Course table'; +$string['sett_course_table_desc'] = 'The course table lists all courses and is displayed in the bottom left.'; +$string['sett_course_table_pagelength'] = 'The amount of courses shown'; $string['sett_enable_lvl_1'] = 'Enable Level 1'; $string['sett_enable_lvl_2'] = 'Enable Level 2'; $string['sett_enable_lvl_3'] = 'Enable Level 3'; $string['sett_enable_lvl_4'] = 'Enable Level 4'; $string['sett_enable_lvl_5'] = 'Enable Level 5'; +$string['sett_levels'] = 'Labeling of course category levels'; $string['sett_levels_default'] = 'L1;L2;L3;L4;L5'; $string['sett_levels_description'] = 'Specify the displayed names of the course levels. In descending order (uppermost level first) and separated by semicolon. '; - -$string['sett_course_table'] = 'Course table'; -$string['sett_user_table'] = 'User table'; -$string['sett_user_details'] = 'User details'; -$string['sett_course_details'] = 'Course details'; - -$string['sett_course_table_desc'] = 'The course table lists all courses and is displayed in the bottom left.'; -$string['sett_course_table_pagelength'] = 'The amount of courses shown'; -$string['sett_user_table_desc'] = 'The user table lists all users and is displayed in the bottom right.'; -$string['sett_user_table_pagelength'] = 'The amount of user-courses shown'; -$string['sett_sort_course_table'] = 'Sorting of the ID-Column in course table'; +$string['sett_never'] = 'never'; $string['sett_sort_course_details'] = 'Sorting of the ID-Column in course view (enrolled users)'; -$string['sett_sort_user_table'] = 'Sorting of the ID-Column in user table'; +$string['sett_sort_course_table'] = 'Sorting of the ID-Column in course table'; $string['sett_sort_user_details'] = 'Sorting of the ID-Column in user view (enrolled courses)'; +$string['sett_sort_user_table'] = 'Sorting of the ID-Column in user table'; +$string['sett_title'] = 'Supporter configuration'; +$string['sett_user_details'] = 'User details'; $string['sett_user_details_desc'] = 'The user details are shown in the top right when a user is clicked.'; -$string['sett_course_details_desc'] = 'The course details are shown in the top left when a course is clicked.'; -$string['sett_course_detail_showrolesandamount'] = 'Show all roles and their amount'; -$string['sett_course_detail_showrolesandamount_desc'] = 'Explicitly shows all roles and their amounts in a seperate table row per role, i.e. amount of teachers, amount of students, etc.'; - -$string['sett_never'] = 'never'; +$string['sett_user_table'] = 'User table'; +$string['sett_user_table_desc'] = 'The user table lists all users and is displayed in the bottom right.'; +$string['sett_user_table_pagelength'] = 'The amount of user-courses shown'; $string['strftimesecondsdatetimeshort'] = '%d/%m/%Y, %H:%M:%S'; - -// Privacy API. -$string['privacy:metadata'] = 'This plugin does not save user-specific data, only global settings.'; +$string['toolsupporter'] = 'toolsupporter'; diff --git a/settings.php b/settings.php index 2635a1a..c67fdee 100644 --- a/settings.php +++ b/settings.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Navigation and settings definitions. * diff --git a/version.php b/version.php index 30b2c99..a3cf590 100644 --- a/version.php +++ b/version.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Plugin version info * @@ -21,8 +22,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023121300; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024082000; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2022041900; // Requires Moodle version 4.0 or higher. $plugin->component = 'tool_supporter'; // Full name of the plugin (used for diagnostics). -$plugin->release = 'v4-r3'; +$plugin->release = 'v4-r4'; $plugin->maturity = MATURITY_STABLE;