From e73f046eb96392d69bc3def65b0ed35483a4b9cb Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 12 Jun 2020 14:32:09 +0200 Subject: [PATCH] Add group filter in LP report see BT#17370 --- main/lp/lp_report.php | 37 ++++++++++++++++++---- main/template/default/learnpath/report.tpl | 1 + 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/main/lp/lp_report.php b/main/lp/lp_report.php index 970b2f3eba..bb01a8c2f5 100644 --- a/main/lp/lp_report.php +++ b/main/lp/lp_report.php @@ -20,14 +20,16 @@ if (!$isAllowedToEdit) { $lpTable = Database::get_course_table(TABLE_LP_MAIN); -$lpId = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0; -$export = isset($_GET['export']); +$lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0; +$export = isset($_REQUEST['export']); $lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id()); if (empty($lp)) { api_not_allowed(true); } +$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=report&lp_id='.$lpId; + $em = Database::getManager(); $sessionId = api_get_session_id(); $courseId = api_get_course_int_id(); @@ -93,6 +95,28 @@ $lpInfo = Database::select( 'first' ); +$groups = GroupManager::get_groups(); + +$groupFilter = ''; +if (!empty($groups)) { + $form = new FormValidator('group', 'post', $url); + $form->addSelect( + 'group_id', + get_lang('Groups'), + array_column($groups, 'name', 'iid'), + ['placeholder' => get_lang('SelectAnOption')] + ); + $form->addButtonSearch(get_lang('Search')); + + if ($form->validate()) { + $groupId = $form->getSubmitValue('group_id'); + if (!empty($groupId)) { + $users = GroupManager::getStudents($groupId, true); + } + } + $groupFilter = $form->returnForm(); +} + $userList = []; $showEmail = api_get_setting('show_email_addresses'); @@ -171,7 +195,7 @@ if (!empty($users)) { [], ICON_SIZE_MEDIUM ), - api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=report&export=pdf&lp_id='.$lpId + $url.'&export=pdf' ); } @@ -182,13 +206,12 @@ $template->assign('course_code', api_get_course_id()); $template->assign('lp_id', $lpId); $template->assign('show_email', 'true' === $showEmail); $template->assign('export', (int) $export); +$template->assign('groups', $groupFilter); + $layout = $template->get_template('learnpath/report.tpl'); $template->assign('header', $lpInfo['name']); -$template->assign( - 'actions', - Display::toolbarAction('lp_actions', [$actions]) -); +$template->assign('actions', Display::toolbarAction('lp_actions', [$actions])); $result = $template->fetch($layout); $template->assign('content', $result); diff --git a/main/template/default/learnpath/report.tpl b/main/template/default/learnpath/report.tpl index 5b7a08e7a4..7eb75f8952 100644 --- a/main/template/default/learnpath/report.tpl +++ b/main/template/default/learnpath/report.tpl @@ -1,3 +1,4 @@ +{{ groups }}