find(
ToolLaunch::class,
$request->query->getInt('id')
);
if (null === $toolLaunch) {
header('Location: '.api_get_course_url());
exit;
}
$course = api_get_course_entity();
$session = api_get_session_entity();
$cidReq = api_get_cidreq();
$plugin = XApiPlugin::create();
$length = 20;
$page = $request->query->getInt('page', 1);
$start = ($page - 1) * $length;
$countStudentList = CourseManager::get_student_list_from_course_code(
$course->getCode(),
(bool) $session,
$session ? $session->getId() : 0,
null,
null,
true,
0,
true
);
$statsUrl = api_get_self().'?'.api_get_cidreq().'&id='.$toolLaunch->getId();
$paginator = new Paginator();
$pagination = $paginator->paginate([]);
$pagination->setTotalItemCount($countStudentList);
$pagination->setItemNumberPerPage($length);
$pagination->setCurrentPageNumber($page);
$pagination->renderer = function ($data) use ($statsUrl) {
$render = '';
if ($data['pageCount'] > 1) {
$render = '
';
}
return $render;
};
$students = CourseManager::get_student_list_from_course_code(
$course->getCode(),
(bool) $session,
$session ? $session->getId() : 0,
null,
null,
true,
0,
false,
$start,
$length
);
$content = '';
$content .= '';
$loadingMessage = Display::returnFontAwesomeIcon('spinner', '', true, 'fa-pulse').' '.get_lang('Loading');
foreach ($students as $studentInfo) {
$content .= Display::panelCollapse(
api_get_person_name($studentInfo['firstname'], $studentInfo['lastname']),
$loadingMessage,
"pnl-student-{$studentInfo['id']}",
[
'class' => 'pnl-student',
'data-student' => $studentInfo['id'],
'data-tool' => $toolLaunch->getId(),
],
"pnl-student-{$studentInfo['id']}-accordion",
"pnl-student-{$studentInfo['id']}-collapse",
false
);
}
$content .= '
';
$content .= $pagination;
// View
$interbreadcrumb[] = [
'name' => $plugin->get_title(),
'url' => '../start.php',
];
$htmlHeadXtra[] = "";
$actions = Display::url(
Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM),
"../start.php?$cidReq"
);
$view = new Template($toolLaunch->getTitle());
$view->assign(
'actions',
Display::toolbarAction('xapi_actions', [$actions])
);
$view->assign('header', $toolLaunch->getTitle());
$view->assign('content', $content);
$view->display_one_col_template();