Skip to content

Commit

Permalink
added get_evasyscourses to persistenceclass
Browse files Browse the repository at this point in the history
  • Loading branch information
r.tschu committed Oct 23, 2019
1 parent a569b20 commit 47ef65b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions classes/course_evasys_courses_allocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 47ef65b

Please sign in to comment.