fix report see BT#9428

1.10.x
Julio Montoya 10 years ago
parent b70441a434
commit d96242243d
  1. 36
      main/gradebook/lib/fe/gradebooktable.class.php
  2. 32
      main/gradebook/lib/gradebook_data_generator.class.php
  3. 1
      main/gradebook/personal_stats.php

@ -60,6 +60,10 @@ class GradebookTable extends SortableTable
$this->cats = $cats;
$this->datagen = new GradebookDataGenerator($cats, $evals, $links);
if (!empty($userId)) {
$this->datagen->userId = $userId;
}
if (isset($addparams)) {
$this->set_additional_parameters($addparams);
}
@ -188,10 +192,14 @@ class GradebookTable extends SortableTable
}
// Status of user in course.
$user_id = api_get_user_id();
//$user_id = api_get_user_id();
$user_id = $this->userId;
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$status_user = api_get_status_of_user_in_course($user_id, api_get_course_int_id());
$status_user = api_get_status_of_user_in_course(
api_get_user_id(),
api_get_course_int_id()
);
if (empty($session_id)) {
$statusToFilter = STUDENT;
@ -207,6 +215,8 @@ class GradebookTable extends SortableTable
$statusToFilter
);
$this->datagen->userId = $this->userId;
$data_array = $this->datagen->get_data(
$sorting,
$from,
@ -299,7 +309,7 @@ class GradebookTable extends SortableTable
$weight_total_links += $data[3];
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$scoretotal = $cattotal[0]->calc_score($this->userId);
$item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
}
@ -311,7 +321,7 @@ class GradebookTable extends SortableTable
$row[] = $this->build_edit_column($item);
}
} else {
$score = $item->calc_score(api_get_user_id());
$score = $item->calc_score($this->userId);
if (!empty($score[1])) {
$completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
@ -397,6 +407,7 @@ class GradebookTable extends SortableTable
$alllink = $cats[0]->get_links($this->userId);
$sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink);
$sub_cat_info->userId = $user_id;
$data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page);
$total_weight = 0;
@ -440,12 +451,16 @@ class GradebookTable extends SortableTable
//$weight_total_links += intval($data[3]);
} else {
$cattotal = Category::load($_GET['selectcat']);
$scoretotal = $cattotal[0]->calc_score(api_get_user_id());
$scoretotal = $cattotal[0]->calc_score($this->userId);
$item_value = $scoretotal[0];
}
// Admins get an edit column.
if ($this->teacherView) {
if (api_is_allowed_to_edit(null, true) &&
isset($_GET['user_id']) == false &&
(isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action'])
)
) {
$cat = new Category();
$show_message = $cat->show_message_resource_delete($item->get_course_code());
if ($show_message === false) {
@ -457,7 +472,7 @@ class GradebookTable extends SortableTable
// Students get the results and certificates columns
$eval_n_links = array_merge($alleval, $alllink);
if (count($eval_n_links)> 0 && $status_user != 1) {
if (count($eval_n_links)> 0) {
$value_data = isset($data[4]) ? $data[4] : null;
if (!is_null($value_data)) {
@ -487,7 +502,10 @@ class GradebookTable extends SortableTable
}
}
}
$row['child_of'] = $parent_id;
if ($this->exportToPdf == false) {
$row['child_of'] = $parent_id;
}
$sortable_data[] = $row;
}
@ -567,7 +585,7 @@ class GradebookTable extends SortableTable
$totalRanking[$student['user_id']] = $score[0];
}
$totalRanking = AbstractLink::getCurrentUserRanking($totalRanking);
$totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking);
$totalRanking = $scoredisplay->display_score(
$totalRanking,

@ -19,6 +19,7 @@ class GradebookDataGenerator
const GDG_SORT_ASC = 32;
const GDG_SORT_DESC = 64;
const GDG_SORT_ID = 128;
public $userId;
private $items;
private $evals_links;
@ -56,6 +57,7 @@ class GradebookDataGenerator
// merge categories, evaluations and links
$this->items = array_merge($allcats, $allevals, $tabLinkToDisplay);
$this->evals_links = array_merge($allevals, $tabLinkToDisplay);
$this->userId = api_get_user_id();
}
/**
@ -106,13 +108,17 @@ class GradebookDataGenerator
if ($sorting & self :: GDG_SORT_DESC) {
$allitems = array_reverse($allitems);
}
// get selected items
$userId = $this->userId;
// Get selected items
$visibleitems = array_slice($allitems, $start, $count);
//status de user in course
$userId = api_get_user_id();
$course_code = api_get_course_id();
$sessionId = api_get_session_id();
$status_user = api_get_status_of_user_in_course($userId, api_get_course_int_id());
$status_user = api_get_status_of_user_in_course(
api_get_user_id(),
api_get_course_int_id()
);
if (empty($sessionId)) {
$statusToFilter = STUDENT;
@ -145,9 +151,9 @@ class GradebookDataGenerator
$row[] = $item->get_weight();
if (count($this->evals_links) > 0) {
// Items inside a category.
if (!api_is_allowed_to_edit() || $status_user != 1) {
if (1) {
$resultColumn = $this->build_result_column(
api_get_user_id(),
$userId,
$item,
$ignore_score_color
);
@ -167,7 +173,7 @@ class GradebookDataGenerator
$row['average_score'] = $average['score'];
// Ranking
$ranking = $this->buildRankingColumn($item, $userCount);
$ranking = $this->buildRankingColumn($item, $userId, $userCount);
$row['ranking'] = $ranking['display'];
$row['ranking_score'] = $ranking['score'];
@ -206,7 +212,7 @@ class GradebookDataGenerator
}
$scoreDisplay = ScoreDisplay::instance();
$score = AbstractLink::getCurrentUserRanking($rankingStudentList);
$score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList);
$row['ranking'] = $scoreDisplay->display_score($score, SCORE_DIV);
}
$data[] = $row;
@ -255,13 +261,14 @@ class GradebookDataGenerator
/**
* @param GradebookItem $item
* @param int $userId
* @param int $userCount
*
* @return string
*/
private function buildRankingColumn(GradebookItem $item, $userCount = 0)
private function buildRankingColumn(GradebookItem $item, $userId = null, $userCount = 0)
{
$score = $item->calc_score(null, 'ranking');
$score = $item->calc_score($userId, 'ranking');
$score[1] = $userCount;
$scoreDisplay = null;
@ -328,11 +335,6 @@ class GradebookDataGenerator
// evaluation and link
case 'E' :
case 'L' :
/** @var Category $category */
$category = $item->getCategory();
$parentId = $category->get_parent_id();
$scoreWeight = [];
//if ($parentId == 0) {
$scoreWeight = [
$score[0] / $score[1] * $item->get_weight(),

@ -27,6 +27,7 @@ $gradebooktable = new GradebookTable(
array(),
false
);
$gradebooktable->userId = $userId;
$table = $gradebooktable->return_table();
echo $gradebooktable->getGraph();

Loading…
Cancel
Save