Skip to content

Commit

Permalink
Merge branch 'MDL-71530' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed May 5, 2021
2 parents 162278e + bf55873 commit 25a2729
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions competency/classes/course_competency.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25a2729

Please sign in to comment.