Problem/Motivation
In using LMS module, I was getting warnings as reported here: https://www.drupal.org/project/lms/issues/3571120#comment-16489648
Since that comment was added to a closed issue, I thought better to open a fresh one.
The actual message:
Warning: Undefined array key "activity" message in Drupal\lms\TrainingManager->getBackNavDeltas()
And of course the back-nav doesn't work in this case.
Steps to reproduce
- The student opens the first activity of a lesson other than the first lesson.
What happens (I think):
- Drupal tries to construct the Back button to the preceding lesson.
- The student does not yet have $previous_lesson_status set.
- LMS initializes that missing status on demand but does not calculate the previous lesson’s final activity number.
Proposed resolution
The bug is in TrainingManager::getBackNavDeltas():
if ($previous_lesson_status === NULL) {
try {
$previous_lesson_status = $this->initializeLesson($course_status, $lesson_item);
}
catch (TrainingException $e) {
// Backwards navigation is not possible
// if the previous lesson couldn't be initialized.
return [];
}
}
else { // should be removed
// The deltas should be calculated either way.
$deltas['activity'] = $previous_lesson_status->getActivityCount() - 1;
} // should also be removed
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #5
graber commentedGood find, thank you!