Moodle
  1. Moodle
  2. MDL-17533

modify database and a few core file to prepare for supporting to list courses in multiple categories

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Rank:
      9520

      Description

      Functionality that would allow listing a course in multiple categories has been requested for a long time (at least since Moodle 1.4 as evidenced by the MDL_2231 and numerous discussions on the forums). I have this functionality implemented in Moodle 1.5 and it works really well for the past few years . I am hereby proposing here a few to the database and a few core files to provide foundation for proper implementation of that feature. The proposed changes do not affect the current operation. However, with these changes in place, I will be able to create a hack/patch to prepare for implementing it properly in a future release.

      1. Add a new table mdl_course_category with the following fields (see attached pic for this table in Moodle 1.5)

      id – bigint(10) – the usual running id for a given table
      course – bigint(10) – the id field from mdl_course
      category – bigint(10) – the category field from mdl_course (in turn id field in mdl_course_categories)
      sortorder – bigint(10) – the sortorder field from mdl_course
      visiblehere - tinyint(1) – new field to control visibility of course in a given category

      The new field visiblehere is needed since a course can be visible in one but not in another category. This field will not be used for now.

      2. Modify the Moodle upgrade script to

      a) create the above table automatically upon version upgrade
      b) create a record in the new table for each record in the mdl_course table copying the values as listed in item 1.
      c) remove field sortorder and category from the mdl_course table

      3. Modify the course backup and restore functions to support new table

      a. backup must write the new table out
      b. restore must enter values into the new table for all restores, that is copying data to new table for pre-version2 backups

      4. Modify the course/category.php (and any related files if needed) to use the new table instead of mdl_course for handling category assignments and sorting courses within category

      I think this is all.

        Issue Links

          Activity

          Hide
          Robert Brenstein added a comment -

          If somebody wants to see how listing courses in multiple categories works in a live Moodle site, please contact me directly for access.

          Show
          Robert Brenstein added a comment - If somebody wants to see how listing courses in multiple categories works in a live Moodle site, please contact me directly for access.
          Hide
          Robert Brenstein added a comment -

          I just remembered about the old post from Martin about the problems listing courses in multiple categories bring into the realm of roles. http://moodle.org/mod/forum/discuss.php?d=69869#p313773

          One possible solution could be to allow either multiple category listings or assigning student roles at category level. May be someone has a better idea.

          If it is decided that there is really an inherent conflict, having the suggested changes will allow local hacks to support that feature as needed without affecting Moodle as whole.

          Show
          Robert Brenstein added a comment - I just remembered about the old post from Martin about the problems listing courses in multiple categories bring into the realm of roles. http://moodle.org/mod/forum/discuss.php?d=69869#p313773 One possible solution could be to allow either multiple category listings or assigning student roles at category level. May be someone has a better idea. If it is decided that there is really an inherent conflict, having the suggested changes will allow local hacks to support that feature as needed without affecting Moodle as whole.
          Hide
          Petr Škoda added a comment -

          This seems problematic because it collides with context tree concept, my -1 for this.
          What do you think Tim?

          Show
          Petr Škoda added a comment - This seems problematic because it collides with context tree concept, my -1 for this. What do you think Tim?
          Hide
          Robert Brenstein added a comment -

          Can you elaborate Petr on this conflict? I presume you refer to the next step of actually implementing listing courses in multiple categories not what is specifically proposed here. As I wrote above, the changes proposed here do NOT change anything in the logic of Moodle as it is now. You are essentially moving a few fields to another table. That's it. No conflict with anything possible.

          What happens next is a matter of discussion. If it is decided that there is really an inherent conflict, having these changes would allow those in need to implement local hacks without affecting Moodle as whole. Without these changes, the hacks must be so deep and wide that they effectively prohibit Moodle updates.

          What about some other approach to get this feature in Moodle? I don't want to be stuck in Moodle 1.5/1.6 forever and there are many others who want/need it. I could list many forum discussions.

          Show
          Robert Brenstein added a comment - Can you elaborate Petr on this conflict? I presume you refer to the next step of actually implementing listing courses in multiple categories not what is specifically proposed here. As I wrote above, the changes proposed here do NOT change anything in the logic of Moodle as it is now. You are essentially moving a few fields to another table. That's it. No conflict with anything possible. What happens next is a matter of discussion. If it is decided that there is really an inherent conflict, having these changes would allow those in need to implement local hacks without affecting Moodle as whole. Without these changes, the hacks must be so deep and wide that they effectively prohibit Moodle updates. What about some other approach to get this feature in Moodle? I don't want to be stuck in Moodle 1.5/1.6 forever and there are many others who want/need it. I could list many forum discussions.
          Hide
          Tim Hunt added a comment -

          Yes, this is a bad idea. The roles system relies on the fact that the contexts in Moodle form a tree structure - and categories are an important type of context. It would also break stats, wouldn't it.

          If you want multiple categorisation of courses, then in Moodle 2.0 we already have (or are planning to have) tagging of courses. That achieves what you want.

          Possible all that needs to be added are some options for allowing browsing of courses by tag, in a way that makes the tags look like a categorisation.

          Show
          Tim Hunt added a comment - Yes, this is a bad idea. The roles system relies on the fact that the contexts in Moodle form a tree structure - and categories are an important type of context. It would also break stats, wouldn't it. If you want multiple categorisation of courses, then in Moodle 2.0 we already have (or are planning to have) tagging of courses. That achieves what you want. Possible all that needs to be added are some options for allowing browsing of courses by tag, in a way that makes the tags look like a categorisation.
          Hide
          Tim Hunt added a comment -

          Yes, course tagging is already done in HEAD MDL-11992.

          Show
          Tim Hunt added a comment - Yes, course tagging is already done in HEAD MDL-11992 .
          Hide
          Petr Škoda added a comment -

          aaah thanks Tim - sure tagging should be suitable for this. I agree internally we must keep the tree structure.
          I hope the tagging user interface can be improved so that it achieves the same goals stated here.

          thanks for the report

          Show
          Petr Škoda added a comment - aaah thanks Tim - sure tagging should be suitable for this. I agree internally we must keep the tree structure. I hope the tagging user interface can be improved so that it achieves the same goals stated here. thanks for the report
          Hide
          Robert Brenstein added a comment -

          I have looked at the documentation for tags in 1.9, tracker entries for tagging courses, improvements to the tagging system in head, and demo at OU. Unfortunately, I fail to see how tags can be used to address the issue of having a category structure which allows to list specific courses in multiple categories. As far as I can see, tags offer an alternative way of searching, admittedly neat and effective, but not an alternative way for browsing. Or am I missing something?

          Show
          Robert Brenstein added a comment - I have looked at the documentation for tags in 1.9, tracker entries for tagging courses, improvements to the tagging system in head, and demo at OU. Unfortunately, I fail to see how tags can be used to address the issue of having a category structure which allows to list specific courses in multiple categories. As far as I can see, tags offer an alternative way of searching, admittedly neat and effective, but not an alternative way for browsing. Or am I missing something?
          Hide
          Howard Miller added a comment -

          Just reading this now...... there's a few "cart before the horse" moments here. It saddens me when good ideas get rejected because "roles doesn't work like that". Moodle isn't there to make roles work it's to teach stuff. If a good idea doesn't work with the roles structure then fix the roles structure.

          While we're at it, it would be good to have "place holders" in course lists to add links to courses that are not in Moodle.

          Show
          Howard Miller added a comment - Just reading this now...... there's a few "cart before the horse" moments here. It saddens me when good ideas get rejected because "roles doesn't work like that". Moodle isn't there to make roles work it's to teach stuff. If a good idea doesn't work with the roles structure then fix the roles structure. While we're at it, it would be good to have "place holders" in course lists to add links to courses that are not in Moodle.
          Hide
          Tim Hunt added a comment -

          No one is rejecting the idea that it might be nice to have more flexible ways to display lists of available courses to students.

          However, read the summary of this bug again, it is about specifically making certain changes to the DB tables to do this. Petr and I both agree that is a bad way to implement this, so we Won't Fix-ed the bug.

          And I bet there are already other bugs about more flexible course listing, so please search before filing a dupe.

          Show
          Tim Hunt added a comment - No one is rejecting the idea that it might be nice to have more flexible ways to display lists of available courses to students. However, read the summary of this bug again, it is about specifically making certain changes to the DB tables to do this. Petr and I both agree that is a bad way to implement this, so we Won't Fix-ed the bug. And I bet there are already other bugs about more flexible course listing, so please search before filing a dupe.
          Hide
          Robert Brenstein added a comment -

          @Howard Re: "place holders" for links to external courses

          I wonder whether MDL-4384 is not a workable solution for this. I believe one can stick there html code with links as the content. A few CSS tags would have to be included to control the appearance of that box.

          Show
          Robert Brenstein added a comment - @Howard Re: "place holders" for links to external courses I wonder whether MDL-4384 is not a workable solution for this. I believe one can stick there html code with links as the content. A few CSS tags would have to be included to control the appearance of that box.
          Hide
          Robert Brenstein added a comment -

          @Tim and others:

          The issue of listing courses in multiple categories is not just about nice to have and more flexible. If you search forums hard enough, you will find multiple discussions on the issue, including mentions of people who left Moodle because of this restriction. For some sites, category and course structure need to match their reality.

          I have been on this issue ever since Moodle 1.5 is out and I haven't seen an alternative and usable proposal yet, and as far as I know, I am the only one who has MDL-2231 (multiple course categories) actually working in a production mode. I have just uploaded in MDL-2231 several screen shots from a site which actually uses multiple category listing of courses for a few years. Look in particular at the statistics.

          The issue of database: Currently, Moodle has a 1:N relation between categories and courses. I can't think of a way to change it to N:N relation (as needed to support listing a course in multiple categories) without altering the database. If you have any ideas how to implement this otherwise, I am all ears. Suggesting to use tagging means to me that you don't understand the issue.

          What is proposed here in MDL-17533, is to create a new table in a way which lets Moodle to continue to function exactly as it is. So yes, this changes the database but does change the way Moodle works. However, this change will allow creating a hack to offer multiple listings for those who need them badly enough even if Moodle core never takes it in.

          Implementing such a database change in Moodle is critical to keep course exports, backups, etc compatible with standard Moodle sites as well as allow routine Moodle version upgrades.

          I don't think issues with roles are blockers.

          Show
          Robert Brenstein added a comment - @Tim and others: The issue of listing courses in multiple categories is not just about nice to have and more flexible. If you search forums hard enough, you will find multiple discussions on the issue, including mentions of people who left Moodle because of this restriction. For some sites, category and course structure need to match their reality. I have been on this issue ever since Moodle 1.5 is out and I haven't seen an alternative and usable proposal yet, and as far as I know, I am the only one who has MDL-2231 (multiple course categories) actually working in a production mode. I have just uploaded in MDL-2231 several screen shots from a site which actually uses multiple category listing of courses for a few years. Look in particular at the statistics. The issue of database: Currently, Moodle has a 1:N relation between categories and courses. I can't think of a way to change it to N:N relation (as needed to support listing a course in multiple categories) without altering the database. If you have any ideas how to implement this otherwise, I am all ears. Suggesting to use tagging means to me that you don't understand the issue. What is proposed here in MDL-17533 , is to create a new table in a way which lets Moodle to continue to function exactly as it is. So yes, this changes the database but does change the way Moodle works. However, this change will allow creating a hack to offer multiple listings for those who need them badly enough even if Moodle core never takes it in. Implementing such a database change in Moodle is critical to keep course exports, backups, etc compatible with standard Moodle sites as well as allow routine Moodle version upgrades. I don't think issues with roles are blockers.
          Hide
          Robert Brenstein added a comment -

          Sorry, it should be

          So yes, this changes the database but does NOT change the way Moodle works.

          Show
          Robert Brenstein added a comment - Sorry, it should be So yes, this changes the database but does NOT change the way Moodle works.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: