Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-84067

Optimize completion.php for improved scalability

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Future Dev
    • Activity completion

      In the current implementation of the scripts, mostly in the completion.php of Moodle, the problem of scalability is felt arising from repetitive database queries every time there is a request for completion details of specific course modules. This issue intensifies especially when there are many activities in a given course, because the same completion details are queried in the same request lifecycle severally. This approach also puts more strain on and slows down the servers and system and is more rigid when it comes to incorporating improvements for larger courses.

      Steps to Reproduce
      Develop a course that has many activities.
      The completion tracking of the following activities should be enabled.
      Use the course as a student and observe database queries during the request life cycle.
      Notice that the method cm_completion_details: All of the activity requires to call:get_instance without caching, which is the problem of the current design.
      What Was Expected
      Course module completion details should be obtained, ideally and reasonably, by invoking the appropriate data in the completion table; the system should not repeatedly hit the database for unproductive queries.

      What Happens
      Each request currently has multiple queries to the database to retrieve information on the completion status of each of the course modules.
      Larger numbers of servers and processing time result in longer time taken to display course pages and pages equipped with numerous activities.
      There exist limitations in scalability for large courses or high concurrent users hitting the system at a particular time.
      Proposed Solution
      Introduce architectural improvements to optimize the handling of completion details:

      Caching Completion Details: Use a static cache for storing the completion details within the lifecycle of a particular request.
      Refactor Code for Separation of Concerns: Propose to implement ‘service classes’ which would contain the responsibility of fetching data and the foundational logic.
      Optimize Logic in export_for_template: To increase efficiency and reusability of code, they should be rearranged and looked through.
      Adopt Dependency Injection: Global dependency access should be substituted by direct dependency injection for the purpose of improving testability.

            Unassigned Unassigned
            Nes.775 Nesma Alshaibani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.