Gradebook: Adding the feature of hide/show subcategories see BT#4080

skala
Julio Montoya 14 years ago
parent 017d370c26
commit 5a52e3b5e4
  1. 21
      main/gradebook/index.php
  2. 21
      main/gradebook/lib/fe/gradebooktable.class.php
  3. 7
      main/gradebook/lib/gradebook_data_generator.class.php
  4. 4
      main/gradebook/lib/gradebook_functions.inc.php
  5. 61
      main/inc/lib/sortabletable.class.php

@ -46,7 +46,26 @@ $htmlHeadXtra[] = api_get_js('jqplot/plugins/jqplot.donutRenderer.min.js');*/
$htmlHeadXtra[] = '<script type="text/javascript">
$(document).ready( function() {
var show_icon = "../img/view_more_stats.gif";
var hide_icon = "../img/view_less_stats.gif";
$(document).ready(function() {
$(".view_children").live("click", function() {
var id = $(this).attr("data-cat-id");
$(".hidden_"+id).removeClass("hidden");
$(this).removeClass("view_children");
$(this).find("img").attr("src", hide_icon);
$(this).attr("class", "hide_children");
});
$(".hide_children").live("click", function(event) {
var id = $(this).attr("data-cat-id");
$(".hidden_"+id).addClass("hidden");
$(this).removeClass("hide_children");
$(this).addClass("view_children");
$(this).find("img").attr("src", show_icon);
});
/*
var s1 = [["a",25]];

@ -255,7 +255,7 @@ class GradebookTable extends SortableTable {
$invisibility_span_open = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_edit() && $item->is_visible() == '0') ? '</span>' : '';
$main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
$main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name();
$main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight();
if (api_is_allowed_to_edit(null, true)) {
@ -274,7 +274,7 @@ class GradebookTable extends SortableTable {
$weight = $data[3]/$category_weight*$main_cat[0]->get_weight();
$total_weight += $weight;
$row[] = $invisibility_span_open . $weight.$invisibility_span_close;
$row[] = $invisibility_span_open.$weight.$invisibility_span_close;
if (api_is_allowed_to_edit(null, true)) {
//$weight_total_links += intval($data[3]);
@ -301,13 +301,13 @@ class GradebookTable extends SortableTable {
if (count($eval_n_links)> 0 && $status_user!=1 ) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
//$my_score = $data[5]->get_eval_max()/;
//var_dump($data[5]);
if (!is_null($value_data)) {
$row[] = $value_data;
}
}
}
}
}
$row['child_of'] = $parent_id;
$sortable_data[] = $row;
}
@ -323,11 +323,11 @@ class GradebookTable extends SortableTable {
$label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $main_weight) );
$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);
$row = array(null, null, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h5>".get_lang('SubTotal').'</h5>',null, $total.' '.$label, 'child_of' =>$parent_id);
$sortable_data[] = $row;
}
}
}
}
} //end looping categories
if (api_is_allowed_to_edit()) {
@ -354,7 +354,7 @@ class GradebookTable extends SortableTable {
$weight_category = intval($this->build_weight($category[0]));
$course_code = $this->build_course_code($category[0]);
$weight_total_links = round($weight_total_links);
//var_dump($weight_total_links);;
if ($weight_total_links > $weight_category) {
$warning_message = get_lang('TotalWeightMustNotBeMoreThan').'&nbsp;'.$weight_category;
@ -414,7 +414,6 @@ class GradebookTable extends SortableTable {
}
}
}
//var_dump($main_categories);
return $sortable_data;
}

@ -102,8 +102,7 @@ class GradebookDataGenerator
$row[] = $this->build_date_column($item);
}*/
if (count($this->evals_links) > 0) {
if (!api_is_allowed_to_edit() || $status_user != 1 ) {
if (!api_is_allowed_to_edit() || $status_user != 1 ) {
$row[] = $this->build_result_column($item, $ignore_score_color);
$row[] = $item;
}
@ -163,7 +162,7 @@ class GradebookDataGenerator
}
function sort_by_date($item1, $item2) {
if(is_int($item1->get_date())) {
if (is_int($item1->get_date())) {
$timestamp1 = $item1->get_date();
} else {
$date = $item1->get_date();
@ -187,9 +186,7 @@ class GradebookDataGenerator
}
}
// Other functions
private function build_result_column($item, $ignore_score_color) {
$scoredisplay = ScoreDisplay :: instance();
$score = $item->calc_score(api_get_user_id());

@ -208,6 +208,10 @@ function build_edit_icons_cat($cat, $selectcat) {
if (empty($grade_model_id) || $grade_model_id == -1) {
$modify_icons= '<a href="gradebook_edit_cat.php?editcat='.$cat->get_id().'&amp;cidReq='.$cat->get_course_code().'">'.Display::return_icon('edit.png', get_lang('Modify'),'',ICON_SIZE_SMALL).'</a>';
}
if (!empty($grade_model_id) && $grade_model_id != -1) {
$modify_icons= '<a class="view_children" data-cat-id="'.$cat->get_id().'" href="javascript:void(0);">'.Display::return_icon('view_more_stats.gif', get_lang('Show'),'',ICON_SIZE_SMALL).'</a>';
}
$modify_icons .= '&nbsp;<a href="' . api_get_self() . '?visiblecat=' . $cat->get_id() . '&amp;' . $visibility_command . '=&amp;selectcat=' . $selectcat . ' ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_SMALL).'</a>';

@ -279,40 +279,35 @@ class SortableTable extends HTML_Table {
$html .= $content;
if (!$empty_table) {
if (!$empty_table) {
if (!empty($this->additional_parameters)) {
foreach($this->additional_parameters as $key => $value) {
$html .= '<input type="hidden" name ="'.Security::remove_XSS($key).'" value ="'.Security::remove_XSS($value).'" />';
}
}
$html .= '<input type="hidden" name = "action">';
$html .= '<input type="hidden" name="action">';
$html .= '<table style="width:100%;">';
$html .= '<tr>';
$html .= '<td colspan="2">';
if (count($this->form_actions) > 0) {
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" onclick="javascript: setCheckbox(true); return false;">'.get_lang('SelectAll').'</a>';
$html .= '<a class="btn" href="?'.$params.'" onclick="javascript: setCheckbox(false); return false;">'.get_lang('UnSelectAll').'</a> ';
$html .= '</div>';
$html .= '<div class="btn-group">
<button class="btn" onclick="javascript:return false;">'.get_lang('Actions').'</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>';
$html .= '<ul class="dropdown-menu">';
//$html .= '<select name="action">';
foreach ($this->form_actions as $action => & $label) {
//$html .= '<option value="'.$action.'">'.$label.'</option>';
$html .= '<li><a data ="'.$action.'" href="#" onclick="javascript:action_click(this); " >'.$label.'</a></li>';
}
$html .= '</ul>';
//$html .= '&nbsp;&nbsp;<button type="submit" class="btn save" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."'".')) return false;">'.get_lang('Select').'</button>';
$html .= '</div>';//btn-group
$html .= '<div class="btn-toolbar">';
$html .= '<div class="btn-group">';
$html .= '<a class="btn" href="?'.$params.'&amp;'.$this->param_prefix.'selectall=1" onclick="javascript: setCheckbox(true); return false;">'.get_lang('SelectAll').'</a>';
$html .= '<a class="btn" href="?'.$params.'" onclick="javascript: setCheckbox(false); return false;">'.get_lang('UnSelectAll').'</a> ';
$html .= '</div>';
$html .= '<div class="btn-group">
<button class="btn" onclick="javascript:return false;">'.get_lang('Actions').'</button>
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>';
$html .= '<ul class="dropdown-menu">';
foreach ($this->form_actions as $action => & $label) {
$html .= '<li><a data ="'.$action.'" href="#" onclick="javascript:action_click(this); " >'.$label.'</a></li>';
}
$html .= '</ul>';
$html .= '</div>';//btn-group
$html .= '</div>'; //toolbar
} else {
$html .= $form;
@ -579,7 +574,7 @@ class SortableTable extends HTML_Table {
public function get_navigation_html () {
$pager = $this->get_pager();
$pager_links = $pager->getLinks();
//$showed_items = $pager->getOffsetByPageId();
$nav = $pager_links['first'].' '.$pager_links['back'];
$nav .= ' '.$pager->getCurrentPageId().' / '.$pager->numPages().' ';
$nav .= $pager_links['next'].' '.$pager_links['last'];
@ -590,20 +585,25 @@ class SortableTable extends HTML_Table {
* Get the HTML-code with the data-table.
*/
public function get_table_html() {
$pager = $this->get_pager();
//$val = $pager->getOffsetByPageId();
$pager = $this->get_pager();
$offset = $pager->getOffsetByPageId();
$from = $offset[0] - 1;
$table_data = $this->get_table_data($from);
$this->altRowAttributes(0, array ('class' => 'row_odd'), array ('class' => 'row_even'), true);
if (is_array($table_data)) {
$count = 1;
foreach ($table_data as $index => & $row) {
$row = $this->filter_data($row);
$row = $this->filter_data($row);
$this->addRow($row);
if (isset($row['child_of'])) {
$this->setRowAttributes ($count, array('class' => 'hidden hidden_'.$row['child_of']), true);
}
$count++;
}
}
$this->altRowAttributes(0, array ('class' => 'row_odd'), array ('class' => 'row_even'), true);
foreach ($this->th_attributes as $column => $attributes) {
$this->setCellAttributes(0, $column, $attributes);
}
@ -619,8 +619,7 @@ class SortableTable extends HTML_Table {
* @return array table row items
*/
public function get_clean_html($sort = true) {
$pager = $this->get_pager();
$val = $pager->getOffsetByPageId();
$pager = $this->get_pager();
$offset = $pager->getOffsetByPageId();
$from = $offset[0] - 1;
@ -645,7 +644,7 @@ class SortableTable extends HTML_Table {
if ($total_number_of_items <= $this->default_items_per_page) {
return '';
}
$result[] = '<form method="get" action="'.api_get_self().'" style="display:inline;">';
$result[] = '<form method="GET" action="'.api_get_self().'" style="display:inline;">';
$param[$this->param_prefix.'direction'] = $this->direction;
$param[$this->param_prefix.'page_nr'] = $this->page_nr;
$param[$this->param_prefix.'column'] = $this->column;

Loading…
Cancel
Save