map course to multiple categories

map course to multiple categories

by Ye Chen -
Number of replies: 6

Hello, all moodle developer,

I need some suggestions from your guys. I am going to develop a web page which can be used for people to define, add, modify multiple categories. Finally the category should be connected to moodle course. See the attachment I included here.  Of course, there are some other functions in the page, but it is all based on the structure listed in the file.

From the page, when user click the course, it should be able to go to the moodle course page. And also the page can display all links to the moodle courses.

Since this page will be connected to all the moodle courses, not dedicated to one course, I don't think I should develop an activity module. Because from my understanding, the activity modle is added for each course. Activity modle is not good choice to the functions I need for the page. Am I right? I am not sure about it.

Another question is if I develop the page, I need to reuse a lot of functions defined in moodle, especially for identify who the user is. Can I just include config.php in my PHP file, use the global object $USERS to know who is visiting the page?

Any suggestion will be very appreciated.

Thanks

Ye

Average of ratings: -
In reply to Ye Chen

Re: map course to multiple categories

by Martín Langhoff -
Ye - this is a good idea, but you should avoid using the categories that Moodle uses today. Instead, add some other metadata ("labels") to the courses to organise this multi-view categorisation.

Since v1.7, categories are used not only for display in the categories listing, but also as part of the security and access control framework. If you read about roles, you'll see what I mean.

So categories are for display _and_ for security/access control administration (yes, I know, unfortunate combination). Add something that is "just like categories" but only for display.
In reply to Martín Langhoff

Re: map course to multiple categories

by Ye Chen -

Martin,

Thanks for the quick response. Acturally, I am not going to use category designed in moodle system. And I may not use metadata either. The page I am going to develop  will use my own tables about multiple level categories. I may not call it categories, I will call them like level 1 competencies, level 2 competencies, this page needs to interconnect or communicate with the course defined in moodle system.

This is exactly what I want to do: after people login to moodle system, there should be a link to the page I am going to develop.

So where I can add the link to?

The page should be able to list all the links to the courses in moodle system, the page should access user's information through $USERS, so I know who is accessing the page. Some function in the page only availabe to teachers not for students.  for this purpose, in my PHP file for this page, what I need to include, is config.php enough or I have to do some extra things which I don't know yet now. I am still exploring the whole moodle system. It is a great system, however for new developer like me who wants add function and page to communicate with, it is not that easy. Seems need to take a lot of time to look deeply inside the structure of the system by looking into the code.

So any suggestion or help will be saving a lot of my time.

Ye

In reply to Martín Langhoff

Re: map course to multiple categories

by Robert Brenstein -
Martin, I wonder how you envision that. Our local Moodle has extended the category system to allow listing courses in multiple categories, and we can't move to newer version if that is not ported further. This feature has actually been requested by quite a few different people over the years but ignored by core developers and never included in the road map. You seem to be now saying that we have to implement a parallel system of categories to what Moodle has to support multiple-category listing. Sounds counterproductive to me.
In reply to Robert Brenstein

Re: map course to multiple categories

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The issue is with roles, because people can be given permissions at a category level which flow down to the courses beneath. So if Moodle is checking whether you can access a particular forum checks are made in the forum, the course, the parent categories and up to the top system level.

We already check multiple categories (eg parent of parent of parent), but it is assumed each course is in one catageory. It should not be too difficult to check parallel parents as well if they exist, but it could mean some significant performance issues when producing lists of participants, for example, and this would have to be checked very carefully.

If someone produces a patch with some benchmarks on the differences, and attaches it to an issue in the tracker then this is more likely to be looked at.
In reply to Martin Dougiamas

Re: map course to multiple categories

by Robert Brenstein -
Checking multiple category branches for access privileges is one aspect. Building participant list is a bit more complex since results from multiple category branches have to be uniquely or'ed.

In my case, I'd likely hack the code to disable the latter altogether since our participants are assigned on the course level only. May be such an option could be entertained as a feature.

It is too bad that you guys did not want to take in my code when we were in 1.6 era. I have no time to recode this for roles in the foreseeable future. It is far from trivial. Traversing multiple category branches for permissions in the course is actually a small aspect only, although it does affect performance the most.
In reply to Martin Dougiamas

Re: map course to multiple categories

by Martín Langhoff -

It should not be too difficult to check parallel parents as well if they exist, but it could mean some significant performance issues

And what about conflicting capabilities between similar-level categories. This could get really messy.

If someone produces a patch with some benchmarks on the differences,

I am working on this area too - please add me to the watchers list or assign it to me.

We are trying to speed up participants listing, so if you are coding in this area, it's probably worthwhile to track the ongoing discussions -- and build based on the fast code, not on the current slow code wink