function count_courses_notin_metacourse($metacourseid) { global $CFG; $alreadycourses = get_courses_in_metacourse($metacourseid); $sql = "SELECT COUNT(c.id) AS notin FROM {$CFG->prefix}course c\n WHERE " . (!empty($alreadycourses) ? "c.id NOT IN (" . implode(',', array_keys($alreadycourses)) . ")\n AND " : "") . " c.id !={$metacourseid} and c.id != " . SITEID . " and c.metacourse != 1"; if (!($count = get_record_sql($sql))) { return 0; } return $count->notin; }
function count_courses_notin_metacourse($metacourseid) { global $DB; if ($alreadycourses = get_courses_in_metacourse($metacourseid)) { $alreadycourses = implode(',', array_keys($alreadycourses)); $alreadycourses = "AND c.id NOT IN ({$alreadycourses})"; } else { $alreadycourses = ""; } $sql = "SELECT COUNT(c.id)\n FROM {course} c\n WHERE c.id != ? and c.id != " . SITEID . " and c.metacourse != 1\n {$alreadycourses}"; $params = array($metacourseid); return $DB->count_records_sql($sql, $params); }
set_time_limit(180); $removecourse = clean_param($removecourse, PARAM_INT); if (!remove_from_metacourse($course->id, $removecourse)) { print_error("cannotremovefrommeta"); } } } else { if ($showall and confirm_sesskey()) { $searchtext = ''; $previoussearch = 0; } } } } /// Get all existing students and teachers for this course. if (!($alreadycourses = get_courses_in_metacourse($course->id))) { $alreadycourses = array(); } $numcourses = 0; /// Get search results excluding any users already in this course if ($searchtext != '' and $previoussearch and confirm_sesskey()) { if ($searchcourses = get_courses_search(explode(" ", $searchtext), 'fullname ASC', 0, 99999, $numcourses)) { foreach ($searchcourses as $tmp) { if (array_key_exists($tmp->id, $alreadycourses)) { unset($searchcourses[$tmp->id]); } if (!empty($tmp->metacourse)) { unset($searchcourses[$tmp->id]); } } if (array_key_exists($course->id, $searchcourses)) {