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

  1. 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

Issue fork lms-3625730

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

leeksoup created an issue. See original summary.

graber made their first commit to this issue’s fork.

  • graber committed f74c2e50 on 1.2.x authored by leeksoup
    Issue #3625730: Fix TrainingManager::getBackNavDeltas gives Undefined...
graber’s picture

Version: 1.2.3 » 1.2.x-dev
Status: Active » Fixed
Related issues: +#3571120: TrainingManager::getBackNavDeltas breaks in free navigation

Good find, thank you!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.