@ -5578,15 +5578,20 @@ class CourseManager
* This function gets all the courses that are not in a session
* This function gets all the courses that are not in a session
* @param date Start date
* @param date Start date
* @param date End date
* @param date End date
* @param bool $includeClosed Whether to include closed and hidden courses
* @return array Not-in-session courses
* @return array Not-in-session courses
*/
*/
public static function getCoursesWithoutSession($startDate = null, $endDate = null)
public static function getCoursesWithoutSession($startDate = null, $endDate = null, $includeClosed = false )
{
{
$dateConditional = ($startDate & & $endDate) ?
$dateConditional = ($startDate & & $endDate) ?
" WHERE id_session IN (SELECT id FROM " . Database::get_main_table(TABLE_MAIN_SESSION) .
" WHERE id_session IN (SELECT id FROM " . Database::get_main_table(TABLE_MAIN_SESSION) .
" WHERE date_start = '$startDate' AND date_end = '$endDate')" :
" WHERE date_start = '$startDate' AND date_end = '$endDate')" :
null;
null;
$query = "SELECT id, code, title FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " WHERE CODE NOT IN
$visibility = ($includeClosed ? '' : 'visibility NOT IN (0, 4) AND ');
$query = "SELECT id, code, title FROM " . Database::get_main_table(TABLE_MAIN_COURSE)
. " WHERE $visibility
code NOT IN
(SELECT DISTINCT course_code FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . $dateConditional . ")
(SELECT DISTINCT course_code FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . $dateConditional . ")
ORDER BY id";
ORDER BY id";