function opigno_quiz_app_get_next_lesson_from_course in Opigno Quiz App 7
Returns the next lesson NID for a course.
Return value
int|null The next lesson or NULL if no more lesson
1 call to opigno_quiz_app_get_next_lesson_from_course()
File
- ./
opigno_quiz_app.module, line 2143 - Module file. Defines module hooks.
Code
function opigno_quiz_app_get_next_lesson_from_course($course_nid, $current_lesson_nid) {
// From the current course, get the next lesson.
// Get all the lessons from the course. If no lesson, return NULL.
$lessons = opigno_quiz_app_course_lessons($course_nid);
if (empty($lessons[$course_nid])) {
return NULL;
}
// Loop through all lessons. If we arrive to the current lesson, do a
// loop more and return the next lesson NID.
// If there is no more loop, it means there is no more lesson. Return NULL.
$return_next_lesson = false;
foreach ($lessons[$course_nid] as $lesson_nid => $lesson_vid) {
if ($return_next_lesson) {
return $lesson_nid;
}
if ($lesson_nid == $current_lesson_nid) {
$return_next_lesson = true;
}
}
// If no more lesson in this course, return NULL
return NULL;
}