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

Incorporate section name into other parts of Moodle

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Course, Navigation, Usability
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Moodle 2.0 provides a way to set the section name (e.g. Topic 1) to something more specific (e.g. Introduction to Calculus). Currently the section name is included in navigation, but not anywhere else in Moodle. Other places in Moodle refer to the section name as "Topic 1", "Week 1" or "Section 1" depending on the current course format.

      It would be nice if the rest of Moodle supported section names the way navigation does.

      The attached patches attempt to incorporate section name functionality into Moodle. I've split the changes into two patches.

      The first patch (get-section-name.patch):

      1. Modifies the get_section_name function in /course/lib.php to return the full name (e.g. Topic 1, Intro to Calculus, Week 4) instead of just the language string.
      2. Adds support for using navigation's callback_xxx_get_section_name callbacks in course formatters to control what section name is returned.
      3. Updates code references (as many as I could find) throughout Moodle to use the /course/lib.php get_section_name function.

      The second patch (use-sections.patch):

      1. Adds support for a new function, course_format_uses_sections, in /course/lib.php. This function returns true if the course format uses sections to display information (e.g. Topic format, Week format, but not SCORM format), Activity modules can use this function to determine how to display information.
      2. By default, course_format_uses_sections returns false. Course formats can implement a callback_xxx_uses_sections function in their lib.php file to indicate they use sections.
      3. Modifies several places, mainly index.php in activity modules, to use the new course_format_uses_sections function.

      In my opinion, students and teachers should benefit from consistently named sections throughout Moodle.

      These patches replace a lot of code that specifically looks for the topic or week course formats with more generic code. This should make writing additional course formats a little easier.

        Gliffy Diagrams

        1. get-section-name.patch
          16 kB
          Brandon Turner
        2. use-sections.patch
          47 kB
          Brandon Turner

          Issue Links

            Activity

            blt04 Brandon Turner created issue -
            blt04 Brandon Turner made changes -
            Field Original Value New Value
            Component/s Usability [ 10309 ]
            Component/s Themes [ 10088 ]
            Hide
            quen Sam Marshall added a comment -

            I voted for this. The first patch in particular is great. Without this feature, custom course formats are lacking. I'm sure we have hacky customisations here to do this, a proper solution would be much appreciated.

            Re the second feature - makes sense, but rather than adding a new function, can the plugin_supports infrastructure deal with this case? Just needs a new constant - plugin_supports('format', $name, FEATURE_HAS_SECTIONS)

            Show
            quen Sam Marshall added a comment - I voted for this. The first patch in particular is great. Without this feature, custom course formats are lacking. I'm sure we have hacky customisations here to do this, a proper solution would be much appreciated. Re the second feature - makes sense, but rather than adding a new function, can the plugin_supports infrastructure deal with this case? Just needs a new constant - plugin_supports('format', $name, FEATURE_HAS_SECTIONS)
            Hide
            dougiamas Martin Dougiamas added a comment -

            Thanks Brandon! Sam H, can you review this and check it in if it looks OK? Main thing I'd look for is for new db access.

            Show
            dougiamas Martin Dougiamas added a comment - Thanks Brandon! Sam H, can you review this and check it in if it looks OK? Main thing I'd look for is for new db access.
            dougiamas Martin Dougiamas made changes -
            Fix Version/s 2.0 [ 10122 ]
            dougiamas Martin Dougiamas made changes -
            Assignee moodle.com [ moodle.com ] Sam Hemelryk [ samhemelryk ]
            dougiamas Martin Dougiamas made changes -
            Priority Minor [ 4 ] Critical [ 2 ]
            Hide
            blt04 Brandon Turner added a comment -

            Unfortunately I had to add calls to get_all_sections (resulting in a new db access) in many new places (especially in the second patch) because navigation's callback_xxx_get_section_name needs an array of section objects.

            I'm happy to revise the second patch per Sam Marshall's comments if everyone agrees.

            Show
            blt04 Brandon Turner added a comment - Unfortunately I had to add calls to get_all_sections (resulting in a new db access) in many new places (especially in the second patch) because navigation's callback_xxx_get_section_name needs an array of section objects. I'm happy to revise the second patch per Sam Marshall's comments if everyone agrees.
            Hide
            samhemelryk Sam Hemelryk added a comment -

            Hi Brandon,

            Thank you very much for the patch, it was spot on.
            There were a couple of minor changes I made after looking into the get_all_sections calls that were being made.
            First the get_all_sections method now stores retrieved sections in a static array to avoid hitting the database again for subsequent calls. Navigation nearly always calls when in a course context or higher which many of the implemented locations were resulting in more than one request for the same information.
            The changes I made to your patch were as follows:

            1. get_section_name no longer takes an array of sections as an argument. It is now the responsibility of the course formats get name callback to call get_all_sections if it requires it.
            2. get_section_name no longer takes the format as an argument. The format is taken from the course object that is being passed in.
            3. I got rid of the $course argument from the get_generic_section_name function as it wasn't being used.

            In regards to what you were asking Sam using the plugin_supports method sounds like a good idea however the current plugin_supports method only works for modules (yuk!)
            I'll ask Petr about this one when he comes online today. If he has no objections I'll create a tracker issue to implement the plugin_supports method for all plugins and then switch this over to it.

            Cheers
            Sam

            Show
            samhemelryk Sam Hemelryk added a comment - Hi Brandon, Thank you very much for the patch, it was spot on. There were a couple of minor changes I made after looking into the get_all_sections calls that were being made. First the get_all_sections method now stores retrieved sections in a static array to avoid hitting the database again for subsequent calls. Navigation nearly always calls when in a course context or higher which many of the implemented locations were resulting in more than one request for the same information. The changes I made to your patch were as follows: get_section_name no longer takes an array of sections as an argument. It is now the responsibility of the course formats get name callback to call get_all_sections if it requires it. get_section_name no longer takes the format as an argument. The format is taken from the course object that is being passed in. I got rid of the $course argument from the get_generic_section_name function as it wasn't being used. In regards to what you were asking Sam using the plugin_supports method sounds like a good idea however the current plugin_supports method only works for modules (yuk!) I'll ask Petr about this one when he comes online today. If he has no objections I'll create a tracker issue to implement the plugin_supports method for all plugins and then switch this over to it. Cheers Sam
            samhemelryk Sam Hemelryk made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            blt04 Brandon Turner made changes -
            Link This issue blocks MDL-22709 [ MDL-22709 ]
            blt04 Brandon Turner made changes -
            Link This issue has been marked as being related by MDL-24153 [ MDL-24153 ]
            dougiamas Martin Dougiamas made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            QA Assignee nobody
            dougiamas Martin Dougiamas made changes -
            Workflow jira [ 36571 ] MDL Workflow [ 64471 ]
            dougiamas Martin Dougiamas made changes -
            Workflow MDL Workflow [ 64471 ] MDL Full Workflow [ 93752 ]

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  24/Nov/10