Add group filter in LP report see BT#17370

pull/3312/head
Julio Montoya 5 years ago
parent b2ebce6710
commit e73f046eb9
  1. 37
      main/lp/lp_report.php
  2. 1
      main/template/default/learnpath/report.tpl

@ -20,14 +20,16 @@ if (!$isAllowedToEdit) {
$lpTable = Database::get_course_table(TABLE_LP_MAIN); $lpTable = Database::get_course_table(TABLE_LP_MAIN);
$lpId = isset($_GET['lp_id']) ? (int) $_GET['lp_id'] : 0; $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
$export = isset($_GET['export']); $export = isset($_REQUEST['export']);
$lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id()); $lp = new learnpath(api_get_course_id(), $lpId, api_get_user_id());
if (empty($lp)) { if (empty($lp)) {
api_not_allowed(true); 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(); $em = Database::getManager();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
@ -93,6 +95,28 @@ $lpInfo = Database::select(
'first' '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 = []; $userList = [];
$showEmail = api_get_setting('show_email_addresses'); $showEmail = api_get_setting('show_email_addresses');
@ -171,7 +195,7 @@ if (!empty($users)) {
[], [],
ICON_SIZE_MEDIUM 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('lp_id', $lpId);
$template->assign('show_email', 'true' === $showEmail); $template->assign('show_email', 'true' === $showEmail);
$template->assign('export', (int) $export); $template->assign('export', (int) $export);
$template->assign('groups', $groupFilter);
$layout = $template->get_template('learnpath/report.tpl'); $layout = $template->get_template('learnpath/report.tpl');
$template->assign('header', $lpInfo['name']); $template->assign('header', $lpInfo['name']);
$template->assign( $template->assign('actions', Display::toolbarAction('lp_actions', [$actions]));
'actions',
Display::toolbarAction('lp_actions', [$actions])
);
$result = $template->fetch($layout); $result = $template->fetch($layout);
$template->assign('content', $result); $template->assign('content', $result);

@ -1,3 +1,4 @@
{{ groups }}
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover table-striped table-bordered"> <table class="table table-hover table-striped table-bordered">
<thead> <thead>

Loading…
Cancel
Save