From 4e75827d72272c06d06c770c3a0c8d97672c72fc Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 22 Feb 2021 17:32:41 +0800 Subject: [PATCH] MDL-70959 completion: Documentation improvements * Fix typo in $cm parameter's type in PHPDoc * Improve the comment to better explain the logic why fetching the completion data for the whole course can only be done when caching is used. Even if $wholecourse is set to true, there's no point in fetching the completion data for all the course modules unless we're caching the results. --- lib/completionlib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/completionlib.php b/lib/completionlib.php index 2258259f865..2069133454e 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -927,7 +927,7 @@ class completion_info { * Obtains completion data for a particular activity and user (from the * completion cache if available, or by SQL query) * - * @param stcClass|cm_info $cm Activity; only required field is ->id + * @param stdClass|cm_info $cm Activity; only required field is ->id * @param bool $wholecourse If true (default false) then, when necessary to * fill the cache, retrieves information from the entire course not just for * this one activity @@ -965,7 +965,9 @@ class completion_info { } } - // Not there, get via SQL + // If cached completion data is not found, fetch via SQL. + // Fetch completion data for all of the activities in the course ONLY if we're caching the fetched completion data. + // If we're not caching the completion data, then just fetch the completion data for the user in this course module. if ($usecache && $wholecourse) { // Get whole course data for cache $alldatabycmc = $DB->get_records_sql("