From bf558732cef7ea033e8c8afbab10ca11bc78a461 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 4 May 2021 17:53:00 +0100 Subject: [PATCH] MDL-71530 competency: ensure all exported course fields are present. Previously missing were the two new properties added in 36bc7b07: showactivitydates & showcompletionconditions - this change ensures all properties are requested before exporting courses linked to competencies. --- competency/classes/course_competency.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/competency/classes/course_competency.php b/competency/classes/course_competency.php index 427728270dc4a..f53838ae05521 100644 --- a/competency/classes/course_competency.php +++ b/competency/classes/course_competency.php @@ -22,11 +22,10 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core_competency; -defined('MOODLE_INTERNAL') || die(); use coding_exception; -use stdClass; use lang_string; +use core_course\external\course_summary_exporter; /** * Class for loading/storing course_competencies from the DB. @@ -243,9 +242,13 @@ public static function list_courses_min($competencyid) { public static function list_courses($competencyid) { global $DB; - $results = $DB->get_records_sql('SELECT course.id, course.visible, course.shortname, course.idnumber, - course.fullname, course.summary, course.summaryformat, course.startdate, - course.enddate, course.category + // We need all the course summary exporter properties, plus category. + $coursefields = course_summary_exporter::properties_definition(); + $coursefields = array_map(function(string $field): string { + return "course.{$field}"; + }, array_keys($coursefields)); + + $results = $DB->get_records_sql('SELECT ' . implode(',', $coursefields) . ', course.category FROM {course} course JOIN {' . self::TABLE . '} coursecomp ON coursecomp.courseid = course.id