From c56513c41b7e27c825093b0aa1eed9445e8ee848 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 14 Aug 2017 10:18:45 +0200 Subject: [PATCH] Improve UI --- main/admin/gradebook_dependency.php | 16 ++++- main/admin/gradebook_list.php | 66 ++++++++++++------- .../default/admin/gradebook_dependency.tpl | 4 +- .../template/default/admin/gradebook_list.tpl | 55 ++++++++-------- 4 files changed, 86 insertions(+), 55 deletions(-) diff --git a/main/admin/gradebook_dependency.php b/main/admin/gradebook_dependency.php index a5862b68c5..4f8af5588f 100644 --- a/main/admin/gradebook_dependency.php +++ b/main/admin/gradebook_dependency.php @@ -27,6 +27,7 @@ if (!$category) { $categoryObj = Category::load($categoryId); /** @var Category $categoryObj */ $categoryObj = $categoryObj[0]; + $dependencies = $categoryObj->getCourseListDependency(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; @@ -48,12 +49,20 @@ if (empty($dependencies)) { $content = ''; $courseList = []; + +/*$mandatoryList = api_get_configuration_value('gradebook_dependency_mandatory_courses'); +$mandatoryList = isset($mandatoryList['courses']) ? $mandatoryList['courses'] : [];*/ + foreach ($dependencies as $courseId) { $courseInfo = api_get_course_info_by_id($courseId); - $subCategory = Category::load(null, null, $courseInfo['code']); + $courseCode = $courseInfo['code']; + $subCategory = Category::load(null, null, $courseCode); /** @var Category $subCategory */ - $subCategory = $subCategory[0]; - $userList = CourseManager::get_student_list_from_course_code($courseInfo['code']); + $subCategory = $subCategory ? $subCategory[0] : []; + if (empty($subCategory)) { + continue; + } + $userList = CourseManager::get_student_list_from_course_code($courseCode); $users = []; foreach ($userList as $user) { $userInfo = api_get_user_info($user['user_id']); @@ -66,6 +75,7 @@ foreach ($dependencies as $courseId) { $users[] = $userInfo; } $courseInfo['users'] = $users; + //$courseInfo['is_mandatory'] = in_array($courseCode, $mandatoryList); $courseList[] = $courseInfo; } diff --git a/main/admin/gradebook_list.php b/main/admin/gradebook_list.php index 863ac4628d..6804456355 100644 --- a/main/admin/gradebook_list.php +++ b/main/admin/gradebook_list.php @@ -39,8 +39,19 @@ $currentUrl = api_get_self().'?'; $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $contentForm = ''; +$toolbar = Display::url( + Display::return_icon('add.png', get_lang('Add'), [], ICON_SIZE_MEDIUM), + $currentUrl.'&action=add' +); + +$tpl = new Template(get_lang('Gradebook')); + switch ($action) { case 'add': + $toolbar = Display::url( + Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), + $currentUrl + ); $form = new FormValidator( 'category_add', 'post', @@ -127,6 +138,10 @@ switch ($action) { } break; case 'edit': + $toolbar = Display::url( + Display::return_icon('back.png', get_lang('Back'), [], ICON_SIZE_MEDIUM), + $currentUrl + ); /** @var GradebookCategory $category */ $category = $repo->find($categoryId); if (!empty($category)) { @@ -209,23 +224,31 @@ switch ($action) { } } break; -} + case 'list': + default: + $paginator = new Paginator(); + $pagination = $paginator->paginate( + $gradeBookList, + $page, + 5 + ); -$paginator = new Paginator; -$pagination = $paginator->paginate( - $gradeBookList, - $page, - 5 -); + // pagination.tpl needs current_url with out "page" param + $pagination->setCustomParameters(['current_url' => $currentUrl]); -// pagination.tpl needs current_url with out "page" param -$pagination->setCustomParameters(['current_url' => $currentUrl]); -$tpl = new Template(get_lang('Gradebook')); -$toolbar = Display::url( - Display::return_icon('add.png', get_lang('Add'), [], ICON_SIZE_MEDIUM), - $currentUrl.'&action=add' -); + $pagination->renderer = function ($data) use ($tpl) { + foreach ($data as $key => $value) { + $tpl->assign($key, $value); + } + $layout = $tpl->get_template('admin/pagination.tpl'); + $content = $tpl->fetch($layout); + + return $content; + }; + + break; +} $searchForm = new FormValidator( 'course_filter', @@ -238,16 +261,6 @@ $searchForm = new FormValidator( $searchForm->addText('keyword', '', false); $searchForm->addButtonSearch(get_lang('Search')); -$pagination->renderer = function ($data) use ($tpl) { - foreach ($data as $key => $value) { - $tpl->assign($key, $value); - } - $layout = $tpl->get_template('admin/pagination.tpl'); - $content = $tpl->fetch($layout); - - return $content; -}; - $tpl->assign('current_url', $currentUrl); $tpl->assign( 'actions', @@ -257,7 +270,10 @@ $tpl->assign( [1, 4] ) ); + $tpl->assign('form', $contentForm); -$tpl->assign('gradebook_list', $pagination); +if (!empty($pagination)) { + $tpl->assign('gradebook_list', $pagination); +} $layout = $tpl->get_template('admin/gradebook_list.tpl'); $tpl->display($layout); diff --git a/main/template/default/admin/gradebook_dependency.tpl b/main/template/default/admin/gradebook_dependency.tpl index 6bd99df4be..248c88833d 100644 --- a/main/template/default/admin/gradebook_dependency.tpl +++ b/main/template/default/admin/gradebook_dependency.tpl @@ -2,7 +2,9 @@ {% block content %} {% for course in courses %} -

{{ course.title }} ({{ course.code }})

+

+ {{ course.title }} ({{ course.code }}) +

{% if course.users %} diff --git a/main/template/default/admin/gradebook_list.tpl b/main/template/default/admin/gradebook_list.tpl index 6a85ed7918..24d64ad2b6 100644 --- a/main/template/default/admin/gradebook_list.tpl +++ b/main/template/default/admin/gradebook_list.tpl @@ -2,33 +2,36 @@ {% block content %} {{ form }} -
- + + {% if gradebook_list %} +
+ + + + + + + + {% for item in gradebook_list %} - - - + + + - - {% for item in gradebook_list %} - - - - - - {% endfor %} -
{{ 'Name' | get_lang }}{{ 'Course' | get_lang }}{{ 'Actions' | get_lang }}
{{ 'Name' | get_lang }}{{ 'Course' | get_lang }}{{ 'Actions' | get_lang }} + {{ item.name }} + + {{ item.courseCode }} + + + + + + + +
- {{ item.name }} - - {{ item.courseCode }} - - - - - - - -
+ {% endfor %} + - {{ gradebook_list }} + {{ gradebook_list }} + {% endif %} {% endblock %}