More gradebook fixes

skala
Julio Montoya 13 years ago
parent 1fe323eba3
commit 08c94cbbe2
  1. 24
      main/gradebook/lib/fe/displaygradebook.php
  2. 4
      main/gradebook/lib/fe/evalform.class.php
  3. 3
      main/gradebook/lib/fe/flatviewtable.class.php
  4. 9
      main/gradebook/lib/fe/linkaddeditform.class.php
  5. 47
      main/gradebook/lib/flatview_data_generator.class.php
  6. 15
      main/gradebook/lib/scoredisplay.class.php

@ -175,25 +175,12 @@ class DisplayGradebook
$header .= '<a href="' . api_get_self() . '?export_format=doc&export_report=export_report&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('export_doc.png', get_lang('ExportAsDOC'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="' . api_get_self() . '?print=&selectcat=' . $catobj->get_id() . '" target="_blank">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="' . api_get_self() . '?exportpdf=&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a>';
//exportpdf
//<div class="clear">
$header .= '</div>';
if (!$catobj->get_id() == '0') {
//this is necessary?
//$header .= '<table border="0" cellpadding="5"><tr><td><form name="itemfilter" method="post" action="' . api_get_self() . '?selectcat=' . $catobj->get_id() . '"><input type="checkbox" name="showeval" onclick="document.itemfilter.submit()" ' . (($showeval == '1') ? 'checked' : '') . '>Show Evaluations &nbsp;';
//$header .= '<input type="checkbox" name="showlink" onclick="document.itemfilter.submit()" ' . (($showlink == '1') ? 'checked' : '') . '>'.get_lang('ShowLinks').'</form></td></tr></table>';
}
/*
if (isset ($_GET['search'])) {
$header .= '<b>'.get_lang('SearchResults').' :</b>';
}*/
$header .= '</div>';
echo $header;
}
function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) {
//student
// Student
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
$objcat = new Category();
$course_id = Database::get_course_by_category($selectcat);
@ -218,8 +205,7 @@ class DisplayGradebook
$score = $item->calc_score($user_id);
$my_score_denom=($score[1]==0) ? 1 : $score[1];
$item_value+=$score[0]/$my_score_denom*$item->get_weight();
$item_total+=$item->get_weight();
//$row[] = $scoredisplay->display_score($score,SCORE_DIV_PERCENT);
$item_total+=$item->get_weight();
}
$item_value = number_format($item_value, 2, '.', ' ');
$total_score=array($item_value,$item_total);
@ -234,8 +220,8 @@ class DisplayGradebook
}
Display :: display_normal_message($scoreinfo, false);
}
// show navigation tree and buttons?
// show navigation tree and buttons?
$header = '<div class="actions"><table border=0>';
if (($showtree == '1') || (isset ($_GET['studentoverview']))) {
$header .= '<tr>';

@ -463,9 +463,7 @@ class EvalForm extends FormValidator
}
}
$global_weight = api_get_setting('gradebook_default_weight');
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array (
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$all_categories[0]->get_weight().'] '), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'

@ -78,8 +78,7 @@ class FlatViewTable extends SortableTable
$show_draw = false;
if ($total_users >0 ) {
foreach($pre_result as $res) {
$total = $res / ($total_users);
$total = $res / ($total_users);
if ($total != 0) {
$show_draw = true;
}

@ -87,17 +87,12 @@ class LinkAddEditForm extends FormValidator
if ($link->get_category_id() == $my_cat->get_id()) {
$default_weight = $my_cat->get_weight();
}
}
}
}
}
}
$global_weight = api_get_setting('gradebook_default_weight');
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$global_weight.'] '), true, array (
$this->add_textfield('weight_mask', array(get_lang('Weight'), null, ' [0 .. '.$category_object[0]->get_weight().'] '), true, array (
'size' => '4',
'maxlength' => '5',
'class' => 'span1'

@ -87,7 +87,7 @@ class FlatViewDataGenerator
$session_id = api_get_session_id();
$allcat = $this->category->get_subcategories(null, $course_code, $session_id);
foreach ($allcat as $sub_cat) {
$headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).' <br /> '.$sub_cat->get_weight().' % ';
$headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).' '.$sub_cat->get_weight().' % ';
}
} else {
for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
@ -97,18 +97,13 @@ class FlatViewDataGenerator
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
$weight = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight() *100, 2);
$headers[] = $item->get_name().' <br />'.$weight.' % ';
$headers[] = $item->get_name().' '.$weight.' % ';
if ($show_detail) {
//$headers[] = $item->get_name().' ('.get_lang('Detail').')';
}
}
}
$headers[] = get_lang('GradebookQualificationTotal').' 100%';
if ($show_detail) {
//$headers[] = get_lang('GradebookQualificationTotal').' ('.get_lang('Detail').')';
}
$headers[] = get_lang('GradebookQualificationTotal').' 100%';
return $headers;
}
@ -145,8 +140,7 @@ class FlatViewDataGenerator
$headers[] = $item->get_name();
}
return $headers;
}
}
/**
* Get actual array data
@ -217,8 +211,12 @@ class FlatViewDataGenerator
$grade_model_id = $this->category->get_grade_model_id();
$parent_id = $this->category->get_parent_id();
$main_cat = Category::load($parent_id, null, null);
$main_weight = $main_cat[0]->get_weight();
if ($parent_id == 0) {
$main_weight = $this->category->get_weight();
} else {
$main_cat = Category::load($parent_id, null, null);
$main_weight = $main_cat[0]->get_weight();
}
$use_grade_model = true;
if (empty($grade_model_id) || $grade_model_id == -1) {
@ -233,7 +231,9 @@ class FlatViewDataGenerator
$item_value = 0;
$item_value_total = 0;
$item_total = 0;
$item_total = 0;
$convert_using_the_global_weight = false;
if ($use_grade_model) {
$course_code = api_get_course_id();
@ -244,26 +244,31 @@ class FlatViewDataGenerator
$divide = ( ($score[1])==0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
$item_value = round($score[0]/$divide,2) * 100;
$item_value = round($score[0]/$divide,2) * $main_weight;
//Fixing total when using one or multiple gradebooks
$percentage = round($sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2);
$item_value = $percentage*$item_value;
$item_total += $sub_cat->get_weight();
if ($convert_using_the_global_weight) {
$score[0] = $main_weight*$score[0]/$sub_cat->get_weight();
$score[1] = $main_weight ;
}
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE);
$temp_score = $temp_score;
if (!$show_all) {
$row[] = $temp_score.' ';
} else {
$row[] = $temp_score;
}
}
$item_value_total +=$item_value;
}
}
if ($convert_using_the_global_weight) {
//$item_total = $main_weight;
}
} else {
for ($count=0; ($count < $items_count ) && ($items_start + $count < count($this->evals_links)); $count++) {
$item = $this->evals_links[$count + $items_start];
@ -287,7 +292,7 @@ class FlatViewDataGenerator
//$percentage = round($item->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(), 2);
//if ($debug) var_dump($item->get_weight().' '.$item_value .' -'.$sub_cat_percentage);
$item_value = $item_value*$item->get_weight();
$item_value = 100*$item_value/$item->get_weight();
$item_value = $main_weight*$item_value/$item->get_weight();
}
//if ($debug) var_dump($item_value);
$item_total += $item->get_weight();

@ -251,8 +251,7 @@ class ScoreDisplay
* (only taken into account if custom score display is enabled and for course/platform admin)
*/
public function display_score($score, $type = SCORE_DIV_PERCENT, $what = SCORE_BOTH, $no_color = false) {
$my_score = ($score==0) ? 1 : $score;
$my_score = ($score==0) ? 1 : $score;
if ($this->custom_enabled && isset($this->custom_display_conv)) {
$display = $this->display_default($my_score, $type);
} else {
@ -317,8 +316,16 @@ class ScoreDisplay
* Returns "100 %" for array("100", "100");
*/
private function display_as_percent($score) {
$score_denom=($score[1]==0) ? 1 : $score[1];
return round(($score[0] / $score_denom) * 100,2) . ' %';
//Add real weight ugly hack
/*$course_code = api_get_course_id();
$session_id = api_get_session_id();
$main_cat = Category :: load(null, null, $course_code, null, null, $session_id, false);
$global_weight = $main_cat[0]->get_weight();
$extra = $score[0] / $score_denom*$global_weight;
*/
$score_denom=($score[1]==0) ? 1 : $score[1];
return round(($score[0] / $score_denom) * 100,2) . ' %'.$extra;
}
/**

Loading…
Cancel
Save