|
|
|
@ -1420,7 +1420,7 @@ function convert_score($score, $weight) { |
|
|
|
|
* @param string Search exercise name |
|
|
|
|
* @return array array with exercise data |
|
|
|
|
*/ |
|
|
|
|
function get_all_exercises($course_info = null, $session_id = 0, $check_publication_dates = false, $search_exercise = '') { |
|
|
|
|
function get_all_exercises($course_info = null, $session_id = 0, $check_publication_dates = false, $search_exercise = '', $search_all_sessions = false) { |
|
|
|
|
$TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
@ -1445,11 +1445,16 @@ function get_all_exercises($course_info = null, $session_id = 0, $check_publicat |
|
|
|
|
$needle_where = (!empty($search_exercise)) ? " AND title LIKE '?' " : ''; |
|
|
|
|
$needle = (!empty($search_exercise)) ? "%" . $search_exercise . "%" : ''; |
|
|
|
|
|
|
|
|
|
if ($session_id == 0) { |
|
|
|
|
$conditions = array('where'=>array('active = ? AND session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array('1', $session_id, $course_id, $needle)), 'order'=>'title'); |
|
|
|
|
} else { |
|
|
|
|
//All exercises |
|
|
|
|
$conditions = array('where'=>array('active = ? AND (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array('1', $session_id, $course_id, $needle)), 'order'=>'title'); |
|
|
|
|
if ($search_all_sessions == true) |
|
|
|
|
{ |
|
|
|
|
$conditions = array('where'=>array('active = ? AND c_id = ? '. $needle_where . $time_conditions => array('1', $course_id, $needle)), 'order'=>'title'); |
|
|
|
|
} else |
|
|
|
|
{ |
|
|
|
|
if ($session_id == 0) { |
|
|
|
|
$conditions = array('where'=>array('active = ? AND session_id = ? AND c_id = ? '. $needle_where . $time_conditions => array('1', $session_id, $course_id, $needle)), 'order'=>'title'); |
|
|
|
|
} else { |
|
|
|
|
$conditions = array('where'=>array('active = ? AND (session_id = 0 OR session_id = ? ) AND c_id = ? ' . $needle_where . $time_conditions => array('1', $session_id, $course_id, $needle)), 'order'=> |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return Database::select('*',$TBL_EXERCICES, $conditions); |
|
|
|
|
} |
|
|
|
|