Moodle
  1. Moodle
  2. MDL-29719

Courses page should optionally display shortname

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.2
    • Component/s: Course
    • Labels:
      None
    • Testing Instructions:
      Hide

      1) On a default Moodle install with some courses, view the /course/ page.

      • Verify that the courses shown on this page do not show the short name.
        2) Go to the edit version of the page from admin Courses / Add/edit courses and click into a category.
      • Verify that the courses shown on this page do not show the short name.
        3) Visit the admin settings Appearance / Courses
        4) Change the option 'Display shortname' to tick the box and save.
        5) Return to /course/
      • Verify that each course shown on the page now is in the format 'CF101 Introduction to filesharing' (both shortname and fullname).
        6) Go to the edit version of the page from admin Courses / Add/edit courses and click into a category.
      • Verify that each course shown on the page now is in the format 'CF101 Introduction to filesharing' (both shortname and fullname).
      Show
      1) On a default Moodle install with some courses, view the /course/ page. Verify that the courses shown on this page do not show the short name. 2) Go to the edit version of the page from admin Courses / Add/edit courses and click into a category. Verify that the courses shown on this page do not show the short name. 3) Visit the admin settings Appearance / Courses 4) Change the option 'Display shortname' to tick the box and save. 5) Return to /course/ Verify that each course shown on the page now is in the format 'CF101 Introduction to filesharing' (both shortname and fullname). 6) Go to the edit version of the page from admin Courses / Add/edit courses and click into a category. Verify that each course shown on the page now is in the format 'CF101 Introduction to filesharing' (both shortname and fullname).
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-29719-master
    • Rank:
      19232

      Description

      The /course/ page in Moodle only displays course full names.

      For example, if you have a course where the shortname is CF101 and the full name is 'Introduction to creative file sharing', then the /course/ page will only display 'Introduction to creative file sharing'.

      In the OU system each course has a name (=fullname) and a code (=shortname). Staff need to be able to refer to courses by the code.

      There are two workarounds:

      1) We could include the course code in the fullname, so that the shortname is 'CF101' and the fullname is 'CF101 Introduction to creative filesharing'. This would work and may well be what is intended by the Moodle use of the names, but seems like unnecessary duplication (and it doesn't work right with other parts of our system where we display these two things separately).

      2) Users can use the search facility to find courses instead of the list. This does work to search shortnames.

      However, it would be a lot better for us if we could display the shortname alongside the fullname (as in, they are going to make me do this one way or another)

      I propose a new feature as follows:

      1) Rename the existing settings page 'Appearance > Course contacts' to 'Appearance > Courses'

      2) Add new checkbox option to this page: 'Display shortname', 'Include shortname as well as fullname on course lists'. $CFG->courselistshortnames=1/0.

      3) Change course/index.php (both the 'view' and 'edit' modes) so that, if this option is turned on, the shortname is displayed before the fullname, separated by a space, in the existing column/location. ('CF101 Introduction to filesharing' from example above)

      There may also be other places where the system shows lists of multiple courses; if this is implemented I will attempt to find them.

      Opinions on this, suggestions of different place to put the settings, etc., are welcome. As it is simple, I will implement it (initial version at least) and provide screenshots shortly.

      1. basic.png
        36 kB
      2. categories.png
        38 kB
      3. editing.png
        49 kB
      4. search.png
        34 kB
      5. settings.png
        83 kB

        Issue Links

          Activity

          Hide
          Sam Marshall added a comment -

          Now added screenshots and initial implementation

          Show
          Sam Marshall added a comment - Now added screenshots and initial implementation
          Hide
          Tim Hunt added a comment -

          Looks very good to me (but then I would say that, I work for the OU). I am surprised how small the patch is.

          Show
          Tim Hunt added a comment - Looks very good to me (but then I would say that, I work for the OU). I am surprised how small the patch is.
          Hide
          Sam Marshall added a comment -
          Show
          Sam Marshall added a comment - Forum discussion thread is http://moodle.org/mod/forum/discuss.php?d=187769
          Hide
          Ray Lawrence added a comment -

          +1 Nice option.

          Show
          Ray Lawrence added a comment - +1 Nice option.
          Hide
          Dan Poltawski added a comment -

          This is useful and we've had a client wanting the same recently (we worked it around with 1) )

          Show
          Dan Poltawski added a comment - This is useful and we've had a client wanting the same recently (we worked it around with 1) )
          Hide
          Martin Dougiamas added a comment -

          Looks like a useful option.

          Since it's an option not on by default, it's +1 from me.

          Show
          Martin Dougiamas added a comment - Looks like a useful option. Since it's an option not on by default, it's +1 from me.
          Hide
          Sam Marshall added a comment -

          Thanks Martin! I got Tim to review the code, so submitting for integration next time.

          (Have rebased for current week.)

          Show
          Sam Marshall added a comment - Thanks Martin! I got Tim to review the code, so submitting for integration next time. (Have rebased for current week.)
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Ho, this looks near perfect, some tiny comments:

          1) if ($CFG->courselistshortnames), I guess we need empty() check there to prevent notices before installation/upgrade/setting the variable.

          2) would be great to get all the new code backed by some unit tests, I know this is trivial, but...

          3) Offtopic bet: I'm sure next step will be to create new options for people wanting the shortname on the right, or enclosed by parenthesis or... let's see if this ends requiring one $CFG->courselistnames_template, lol

          Ciao

          PS: I'm halting this till 1) gets fixed

          Show
          Eloy Lafuente (stronk7) added a comment - Ho, this looks near perfect, some tiny comments: 1) if ($CFG->courselistshortnames), I guess we need empty() check there to prevent notices before installation/upgrade/setting the variable. 2) would be great to get all the new code backed by some unit tests, I know this is trivial, but... 3) Offtopic bet: I'm sure next step will be to create new options for people wanting the shortname on the right, or enclosed by parenthesis or... let's see if this ends requiring one $CFG->courselistnames_template, lol Ciao PS: I'm halting this till 1) gets fixed
          Hide
          Sam Marshall added a comment -

          Thanks Eloy!

          1) You are right, I have corrected it. (It wouldn't cause any problem as defaults to false, but there would be php warning.)

          2) Yes it is trivial which is what I thought, but I agree better to set a good example with new code where possible. I have added a test for my new function into the existing courselib unit test file.

          3) My offtopic imagination didn't go quite that far - I thought when I was making that checkbox 'I bet people will want this to be a dropdown with more options', but I didn't come up with the template idea

          New version is pushed to github now, using same link as above (I amended the commit). Only changes are those for #1 and #2 listed here.

          Show
          Sam Marshall added a comment - Thanks Eloy! 1) You are right, I have corrected it. (It wouldn't cause any problem as defaults to false, but there would be php warning.) 2) Yes it is trivial which is what I thought, but I agree better to set a good example with new code where possible. I have added a test for my new function into the existing courselib unit test file. 3) My offtopic imagination didn't go quite that far - I thought when I was making that checkbox 'I bet people will want this to be a dropdown with more options', but I didn't come up with the template idea New version is pushed to github now, using same link as above (I amended the commit). Only changes are those for #1 and #2 listed here.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
          Hide
          Sam Hemelryk added a comment -

          Hmm failing this as there is a typo leading to notices and course name names not being displayed when on the editing screen.

          Notice: Undefined variable: course in /course/category.php on line 317 Notice: Trying to get property of non-object in /course/lib.php on line 2186 Notice: Trying to get property of non-object in /course/lib.php on line 2186

          Fix is VERY simple

          diff --git a/course/category.php b/course/category.php
          index 0fb8ac5..27f4653 100644
          --- a/course/category.php
          +++ b/course/category.php
          @@ -314,7 +314,7 @@
           
                       $linkcss = $acourse->visible ? '' : ' class="dimmed" ';
                       echo '<tr>';
          -            $coursename = get_course_display_name_for_list($course);
          +            $coursename = get_course_display_name_for_list($acourse);
                       echo '<td><a '.$linkcss.' href="view.php?id='.$acourse->id.'">'. format_string($coursename) .'</a></td>';
                       if ($editingon) {
                           echo '<td>';
          

          I was considering just integrating this and then passing it however I'm sure Murphy would punish me for doing that so I will stick to what I imagine protocol is an await Eloy's return to integrate the fix at which point I'll pass this

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Hmm failing this as there is a typo leading to notices and course name names not being displayed when on the editing screen. Notice: Undefined variable: course in /course/category.php on line 317 Notice: Trying to get property of non-object in /course/lib.php on line 2186 Notice: Trying to get property of non-object in /course/lib.php on line 2186 Fix is VERY simple diff --git a/course/category.php b/course/category.php index 0fb8ac5..27f4653 100644 --- a/course/category.php +++ b/course/category.php @@ -314,7 +314,7 @@ $linkcss = $acourse->visible ? '' : ' class= "dimmed" '; echo '<tr>'; - $coursename = get_course_display_name_for_list($course); + $coursename = get_course_display_name_for_list($acourse); echo '<td><a '.$linkcss.' href= "view.php?id='.$acourse->id.'" >'. format_string($coursename) .'</a></td>'; if ($editingon) { echo '<td>'; I was considering just integrating this and then passing it however I'm sure Murphy would punish me for doing that so I will stick to what I imagine protocol is an await Eloy's return to integrate the fix at which point I'll pass this Cheers Sam
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated extra commit from Sam Marshall fixing the problem. Reseting to testing phase.

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated extra commit from Sam Marshall fixing the problem. Reseting to testing phase.
          Hide
          Sam Hemelryk added a comment -

          Passed thanks guys

          Show
          Sam Hemelryk added a comment - Passed thanks guys
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Many thanks for all the hard work. This is now part of Moodle, your favorite LMS.

          Closing as fixed, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Many thanks for all the hard work. This is now part of Moodle, your favorite LMS. Closing as fixed, ciao
          Hide
          Helen Foster added a comment -

          Linking to master copy of QA test for this improvement. Comments about the QA test welcome!

          Show
          Helen Foster added a comment - Linking to master copy of QA test for this improvement. Comments about the QA test welcome!

            People

            • Votes:
              6 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: