From 6b8a5f0964f0654c4aca40f287c84dd1581d1408 Mon Sep 17 00:00:00 2001 From: Markus Heck Date: Tue, 9 Jul 2024 16:34:15 +0200 Subject: [PATCH] minor improvements/cleanups/fixes --- classes/external/upload_course.php | 16 +++++--- composer.json | 3 +- dev_utils/backup_test_course.php | 1 + test.plantuml | 60 ------------------------------ test2.plantuml | 1 - version.php | 4 +- 6 files changed, 14 insertions(+), 71 deletions(-) delete mode 100644 test.plantuml delete mode 100644 test2.plantuml diff --git a/classes/external/upload_course.php b/classes/external/upload_course.php index 4cee852..43643a0 100644 --- a/classes/external/upload_course.php +++ b/classes/external/upload_course.php @@ -10,7 +10,7 @@ use backup; use context_coursecat; use core_course_category; -use Exception; +use dml_exception; use external_api; use external_function_parameters; use external_single_structure; @@ -18,6 +18,7 @@ use invalid_parameter_exception; use local_adler\local\exceptions\not_an_adler_course_exception; use moodle_exception; +use required_capability_exception; use restore_controller; use restore_controller_exception; use restore_dbops; @@ -27,7 +28,7 @@ class upload_course extends external_api { public static function execute_parameters(): external_function_parameters { return new external_function_parameters( array( - 'category_id' => new external_value(PARAM_INT, 'ID of the category in which the course should be created. If null, the course will be created in the category with the lowest available ID. Please note that even if a user has restore permissions for a category other than the one with the lowest ID, the course restoration process will not be successful.', VALUE_DEFAULT, null), + 'category_id' => new external_value(PARAM_INT, 'ID of the category in which the course should be created. If null, the course will be created in the first category the user is allowed to create a course in.', VALUE_DEFAULT, null), 'only_check_permissions' => new external_value(PARAM_BOOL, 'Check only if user has the permissions for restore. No mbz needed. Will return generic data for course name and id.', VALUE_DEFAULT, false), 'mbz' => new external_value(PARAM_FILE, 'Required (moodle tag "optional" is due to moodle limitations), except if only_check_permissions is true. MBZ as file upload. Upload the file in this field. Moodle external_api wont recognize it / this field will be empty but it can be loaded from this field via plain PHP code.', VALUE_DEFAULT, null), ) @@ -46,14 +47,17 @@ public static function execute_returns(): external_function_parameters { } /** - * @param int $category_id ID of the category the course should be restored in + * @param int|null $category_id ID of the category the course should be restored in + * @param bool $only_check_permissions + * @return array + * @throws dml_exception + * @throws required_capability_exception * @throws invalid_parameter_exception + * @throws moodle_exception * @throws not_an_adler_course_exception * @throws restore_controller_exception - * @throws moodle_exception - * @throws Exception */ - public static function execute(int $category_id=null, $only_check_permissions=false): array { + public static function execute(int $category_id=null, bool $only_check_permissions=false): array { global $USER; // param validation except mbz diff --git a/composer.json b/composer.json index c3dc868..e01c76c 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { "name": "projekt-adler/local_adler", "description": "Main plugin for the Adler project", - "require": {}, "require-dev": { "mockery/mockery": "^1.5.1" } -} \ No newline at end of file +} diff --git a/dev_utils/backup_test_course.php b/dev_utils/backup_test_course.php index 979cb29..04d61bc 100644 --- a/dev_utils/backup_test_course.php +++ b/dev_utils/backup_test_course.php @@ -21,6 +21,7 @@ $file = reset($file); $filepath = $file->get_contenthash(); $filepath = $CFG->dataroot . '/filedir/' . substr($filepath, 0, 2) . '/' . substr($filepath, 2, 2) . '/' . $filepath; +// $this->bc->get_results()['backup_destination']->copy_content_to_temp() echo "Backup file path:\n"; echo $filepath . "\n"; diff --git a/test.plantuml b/test.plantuml deleted file mode 100644 index 87c3372..0000000 --- a/test.plantuml +++ /dev/null @@ -1,60 +0,0 @@ -@startuml - -!define classdiagram -skinparam classAttributeIconSize 0 - -namespace local_adler { - class adler_score { - -course_module: object - -user_id: int - #score_item: stdClass - #helpers: string - #completion_info: string - #adler_score_helpers: string - - +__construct(course_module: object, user_id: int = null) - +get_cmid(): int - +get_score(): float - -get_h5p_score(): float - -get_primitive_score(): float - -calculate_score(max_score: float, percentage_achieved: float): float - -calculate_percentage_achieved(value: float, max: float, min: float = 0): float - } - - class helpers { - +get_course_from_course_id(course_id: int) - +delete_adler_course_record(course_id: int) - +course_is_adler_course(course_id: int): bool - +is_primitive_learning_element(course_module: object): bool - } -} - -class completion_info { -} - -class context_course { -} - -class dml_exception { -} - -class user_not_enrolled_exception { -} - -class moodle_exception { -} - -class stdClass { -} - -adler_score ..> helpers: <> -adler_score ..> completion_info: <> -adler_score ..> adler_score_helpers: <> - -adler_score .. context_course: <> -adler_score ..> dml_exception: <> -adler_score ..> user_not_enrolled_exception: <> -adler_score ..> moodle_exception: <> -adler_score -- stdClass: <> - -@enduml diff --git a/test2.plantuml b/test2.plantuml deleted file mode 100644 index 38466d9..0000000 --- a/test2.plantuml +++ /dev/null @@ -1 +0,0 @@ -@startuml diff --git a/version.php b/version.php index 13de99a..305d49e 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ $plugin->version = 2024060300; $plugin->requires = 2022112800; // Moodle version $plugin->component = 'local_adler'; -$plugin->release = '3.2.0'; -$plugin->maturity = MATURITY_STABLE; +$plugin->release = '3.2.0-dev'; +$plugin->maturity = MATURITY_ALPHA; $plugin->dependencies = array( 'local_logging' => ANY_VERSION, ); \ No newline at end of file