Skip to content
Snippets Groups Projects

Issue #3309362: Cover API endpoints for checklists & progress saving with automated tests

Merged Issue #3309362: Cover API endpoints for checklists & progress saving with automated tests
5 unresolved threads
5 unresolved threads
Files
3
+ 6
2
@@ -156,7 +156,9 @@ class CourseProgress {
@@ -156,7 +156,9 @@ class CourseProgress {
*/
*/
public function getCompletedLessons(NodeInterface $course): array {
public function getCompletedLessons(NodeInterface $course): array {
return array_filter(
return array_filter(
$this->course->getLessons($course),
array_map(function (NodeInterface $lesson) {
    • How does this work? If you return only lesson IDs, then array_filter will not be able to call ->isCompleted() on the lesson ID.

      • getLessons returns exactly node objects, not ids. This function were not used anywhere in the code (since some moment) and that's a reason why you didn't detect it before. But I decided that I could use it for tests.

      • I think this is misleading now. The method says "get completed lessons", not "get completed lesson ids". Also, bare in mind that someone else might be using this method in their code - we can't just provide breaking changes for no real reason. Please, either move your code to another method with the appropriate name or use this method in your tests and get only IDs there.

      • Please register or sign in to reply
Please register or sign in to reply
 
return $lesson->id();
 
}, $this->course->getLessons($course)),
[$this->lesson, 'isCompleted']
[$this->lesson, 'isCompleted']
);
);
}
}
@@ -172,7 +174,9 @@ class CourseProgress {
@@ -172,7 +174,9 @@ class CourseProgress {
*/
*/
public function getCompletedQuizzes(NodeInterface $course) {
public function getCompletedQuizzes(NodeInterface $course) {
return array_filter(
return array_filter(
$this->course->getQuizzes($course),
array_map(function (NodeInterface $quiz) {
 
return $quiz->id();
 
}, $this->course->getQuizzes($course)),
[$this->lesson, 'isCompleted']
[$this->lesson, 'isCompleted']
);
);
}
}
Loading