update list session - refs #2681

pull/2818/head
Alex Aragón 6 years ago
parent 362b09e97c
commit 0ae02756fe
  1. 9
      assets/css/scss/_base.scss
  2. 31
      main/inc/lib/display.lib.php
  3. 6
      main/inc/lib/userportal.lib.php
  4. 2
      main/template/default/user_portal/sessions.html.twig

@ -588,6 +588,15 @@ footer {
flex: auto;
overflow: hidden;
break-inside: avoid;
display: inline-table;
.card-session{
.card-title{
font-size: 16px;
a{
color: $grey-800;
}
}
}
}
}

@ -2738,8 +2738,33 @@ HTML;
$show_learnpath
);
}
public static function randomColor($id){
$color = substr(md5(time()*$id), 0, 6);
return '#'.$color; // example: #fc443a
public static function randomColor($id)
{
static $colors = [];
if (!empty($colors[$id])) {
return $colors[$id];
} else {
$color = substr(md5(time() * $id), 0, 6);
$c1 = hexdec(substr($color, 0, 2));
$c2 = hexdec(substr($color, 2, 2));
$c3 = hexdec(substr($color, 4, 2));
$luminosity = $c1 + $c2 + $c3;
$type = "#000000";
if ($luminosity < (255 + 255 + 255) / 2) {
$type = "#FFFFFF";
}
$result = [
'color' => '#' . $color,
'luminosity' => $type
];
$colors[$id] = $result;
return $result; // example: #fc443a
}
}
}

@ -1061,7 +1061,6 @@ class IndexManager
$viewGridCourses = api_get_configuration_value('view_grid_courses') === true;
$showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info');
$coursesWithoutCategoryTemplate = '/user_portal/classic_courses.html.twig';
$coursesWithCategoryTemplate = '/user_portal/classic_courses_with_category.tpl';
$showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true;
if ($loadHistory) {
@ -1277,7 +1276,6 @@ class IndexManager
if ($viewGridCourses) {
$coursesWithoutCategoryTemplate = '/user_portal/grid_courses.html.twig';
$coursesWithCategoryTemplate = '/user_portal/grid_courses_with_category.tpl';
}
if ($specialCourses) {
@ -1319,8 +1317,8 @@ class IndexManager
$this->tpl->assign('courses', $courses['not_category']);
$this->tpl->assign('categories', $courses['in_category']);
$listCourse = $this->tpl->fetch($this->tpl->get_template($coursesWithCategoryTemplate));
$listCourse .= $this->tpl->fetch($this->tpl->get_template($coursesWithoutCategoryTemplate));
$listCourse = $this->tpl->fetch($this->tpl->get_template($coursesWithoutCategoryTemplate));
}
$courseCount = count($specialCourses) + $coursesInCategoryCount + $coursesNotInCategoryCount;

@ -4,7 +4,7 @@
{% for item in session %}
{% set image %}
{% if item.category %}
<div class="category" style="background: {{ item.color }}">
<div class="category" style="background: {{ item.color.color }}; color:{{ item.color.luminosity }}">
{{ item.category.name }}
</div>
{% endif %}

Loading…
Cancel
Save