* All updates to user.lastaccess and user_lastaccess.timeaccess are paced to
60s of the last update on the same record -- this should reduce the heat
on those tables.
* Updates/inserts to user_lastaccess are down with raw SQL to avoid costly
schema lookups on every request.
With this patch we preload the child contexts for the course
and hold on to them. This means that in one DB query we have all the contexts
we are going to need.
The checks for user_allowed_editing() move from weblib:update_icon() to
user_allowed_editing(), where we cache the result, and in the process save
50% of the cap checks by testing separately blocks from modules (doh!).
Still, the cap checks here are very inefficient...
With the last 3 patches, a course page with default blocks and 9 modinstances
goes from 157 to 86 db queries when logged in as a non-editing user (guest,
student). As admin it drops from 88 to 81.
Conflicts:
lib/pagelib.php
Access control for the course icon display should happen
at the page level, as we'll need to ask "can edit?" quite
a few times in the page.
The fact that this is weblib should be a good hint that
functions that print html should not be doing access control...
Using context.path, now get_child_contexts...
- always takes 1 query
- populated the context_cache
- returns full records
- when called with an category, it won't
recurse into the children of courses
Also
- All callers in accesslib changed to the new
calling convention
A normal course page with a std blocks and a few
activities sees around 100 queries less with this patch.
Note: this commit is slightly different on HEAD/19 and on
MOODLE_18_STABLE, as groups-related tables have changed.
Issue:
Teachers can edit grader report preferences (including switches for quickgrading and
quickfeedback), but do not have access to the "Turn editing on/off" button, so they
can't do quickgrading.
Solutions:
1.Decouple the quickgrading and quickfeedback modes from the editing mode,
and turn them on/off through the preferences page. New capability: moodle/grade:edit
* preferences: don't show quickgrading if no capability grade:edit
* If quickgrading is switched off as a preference and user doesn't have manage cap, show edit icons around grades when in editing mode
By moving the performance profile logging to the very
end of PHP processing, we cover more pages, notably those
that don't end up with a footer or a redirect, like file
serving.
This should improve quality of our performance logs, and
help catch some piggies...
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.
Two improvements for fix_course_sortorder()
- If the category has more courses than the shift range
use a larger shift range to avoid overlapping with itself
- If things do go wrong during the per-course sortorder updates,
rollback and try and call ourselves with a 'safe' flag.
Still - far from perfect. Probably the global sortorder approach
is broken. The sanest way is to rework things to always join against
course_categories and order by the combined sortorders.