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

Add a webservice to get the activity overview information for the mobile APP

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 5.1
    • Course
    • 5
    • C->HQ 2025 Sprint I2.2 Moppies

      The new activities overview page needs to be compatible with the mobile APP. We need a new "core_courseformat_get_overview_information" webservice to get as much raw data as possible from the current overview items.

      Webservice contract

      The webservice only requires two paràmeters:

      • courseid (PARAM_INT)
      • pluginname (PARAM_PLUGIN)

      The result of the webservice will be:

      • courseid (int)
      • activities (object[])
        • name (string)
        • pluginname (string)
        • contextid (int)
        • cmid (int)
        • URL (string)
        • items (object[])
          • Key (string) - > this is unique at array level
          • name (string) -> this name will be unique in the array
          • contentytpe (string) -> has the name of the content output class, or "string" if the content is a prerendered HTML.
          • data (object encoded in json) --> will depend on the output type.

      Only the overview items that are not null will be exported.

      Overview item data export

      While all the result data will be coded using an exported class, the main challenge is to export every item's data. The overview item can handle content as a string, null, or renderable. The trick will be:

      1. Create a new interface "exportable" with a method: export_for_external (renderer_base $output): stdClass --> the method can be used to get the raw data and can be implemented by any class, even output ones.
      2. The activityoverviewbase will have a new optional attribute called "data" (stdClass) and its getter and setter, so any activity can store data inside it to export. However, this attribute is optional and may not be informed.
      3. The activityoverviewbase will implement "exportable" following this logic:
        1. If the item has data defined, it will be returned.
        2. If the output element implements exportable, the exported output data will be returned.
        3. In any other case, it will generate an object with the item attributes: value, alert, and alertcount.

      The rationale of this design is:

      • Differentiating export_for_template and export_for_external will guarantee the webservices will not break because of template changes or new requirements.
      • All export_for_external will have their PHPUnit tests to ensure nobody accidentally modifies the data structure.
      • By having export_for_external in outputs, classes like "humandate" can be easily reused by many items and could be used in more contexts.
      • Because the data for each overview item depends on the output type, JSON encoding is the most versatile option.

       

            Unassigned Unassigned
            tusefomal Ferran Recio
            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.