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

It should be easier to add new mutations and states to the course format course index menu

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 4.2.9, 4.1.15, 4.3.9, 4.4.5, 4.5.1
    • Course
    • None
    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE

      We have a course format that has an additional containers that let us group several related sections into a group.

      When trying to implement this there seemed to be a fundamental mismatch between the way the JavaScript side of the course index and the web service side.

      The JavaScript and the documentation seems to assume that the course format will be able to send this new set of items as a new type of top level item as it eventually gets passed into statemanager::setInitialState(), while the get core_courseformat_get_state service itself does not allow this.

      While I could get around this on the web service side by adding my extra level of items onto the course part of the response this had many issues with me then being able to add the required state and mutation classes into things because some of the JavaScript has calls to other parts hardcoded into it, which meant that I needed to completely copy files, rather than just being able to do minor overrides.

      The course editor method also has issues with handling new mutations and states because of the way the exporter is loaded.

      In theory it looks as though it should be easy to handle modifications to the exporter by simply extending it, however it turns out to be incredibly hard to do this.

      1. Code trying to get it will call this.reactive.getExporter()
      2. Reactive is got via the getCurrentCourseEditor() method, the calls are effectively hardcoded to this specific method by the imports.
      3. The then creates a new CourseEditor object (again hardcoded) with a hardcoded DefaultMutation object which is also hardcoded in the imports and the way the code is structured.
      4. The exporter is loaded via the getExporter() method in the course editor class again the class is pretty much hard coded (although if we could load a custom course edtiro easily it would in theory be easy to override this one.

      All of this means that the only way I could use my own exporter was to copy any method that wanted to use one in full and then change it to directly get my own exporter that I directly into my overridden class, this resulted in me having to duplicate rather a lot of code.

      While I did manage to get it working it felt like it was massively hacky and fragile, and it feels like it is something course formats should be able to do relatively easily, while still making use of the core code as much as possible.

            Unassigned Unassigned
            nmagill Neill Magill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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