Minor - format code

pull/2487/head
jmontoyaa 7 years ago
parent a8d1767af9
commit 6aecb8fb6b
  1. 24
      main/gradebook/gradebook_flatview.php
  2. 44
      main/gradebook/lib/fe/flatviewtable.class.php
  3. 109
      main/gradebook/lib/flatview_data_generator.class.php

@ -55,7 +55,13 @@ if ($showlink) {
} }
if (isset($export_flatview_form) && (!$file_type == 'pdf')) { if (isset($export_flatview_form) && (!$file_type == 'pdf')) {
Display::addFlash(Display::return_message($export_flatview_form->toHtml(), 'normal', false)); Display::addFlash(
Display::return_message(
$export_flatview_form->toHtml(),
'normal',
false
)
);
} }
if (isset($_GET['selectcat'])) { if (isset($_GET['selectcat'])) {
@ -107,7 +113,7 @@ $mainCourseCategory = Category::load(
api_get_session_id() api_get_session_id()
); );
$flatviewtable = new FlatViewTable( $flatViewTable = new FlatViewTable(
$cat[0], $cat[0],
$users, $users,
$alleval, $alleval,
@ -118,9 +124,9 @@ $flatviewtable = new FlatViewTable(
$mainCourseCategory[0] $mainCourseCategory[0]
); );
$flatviewtable->setAutoFill(false); $flatViewTable->setAutoFill(false);
$parameters = array('selectcat' => intval($_GET['selectcat'])); $parameters = array('selectcat' => intval($_GET['selectcat']));
$flatviewtable->set_additional_parameters($parameters); $flatViewTable->set_additional_parameters($parameters);
$params = array(); $params = array();
if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') { if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
@ -131,7 +137,7 @@ if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
if ($cat[0]->is_locked() == true || api_is_platform_admin()) { if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false); Display :: set_header(null, false, false);
GradebookUtils::export_pdf_flatview( GradebookUtils::export_pdf_flatview(
$flatviewtable, $flatViewTable,
$cat, $cat,
$users, $users,
$alleval, $alleval,
@ -175,7 +181,7 @@ if (isset($_GET['exportpdf'])) {
$params['export_pdf'] = true; $params['export_pdf'] = true;
$params['only_total_category'] = false; $params['only_total_category'] = false;
GradebookUtils::export_pdf_flatview( GradebookUtils::export_pdf_flatview(
$flatviewtable, $flatViewTable,
$cat, $cat,
$users, $users,
$alleval, $alleval,
@ -276,7 +282,7 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
$showlink, $showlink,
$simple_search_form $simple_search_form
); );
$flatviewtable->display(); $flatViewTable->display();
} elseif (isset($_GET['selectcat']) && ($_SESSION['studentview'] == 'teacherview')) { } elseif (isset($_GET['selectcat']) && ($_SESSION['studentview'] == 'teacherview')) {
DisplayGradebook:: display_header_reduce_flatview( DisplayGradebook:: display_header_reduce_flatview(
$cat[0], $cat[0],
@ -286,10 +292,10 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
); );
// Table // Table
$flatviewtable->display(); $flatViewTable->display();
//@todo load images with jquery //@todo load images with jquery
echo '<div id="contentArea" style="text-align: center;" >'; echo '<div id="contentArea" style="text-align: center;" >';
$flatviewtable->display_graph_by_resource(); $flatViewTable->display_graph_by_resource();
echo '</div>'; echo '</div>';
} }

@ -52,7 +52,6 @@ class FlatViewTable extends SortableTable
); );
$this->selectcat = $selectcat; $this->selectcat = $selectcat;
$this->datagen = new FlatViewDataGenerator( $this->datagen = new FlatViewDataGenerator(
$users, $users,
$evals, $evals,
@ -361,10 +360,20 @@ class FlatViewTable extends SortableTable
. '?selectcat='.Security::remove_XSS($_GET['selectcat']) . '?selectcat='.Security::remove_XSS($_GET['selectcat'])
. '&offset='.(($this->offset) - GRADEBOOK_ITEM_LIMIT) . '&offset='.(($this->offset) - GRADEBOOK_ITEM_LIMIT)
. (isset($_GET['search']) ? '&search='.Security::remove_XSS($_GET['search']) : '').'">' . (isset($_GET['search']) ? '&search='.Security::remove_XSS($_GET['search']) : '').'">'
. Display::return_icon('action_prev.png', get_lang('PreviousPage'), array(), 32) .Display::return_icon(
'action_prev.png',
get_lang('PreviousPage'),
array(),
ICON_SIZE_MEDIUM
)
. '</a>'; . '</a>';
} else { } else {
$header .= Display::return_icon('action_prev_na.png', get_lang('PreviousPage'), array(), 32); $header .= Display::return_icon(
'action_prev_na.png',
get_lang('PreviousPage'),
array(),
ICON_SIZE_MEDIUM
);
} }
$header .= ' '; $header .= ' ';
// next X // next X
@ -376,10 +385,15 @@ class FlatViewTable extends SortableTable
. '?selectcat='.Security::remove_XSS($_GET['selectcat']) . '?selectcat='.Security::remove_XSS($_GET['selectcat'])
. '&offset='.($this->offset + GRADEBOOK_ITEM_LIMIT) . '&offset='.($this->offset + GRADEBOOK_ITEM_LIMIT)
. (isset($_GET['search']) ? '&search='.Security::remove_XSS($_GET['search']) : '').'">' . (isset($_GET['search']) ? '&search='.Security::remove_XSS($_GET['search']) : '').'">'
. Display::return_icon('action_next.png', get_lang('NextPage'), array(), 32) . Display::return_icon('action_next.png', get_lang('NextPage'), array(), ICON_SIZE_MEDIUM)
. '</a>'; . '</a>';
} else { } else {
$header .= Display::return_icon('action_next_na.png', get_lang('NextPage'), array(), 32); $header .= Display::return_icon(
'action_next_na.png',
get_lang('NextPage'),
array(),
ICON_SIZE_MEDIUM
);
} }
$header .= '</td>'; $header .= '</td>';
$header .= '</tbody></table>'; $header .= '</tbody></table>';
@ -461,11 +475,23 @@ class FlatViewTable extends SortableTable
unset($user_row[0]); unset($user_row[0]);
$userInfo = api_get_user_info($user_id); $userInfo = api_get_user_info($user_id);
if ($is_western_name_order) { if ($is_western_name_order) {
$user_row[1] = $this->build_name_link($user_id, $userInfo['firstname']); $user_row[1] = $this->build_name_link(
$user_row[2] = $this->build_name_link($user_id, $userInfo['lastname']); $user_id,
$userInfo['firstname']
);
$user_row[2] = $this->build_name_link(
$user_id,
$userInfo['lastname']
);
} else { } else {
$user_row[1] = $this->build_name_link($user_id, $userInfo['lastname']); $user_row[1] = $this->build_name_link(
$user_row[2] = $this->build_name_link($user_id, $userInfo['firstname']); $user_id,
$userInfo['lastname']
);
$user_row[2] = $this->build_name_link(
$user_id,
$userInfo['firstname']
);
} }
$user_row = array_values($user_row); $user_row = array_values($user_row);

@ -39,9 +39,9 @@ class FlatViewDataGenerator
$params = array(), $params = array(),
$mainCourseCategory = null $mainCourseCategory = null
) { ) {
$this->users = (isset($users) ? $users : array()); $this->users = isset($users) ? $users : array();
$this->evals = (isset($evals) ? $evals : array()); $this->evals = isset($evals) ? $evals : array();
$this->links = (isset($links) ? $links : array()); $this->links = isset($links) ? $links : array();
$this->evals_links = array_merge($this->evals, $this->links); $this->evals_links = array_merge($this->evals, $this->links);
$this->params = $params; $this->params = $params;
$this->mainCourseCategory = $mainCourseCategory; $this->mainCourseCategory = $mainCourseCategory;
@ -110,7 +110,6 @@ class FlatViewDataGenerator
} }
$parent_id = $this->category->get_parent_id(); $parent_id = $this->category->get_parent_id();
if ($parent_id == 0 || if ($parent_id == 0 ||
isset($this->params['only_subcat']) && isset($this->params['only_subcat']) &&
$this->params['only_subcat'] == $this->category->get_id() $this->params['only_subcat'] == $this->category->get_id()
@ -130,7 +129,6 @@ class FlatViewDataGenerator
//@todo move these in a function //@todo move these in a function
$sum_categories_weight_array = array(); $sum_categories_weight_array = array();
$mainCategoryId = null; $mainCategoryId = null;
$mainCourseCategory = $this->getMainCourseCategory(); $mainCourseCategory = $this->getMainCourseCategory();
@ -139,7 +137,12 @@ class FlatViewDataGenerator
} }
if (isset($this->category) && !empty($this->category)) { if (isset($this->category) && !empty($this->category)) {
$categories = Category::load(null, null, null, $this->category->get_id()); $categories = Category::load(
null,
null,
null,
$this->category->get_id()
);
if (!empty($categories)) { if (!empty($categories)) {
foreach ($categories as $category) { foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight(); $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
@ -150,7 +153,6 @@ class FlatViewDataGenerator
} }
// No category was added // No category was added
$course_code = api_get_course_id(); $course_code = api_get_course_id();
$session_id = api_get_session_id(); $session_id = api_get_session_id();
@ -164,7 +166,6 @@ class FlatViewDataGenerator
$evaluationsAdded = array(); $evaluationsAdded = array();
if ($parent_id == 0 && !empty($allcat)) { if ($parent_id == 0 && !empty($allcat)) {
// Means there are any subcategory // Means there are any subcategory
foreach ($allcat as $sub_cat) { foreach ($allcat as $sub_cat) {
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1); $sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %"; $add_weight = " $sub_cat_weight %";
@ -327,7 +328,7 @@ class FlatViewDataGenerator
$selected_users = array_slice($userTable, $users_start, $users_count); $selected_users = array_slice($userTable, $users_start, $users_count);
// Generate actual data array // Generate actual data array
$scoredisplay = ScoreDisplay::instance(); $scoreDisplay = ScoreDisplay::instance();
$data = array(); $data = array();
$displaytype = SCORE_DIV; $displaytype = SCORE_DIV;
@ -344,7 +345,12 @@ class FlatViewDataGenerator
} }
if (isset($this->category) && !empty($this->category)) { if (isset($this->category) && !empty($this->category)) {
$categories = Category::load(null, null, null, $this->category->get_id()); $categories = Category::load(
null,
null,
null,
$this->category->get_id()
);
if (!empty($categories)) { if (!empty($categories)) {
foreach ($categories as $category) { foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight(); $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
@ -409,11 +415,11 @@ class FlatViewDataGenerator
} else { } else {
if ($export_to_pdf) { if ($export_to_pdf) {
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
$row['firstname'] = $user[3]; $row['firstname'] = $user[3];
$row['lastname'] = $user[2]; $row['lastname'] = $user[2];
} else { } else {
$row['lastname'] = $user[2]; $row['lastname'] = $user[2];
$row['firstname'] = $user[3]; $row['firstname'] = $user[3];
} }
} else { } else {
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
@ -455,7 +461,7 @@ class FlatViewDataGenerator
$linkScoreList = []; $linkScoreList = [];
foreach ($links as $link) { foreach ($links as $link) {
$linkScore = $link->calc_score($user_id); $linkScore = $link->calc_score($user_id);
$linkScoreList[] = $scoredisplay->display_score( $linkScoreList[] = $scoreDisplay->display_score(
$linkScore, $linkScore,
SCORE_SIMPLE SCORE_SIMPLE
); );
@ -464,7 +470,7 @@ class FlatViewDataGenerator
$evalScoreList = []; $evalScoreList = [];
foreach ($evaluations as $evaluation) { foreach ($evaluations as $evaluation) {
$evalScore = $evaluation->calc_score($user_id); $evalScore = $evaluation->calc_score($user_id);
$evalScoreList[] = $scoredisplay->display_score( $evalScoreList[] = $scoreDisplay->display_score(
$evalScore, $evalScore,
SCORE_SIMPLE SCORE_SIMPLE
); );
@ -473,7 +479,6 @@ class FlatViewDataGenerator
$real_score = $score; $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()]; $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
$item_value = $score[0] / $divide * $main_weight; $item_value = $score[0] / $divide * $main_weight;
@ -488,12 +493,28 @@ class FlatViewDataGenerator
} }
*/ */
if (api_get_setting('gradebook_show_percentage_in_reports') === 'false') { if (api_get_setting('gradebook_show_percentage_in_reports') === 'false') {
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE, true); $real_score = $scoreDisplay->display_score(
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM, null); $real_score,
SCORE_SIMPLE,
true
);
$temp_score = $scoreDisplay->display_score(
$score,
SCORE_DIV_SIMPLE_WITH_CUSTOM,
null
);
$temp_score = Display::tip($real_score, $temp_score); $temp_score = Display::tip($real_score, $temp_score);
} else { } else {
$real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); $real_score = $scoreDisplay->display_score(
$temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM, null); $real_score,
SCORE_DIV_PERCENT,
SCORE_ONLY_SCORE
);
$temp_score = $scoreDisplay->display_score(
$score,
SCORE_DIV_SIMPLE_WITH_CUSTOM,
null
);
$temp_score = Display::tip($temp_score, $real_score); $temp_score = Display::tip($temp_score, $real_score);
} }
@ -561,18 +582,18 @@ class FlatViewDataGenerator
if (!$show_all) { if (!$show_all) {
if ($export_to_pdf) { if ($export_to_pdf) {
$row['total'] = $scoredisplay->display_score($total_score); $row['total'] = $scoreDisplay->display_score($total_score);
} else { } else {
$row[] = $scoredisplay->display_score($total_score); $row[] = $scoreDisplay->display_score($total_score);
} }
} else { } else {
if ($export_to_pdf) { if ($export_to_pdf) {
$row['total'] = $scoredisplay->display_score( $row['total'] = $scoreDisplay->display_score(
$total_score, $total_score,
SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS
); );
} else { } else {
$row[] = $scoredisplay->display_score( $row[] = $scoreDisplay->display_score(
$total_score, $total_score,
SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS
); );
@ -607,10 +628,9 @@ class FlatViewDataGenerator
$evaluationsAlreadyAdded = array() $evaluationsAlreadyAdded = array()
) { ) {
// Generate actual data array // Generate actual data array
$scoredisplay = ScoreDisplay::instance(); $scoreDisplay = ScoreDisplay::instance();
$item_total = 0; $item_total = 0;
$item_value_total = 0; $item_value_total = 0;
$evaluationsAdded = array(); $evaluationsAdded = array();
for ($count = 0; $count < $items_count && ($items_start + $count < count($this->evals_links)); $count++) { for ($count = 0; $count < $items_count && ($items_start + $count < count($this->evals_links)); $count++) {
@ -655,13 +675,28 @@ class FlatViewDataGenerator
} }
$item_total += $item->get_weight(); $item_total += $item->get_weight();
$complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); $complete_score = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT,
SCORE_ONLY_SCORE
);
if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
$real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); $real_score = $scoreDisplay->display_score(
$temp_score = $scoredisplay->display_score(array($item_value, null), SCORE_DIV_SIMPLE_WITH_CUSTOM); $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); $temp_score = Display::tip($real_score, $temp_score);
} else { } else {
$temp_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT_WITH_CUSTOM); $temp_score = $scoreDisplay->display_score(
$real_score,
SCORE_DIV_PERCENT_WITH_CUSTOM
);
$temp_score = Display::tip($temp_score, $complete_score); $temp_score = Display::tip($temp_score, $complete_score);
} }
@ -710,7 +745,7 @@ class FlatViewDataGenerator
* @param int $session_id * @param int $session_id
* @return array * @return array
*/ */
public function get_evaluation_sumary_results($session_id = null) public function getEvaluationSummaryResults($session_id = null)
{ {
$usertable = array(); $usertable = array();
foreach ($this->users as $user) { foreach ($this->users as $user) {
@ -832,7 +867,7 @@ class FlatViewDataGenerator
usort($usertable, array('FlatViewDataGenerator', 'sort_by_first_name')); usort($usertable, array('FlatViewDataGenerator', 'sort_by_first_name'));
// generate actual data array // generate actual data array
$scoredisplay = ScoreDisplay::instance(); $scoreDisplay = ScoreDisplay::instance();
$data = array(); $data = array();
$selected_users = $usertable; $selected_users = $usertable;
foreach ($selected_users as $user) { foreach ($selected_users as $user) {
@ -864,7 +899,7 @@ class FlatViewDataGenerator
$row[] = array( $row[] = array(
$item_value, $item_value,
trim( trim(
$scoredisplay->display_score( $scoreDisplay->display_score(
$real_score, $real_score,
SCORE_CUSTOM, SCORE_CUSTOM,
null, null,
@ -881,7 +916,7 @@ class FlatViewDataGenerator
$row[] = array( $row[] = array(
$final_score, $final_score,
trim( trim(
$scoredisplay->display_score( $scoreDisplay->display_score(
$total_score, $total_score,
SCORE_CUSTOM, SCORE_CUSTOM,
null, null,
@ -901,7 +936,7 @@ class FlatViewDataGenerator
$row[] = array( $row[] = array(
$score_final, $score_final,
trim( trim(
$scoredisplay->display_score( $scoreDisplay->display_score(
$score, $score,
SCORE_CUSTOM, SCORE_CUSTOM,
null, null,
@ -919,7 +954,7 @@ class FlatViewDataGenerator
$row[] = array( $row[] = array(
$score_final, $score_final,
trim( trim(
$scoredisplay->display_score( $scoreDisplay->display_score(
$total_score, $total_score,
SCORE_CUSTOM, SCORE_CUSTOM,
null, null,

Loading…
Cancel
Save