Allow show course grouped by category in session list - refs BT#12430

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent 98ec16a5cc
commit 00ecb30cc9
  1. 16
      main/inc/lib/course.lib.php
  2. 7
      main/inc/lib/userportal.lib.php
  3. 2
      main/install/configuration.dist.php
  4. 141
      main/template/default/user_portal/grid_session.tpl

@ -4141,6 +4141,7 @@ class CourseManager
$params['title'] = $session_title; $params['title'] = $session_title;
$params['edit_actions'] = ''; $params['edit_actions'] = '';
$params['document'] = ''; $params['document'] = '';
$params['category'] = $course_info['categoryName'];
if ($course_visibility != COURSE_VISIBILITY_CLOSED && if ($course_visibility != COURSE_VISIBILITY_CLOSED &&
$course_visibility != COURSE_VISIBILITY_HIDDEN $course_visibility != COURSE_VISIBILITY_HIDDEN
@ -6285,4 +6286,19 @@ class CourseManager
$courseFieldValue = new ExtraFieldValue('course'); $courseFieldValue = new ExtraFieldValue('course');
$courseFieldValue->saveFieldValues($params); $courseFieldValue->saveFieldValues($params);
} }
/**
* Get the course categories form a course list
* @param array $courseList
* @return array
*/
public static function getCourseCategoriesFromCourseList(array $courseList)
{
$allCategories = array_column($courseList, 'category');
$categories = array_unique($allCategories);
sort($categories);
return $categories;
}
} }

@ -1133,7 +1133,7 @@ class IndexManager
$listCourse = ''; $listCourse = '';
$specialCourseList = ''; $specialCourseList = '';
$load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; $load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false;
$viewGridCourses = api_get_configuration_value('view_grid_courses'); $viewGridCourses = api_get_configuration_value('view_grid_courses') === 'true';
$showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info'); $showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info');
$coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl'; $coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl';
@ -1330,6 +1330,9 @@ class IndexManager
$params['course_list_session_style'] = $coursesListSessionStyle; $params['course_list_session_style'] = $coursesListSessionStyle;
$params['num_users'] = $session_box['num_users']; $params['num_users'] = $session_box['num_users'];
$params['num_courses'] = $session_box['num_courses']; $params['num_courses'] = $session_box['num_courses'];
$params['course_categories'] = CourseManager::getCourseCategoriesFromCourseList(
$html_courses_session
);
$params['courses'] = $html_courses_session; $params['courses'] = $html_courses_session;
if ($showSimpleSessionInfo) { if ($showSimpleSessionInfo) {
@ -1511,7 +1514,7 @@ class IndexManager
$this->tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false)); $this->tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
$this->tpl->assign('gamification_mode', $gameModeIsActive); $this->tpl->assign('gamification_mode', $gameModeIsActive);
if (api_get_configuration_value('view_grid_courses')) { if ($viewGridCourses) {
$sessions_with_no_category = $this->tpl->fetch( $sessions_with_no_category = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/grid_session.tpl') $this->tpl->get_template('/user_portal/grid_session.tpl')
); );

@ -244,6 +244,8 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//$_configuration['show_invisible_exercise_in_lp_list'] = false; //$_configuration['show_invisible_exercise_in_lp_list'] = false;
// New grid view the list of courses // New grid view the list of courses
//$_configuration['view_grid_courses'] = 'true'; //$_configuration['view_grid_courses'] = 'true';
// Show courses grouped by categories when $_configuration['view_grid_courses'] is enabled
//$_configuration['view_grid_courses_grouped_categories_in_sessions'] = true;
// Chamilo is installed/downloaded. Packagers can change this // Chamilo is installed/downloaded. Packagers can change this
// to reflect their packaging method. The default value is 'chamilo'. This will // to reflect their packaging method. The default value is 'chamilo'. This will
// be reflected on the https://version.chamilo.org/stats page in the future. // be reflected on the https://version.chamilo.org/stats page in the future.

@ -1,3 +1,68 @@
{% set group_courses = 'view_grid_courses_grouped_categories_in_sessions'|get_configuration_value %}
{% macro course_block(course, show_category) %}
<div class="col-xs-12 col-sm-6 col-md-4">
<div class="items">
<div class="image">
<img src="{{ course.image }}" class="img-responsive">
{% if course.category != '' and show_category %}
<span class="category">{{ course.category }}</span>
<div class="cribbon"></div>
{% endif %}
<div class="black-shadow">
<div class="author-card">
{% for teacher in course.teachers %}
{% set counter = counter + 1 %}
{% if counter <= 3 %}
<a href="{{ teacher.url }}" class="ajax"
data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
<img src="{{ teacher.avatar }}"/>
</a>
<div class="teachers-details">
<h5>
<a href="{{ teacher.url }}" class="ajax"
data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }}
</a>
</h5>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% if course.edit_actions != '' %}
<div class="admin-actions">
{% if course.document == '' %}
<a class="btn btn-default btn-sm" href="{{ course.edit_actions }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% else %}
<div class="btn-group" role="group">
<a class="btn btn-default btn-sm" href="{{ course.edit_actions }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{{ course.document }}
</div>
{% endif %}
</div>
{% endif %}
</div>
<div class="description">
<h4 class="title">
{% if course.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
{{ course.title }} {{ course.code_course }}
{% else %}
<a href="{{ course.link }}">{{ course.title }} {{ course.code_course }}</a>
{% endif %}
</h4>
<div class="notifications">{{ course.notifications }}</div>
</div>
</div>
</div>
{% endmacro %}
{% import _self as blocks %}
{% for row in session %} {% for row in session %}
<div id="session-{{ item.id }}" class="session panel panel-default"> <div id="session-{{ item.id }}" class="session panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
@ -29,68 +94,26 @@
</span> </span>
</div> </div>
<div class="grid-courses"> <div class="grid-courses">
<div class="row"> {% if not group_courses %}
{% for item in row.courses %} <div class="row">
<div class="col-xs-12 col-sm-6 col-md-4"> {% for item in row.courses %}
<div class="items"> {{ blocks.course_block(item, true) }}
<div class="image"> {% endfor %}
<img src="{{ item.image }}" class="img-responsive"> </div>
{% if item.category != '' %} {% else %}
<span class="category">{{ item.category }}</span> {% for category_code in row.course_categories %}
<div class="cribbon"></div> <div class="row">
{% endif %} <div class="col-xs-12">
<div class="black-shadow"> <h4>{{ category_code }}</h4>
<div class="author-card">
{% for teacher in item.teachers %}
{% set counter = counter + 1 %}
{% if counter <= 3 %}
<a href="{{ teacher.url }}" class="ajax"
data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
<img src="{{ teacher.avatar }}"/>
</a>
<div class="teachers-details">
<h5>
<a href="{{ teacher.url }}" class="ajax"
data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
{{ teacher.firstname }} {{ teacher.lastname }}
</a>
</h5>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% if item.edit_actions != '' %}
<div class="admin-actions">
{% if item.document == '' %}
<a class="btn btn-default btn-sm" href="{{ item.edit_actions }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{% else %}
<div class="btn-group" role="group">
<a class="btn btn-default btn-sm" href="{{ item.edit_actions }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
{{ item.document }}
</div>
{% endif %}
</div>
{% endif %}
</div>
<div class="description">
<h4 class="title">
{% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
{{ item.title }} {{ item.code_course }}
{% else %}
<a href="{{ item.link }}">{{ item.title }} {{ item.code_course }}</a>
{% endif %}
</h4>
<div class="notifications">{{ item.notifications }}</div>
</div>
</div> </div>
{% for course in row.courses %}
{% if course.category == category_code %}
{{ blocks.course_block(course, false) }}
{% endif %}
{% endfor %}
</div> </div>
{% endfor %} {% endfor %}
</div> {% endif %}
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save