Fixe for showing result in header into gradebook cateboris -refs #7153

1.9.x
unknown 11 years ago
parent 6ce2dd138c
commit 7180de415e
  1. 12
      main/gradebook/lib/be/category.class.php
  2. 40
      main/gradebook/lib/fe/displaygradebook.php

@ -1378,7 +1378,17 @@ class Category implements GradebookItem
return $links;
}
public function getCategories($catId)
{
$tblGradeCategories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$courseInfo = api_get_course_info(api_get_course_id());
$courseCode = $courseInfo['code'];
$sql='SELECT * FROM '.$tblGradeCategories.' WHERE parent_id = '.intval($catId);
$result = Database::query($sql);
$allcats = Category::create_category_objects_from_sql_result($result);
return $allcats;
}
public function get_item_type()
{
return 'C';

@ -391,11 +391,20 @@ class DisplayGradebook
$catcourse = Category::load($catobj->get_id());
$main_weight = $catcourse[0]->get_weight();
$scoredisplay = ScoreDisplay :: instance();
$categories = Category::getCategories($catcourse[0]->get_id());
// generating the total score for a course
if (count($categories) > 0) {
foreach ($categories as $category) {
$allevals = $category->get_evaluations($user_id, true);
$alllinks = $category->get_links($user_id, true);
$catEvalsLinks = array_merge($allevals, $alllinks);
}
}
$allevals = $catcourse[0]->get_evaluations($user_id, true);
$alllinks = $catcourse[0]->get_links($user_id, true);
$evals_links = array_merge($allevals, $alllinks);
$allEvalsLinks = array_merge($allevals, $alllinks);
//echo count($alllinks);
//$allEvalsLinks = array_merge($catEvalsLinks, $evalsLinks);
$item_value = 0;
$item_total = 0;
@ -403,18 +412,33 @@ class DisplayGradebook
$item_value_total = 0;
$scoreinfo = null;
for ($count = 0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
for ($count = 0; $count < count($allEvalsLinks); $count++) {
$item = $allEvalsLinks[$count];
$score = $item->calc_score($user_id);
$divide = ( ($score[1]) == 0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$item_value = $score[0]/$divide;
$item_value = $score[0] / $divide * $item->get_weight() * $sub_cat_percentage / $main_weight;
$item_value_total +=$item_value;
$item_value_total += $score[0];
$item_total += $item->get_weight();
}
$item_total = $main_weight;
for ($count = 0; $count < count($catEvalsLinks); $count++) {
$item = $catEvalsLinks[$count];
$score = $item->calc_score($user_id);
$divide = ( ($score[1]) == 0 ) ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$item_value = $score[0]/$divide;
$item_value = $score[0] / $divide * $item->get_weight() * $sub_cat_percentage / $main_weight;
$catItemValueTotal += $score[0];
$catItemTotal += $item->get_weight();
}
//$item_total = $item->get_weight;
$item_value_total += $catItemValueTotal;
$item_total += $catItemTotal;
$total_score = array($item_value_total, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);

Loading…
Cancel
Save