Move status saving out of TrainingController if possible

Created on 6 August 2024, 3 months ago
Updated 16 August 2024, 3 months ago

Problem/Motivation

TrainingController has some logic to track status in it, which runs when the page is visited. If possible, we should look at moving this so it only runs when the 'next' or back button is pressed.

  // Different module - initialize the module status if not previously
    // taken with the requested activity and update CourseStatus information.
    if (!$same_lesson) {
      if ($lesson_status === NULL) {
        try {
          $lesson_status = $this->trainingManager->initializeLesson($course_status, $step, $activity_item->entity);
        }
        catch (\Exception $e) {
          $url = $this->handleError($group, $e);
          return $this->redirect($url->getRouteName(), $url->getRouteParameters());
        }
      }
      else {
        $lesson_status->set('current_activity', $activity_delta);
      }
      $lesson_status->save();
      $course_status->set('current_lesson_status', $lesson_status);
      $course_status->save();
    }

    // Different activity - all we need to do is update the current
    // module status activity. Lesson status cannot be NULL.
    elseif (!$same_activity) {
      $lesson_status->set('current_activity', $activity_delta);
      $lesson_status->save();
    }

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Activities and answers

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024