-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProgressConfigurable.php
37 lines (33 loc) · 1.04 KB
/
ProgressConfigurable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace EscolaLms\Courses\Tests;
use EscolaLms\Core\Models\User;
use EscolaLms\Courses\Enum\ProgressStatus;
use EscolaLms\Courses\Models\Course;
use EscolaLms\Courses\ValueObjects\CourseProgressCollection;
trait ProgressConfigurable
{
/**
* @param Course $course
* @param int $status
* @return array
*/
private function getProgressUpdate(Course $course, int $status = ProgressStatus::COMPLETE): array
{
$progress = [];
foreach ($course->lessons as $lesson) {
foreach ($lesson->topics as $topic) {
$progress[] = [
'topic_id' => $topic->getKey(),
'status' => $status
];
}
}
return $progress;
}
private function progressUpdate(Course $course, User $user, int $status = ProgressStatus::COMPLETE): CourseProgressCollection
{
return CourseProgressCollection::make($user, $course)
->start()
->setProgress($this->getProgressUpdate($course, $status));
}
}