/** * Get actual array data * @return array 2-dimensional array - each array contains the elements: * 0: cat/eval/link object * 1: item name * 2: description * 3: weight * 4: date * 5: student's score (if student logged in) */ public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false) { //$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); // do some checks on count, redefine if invalid value if (!isset($count)) { $count = count($this->items) - $start; } if ($count < 0) { $count = 0; } $allitems = $this->items; // sort array if ($sorting & self::GDG_SORT_TYPE) { usort($allitems, array('GradebookDataGenerator', 'sort_by_type')); } elseif ($sorting & self::GDG_SORT_ID) { usort($allitems, array('GradebookDataGenerator', 'sort_by_id')); } elseif ($sorting & self::GDG_SORT_NAME) { usort($allitems, array('GradebookDataGenerator', 'sort_by_name')); } elseif ($sorting & self::GDG_SORT_DESCRIPTION) { usort($allitems, array('GradebookDataGenerator', 'sort_by_description')); } elseif ($sorting & self::GDG_SORT_WEIGHT) { usort($allitems, array('GradebookDataGenerator', 'sort_by_weight')); } elseif ($sorting & self::GDG_SORT_DATE) { //usort($allitems, array('GradebookDataGenerator', 'sort_by_date')); } if ($sorting & self::GDG_SORT_DESC) { $allitems = array_reverse($allitems); } // get selected items $visibleitems = array_slice($allitems, $start, $count); //status de user in course $user_id = api_get_user_id(); $status_user = api_get_status_of_user_in_course($user_id, api_get_course_int_id()); // generate the data to display $data = array(); foreach ($visibleitems as $item) { $row = array(); $row[] = $item; $row[] = $item->get_name(); // display the 2 first line of description, and all description on mouseover (https://support.chamilo.org/issues/6588) $row[] = '<span title="' . api_remove_tags_with_space($item->get_description()) . '">' . api_get_short_text_from_html($item->get_description(), 160) . '</span>'; $row[] = $item->get_weight(); /*if (api_is_allowed_to_edit(null, true)) { $row[] = $this->build_date_column($item); }*/ if (count($this->evals_links) > 0) { if (!api_is_allowed_to_edit() || $status_user != 1) { $row[] = $this->build_result_column($item, $ignore_score_color); $row[] = $item; } } $data[] = $row; } return $data; }
/** * Get actual array data * @return array 2-dimensional array - each array contains the elements: * 0: cat/eval/link object * 1: item name * 2: description * 3: weight * 4: date * 5: student's score (if student logged in) */ public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $studentList = array()) { //$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); // do some checks on count, redefine if invalid value if (!isset($count)) { $count = count($this->items) - $start; } if ($count < 0) { $count = 0; } $allitems = $this->items; /* // sort array if ($sorting & self :: GDG_SORT_TYPE) { usort($allitems, array('GradebookDataGenerator', 'sort_by_type')); } elseif ($sorting & self :: GDG_SORT_ID) { usort($allitems, array('GradebookDataGenerator', 'sort_by_id')); } elseif ($sorting & self :: GDG_SORT_NAME) { usort($allitems, array('GradebookDataGenerator', 'sort_by_name')); } elseif ($sorting & self :: GDG_SORT_DESCRIPTION) { usort($allitems, array('GradebookDataGenerator', 'sort_by_description')); } elseif ($sorting & self :: GDG_SORT_WEIGHT) { usort($allitems, array('GradebookDataGenerator', 'sort_by_weight')); } elseif ($sorting & self :: GDG_SORT_DATE) { //usort($allitems, array('GradebookDataGenerator', 'sort_by_date')); } if ($sorting & self :: GDG_SORT_DESC) { $allitems = array_reverse($allitems); }*/ usort($allitems, array('GradebookDataGenerator', 'sort_by_name')); $userId = $this->userId; // Get selected items $visibleitems = array_slice($allitems, $start, $count); $course_code = api_get_course_id(); $sessionId = api_get_session_id(); $status_user = api_get_status_of_user_in_course(api_get_user_id(), api_get_course_int_id()); $userCount = count($studentList); // Generate the data to display $data = array(); /** @var GradebookItem $item */ $totalWeight = 0; foreach ($visibleitems as $item) { $row = array(); $row[] = $item; $row[] = $item->get_name(); // display the 2 first line of description, and all description on mouseover (https://support.chamilo.org/issues/6588) $row[] = '<span title="' . api_remove_tags_with_space($item->get_description()) . '">' . api_get_short_text_from_html($item->get_description(), 160) . '</span>'; $totalWeight += $item->get_weight(); $row[] = $item->get_weight(); $item->setStudentList($studentList); //if (count($this->evals_links) > 0) { if (get_class($item) == 'Evaluation') { // Items inside a category. if (1) { $resultColumn = $this->build_result_column($userId, $item, $ignore_score_color); $row[] = $resultColumn['display']; $row['result_score'] = $resultColumn['score']; $row['result_score_weight'] = $resultColumn['score_weight']; // Best $best = $this->buildBestResultColumn($item); $row['best'] = $best['display']; $row['best_score'] = $best['score']; // Average $average = $this->buildAverageResultColumn($item); $row['average'] = $average['display']; $row['average_score'] = $average['score']; // Ranking $ranking = $this->buildRankingColumn($item, $userId, $userCount); $row['ranking'] = $ranking['display']; $row['ranking_score'] = $ranking['score']; $row[] = $item; } } else { // Category. $result = $this->build_result_column($userId, $item, $ignore_score_color, true); $row[] = $result['display']; $row['result_score'] = $result['score']; $row['result_score_weight'] = $result['score']; // Best $best = $this->buildBestResultColumn($item); $row['best'] = $best['display']; $row['best_score'] = $best['score']; // Average $average = $this->buildAverageResultColumn($item); $row['average'] = $average['display']; $row['average_score'] = $average['score']; // Ranking $rankingStudentList = array(); $invalidateResults = true; foreach ($studentList as $user) { $score = $this->build_result_column($user['user_id'], $item, $ignore_score_color, true); if (!empty($score['score'][0])) { $invalidateResults = false; } $rankingStudentList[$user['user_id']] = $score['score'][0]; } $scoreDisplay = ScoreDisplay::instance(); $score = AbstractLink::getCurrentUserRanking($userId, $rankingStudentList); $row['ranking'] = $scoreDisplay->display_score($score, SCORE_DIV, SCORE_BOTH, true); if ($invalidateResults) { $row['ranking'] = null; } } $data[] = $row; } return $data; }