Skip to content

Commit

Permalink
add some log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Glutamat42 committed Apr 5, 2024
1 parent 511f9bd commit 7950910
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions classes/local/course_category_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use invalid_parameter_exception;
use local_adler\local\db\moodle_core_repository;
use local_adler\moodle_core;
use local_logging\logger;
use moodle_exception;

class course_category_manager {
Expand Down Expand Up @@ -60,9 +61,12 @@ public static function create_category_user_can_create_courses_in(string $userna
*/
private static function assign_user_to_role_in_category(string $username, int $role_id, int $category_id): void {
$moodle_core_repository = new moodle_core_repository();
$logger = new logger('local_adler', 'course_category_manager');

$user_id = $moodle_core_repository->get_user_id_by_username($username);
$context = moodle_core::context_coursecat_instance($category_id);

$logger->info("Assigning user with ID {$user_id} to role with ID {$role_id} in category with ID {$category_id}");
moodle_core::role_assign($role_id, $user_id, $context->id);
}
}

0 comments on commit 7950910

Please sign in to comment.