diff --git a/main/exercise/pending.php b/main/exercise/pending.php index 2cc0d02a2ac..46b4d5b164f 100644 --- a/main/exercise/pending.php +++ b/main/exercise/pending.php @@ -16,6 +16,8 @@ $questionTypeId = isset($_REQUEST['questionTypeId']) ? (int) $_REQUEST['questionTypeId'] : 0; $exportXls = isset($_REQUEST['export_xls']) && !empty($_REQUEST['export_xls']) ? (int) $_REQUEST['export_xls'] : 0; $action = $_REQUEST['a'] ?? null; +$startDate = isset($_REQUEST['start_date']) ? $_REQUEST['start_date'] : ''; +$endDate = isset($_REQUEST['end_date']) ? $_REQUEST['end_date'] : ''; api_block_anonymous_users(); @@ -170,6 +172,14 @@ function updateExerciseList(courseId) { } '; +$htmlHeadXtra[] = ''; + if ($exportXls) { ExerciseLib::exportPendingAttemptsToExcel($_REQUEST); } @@ -293,16 +303,27 @@ function updateExerciseList(courseId) { 4 => get_lang('Unclosed'), 5 => get_lang('Ongoing'), ]; - $form->addSelect('status', get_lang('Status'), $status); $questionType = [ 0 => get_lang('All'), 1 => get_lang('QuestionsWithNoAutomaticCorrection'), ]; - $form->addSelect('questionTypeId', get_lang('QuestionType'), $questionType); +$form->addElement( + 'text', + 'start_date', + get_lang('StartDate'), + ['id' => 'start_date', 'class' => 'datepicker', 'autocomplete' => 'off', 'style' => 'width:120px'] +); +$form->addElement( + 'text', + 'end_date', + get_lang('EndDate'), + ['id' => 'end_date', 'class' => 'datepicker', 'autocomplete' => 'off', 'style' => 'width:120px'] +); + $form->addButtonSearch(get_lang('Search'), 'pendingSubmit'); $content = $form->returnForm(); @@ -315,7 +336,9 @@ function updateExerciseList(courseId) { $url = api_get_path(WEB_AJAX_PATH). 'model.ajax.php?a=get_exercise_pending_results&filter_by_user='.$filter_user. - '&course_id='.$courseId.'&exercise_id='.$exerciseId.'&status='.$statusId.'&questionType='.$questionTypeId.'&showAttemptsInSessions='.$showAttemptsInSessions; + '&course_id='.$courseId.'&exercise_id='.$exerciseId.'&status='.$statusId.'&questionType='.$questionTypeId. + '&showAttemptsInSessions='.$showAttemptsInSessions. + '&start_date='.$startDate.'&end_date='.$endDate; $action_links = ''; $officialCodeInList = api_get_setting('show_official_code_exercise_result_list'); @@ -375,16 +398,6 @@ function updateExerciseList(courseId) { 'align' => 'left', 'search' => 'false', 'sortable' => 'false', - //'stype' => 'select', - //for the bottom bar - /*'searchoptions' => [ - 'defaultValue' => '', - 'value' => ':'.get_lang('All').';1:'.get_lang('Validated').';0:'.get_lang('NotValidated'), - ],*/ - //for the top bar - /*'editoptions' => [ - 'value' => ':'.get_lang('All').';1:'.get_lang('Validated').';0:'.get_lang('NotValidated'), - ],*/ ], [ 'name' => 'qualificator_fullname', diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 40e6bcf15da..4362031f90e 100755 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -643,17 +643,19 @@ function getWhereClause($col, $oper, $val) true ); break; + case 'get_exercise_pending_results': if ((false === api_is_teacher()) && (false === api_is_session_admin())) { exit; } - + $search_start_date = isset($_REQUEST['start_date']) && !empty($_REQUEST['start_date']) ? $_REQUEST['start_date'] : null; + $search_end_date = isset($_REQUEST['end_date']) && !empty($_REQUEST['end_date']) ? $_REQUEST['end_date'] : null; $courseId = $_REQUEST['course_id'] ?? 0; $exerciseId = $_REQUEST['exercise_id'] ?? 0; $status = $_REQUEST['status'] ?? 0; $questionType = $_REQUEST['questionType'] ?? 0; - $showAttemptsInSessions = (bool) $_REQUEST['showAttemptsInSessions']; - if (!empty($_GET['filter_by_user'])) { + $showAttemptsInSessions = $_REQUEST['showAttemptsInSessions'] ? true : false; + if (isset($_GET['filter_by_user']) && !empty($_GET['filter_by_user'])) { $filter_user = (int) $_GET['filter_by_user']; if (empty($whereCondition)) { $whereCondition .= " te.exe_user_id = '$filter_user'"; @@ -662,7 +664,7 @@ function getWhereClause($col, $oper, $val) } } - if (!empty($_GET['group_id_in_toolbar'])) { + if (isset($_GET['group_id_in_toolbar']) && !empty($_GET['group_id_in_toolbar'])) { $groupIdFromToolbar = (int) $_GET['group_id_in_toolbar']; if (!empty($groupIdFromToolbar)) { if (empty($whereCondition)) { @@ -681,6 +683,14 @@ function getWhereClause($col, $oper, $val) $whereCondition .= " AND te.c_id = $courseId"; } + // Filtrage sur la date de fin d'exercice (exe_date) + if (!empty($search_start_date)) { + $whereCondition .= " AND te.exe_date >= '".Database::escape_string($search_start_date)." 00:00:00'"; + } + if (!empty($search_end_date)) { + $whereCondition .= " AND te.exe_date <= '".Database::escape_string($search_end_date)." 23:59:59'"; + } + $count = ExerciseLib::get_count_exam_results( $exerciseId, $whereCondition,