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

@ -52,7 +52,6 @@ class FlatViewTable extends SortableTable
);
$this->selectcat = $selectcat;
$this->datagen = new FlatViewDataGenerator(
$users,
$evals,
@ -361,10 +360,20 @@ class FlatViewTable extends SortableTable
. '?selectcat='.Security::remove_XSS($_GET['selectcat'])
. '&offset='.(($this->offset) - GRADEBOOK_ITEM_LIMIT)
. (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>';
} 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 .= ' ';
// next X
@ -376,10 +385,15 @@ class FlatViewTable extends SortableTable
. '?selectcat='.Security::remove_XSS($_GET['selectcat'])
. '&offset='.($this->offset + GRADEBOOK_ITEM_LIMIT)
. (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>';
} 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 .= '</tbody></table>';
@ -461,11 +475,23 @@ class FlatViewTable extends SortableTable
unset($user_row[0]);
$userInfo = api_get_user_info($user_id);
if ($is_western_name_order) {
$user_row[1] = $this->build_name_link($user_id, $userInfo['firstname']);
$user_row[2] = $this->build_name_link($user_id, $userInfo['lastname']);
$user_row[1] = $this->build_name_link(
$user_id,
$userInfo['firstname']
);
$user_row[2] = $this->build_name_link(
$user_id,
$userInfo['lastname']
);
} else {
$user_row[1] = $this->build_name_link($user_id, $userInfo['lastname']);
$user_row[2] = $this->build_name_link($user_id, $userInfo['firstname']);
$user_row[1] = $this->build_name_link(
$user_id,
$userInfo['lastname']
);
$user_row[2] = $this->build_name_link(
$user_id,
$userInfo['firstname']
);
}
$user_row = array_values($user_row);

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

Loading…
Cancel
Save