Skip to content

Commit

Permalink
Course completion status
Browse files Browse the repository at this point in the history
  • Loading branch information
nelkasovic committed Sep 7, 2021
1 parent d80449b commit 2cef474
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Facades/MoodleCourse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = [])
Expand Down
10 changes: 10 additions & 0 deletions src/Resources/CourseCompletionResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Wimando\LaravelMoodle\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class CourseCompletionResource extends JsonResource
{

}
10 changes: 10 additions & 0 deletions src/Resources/CourseCompletionResourceCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Wimando\LaravelMoodle\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class CourseCompletionResourceCollection extends ResourceCollection
{

}
13 changes: 13 additions & 0 deletions src/Services/CourseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Wimando\LaravelMoodle\Services;

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;
Expand Down Expand Up @@ -38,6 +39,18 @@ public function getCourseGroups(int $moodleCourseId): GroupResourceCollection
return GroupResourceCollection::make($response);
}

public function getCourseCompletionStatus(int $moodleCourseId, int $moodleUserId): CourseCompletionResource
{
$arguments = [
'courseid' => $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(
Expand Down
1 change: 1 addition & 0 deletions src/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2cef474

Please sign in to comment.