Adding nice badges in gradebook see BT#8040

skala
Julio Montoya 13 years ago
parent 0af91f72e6
commit 7bb6adaba0
  1. 34
      main/css/base.css
  2. 11
      main/gradebook/gradebook_flatview.php
  3. 11
      main/gradebook/lib/fe/gradebooktable.class.php
  4. 2
      main/gradebook/lib/flatview_data_generator.class.php
  5. 18
      main/gradebook/lib/gradebook_functions.inc.php
  6. 13
      main/inc/lib/display.lib.php

@ -57,6 +57,40 @@ label, input, button, select, textarea, p {
font-size: inherit; font-size: inherit;
} }
.badge-group {
width: 200px;
position: relative;
}
.badge-group .badge {
float:left;
position:relative;
}
.badge-group > :first-child {
z-index: 1000;
}
.badge-group > :nth-child(2) {
z-index: 900;
}
.badge-group > :nth-child(3) {
z-index: 800;
}
.badge-group > :nth-child(4) {
z-index: 700;
}
.badge-group > :nth-child(5) {
z-index: 600;
}
.badge-group .badge:not(:first-child) {
margin-left: -13px;
padding-left: 15px;
}
/* button with image */ /* button with image */
button.add, button.save, button.cancel, button.refresh, button.upload, button.search, button.login, button.plus, button.minus, button.next, button.back { button.add, button.save, button.cancel, button.refresh, button.upload, button.search, button.login, button.plus, button.minus, button.next, button.back {
padding-left:30px; padding-left:30px;

@ -105,8 +105,7 @@ if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params['only_total_category'] = true; $params['only_total_category'] = true;
$params['join_firstname_lastname'] = true; $params['join_firstname_lastname'] = true;
$params['show_official_code'] = true; $params['show_official_code'] = true;
$params['export_pdf'] = true; $params['export_pdf'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) { if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false); Display :: set_header(null, false, false);
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params); export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
@ -122,10 +121,11 @@ if (isset($_GET['exportpdf'])) {
$export_pdf_form = new DataForm(DataForm::TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self().'?exportpdf=&offset='.intval($_GET['offset']).'&selectcat='.intval($_GET['selectcat']), '_blank', ''); $export_pdf_form = new DataForm(DataForm::TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self().'?exportpdf=&offset='.intval($_GET['offset']).'&selectcat='.intval($_GET['selectcat']), '_blank', '');
if ($export_pdf_form->validate()) { if ($export_pdf_form->validate()) {
$params = array();
$params = $export_pdf_form->exportValues(); $params = $export_pdf_form->exportValues();
Display :: set_header(null, false, false); Display :: set_header(null, false, false);
$params['join_firstname_lastname'] = true; $params['join_firstname_lastname'] = true;
$params['show_usercode'] = true; $params['show_official_code'] = true;
$params['export_pdf'] = true; $params['export_pdf'] = true;
$params['only_total_category'] = false; $params['only_total_category'] = false;
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params); export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
@ -138,8 +138,7 @@ if (isset ($_GET['print'])) {
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks); $printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
echo print_table($printable_data[1],$printable_data[0], get_lang('FlatView'), $cat[0]->get_name()); echo print_table($printable_data[1],$printable_data[0], get_lang('FlatView'), $cat[0]->get_name());
exit; exit;
} }
if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') { if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') {
if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) { if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) {

@ -319,13 +319,12 @@ class GradebookTable extends SortableTable {
if (!empty($data_array)) { if (!empty($data_array)) {
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
$main_weight = intval($main_cat[0]->get_weight()); $main_weight = intval($main_cat[0]->get_weight());
if (intval($total_weight) == $main_weight) { if (intval($total_weight) == $main_weight) {
//$label = Display::return_icon('accept.png', get_lang('Ok'));
$label = null; $label = null;
$total = Display::badge($total_weight.' / '.$main_weight, 'success'); $total = score_badges(array($total_weight.' / '.$main_weight, '100%'));
} else { } else {
$label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $main_weight) ); $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $main_weight) );
$total = Display::badge($total_weight.' / '.$main_weight, 'warning'); $total = Display::badge($total_weight.' / '.$main_weight, 'warning');
} }
$row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',null, $total.' '.$label, 'child_of' =>$parent_id); $row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',null, $total.' '.$label, 'child_of' =>$parent_id);
$sortable_data[] = $row; $sortable_data[] = $row;
@ -337,8 +336,8 @@ class GradebookTable extends SortableTable {
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
if (count($main_cat) > 1) { if (count($main_cat) > 1) {
$main_weight = intval($main_cat[0]->get_weight()); $main_weight = intval($main_cat[0]->get_weight());
if (intval($total_categories_weight) == $main_weight) { if (intval($total_categories_weight) == $main_weight) {
$total = Display::badge($total_categories_weight.' / '.$main_weight, 'success'); $total = score_badges(array($total_categories_weight.' / '.$main_weight, '100%'));
} else { } else {
$total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning'); $total = Display::badge($total_categories_weight.' / '.$main_weight, 'warning');
} }

@ -121,7 +121,7 @@ class FlatViewDataGenerator
$headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).$add_weight; $headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).$add_weight;
} }
} else { } else {
if (!isset($this->params['only_total_category'])) { if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) {
for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) { for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
$item = $this->evals_links[$count + $items_start]; $item = $this->evals_links[$count + $items_start];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];

@ -839,4 +839,22 @@ function export_pdf_flatview($cat, $users, $alleval, $alllinks, $params = array(
$file_name = get_lang('FlatView').'_'.$file_name; $file_name = get_lang('FlatView').'_'.$file_name;
$pdf->content_to_pdf($html, $css, $file_name, api_get_course_id()); $pdf->content_to_pdf($html, $css, $file_name, api_get_course_id());
exit; exit;
}
function score_badges($list_values) {
$counter = 1;
$badges = array();
foreach ($list_values as $value) {
$class = 'info';
if ($counter == 1) {
$class = 'success';
}
$counter++;
$badges[] = Display::badge($value, $class);
}
return Display::badge_group($badges);
} }

@ -1383,7 +1383,7 @@ class Display {
return $div; return $div;
} }
function badge($count, $type ="warning") { function badge($count, $type ="warning") {
$class = ''; $class = '';
switch ($type) { switch ($type) {
@ -1404,12 +1404,21 @@ class Display {
break; break;
} }
if (!empty($count)) { if (!empty($count)) {
return ' <span class="badge '.$class.'">'.$count.'</span>'; return ' <span class="badge '.$class.'">'.$count.'</span>';
} }
return null; return null;
} }
function badge_group($badge_list) {
$html = '<div class="badge-group">';
foreach ($badge_list as $badge) {
$html .= $badge;
}
$html .= '</div>';
return $html;
}
function label($content, $type = null) { function label($content, $type = null) {
$class = ''; $class = '';
switch ($type) { switch ($type) {

Loading…
Cancel
Save