From 2cef4744bc442522b873efb251665bf8277cc2e9 Mon Sep 17 00:00:00 2001 From: Nermin Elkasovic Date: Tue, 7 Sep 2021 16:22:41 +0200 Subject: [PATCH] Course completion status --- src/Facades/MoodleCourse.php | 2 ++ src/Resources/CourseCompletionResource.php | 10 ++++++++++ .../CourseCompletionResourceCollection.php | 10 ++++++++++ src/Services/CourseService.php | 13 +++++++++++++ src/Services/UserService.php | 1 + 5 files changed, 36 insertions(+) create mode 100644 src/Resources/CourseCompletionResource.php create mode 100644 src/Resources/CourseCompletionResourceCollection.php diff --git a/src/Facades/MoodleCourse.php b/src/Facades/MoodleCourse.php index a430d0e..a4f0907 100644 --- a/src/Facades/MoodleCourse.php +++ b/src/Facades/MoodleCourse.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Facade; use Wimando\LaravelMoodle\Clients\ClientAdapterInterface; use Wimando\LaravelMoodle\Entities\Dto\Course as CourseDto; +use Wimando\LaravelMoodle\Resources\CourseCompletionResource; use Wimando\LaravelMoodle\Resources\CourseResourceCollection; use Wimando\LaravelMoodle\Resources\EnrolmentMethodResourceCollection; use Wimando\LaravelMoodle\Resources\GroupResourceCollection; @@ -15,6 +16,7 @@ * @method static CourseResourceCollection getAll(array $ids = []) * @method static CourseResourceCollection getByField(string $field, string $value) * @method static GroupResourceCollection getCourseGroups(int $moodleCourseId) + * @method static CourseCompletionResource getCourseCompletionStatus(int $moodleCourseId, int $moodleUserId) * @method static CourseResourceCollection create(CourseDto ...$courses) * @method static EnrolmentMethodResourceCollection getEnrolmentMethods(int $moodleCourseId) * @method static mixed delete(array $ids = []) diff --git a/src/Resources/CourseCompletionResource.php b/src/Resources/CourseCompletionResource.php new file mode 100644 index 0000000..71c56fc --- /dev/null +++ b/src/Resources/CourseCompletionResource.php @@ -0,0 +1,10 @@ + $moodleCourseId, + 'userid' => $moodleUserId, + ]; + + $response = $this->sendRequest('core_completion_get_course_completion_status', $arguments); + + return CourseCompletionResource::make($response); + } + public function create(CourseDto ...$courses): CourseResourceCollection { $response = $this->sendRequest( diff --git a/src/Services/UserService.php b/src/Services/UserService.php index 8482e21..d196bc4 100644 --- a/src/Services/UserService.php +++ b/src/Services/UserService.php @@ -7,6 +7,7 @@ class UserService extends Service { /** + * Example: search(['key' => 'email', 'value' => '%email.com']); * Search for a user by providing key (column) and value. Values can not be empty. * Specify different keys only once (fullname => 'user1', auth => 'manual', ...) - * The search is executed with AND operator on the criterias. Invalid criterias (keys) are ignored,