course/lib: print_courses() and print_course() rework
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:26:54 +0000 (07:26 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:26:54 +0000 (07:26 +0000)
commit4dde1463ee439c493bc811662eac329b5deab049
tree75df09329643c8f6e93bd2425938d42089eec53e
parent70f158789ef5c0c636c8d3902ab7c0639c95a38b
course/lib: print_courses() and print_course() rework

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.
course/lib.php