mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Child courses import list empty MDL-7424; added new count_courses_notin_metacourse() function, the old one was kept for BC
This commit is contained in:
parent
6403e67965
commit
493cde249e
@ -110,13 +110,12 @@
|
||||
|
||||
/// If no search results then get potential students for this course excluding users already in course
|
||||
if (empty($searchcourses)) {
|
||||
$numcourses = count_courses_notin_metacourse($course->id);
|
||||
|
||||
$numcourses = get_courses_notin_metacourse($course->id,true);
|
||||
|
||||
$courses = array();
|
||||
|
||||
if ($numcourses <= MAX_COURSES_PER_PAGE) {
|
||||
if ($numcourses > 0 and $numcourses <= MAX_COURSES_PER_PAGE) {
|
||||
$courses = get_courses_notin_metacourse($course->id);
|
||||
} else {
|
||||
$courses = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,22 @@ function get_courses_notin_metacourse($metacourseid,$count=false) {
|
||||
return get_records_sql($sql);
|
||||
}
|
||||
|
||||
function count_courses_notin_metacourse($metacourseid) {
|
||||
global $CFG;
|
||||
|
||||
$alreadycourses = get_courses_in_metacourse($metacourseid);
|
||||
|
||||
$sql = "SELECT 1, COUNT(c.id) AS notin FROM {$CFG->prefix}course c
|
||||
WHERE ".((!empty($alreadycourses)) ? "c.id NOT IN (".implode(',',array_keys($alreadycourses)).")
|
||||
AND " : "")." c.id !=$metacourseid and c.id != ".SITEID." and c.metacourse != 1";
|
||||
|
||||
if (!$result = get_records_sql($sql)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $result[1]->notin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search through course users
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user