* Display the grouping a course module belongs to on the course page - for course managers only.
* When adding users to groups, display the groups a user already belongs to.
* Added an overview report that shows groupings, groups and members for a course.
* Added a dialogue to automatically create groups and assign members based on either the number of desired groups or the number of desired users per group.
Very last caller to rebuild_context_rel() and any XX_context_rel()
function. move_category() already takes care of calling
context_moved(), which does the required context.path maintenance.
Addresses MDL-11219
Fix a thinko in a variable assignment that prevented us from grabbing
the correct roles as managers. Addresses Yu's report at
MDL-11182 admin shows up as teacher.
get_my_courses() now defaults to a much leaner dataset, but accepts an
array of "additional" fields we want. So ask nicely for the summary,
so that we can print_course() later with it.
New categories need a context immediately, and for top-level
categories, they also need to taint the "root" context to trigger
a reload of $USER->access.
This fixes problems with creation of initial courses(MDL-11178),
duplicate misc categories, etc.
- The code uses the system context a lot. Declare
$sysctx at the top and use it.
- If the category has a context property, use it
(saves 1 DB query per category displayed)
The DB costs of this page in editing mode are
- ~100 DB queries for fix_course_sortorder()
- ~50 DB queries for the categories listing
If we rewrite both to lose the recursion, we could resolve the
page in perhaps 5 DBq.
print_course() can now recognise a $course object that already has a
$course->context obj and a $course->managers array, which means that
there will be no DB access triggered by print_course().
(Backwards compat is retained so it still works the old way for
callers that get a single course printed anyway (during enrolment
for example.)
And print_courses() now uses get_courses_wmanagers(), and passes the
returned $course objects to print_course().
With this patch, a homepage listing 9 courses (with varying numbers of
teachers) sheds 63 DB queries (88 to 25). A course listing page with
3 courses sheds 9 (33 to 24).
On a single server overall time spent serving the homepage is reduced just
a little bit (262ms to 238ms) -- on a clustered environment, less DB queries
mean much lower latency and DB costs.
move_courses() now calls content_moved() which will take care of any
accesslib-required changes. And introducing move_category() which
also calls content_moved() when needed.
Combined with the path creation in create_context() we can now create
a course, enter and edit it immediately. Amazing.
Like - 21st century technology.
Manually enrolling and unenrolling self, and other users should
transparently set the context dirty. So walk all callers to
role_assign() and role_unassign() and mark the context dirty
where appropriate.
OTOH, most automated-backend enrol/unenrol mechanisms should not.
The backend lookups that happen when you login are well covered
by the login/enrolment process, and don't need to be marked dirty.
This patch saves 1600 context lookups on a 1600 course category. rcache
does help a bit with small categories, but on large setups, this is
not sustainable.
And it's not needed either. We have the data right at our fingertips.
Just get it when it's cheap...
Implemented all the relevant checks for role_switch().
accesslib's role_switch() doesn't do any UI-related checks any more,
being a backend lib call. These belong here.
Move the fixups for orphan courses to the newly minted
fix_coursecategory_orphans() -- and optimise it to take only 1 dbquery for
the common case.
If we do find lots of orphans, we issue 2 updates per orphan.
This cuts down dbqueries drastically - we used to have 2x the number of
courses in the site.