From 251329d0109cddae0eb8320194a3e9ae1ccd2260 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Sun, 31 Mar 2013 19:00:27 -0500 Subject: [PATCH] Minor - Coding conventions spacing --- .../lib/flatview_data_generator.class.php | 164 +++++++++--------- 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 74594734ff..3b3b3c1836 100644 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -180,28 +180,28 @@ class FlatViewDataGenerator 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; } if ($users_count < 0) { $users_count = 0; - } + } if (!isset($items_count)) { $items_count = count ($this->evals) + count ($this->links) - $items_start; } if ($items_count < 0) { $items_count = 0; } - + // copy users to a new array that we will sort // TODO - needed ? $usertable = array (); foreach ($this->users as $user) { $usertable[] = $user; } - + // sort users array if ($users_sorting & self :: FVDG_SORT_LASTNAME) { usort($usertable, array ('FlatViewDataGenerator','sort_by_last_name')); @@ -215,7 +215,7 @@ class FlatViewDataGenerator // select the requested users $selected_users = array_slice($usertable, $users_start, $users_count); - + // generate actual data array $scoredisplay = ScoreDisplay :: instance(); @@ -225,21 +225,21 @@ class FlatViewDataGenerator $displaytype |= SCORE_IGNORE_SPLIT; } //@todo move these in a function - $sum_categories_weight_array = array(); - - if (isset($this->category) && !empty($this->category)) { + $sum_categories_weight_array = array(); + + if (isset($this->category) && !empty($this->category)) { $categories = Category::load(null, null, null, $this->category->get_id()); if (!empty($categories)) { - foreach($categories as $category) { + foreach($categories as $category) { $sum_categories_weight_array[$category->get_id()] = $category->get_weight(); } } else { $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight(); } } - + $parent_id = $this->category->get_parent_id(); - + if ($parent_id == 0 or $this->params['only_subcat'] == $this->category->get_id()) { $main_weight = $this->category->get_weight(); $grade_model_id = $this->category->get_grade_model_id(); @@ -247,173 +247,173 @@ class FlatViewDataGenerator $main_cat = Category::load($parent_id, null, null); $main_weight = $main_cat[0]->get_weight(); $grade_model_id = $main_cat[0]->get_grade_model_id(); - } - + } + $use_grade_model = true; if (empty($grade_model_id) || $grade_model_id == -1) { - $use_grade_model = false; - } - + $use_grade_model = false; + } + $export_to_pdf = false; - if (isset($this->params['export_pdf']) && $this->params['export_pdf']) { + if (isset($this->params['export_pdf']) && $this->params['export_pdf']) { $export_to_pdf = true; } - + foreach ($selected_users as $user) { - $row = array(); + $row = array(); if ($export_to_pdf) { $row['user_id'] = $user_id = $user[0]; //user id } else { $row[] = $user_id = $user[0]; //user id } - - if (isset($this->params['show_official_code']) && $this->params['show_official_code']) { + + if (isset($this->params['show_official_code']) && $this->params['show_official_code']) { if ($export_to_pdf) { $row['official_code'] = $user[4]; //official code } else { $row[] = $user[4]; //official code } } - - if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) { + + if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) { if ($export_to_pdf) { - $row['name'] = api_get_person_name($user[3], $user[2]); //last name + $row['name'] = api_get_person_name($user[3], $user[2]); //last name } else { - $row[] = api_get_person_name($user[3], $user[2]); //last name + $row[] = api_get_person_name($user[3], $user[2]); //last name } } else { if ($export_to_pdf) { if (api_is_western_name_order()) { $row['firstname'] = $user[3]; - $row['lastname'] = $user[2]; + $row['lastname'] = $user[2]; } else { $row['lastname'] = $user[2]; $row['firstname'] = $user[3]; } } else { if (api_is_western_name_order()) { - $row[] = $user[3]; //first name - $row[] = $user[2]; //last name + $row[] = $user[3]; //first name + $row[] = $user[2]; //last name } else { $row[] = $user[2]; //last name - $row[] = $user[3]; //first name + $row[] = $user[3]; //first name } } } - + $item_value = 0; $item_value_total = 0; $item_total = 0; - + $convert_using_the_global_weight = true; - - $course_code = api_get_course_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)) { - + foreach ($allcat as $sub_cat) { $score = $sub_cat->calc_score($user_id); $real_score = $score; - $divide = ( ($score[1])==0 ) ? 1 : $score[1]; - + $divide = ( ($score[1])==0 ) ? 1 : $score[1]; + $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; $item_value = $score[0]/$divide*$main_weight; - //Fixing total when using one or multiple gradebooks + //Fixing total when using one or multiple gradebooks $percentage = $sub_cat->get_weight()/($sub_cat_percentage) * $sub_cat_percentage/$this->category->get_weight(); - $item_value = $percentage*$item_value; + $item_value = $percentage*$item_value; $item_total += $sub_cat->get_weight(); - - if ($convert_using_the_global_weight) { - $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); + +/* + if ($convert_using_the_global_weight) { + $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); $score[1] = $main_weight ; - } - + } +*/ if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { - //if (true) - $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); - $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); + //if (true) + $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); + $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($real_score, $temp_score); - } else { - $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); + } else { + $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($temp_score, $real_score); - } - + } + if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) { if (!$show_all) { - $row[] = $temp_score.' '; - } else { + $row[] = $temp_score.' '; + } else { $row[] = $temp_score; - } + } } - $item_value_total +=$item_value; + $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]; + $item = $this->evals_links[$count + $items_start]; $score = $item->calc_score($user_id); - $real_score = $score; + $real_score = $score; $divide = ( ($score[1])==0 ) ? 1 : $score[1]; - + //sub cat weight $sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()]; $item_value = $score[0]/$divide; - - //Fixing total when using one or multiple gradebooks - if ($this->category->get_parent_id() == 0 ) { + + //Fixing total when using one or multiple gradebooks + if ($this->category->get_parent_id() == 0 ) { $item_value = $score[0]/$divide*$item->get_weight(); } else { - $item_value = $item_value*$item->get_weight(); + $item_value = $item_value*$item->get_weight(); } - - $item_total += $item->get_weight(); + + $item_total += $item->get_weight(); /* $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($temp_score, $complete_score);*/ - - //if (true) + + //if (true) if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { - $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); - $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); + $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); + $temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($real_score, $temp_score); - } else { + } else { $temp_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT_WITH_CUSTOM); $temp_score = Display::tip($temp_score, $complete_score); } - + if (!isset($this->params['only_total_category']) || (isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)) { - if (!$show_all) { + if (!$show_all) { if (in_array($item->get_type() , array(LINK_EXERCISE, LINK_DROPBOX, LINK_STUDENTPUBLICATION, LINK_LEARNPATH, LINK_FORUM_THREAD, LINK_ATTENDANCE,LINK_SURVEY))) { if (!empty($score[0])) { - $row[] = $temp_score.' '; + $row[] = $temp_score.' '; } else { $row[] = ''; } - } else { + } else { $row[] = $temp_score.' '; - } - } else { - $row[] = $temp_score; - } - } + } + } else { + $row[] = $temp_score; + } + } $item_value_total +=$item_value; } $item_total = $main_weight; - } + } $total_score = array($item_value_total, $item_total); -error_log(print_r($total_score,1)); - + if (!$show_all) { if ($export_to_pdf) { $row['total'] = $scoredisplay->display_score($total_score); @@ -427,10 +427,10 @@ error_log(print_r($total_score,1)); $row[] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS); } } - unset($score); + unset($score); //var_dump($row);exit; $data[] = $row; - } + } return $data; }