|
|
|
|
@ -1,13 +1,12 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class FlatViewDataGenerator |
|
|
|
|
* Class to select, sort and transform object data into array data, |
|
|
|
|
* used for the teacher's flat view |
|
|
|
|
* @author Bert Steppé |
|
|
|
|
* @package chamilo.gradebook |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Class |
|
|
|
|
* |
|
|
|
|
* @package chamilo.gradebook |
|
|
|
|
*/ |
|
|
|
|
class FlatViewDataGenerator |
|
|
|
|
@ -28,7 +27,8 @@ class FlatViewDataGenerator |
|
|
|
|
/** |
|
|
|
|
* Constructor |
|
|
|
|
*/ |
|
|
|
|
public function FlatViewDataGenerator ($users = array(), $evals = array(), $links = array(), $params = array()) { |
|
|
|
|
public function FlatViewDataGenerator ($users = array(), $evals = array(), $links = array(), $params = array()) |
|
|
|
|
{ |
|
|
|
|
$this->users = (isset($users) ? $users : array()); |
|
|
|
|
$this->evals = (isset($evals) ? $evals : array()); |
|
|
|
|
$this->links = (isset($links) ? $links : array()); |
|
|
|
|
@ -39,25 +39,28 @@ class FlatViewDataGenerator |
|
|
|
|
/** |
|
|
|
|
* Get total number of users (rows) |
|
|
|
|
*/ |
|
|
|
|
public function get_total_users_count() { |
|
|
|
|
public function get_total_users_count() |
|
|
|
|
{ |
|
|
|
|
return count($this->users); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get total number of evaluations/links (columns) (the 2 users columns not included) |
|
|
|
|
*/ |
|
|
|
|
public function get_total_items_count() { |
|
|
|
|
public function get_total_items_count() |
|
|
|
|
{ |
|
|
|
|
return count($this->evals_links); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Get array containing column header names (incl user columns) |
|
|
|
|
* @param int Start item offset |
|
|
|
|
* @param int Number of items to get |
|
|
|
|
* @param bool whether to show the details or not |
|
|
|
|
* @param int $items_start Start item offset |
|
|
|
|
* @param int $items_count Number of items to get |
|
|
|
|
* @param bool $show_detail whether to show the details or not |
|
|
|
|
* @return array List of headers |
|
|
|
|
*/ |
|
|
|
|
public function get_header_names($items_start = 0, $items_count = null , $show_detail = false) { |
|
|
|
|
public function get_header_names($items_start = 0, $items_count = null, $show_detail = false) |
|
|
|
|
{ |
|
|
|
|
$headers = array(); |
|
|
|
|
|
|
|
|
|
if (isset($this->params['show_official_code']) && $this->params['show_official_code']) { |
|
|
|
|
@ -78,6 +81,7 @@ class FlatViewDataGenerator |
|
|
|
|
$headers[] = get_lang('FirstName'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!isset($items_count)) { |
|
|
|
|
$items_count = count($this->evals_links) - $items_start; |
|
|
|
|
} |
|
|
|
|
@ -100,7 +104,9 @@ class FlatViewDataGenerator |
|
|
|
|
|
|
|
|
|
//@todo move these in a function |
|
|
|
|
$sum_categories_weight_array = array(); |
|
|
|
|
$mainCategoryId = null; |
|
|
|
|
if (isset($this->category) && !empty($this->category)) { |
|
|
|
|
$mainCategoryId = $this->category->get_id(); |
|
|
|
|
$categories = Category::load(null, null, null, $this->category->get_id()); |
|
|
|
|
if (!empty($categories)) { |
|
|
|
|
foreach ($categories as $category) { |
|
|
|
|
@ -111,16 +117,15 @@ class FlatViewDataGenerator |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//No category was added |
|
|
|
|
// No category was added |
|
|
|
|
|
|
|
|
|
$course_code = api_get_course_id(); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
$course_code = api_get_course_id(); |
|
|
|
|
$session_id = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
$allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id'); |
|
|
|
|
|
|
|
|
|
if ($parent_id == 0 && !empty($allcat)) { |
|
|
|
|
|
|
|
|
|
//Means there are any subcategory |
|
|
|
|
// Means there are any subcategory |
|
|
|
|
foreach ($allcat as $sub_cat) { |
|
|
|
|
$sub_cat_weight = round(100*$sub_cat->get_weight()/$main_weight,1); |
|
|
|
|
$add_weight = " $sub_cat_weight %"; |
|
|
|
|
@ -130,19 +135,25 @@ class FlatViewDataGenerator |
|
|
|
|
$headers[] = Display::url($sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id()).$add_weight; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) { |
|
|
|
|
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++) { |
|
|
|
|
$item = $this->evals_links[$count + $items_start]; |
|
|
|
|
var_dump($item); |
|
|
|
|
$weight = round(100*$item->get_weight()/$main_weight,1); |
|
|
|
|
$headers[] = $item->get_name().' '.$weight.' % '; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$headers[] = api_strtoupper(get_lang('GradebookQualificationTotal')); |
|
|
|
|
|
|
|
|
|
return $headers; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function get_max_result_by_link($id) { |
|
|
|
|
public function get_max_result_by_link($id) |
|
|
|
|
{ |
|
|
|
|
$max = 0; |
|
|
|
|
foreach ($this->users as $user) { |
|
|
|
|
$item = $this->evals_links [$id]; |
|
|
|
|
@ -157,7 +168,8 @@ class FlatViewDataGenerator |
|
|
|
|
/** |
|
|
|
|
* Get array containing evaluation items |
|
|
|
|
*/ |
|
|
|
|
public function get_evaluation_items($items_start = 0, $items_count = null) { |
|
|
|
|
public function get_evaluation_items($items_start = 0, $items_count = null) |
|
|
|
|
{ |
|
|
|
|
$headers = array(); |
|
|
|
|
if (!isset($items_count)) { |
|
|
|
|
$items_count = count($this->evals_links) - $items_start; |
|
|
|
|
@ -177,10 +189,15 @@ class FlatViewDataGenerator |
|
|
|
|
* 2: user firstname |
|
|
|
|
* 3+: evaluation/link scores |
|
|
|
|
*/ |
|
|
|
|
public function get_data ($users_sorting = 0, $users_start = 0, $users_count = null, |
|
|
|
|
$items_start = 0, $items_count = null, |
|
|
|
|
$ignore_score_color = false, $show_all = false) { |
|
|
|
|
|
|
|
|
|
public function get_data( |
|
|
|
|
$users_sorting = 0, |
|
|
|
|
$users_start = 0, |
|
|
|
|
$users_count = null, |
|
|
|
|
$items_start = 0, |
|
|
|
|
$items_count = null, |
|
|
|
|
$ignore_score_color = false, |
|
|
|
|
$show_all = false |
|
|
|
|
) { |
|
|
|
|
// do some checks on users/items counts, redefine if invalid values |
|
|
|
|
if (!isset($users_count)) { |
|
|
|
|
$users_count = count ($this->users) - $users_start; |
|
|
|
|
@ -437,9 +454,9 @@ class FlatViewDataGenerator |
|
|
|
|
/** |
|
|
|
|
* Get actual array data evaluation/link scores |
|
|
|
|
*/ |
|
|
|
|
public function get_evaluation_sumary_results ($session_id = null) { |
|
|
|
|
|
|
|
|
|
$usertable = array (); |
|
|
|
|
public function get_evaluation_sumary_results ($session_id = null) |
|
|
|
|
{ |
|
|
|
|
$usertable = array(); |
|
|
|
|
foreach ($this->users as $user) { $usertable[] = $user; } |
|
|
|
|
$selected_users = $usertable; |
|
|
|
|
|
|
|
|
|
@ -484,7 +501,11 @@ class FlatViewDataGenerator |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function get_data_to_graph () { |
|
|
|
|
/** |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_data_to_graph() |
|
|
|
|
{ |
|
|
|
|
// do some checks on users/items counts, redefine if invalid values |
|
|
|
|
$usertable = array (); |
|
|
|
|
foreach ($this->users as $user) { |
|
|
|
|
@ -526,10 +547,11 @@ class FlatViewDataGenerator |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This is a function to show the generated data |
|
|
|
|
* @param type $displayWarning |
|
|
|
|
* @param bool $displayWarning |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_data_to_graph2 ($displayWarning = true) { |
|
|
|
|
public function get_data_to_graph2($displayWarning = true) |
|
|
|
|
{ |
|
|
|
|
// do some checks on users/items counts, redefine if invalid values |
|
|
|
|
$usertable = array (); |
|
|
|
|
foreach ($this->users as $user) { |
|
|
|
|
@ -549,10 +571,7 @@ class FlatViewDataGenerator |
|
|
|
|
$item_value = 0; |
|
|
|
|
$item_total = 0; |
|
|
|
|
$final_score = 0; |
|
|
|
|
|
|
|
|
|
$item_value_total = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$convert_using_the_global_weight = true; |
|
|
|
|
|
|
|
|
|
$course_code = api_get_course_id(); |
|
|
|
|
@ -572,8 +591,6 @@ class FlatViewDataGenerator |
|
|
|
|
$item_total += $sub_cat->get_weight(); |
|
|
|
|
|
|
|
|
|
$row[] = array ($item_value, trim($scoredisplay->display_score($real_score, SCORE_CUSTOM,null, true))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$item_value_total += $item_value; |
|
|
|
|
$final_score += $score[0]; |
|
|
|
|
//$final_score = ($final_score / $item_total) * 100; |
|
|
|
|
@ -581,10 +598,7 @@ class FlatViewDataGenerator |
|
|
|
|
} |
|
|
|
|
$total_score = array($final_score, $item_total); |
|
|
|
|
$row[] = array ($final_score, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
for ($count=0;$count < count($this->evals_links); $count++) { |
|
|
|
|
$item = $this->evals_links [$count]; |
|
|
|
|
$score = $item->calc_score($user[0]); |
|
|
|
|
@ -602,20 +616,20 @@ class FlatViewDataGenerator |
|
|
|
|
Display::display_warning_message( Display::display_warning_message($total_score[1])); |
|
|
|
|
} |
|
|
|
|
$row[] =array ($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$data[] = $row; |
|
|
|
|
} |
|
|
|
|
return $data; |
|
|
|
|
} |
|
|
|
|
// Sort functions - used internally |
|
|
|
|
|
|
|
|
|
function sort_by_last_name($item1, $item2) { |
|
|
|
|
public function sort_by_last_name($item1, $item2) |
|
|
|
|
{ |
|
|
|
|
return api_strcmp($item1[2], $item2[2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function sort_by_first_name($item1, $item2) { |
|
|
|
|
public function sort_by_first_name($item1, $item2) |
|
|
|
|
{ |
|
|
|
|
return api_strcmp($item1[3], $item2[3]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|