try so but it gives absolutely all the lessons

if (CModule::IncludeModule("learning")) { echo $COURSE_ID; $res = CLesson::GetList( Array("SORT" => "ASC"), Array("ACTIVE" => "Y", "ID" => $COURSE_ID) ); while ($arLesson = $res->GetNext()) { echo "Lesson name: " . $arLesson["LESSON_ID"] . "<br>"; } } 

following the example https://dev.1c-bitrix.ru/api_help/learning/classes/clesson/getlist.php

    1 answer 1

    You have a typo in the filter, instead of "ID" => $COURSE_ID should be "COURSE_ID" => $COURSE_ID , because ID is the identifier of the lesson itself, not the course.

    If you want to use to get a list of course lessons, knowing the course ID, then your code should be like this:

     <?php if (CModule::IncludeModule("learning")) { $COURSE_ID = 8; $res = CLesson::GetList( Array("SORT"=>"ASC"), Array("ACTIVE" => "Y", "COURSE_ID" => $COURSE_ID) ); while ($arLesson = $res->GetNext()) { echo "Lesson name: ".$arLesson["NAME"]."<br>"; } } ?> 

    PS Be careful when using examples from the documentation .