From 47ef65bdf6b6f6b041d2a54b188e5b5f51afd760 Mon Sep 17 00:00:00 2001 From: "r.tschu" Date: Thu, 17 Oct 2019 12:48:00 +0200 Subject: [PATCH] added get_evasyscourses to persistenceclass --- classes/course_evasys_courses_allocation.php | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/classes/course_evasys_courses_allocation.php b/classes/course_evasys_courses_allocation.php index ac9e279..896a546 100644 --- a/classes/course_evasys_courses_allocation.php +++ b/classes/course_evasys_courses_allocation.php @@ -44,4 +44,26 @@ protected static function define_properties() { ), ); } + + /** Returns array of evasysids that belong to this course. + * @param $courseid int id of moodle course + * @return array of evasysids + * @throws \dml_exception + */ + public static function get_evasyscourses($courseid) { + global $DB; + $courses = $DB->get_field(self::TABLE, 'evasyscourses', array('course' => $courseid)); + $idcourse = $DB->get_field('course', 'idnumber', array('id' => $courseid)); + if (!$courses) { + return array ($idcourse); + } + $coursearray = explode($courses, '#'); + if ($idcourse) { + if (!in_array($idcourse, $coursearray)) { + $coursearray[] = $idcourse; + } + } + array_unique($coursearray); + return $coursearray; + } } \ No newline at end of file