Moodle
  1. Moodle
  2. MDL-22647

Incorporate section name into other parts of Moodle

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Critical 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
    • Rank:
      32620

      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.

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

        Issue Links

          Activity

          Hide
          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
          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
          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
          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.
          Hide
          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
          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
          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
          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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: