/** * Generate name column * @param GradebookItem $item * @param string $type simple|detail * @return string */ private function build_name_link($item, $type = 'detail') { $view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null; $categoryId = $item->getCategory()->get_id(); switch ($item->get_item_type()) { // category case 'C': $prms_uri = '?selectcat=' . $item->get_id() . '&view=' . $view; if (isset($_GET['isStudentView'])) { if (isset($is_student) || isset($_SESSION['studentview']) && $_SESSION['studentview'] == 'studentview') { $prms_uri = $prms_uri . '&isStudentView=' . Security::remove_XSS($_GET['isStudentView']); } } $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); return ' <a href="' . Security::remove_XSS($_SESSION['gradebook_dest']) . $prms_uri . '">' . $item->get_name() . '</a>' . ($item->is_course() ? ' [' . $item->get_course_code() . ']' . $show_message : ''); // evaluation // evaluation case 'E': $cat = new Category(); $course_id = CourseManager::get_course_by_category($categoryId); $show_message = $cat->show_message_resource_delete($course_id); // course/platform admin can go to the view_results page if (api_is_allowed_to_edit() && $show_message === false) { if ($item->get_type() == 'presence') { return ' ' . '<a href="gradebook_view_result.php?cidReq=' . $course_id . '&selecteval=' . $item->get_id() . '">' . $item->get_name() . '</a>'; } else { $extra = Display::label(get_lang('Evaluation')); if ($type == 'simple') { $extra = ''; } return ' ' . '<a href="gradebook_view_result.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' . $item->get_name() . '</a> ' . $extra; } } elseif (ScoreDisplay::instance()->is_custom() && $show_message === false) { // students can go to the statistics page (if custom display enabled) return ' ' . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' . $item->get_name() . '</a>'; } elseif ($show_message === false && !api_is_allowed_to_edit() && !ScoreDisplay::instance()->is_custom()) { return ' ' . '<a href="gradebook_statistics.php?' . api_get_cidreq() . '&selecteval=' . $item->get_id() . '">' . $item->get_name() . '</a>'; } else { return '[' . get_lang('Evaluation') . '] ' . $item->get_name() . $show_message; } case 'L': // link $cat = new Category(); $course_id = CourseManager::get_course_by_category($categoryId); $show_message = $cat->show_message_resource_delete($course_id); $url = $item->get_link(); if (isset($url) && $show_message === false) { $text = ' <a href="' . $item->get_link() . '">' . $item->get_name() . '</a>'; } else { $text = $item->get_name(); } $extra = Display::label($item->get_type_name(), 'info'); if ($type == 'simple') { $extra = ''; } $text .= " " . $extra . $show_message; $cc = $this->currentcat->get_course_code(); if (empty($cc)) { $text .= ' [<a href="' . api_get_path(REL_COURSE_PATH) . $item->get_course_code() . '/">' . $item->get_course_code() . '</a>]'; } return $text; } }
/** * @param GradebookItem $item1 * @param GradebookItem $item2 * @return int */ public function sort_by_id($item1, $item2) { return api_strnatcmp($item1->get_id(), $item2->get_id()); }