/** * 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 URL where to go to if the user clicks on the link. * First we go to exercise_jump.php and then to the result page. * Check this php file for more info. */ public function get_link() { //status student $user_id = api_get_user_id(); //$course_code = $this->get_course_code(); $status_user = api_get_status_of_user_in_course($user_id, $this->course_id); $session_id = api_get_session_id(); $url = api_get_path(WEB_PATH) . 'main/gradebook/exercise_jump.php?session_id=' . $session_id . '&cidReq=' . $this->get_course_code() . '&gradebook=view&exerciseId=' . $this->get_ref_id(); if (!api_is_allowed_to_edit() && $this->calc_score(api_get_user_id()) == null || $status_user != 1) { $url .= '&doexercise=' . $this->get_ref_id(); } return $url; }
/** * Function used by SortableTable to generate the data to display * @param int $from * @param int $per_page * @param int $column * @param string $direction * @param int $sort * @return array|mixed */ public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { //variables load in index.php global $my_score_in_gradebook, $certificate_min_score; $scoretotal = 0; // determine sorting type $col_adjust = api_is_allowed_to_edit() ? 1 : 0; // By id $this->column = 5; switch ($this->column) { // Type case 0 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_TYPE; break; case 1 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_NAME; break; case 2 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_DESCRIPTION; break; case 3 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_WEIGHT; break; case 4 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_DATE; case 5 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_ID; break; } if ($this->direction == 'DESC') { $sorting |= GradebookDataGenerator::GDG_SORT_DESC; } else { $sorting |= GradebookDataGenerator::GDG_SORT_ASC; } //status of user in course $user_id = api_get_user_id(); $course_code = api_get_course_id(); $courseId = api_get_course_int_id(); $session_id = api_get_session_id(); $status_user = api_get_status_of_user_in_course($user_id, $courseId); $data_array = $this->datagen->get_data($sorting, $from, $this->per_page); // generate the data to display $sortable_data = array(); $weight_total_links = 0; $main_categories = array(); $main_cat = Category::load(null, null, $course_code, null, null, $session_id, false); $total_categories_weight = 0; $scoredisplay = ScoreDisplay::instance(); //Categories foreach ($data_array as $data) { // list of items inside the gradebook (exercises, lps, forums, etc) $row = array(); $item = $item_category = $data[0]; $id = $item->get_id(); //if the item is invisible, wrap it in a span with class invisible $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; if (api_is_allowed_to_edit(null, true)) { //id $row[] = $this->build_id_column($item); } //Type $row[] = $this->build_type_column($item); //Name if (get_class($item) == 'Category') { $row[] = $invisibility_span_open . '<h3>' . $item->get_name() . '</h3>' . $invisibility_span_close; $main_categories[$item->get_id()]['name'] = $item->get_name(); } else { $row[] = $invisibility_span_open . $this->build_name_link($item) . $invisibility_span_close; $main_categories[$item->get_id()]['name'] = $this->build_name_link($item); } $main_categories[$item->get_id()]['weight'] = $item->get_weight(); $total_categories_weight += $item->get_weight(); //Description $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close; //Weight //$row[] = $invisibility_span_open .Display::tag('h4', $data['3'] .' / '.$this->currentcat->get_weight()).$invisibility_span_close; //$average = $data['3']/$this->currentcat->get_weight()*100; $average = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true); if (api_is_allowed_to_edit(null, true)) { $row[] = $invisibility_span_open . Display::tag('h4', $average) . $invisibility_span_close; } else { $row[] = $invisibility_span_open . $average . $invisibility_span_close; } $category_weight = $item->get_weight(); if (api_is_allowed_to_edit(null, true)) { $weight_total_links += $data[3]; } else { $cattotal = Category::load($_GET['selectcat']); $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); } //Date //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; //Edit (for admins) if (api_is_allowed_to_edit(null, true)) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); if ($show_message === false) { $row[] = $this->build_edit_column($item); } } else { //students get the results and certificates columns if (count($this->evals_links) > 0 && $status_user != 1) { $value_data = isset($data[4]) ? $data[4] : null; if (!is_null($value_data)) { $row[] = Display::tag('h4', $value_data); } else { $row[] = $this->build_edit_column($item); } } else { $score = $item->calc_score(api_get_user_id()); if (!empty($score[1])) { $complete_score = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); $score = $score[0] / $score[1] * $item->get_weight(); $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); $row[] = Display::tip($score, $complete_score); } else { $row[] = '-'; } if (!empty($this->cats)) { $row[] = $this->build_edit_column($item); } } } //Category added $sortable_data[] = $row; // Loading childrens if (get_class($item) == 'Category') { $stud_id = api_get_user_id(); $course_code = api_get_course_id(); $session_id = api_get_session_id(); $parent_id = $item->get_id(); $cats = Category::load($parent_id, null, null, null, null, null); if (isset($cats[0])) { $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); $alleval = $cats[0]->get_evaluations($stud_id); $alllink = $cats[0]->get_links($stud_id); $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); $data_array = $sub_cat_info->get_data($sorting, $from, $this->per_page); $total_weight = 0; //Links foreach ($data_array as $data) { $row = array(); $item = $data[0]; //if the item is invisible, wrap it in a span with class invisible $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name(); $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight(); if (api_is_allowed_to_edit(null, true)) { $row[] = $this->build_id_column($item); } $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); //Name $row[] = $invisibility_span_open . " " . $this->build_name_link($item) . $invisibility_span_close; //Description $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close; //Weight //$weight = $data[3]/$category_weight*$main_cat[0]->get_weight(); $weight = $data[3]; //$extra = " - $data[3] $category_weight -".$main_cat[0]->get_weight(); $total_weight += $weight; $row[] = $invisibility_span_open . $weight . $invisibility_span_close; if (api_is_allowed_to_edit(null, true)) { //$weight_total_links += intval($data[3]); } else { $cattotal = Category::load($_GET['selectcat']); $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $item_value = $scoretotal[0]; } //Date //$row[] = $invisibility_span_open.$data[4].$invisibility_span_close; //Admins get an edit column if (api_is_allowed_to_edit(null, true)) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); if ($show_message === false) { $row[] = $this->build_edit_column($item); } } else { //students get the results and certificates columns $eval_n_links = array_merge($alleval, $alllink); if (count($eval_n_links) > 0 && $status_user != 1) { $value_data = isset($data[4]) ? $data[4] : null; if (!is_null($value_data)) { $score = $item->calc_score(api_get_user_id()); $new_score = $data[3] * $score[0] / $score[1]; $new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals'))); $row[] = Display::tip($new_score, $data[4]); } } if (!empty($cats)) { $row[] = null; } } $row['child_of'] = $parent_id; $sortable_data[] = $row; } //"Warning row" if (!empty($data_array)) { if (api_is_allowed_to_edit()) { // Compare the category weight to the sum of all weights inside the category if (intval($total_weight) == $category_weight) { $label = null; $total = score_badges(array($total_weight . ' / ' . $category_weight, '100')); } else { $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight)); $total = Display::badge($total_weight . ' / ' . $category_weight, 'warning'); } $row = array(null, null, " <h5>" . get_lang('SubTotal') . '</h5>', null, $total . ' ' . $label, 'child_of' => $parent_id); $sortable_data[] = $row; } } } } //end looping categories } //end looping categories if (api_is_allowed_to_edit()) { if (count($main_cat) > 1) { $main_weight = intval($main_cat[0]->get_weight()); if (intval($total_categories_weight) == $main_weight) { $total = score_badges(array($total_categories_weight . ' / ' . $main_weight, '100')); } else { $total = Display::badge($total_categories_weight . ' / ' . $main_weight, 'warning'); } $row = array(null, null, '<h3>' . get_lang('Total') . '</h3>', null, $total); $sortable_data[] = $row; } } // warning messages $view = isset($_GET['view']) ? $_GET['view'] : null; if (api_is_allowed_to_edit()) { if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view != 'presence') { $id_cat = intval($_GET['selectcat']); $category = Category::load($id_cat); //$weight_category = intval($this->build_weight($category[0])); $weight_category = intval($this->build_weight($category[0])); $course_code = $this->build_course_code($category[0]); $weight_total_links = round($weight_total_links); if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) { $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); $modify_icons = '<a class="right_link" href="gradebook_edit_cat.php?editcat=' . $id_cat . '&cidReq=' . $course_code . '">' . Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL) . '</a>'; $warning_message .= $modify_icons; Display::display_warning_message($warning_message, false); } $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code); if (!empty($content_html)) { $new_content = explode('</head>', $content_html['content']); } if (empty($new_content[0])) { $warning_message = get_lang('ThereIsNotACertificateAvailableByDefault'); $cert_icon = '<a class="right_link" href="../document/document.php?curdirpath=/certificates&' . $course_code . '&origin=gradebook&selectcat=' . $id_cat . '">' . Display::return_icon('certificate.png', get_lang('AttachCertificate'), array(), ICON_SIZE_SMALL) . '</a>'; Display::display_warning_message($warning_message . $cert_icon, false); } } if (empty($_GET['selectcat'])) { $categories = Category::load(); $weight_categories = $certificate_min_scores = $course_codes = array(); foreach ($categories as $category) { $course_code_category = $this->build_course_code($category); if (!empty($course_code)) { if ($course_code_category == $course_code) { $weight_categories[] = intval($this->build_weight($category)); $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); $course_codes[] = $course_code; break; } } else { $weight_categories[] = intval($this->build_weight($category)); $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); $course_codes[] = $course_code_category; } } if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) { $warning_message = ''; for ($x = 0; $x < count($weight_categories); $x++) { $weight_category = intval($weight_categories[$x]); $certificate_min_score = intval($certificate_min_scores[$x]); $course_code = $course_codes[$x]; if (empty($certificate_min_score) || $certificate_min_score > $weight_category) { $warning_message .= $course_code . ' - ' . get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan') . ' ' . $weight_category . '<br />'; } } if (!empty($warning_message)) { Display::display_warning_message($warning_message, false); } } } } return $sortable_data; }
/** * @param Category $catobj * @param $showtree * @param $selectcat * @param $is_course_admin * @param $is_platform_admin * @param $simple_search_form * @param bool $show_add_qualification * @param bool $show_add_link */ public function display_header_gradebook_per_gradebook($catobj, $showtree, $selectcat, $is_course_admin, $is_platform_admin, $simple_search_form, $show_add_qualification = true, $show_add_link = true) { // Student $status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $objcat = new Category(); $course_id = Database::get_course_by_category($selectcat); $message_resource = $objcat->show_message_resource_delete($course_id); if (!$is_course_admin && $status != 1 && $selectcat != 0) { $user_id = api_get_user_id(); $user = get_user_info_from_id($user_id); $catcourse = Category::load($catobj->get_id()); $scoredisplay = ScoreDisplay::instance(); $scorecourse = $catcourse[0]->calc_score($user_id); // generating the total score for a course $allevals = $catcourse[0]->get_evaluations($user_id, true); $alllinks = $catcourse[0]->get_links($user_id, true); $evals_links = array_merge($allevals, $alllinks); $item_value = 0; $item_total = 0; for ($count = 0; $count < count($evals_links); $count++) { $item = $evals_links[$count]; $score = $item->calc_score($user_id); $my_score_denom = $score[1] == 0 ? 1 : $score[1]; $item_value += $score[0] / $my_score_denom * $item->get_weight(); $item_total += $item->get_weight(); } $item_value = number_format($item_value, 2, '.', ' '); $total_score = array($item_value, $item_total); $scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT); $cattotal = Category::load(0); $scoretotal = $cattotal[0]->calc_score(api_get_user_id()); $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'); $scoreinfo = get_lang('StatsStudent') . ' :<b> ' . api_get_person_name($user['firstname'], $user['lastname']) . '</b><br />'; if (!$catobj->get_id() == '0' && !isset($_GET['studentoverview']) && !isset($_GET['search'])) { $scoreinfo .= '<h2>' . get_lang('Total') . ' : ' . $scorecourse_display . '</h2>'; } Display::display_normal_message($scoreinfo, false); } // show navigation tree and buttons? $header = '<div class="actions"><table border=0>'; if ($showtree == '1' || isset($_GET['studentoverview'])) { $header .= '<tr>'; if (!$selectcat == '0') { $header .= '<td style=" "><a href="' . api_get_self() . '?selectcat=' . $catobj->get_parent_id() . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('RootCat'), '', ICON_SIZE_MEDIUM) . '</a></td>'; } $header .= '<td style=" ">' . get_lang('CurrentCategory') . '</td>' . '<td style=" "><form name="selector"><select name="selectcat" onchange="document.selector.submit()">'; $cats = Category::load(); $tree = $cats[0]->get_tree(); unset($cats); foreach ($tree as $cat) { for ($i = 0; $i < $cat[2]; $i++) { $line .= '—'; } $line = isset($line) ? $line : ''; if (isset($_GET['selectcat']) && $_GET['selectcat'] == $cat[0]) { $header .= '<option selected value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>'; } else { $header .= '<option value=' . $cat[0] . '>' . $line . ' ' . $cat[1] . '</option>'; } $line = ''; } $header .= '</select></form></td>'; if (!empty($simple_search_form) && $message_resource === false) { $header .= '<td style="vertical-align: top;">' . $simple_search_form->toHtml() . '</td>'; } else { $header .= '<td></td>'; } if ($is_course_admin && $message_resource === false && $_GET['selectcat'] != 0) { /* $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>'; if ($is_course_admin && $message_resource===false) { $header .= '<td style="vertical-align: top;"><a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() .'"><img src="../img/acces_tool.gif" alt="' . get_lang('ScoreEdit') . '" /> ' . get_lang('ScoreEdit') . '</a>'; } */ } elseif (!isset($_GET['studentoverview'])) { if ($message_resource === false) { //$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat=' . $catobj->get_id() . '"><img src="../img/view_list.gif" alt="' . get_lang('FlatView') . '" /> ' . get_lang('FlatView') . '</a>'; } } else { $header .= '<td style="vertical-align: top;"><a href="' . api_get_self() . '?' . api_get_cidreq() . '&studentoverview=&exportpdf=&selectcat=' . $catobj->get_id() . '" target="_blank"><img src="../img/icons/32/pdf.png" alt="' . get_lang('ExportPDF') . '" /> ' . get_lang('ExportPDF') . '</a>'; } $header .= '</td></tr>'; } $header .= '</table></div>'; // for course admin & platform admin add item buttons are added to the header $header .= '<div class="actions">'; $my_category = $catobj->shows_all_information_an_category($catobj->get_id()); $user_id = api_get_user_id(); $course_code = $my_category['course_code']; $status_user = api_get_status_of_user_in_course($user_id, $course_code); //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=0"><img src="../img/folder_new.gif" alt="' . get_lang('AddGradebook') . '" /></a></td>'; if (api_is_allowed_to_edit(null, true)) { if ($selectcat == '0') { if ($show_add_qualification === true) { } if ($show_add_link) { //$header .= '<td><a href="gradebook_add_eval.php?'.api_get_cidreq().'"><img src="../img/filenew.gif" alt="' . get_lang('NewEvaluation') . '" /> ' . get_lang('NewEvaluation') . '</a>'; } } else { if ($show_add_qualification === true && $message_resource === false) { //$header .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '" ><img src="../img/folder_new.gif" alt="' . get_lang('NewSubCategory') . '" align="absmiddle" /> ' . get_lang('NewSubCategory') . '</a></td>'; } $my_category = $catobj->shows_all_information_an_category($catobj->get_id()); $my_api_cidreq = api_get_cidreq(); if ($my_api_cidreq == '') { $my_api_cidreq = 'cidReq=' . $my_category['course_code']; } if ($show_add_link && !$message_resource) { //$header .= '<td><a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '" >'.Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'),'',ICON_SIZE_MEDIUM).'</a>'; $cats = Category::load($selectcat); if ($cats[0]->get_course_code() != null && !$message_resource) { //$header .= '<td><a href="gradebook_add_link.php?'.api_get_cidreq().'&selectcat=' . $catobj->get_id() . '"><img src="../img/link.gif" alt="' . get_lang('MakeLink') . '" align="absmiddle" /> ' . get_lang('MakeLink') . '</a>'; //$header .= '<td><a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>'; } else { // $header .= '<td><a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat=' . $catobj->get_id() . '">'.Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'),'',ICON_SIZE_MEDIUM).'</a>'; } } if (!$message_resource) { $myname = $catobj->shows_all_information_an_category($catobj->get_id()); $my_course_id = api_get_course_id(); $my_file = substr($_SESSION['gradebook_dest'], 0, 5); $header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . '</a>'; $header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>'; $visibility_icon = $catobj->is_visible() == 0 ? 'invisible' : 'visible'; $visibility_command = $catobj->is_visible() == 0 ? 'set_visible' : 'set_invisible'; //Right icons $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $catobj->get_id() . '&cidReq=' . $catobj->get_course_code() . '&id_session=' . $catobj->get_session_id() . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM) . '</a>'; //$modify_icons .= '<a href="../document/document.php?curdirpath=/certificates&'.$my_api_cidreq.'&origin=gradebook&selectcat=' . $catobj->get_id() . '">'. //Display::return_icon('certificate.png', get_lang('AttachCertificate'),'',ICON_SIZE_MEDIUM).'</a>'; //hide or delete are not options available //$modify_icons .= ' <a href="' . api_get_self() . '?visiblecat=' . $catobj->get_id() . '&' . $visibility_command . '=&selectcat=0 ">'.Display::return_icon($visibility_icon.'.png', get_lang('Visible'),'',ICON_SIZE_MEDIUM).'</a>'; if ($catobj->get_name() != api_get_course_id()) { $modify_icons .= ' <a href="' . api_get_self() . '?deletecat=' . $catobj->get_id() . '&selectcat=0&cidReq=' . $catobj->get_course_code() . '" onclick="return confirmation();">' . Display::return_icon('delete.png', get_lang('DeleteAll'), '', ICON_SIZE_MEDIUM) . '</a>'; } $header .= Display::div($modify_icons, array('class' => 'right')); } } } elseif (isset($_GET['search'])) { $header .= '<b>' . get_lang('SearchResults') . ' :</b>'; } $header .= '</div>'; echo $header; }
/** * Function used by SortableTable to generate the data to display * @param int $from * @param int $per_page * @param int $column * @param string $direction * @param int $sort * @return array|mixed */ public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = null) { //variables load in index.php global $certificate_min_score; // determine sorting type $col_adjust = api_is_allowed_to_edit() ? 1 : 0; // By id $this->column = 5; switch ($this->column) { // Type case 0 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_TYPE; break; case 1 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_NAME; break; case 2 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_DESCRIPTION; break; case 3 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_WEIGHT; break; case 4 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_DATE; case 5 + $col_adjust: $sorting = GradebookDataGenerator::GDG_SORT_ID; break; } if ($this->direction == 'DESC') { $sorting |= GradebookDataGenerator::GDG_SORT_DESC; } else { $sorting |= GradebookDataGenerator::GDG_SORT_ASC; } // Status of user in course. $user_id = $this->userId; $course_code = api_get_course_id(); $session_id = api_get_session_id(); $status_user = api_get_status_of_user_in_course(api_get_user_id(), api_get_course_int_id()); if (empty($session_id)) { $statusToFilter = STUDENT; } else { $statusToFilter = 0; } if (empty($this->studentList)) { $studentList = CourseManager::get_user_list_from_course_code($course_code, $session_id, null, null, $statusToFilter); $this->studentList = $studentList; } $this->datagen->userId = $this->userId; $data_array = $this->datagen->get_data($sorting, $from, $this->per_page, false, $this->studentList); // generate the data to display $sortable_data = array(); $weight_total_links = 0; $main_categories = array(); $main_cat = Category::load(null, null, $course_code, null, null, $session_id, 'ORDER BY id'); $total_categories_weight = 0; $scoredisplay = ScoreDisplay::instance(); $totalResult = [0, 0]; $totalBest = [0, 0]; $totalAverage = [0, 0]; $type = 'detail'; if ($this->exportToPdf) { $type = 'simple'; } // Categories. if (!empty($data_array)) { foreach ($data_array as $data) { // list of items inside the gradebook (exercises, lps, forums, etc) $row = array(); /** @var AbstractLink $item */ $item = $mainCategory = $data[0]; //if the item is invisible, wrap it in a span with class invisible $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; // Id if ($this->teacherView) { if ($this->exportToPdf == false) { $row[] = $this->build_id_column($item); } } // Type. $row[] = $this->build_type_column($item); // Name. if (get_class($item) == 'Category') { $row[] = $invisibility_span_open . '<strong>' . $item->get_name() . '</strong>' . $invisibility_span_close; $main_categories[$item->get_id()]['name'] = $item->get_name(); } else { $name = $this->build_name_link($item, $type); $row[] = $invisibility_span_open . $name . $invisibility_span_close; $main_categories[$item->get_id()]['name'] = $name; } $this->dataForGraph['categories'][] = $item->get_name(); $main_categories[$item->get_id()]['weight'] = $item->get_weight(); $total_categories_weight += $item->get_weight(); // Description. if ($this->exportToPdf == false) { $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close; } // Weight. $weight = $scoredisplay->display_score(array($data['3'], $this->currentcat->get_weight()), SCORE_SIMPLE, SCORE_BOTH, true); if ($this->teacherView) { $row[] = $invisibility_span_open . Display::tag('p', $weight, array('class' => 'score')) . $invisibility_span_close; } else { $row[] = $invisibility_span_open . $weight . $invisibility_span_close; } $category_weight = $item->get_weight(); $mainCategoryWeight = $main_cat[0]->get_weight(); if ($this->teacherView) { $weight_total_links += $data[3]; } else { $cattotal = Category::load($_GET['selectcat']); $scoretotal = $cattotal[0]->calc_score($this->userId); $item_value = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE); } // Edit (for admins). if ($this->teacherView) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); if ($show_message === false) { $row[] = $this->build_edit_column($item); } } else { $score = $item->calc_score($this->userId); if (!empty($score[1])) { $completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT); $score = $score[0] / $score[1] * $item->get_weight(); $score = $scoredisplay->display_score(array($score, null), SCORE_SIMPLE); $scoreToDisplay = Display::tip($score, $completeScore); } else { $scoreToDisplay = '-'; $categoryScore = null; } // Students get the results and certificates columns //if (count($this->evals_links) > 0 && $status_user != 1) { if (1) { $value_data = isset($data[4]) ? $data[4] : null; $best = isset($data['best']) ? $data['best'] : null; $average = isset($data['average']) ? $data['average'] : null; $ranking = isset($data['ranking']) ? $data['ranking'] : null; $totalResult = [$totalResult[0] + $data['result_score_weight'][0], $totalResult[1] + $data['result_score_weight'][1]]; $totalBest = [$totalBest[0] + $data['best_score'][0], $totalBest[1] + $data['best_score'][1]]; $totalAverage = [$totalAverage[0] + $data['average_score'][0], $totalAverage[1] + $data['average_score'][1]]; // Student result $row[] = $value_data; $totalResultAverageValue = strip_tags($scoredisplay->display_score($totalResult, SCORE_AVERAGE)); $this->dataForGraph['my_result'][] = (double) str_replace('%', '', $totalResultAverageValue); $totalAverageValue = strip_tags($scoredisplay->display_score($totalAverage, SCORE_AVERAGE)); $this->dataForGraph['average'][] = (double) str_replace('%', '', $totalAverageValue); // Ranking $row[] = $ranking; // Best $row[] = $best; // Average $row[] = $average; if (get_class($item) == 'Category') { if ($this->exportToPdf == false) { $row[] = $this->build_edit_column($item); } } } else { $row[] = $scoreToDisplay; if (!empty($this->cats)) { if ($this->exportToPdf == false) { $row[] = $this->build_edit_column($item); } } } } // Category added. $sortable_data[] = $row; // Loading children if (get_class($item) == 'Category') { $course_code = api_get_course_id(); $session_id = api_get_session_id(); $parent_id = $item->get_id(); $cats = Category::load($parent_id, null, null, null, null, null); if (isset($cats[0])) { $allcat = $cats[0]->get_subcategories($this->userId, $course_code, $session_id); $alleval = $cats[0]->get_evaluations($this->userId); $alllink = $cats[0]->get_links($this->userId); $sub_cat_info = new GradebookDataGenerator($allcat, $alleval, $alllink); $sub_cat_info->userId = $user_id; $data_array2 = $sub_cat_info->get_data($sorting, $from, $this->per_page, false, $this->studentList); $total_weight = 0; // Links. foreach ($data_array2 as $data) { $row = array(); $item = $data[0]; //if the item is invisible, wrap it in a span with class invisible $invisibility_span_open = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '<span class="invisible">' : ''; $invisibility_span_close = api_is_allowed_to_edit() && $item->is_visible() == '0' ? '</span>' : ''; if (isset($item)) { $main_categories[$parent_id]['children'][$item->get_id()]['name'] = $item->get_name(); $main_categories[$parent_id]['children'][$item->get_id()]['weight'] = $item->get_weight(); } if ($this->teacherView) { if ($this->exportToPdf == false) { $row[] = $this->build_id_column($item); } } // Type $row[] = $this->build_type_column($item, array('style' => 'padding-left:5px')); // Name. $row[] = $invisibility_span_open . " " . $this->build_name_link($item, $type) . $invisibility_span_close; // Description. if ($this->exportToPdf == false) { $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close; } $weight = $data[3]; $total_weight += $weight; // Weight $row[] = $invisibility_span_open . $weight . $invisibility_span_close; if ($this->teacherView) { //$weight_total_links += intval($data[3]); } else { $cattotal = Category::load($_GET['selectcat']); $scoretotal = $cattotal[0]->calc_score($this->userId); $item_value = $scoretotal[0]; } // Admins get an edit column. if (api_is_allowed_to_edit(null, true) && isset($_GET['user_id']) == false && (isset($_GET['action']) && $_GET['action'] != 'export_all' || !isset($_GET['action']))) { $cat = new Category(); $show_message = $cat->show_message_resource_delete($item->get_course_code()); if ($show_message === false) { if ($this->exportToPdf == false) { $row[] = $this->build_edit_column($item); } } } else { // Students get the results and certificates columns $eval_n_links = array_merge($alleval, $alllink); if (count($eval_n_links) > 0) { $value_data = isset($data[4]) ? $data[4] : null; if (!is_null($value_data)) { //$score = $item->calc_score(api_get_user_id()); //$new_score = $data[3] * $score[0] / $score[1]; //$new_score = floatval(number_format($new_score, api_get_setting('gradebook_number_decimals'))); // Result $row[] = $value_data; $best = isset($data['best']) ? $data['best'] : null; $average = isset($data['average']) ? $data['average'] : null; $ranking = isset($data['ranking']) ? $data['ranking'] : null; // Ranking $row[] = $ranking; // Best $row[] = $best; // Average $row[] = $average; } } if (!empty($cats)) { if ($this->exportToPdf == false) { $row[] = null; } } } if ($this->exportToPdf == false) { $row['child_of'] = $parent_id; } $sortable_data[] = $row; } // "Warning row" if (!empty($data_array)) { if ($this->teacherView) { // Compare the category weight to the sum of all weights inside the category if (intval($total_weight) == $category_weight) { $label = null; $total = GradebookUtils::score_badges(array($total_weight . ' / ' . $category_weight, '100')); } else { $label = Display::return_icon('warning.png', sprintf(get_lang('TotalWeightMustBeX'), $category_weight)); $total = Display::badge($total_weight . ' / ' . $category_weight, 'warning'); } $row = array(null, null, " <h5>" . get_lang('SubTotal') . '</h5>', null, $total . ' ' . $label, 'child_of' => $parent_id); $sortable_data[] = $row; } } } } } } //end looping categories $main_weight = 0; if (count($main_cat) > 1) { /** @var Category $myCat */ foreach ($main_cat as $myCat) { $myParentId = $myCat->get_parent_id(); if ($myParentId == 0) { $main_weight = intval($myCat->get_weight()); } } } if ($this->teacherView) { // Total for teacher. if (count($main_cat) > 1) { if (intval($total_categories_weight) == $main_weight) { $total = GradebookUtils::score_badges(array($total_categories_weight . ' / ' . $main_weight, '100')); } else { $total = Display::badge($total_categories_weight . ' / ' . $main_weight, 'warning'); } $row = array(null, null, '<strong>' . get_lang('Total') . '</strong>', null, $total); $sortable_data[] = $row; } } else { // Total for student. if (count($main_cat) > 1) { $main_weight = intval($main_cat[0]->get_weight()); $global = null; $average = null; // Overwrite main weight $totalResult[1] = $main_weight; $totalResult = $scoredisplay->display_score($totalResult, SCORE_DIV); $totalRanking = array(); $invalidateRanking = true; $average = 0; foreach ($this->studentList as $student) { $score = $main_cat[0]->calc_score($student['user_id']); if (!empty($score[0])) { $invalidateRanking = false; } $totalRanking[$student['user_id']] = $score[0]; $average += $score[0]; } $totalRanking = AbstractLink::getCurrentUserRanking($user_id, $totalRanking); $totalRanking = $scoredisplay->display_score($totalRanking, SCORE_DIV, SCORE_BOTH, true); if ($invalidateRanking) { $totalRanking = null; } // Overwrite main weight $totalBest[1] = $main_weight; $totalBest = $scoredisplay->display_score($totalBest, SCORE_DIV, SCORE_BOTH, true); // Overwrite main weight $totalAverage[0] = $average / count($this->studentList); $totalAverage[1] = $main_weight; $totalAverage = $scoredisplay->display_score($totalAverage, SCORE_DIV, SCORE_BOTH, true); if ($this->exportToPdf) { $row = array(null, '<h3>' . get_lang('Total') . '</h3>', $main_weight, $totalResult, $totalRanking, $totalBest, $totalAverage); } else { $row = array(null, '<h3>' . get_lang('Total') . '</h3>', null, $main_weight, $totalResult, $totalRanking, $totalBest, $totalAverage); } $sortable_data[] = $row; } } // Warning messages $view = isset($_GET['view']) ? $_GET['view'] : null; if ($this->teacherView) { if (isset($_GET['selectcat']) && $_GET['selectcat'] > 0 && $view != 'presence') { $id_cat = intval($_GET['selectcat']); $category = Category::load($id_cat); $weight_category = intval($this->build_weight($category[0])); $course_code = $this->build_course_code($category[0]); $weight_total_links = round($weight_total_links); if ($weight_total_links > $weight_category || $weight_total_links < $weight_category || $weight_total_links > $weight_category) { $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $weight_category); $modify_icons = '<a href="gradebook_edit_cat.php?editcat=' . $id_cat . '&cidReq=' . $course_code . '&id_session=' . api_get_session_id() . '">' . Display::return_icon('edit.png', $warning_message, array(), ICON_SIZE_SMALL) . '</a>'; $warning_message .= $modify_icons; Display::display_warning_message($warning_message, false); } $content_html = DocumentManager::replace_user_info_into_html(api_get_user_id(), $course_code); if (!empty($content_html)) { $new_content = explode('</head>', $content_html['content']); } if (empty($new_content[0])) { // Set default certificate $courseData = api_get_course_info($course_code); DocumentManager::generateDefaultCertificate($courseData); } } if (empty($_GET['selectcat'])) { $categories = Category::load(); $weight_categories = $certificate_min_scores = $course_codes = array(); foreach ($categories as $category) { $course_code_category = $this->build_course_code($category); if (!empty($course_code)) { if ($course_code_category == $course_code) { $weight_categories[] = intval($this->build_weight($category)); $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); $course_codes[] = $course_code; break; } } else { $weight_categories[] = intval($this->build_weight($category)); $certificate_min_scores[] = intval($this->build_certificate_min_score($category)); $course_codes[] = $course_code_category; } } if (is_array($weight_categories) && is_array($certificate_min_scores) && is_array($course_codes)) { $warning_message = ''; for ($x = 0; $x < count($weight_categories); $x++) { $weight_category = intval($weight_categories[$x]); $certificate_min_score = intval($certificate_min_scores[$x]); $course_code = $course_codes[$x]; if (empty($certificate_min_score) || $certificate_min_score > $weight_category) { $warning_message .= $course_code . ' - ' . get_lang('CertificateMinimunScoreIsRequiredAndMustNotBeMoreThan') . ' ' . $weight_category . '<br />'; } } if (!empty($warning_message)) { Display::display_warning_message($warning_message, false); } } } } return $sortable_data; }
echo "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&post=" . $post['post_id'] . "&id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { if ($locked == false) { echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&gidReq=" . Security::remove_XSS($_GET['gidReq']) . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=delete&content=post&id=" . $post['post_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { display_visible_invisible_icon('post', $post['post_id'], $post['visible'], array('forum' => $clean_forum_id, 'thread' => $clean_thread_id)); if ($count > 0) { echo "<a href=\"viewthread.php?" . api_get_cidreq() . "&gidReq=" . Security::remove_XSS($_GET['gidReq']) . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=move&origin=" . $origin . "&post=" . $post['post_id'] . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), ICON_SIZE_SMALL) . "</a>"; } } $userinf = api_get_user_info($post['user_id']); $user_status = api_get_status_of_user_in_course($post['user_id'], api_get_course_id()); if (api_is_allowed_to_edit(null, true)) { //if ($count>0 && $user_status!=1) { if ($count > 0) { $current_qualify_thread = show_qualify('1', $post['user_id'], $_GET['thread']); if ($locked == false) { echo "<a href=\"forumqualify.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=list&post=" . $post['post_id'] . "&user="******"&user_id=" . $post['user_id'] . "&origin=" . $origin . "&idtextqualify=" . $current_qualify_thread . "\" >" . Display::return_icon('new_test_small.gif', get_lang('Qualify')) . "</a>"; } } } if ($current_forum_category && $current_forum_category['locked'] == 0 and $current_forum['locked'] == 0 and $current_thread['locked'] == 0 or api_is_allowed_to_edit(false, true)) { if ($_user['user_id'] or $current_forum['allow_anonymous'] == 1 and !$_user['user_id']) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { echo '<a href="reply.php?' . api_get_cidreq() . '&forum=' . $clean_forum_id . '&thread=' . $clean_thread_id . '&post=' . $post['post_id'] . '&action=replymessage&origin=' . $origin . '">' . Display::return_icon('message_reply_forum.png', get_lang('ReplyToMessage')) . "</a>"; echo '<a href="reply.php?' . api_get_cidreq() . '&forum=' . $clean_forum_id . '&thread=' . $clean_thread_id . '&post=' . $post['post_id'] . '&action=quote&origin=' . $origin . '">' . Display::return_icon('quote.gif', get_lang('QuoteMessage')) . "</a>"; }
} if ($origin != 'learnpath') { if (GroupManager::is_tutor_of_group($userId, $groupId) || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { if ($locked == false) { $iconEdit .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=delete&content=post&id=" . $row['post_id'] . "&origin=" . $origin . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { $iconEdit .= return_visible_invisible_icon('post', $row['post_id'], $row['visible'], array('forum' => $clean_forum_id, 'thread' => $clean_thread_id, 'origin' => $origin)); $iconEdit .= ""; if ($increment > 0) { $iconEdit .= "<a href=\"viewthread.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=move&post=" . $row['post_id'] . "&origin=" . $origin . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), ICON_SIZE_SMALL) . "</a>"; } } } $user_status = api_get_status_of_user_in_course($row['user_id'], api_get_course_int_id()); $current_qualify_thread = showQualify('1', $row['poster_id'], $_GET['thread']); if (($current_thread['thread_peer_qualify'] == 1 || api_is_allowed_to_edit(null, true)) && $current_thread['thread_qualify_max'] > 0 && $origin != 'learnpath') { $my_forum_id = $clean_forum_id; if (isset($_GET['gradebook'])) { $info_thread = get_thread_information($clean_thread_id); $my_forum_id = $info_thread['forum_id']; } $userCanEdit = $current_thread['thread_peer_qualify'] == 1 && $row['poster_id'] != $userId; if (api_is_allowed_to_edit(null, true)) { $userCanEdit = true; } if ($increment > 0 && $locked == false && $userCanEdit) { $iconEdit .= "<a href=\"forumqualify.php?" . api_get_cidreq() . "&forum=" . $my_forum_id . "&thread=" . $clean_thread_id . "&action=list&post=" . $row['post_id'] . "&user="******"&user_id=" . $row['poster_id'] . "&origin=" . $origin . "&idtextqualify=" . $current_qualify_thread . "\" >" . Display::return_icon('quiz.gif', get_lang('Qualify')) . "</a> "; } }
if (!empty($my_post) && is_array($my_post)) { foreach ($my_post as $post_value) { $id_posts[] = $post_value['post_id']; } sort($id_posts, SORT_NUMERIC); reset($id_posts); // The post minor $post_minor = (int) $id_posts[0]; $post_id = isset($_GET['post']) ? (int) $_GET['post'] : 0; if (!isset($_GET['id']) && $post_id > $post_minor) { echo "<a href=\"viewthread.php?" . api_get_cidreq() . "&gidReq=" . Security::remove_XSS($_GET['gidReq']) . "&forum=" . $forumId . "&thread=" . $threadId . "&origin=" . $origin . "&action=move&post=" . $rows[$display_post_id]['post_id'] . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), ICON_SIZE_SMALL) . "</a>"; } } } $userinf = api_get_user_info($rows[$display_post_id]['user_id']); $user_status = api_get_status_of_user_in_course($rows[$display_post_id]['user_id'], api_get_course_id()); if (api_is_allowed_to_edit(null, true)) { if ($post_id > $post_minor) { $current_qualify_thread = show_qualify('1', $rows[$display_post_id]['user_id'], $_GET['thread']); if ($locked == false) { echo "<a href=\"forumqualify.php?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&action=list&post=" . $rows[$display_post_id]['post_id'] . "&user="******"&user_id=" . $rows[$display_post_id]['user_id'] . "&origin=" . $origin . "&idtextqualify=" . $current_qualify_thread . "\" >" . Display::return_icon('new_test_small.gif', get_lang('Qualify')) . "</a>"; } } } if ($current_forum_category && $current_forum_category['locked'] == 0 and $current_forum['locked'] == 0 and $current_thread['locked'] == 0 or api_is_allowed_to_edit(false, true)) { if ($_user['user_id'] or $current_forum['allow_anonymous'] == 1 and !$_user['user_id']) { if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { echo '<a href="reply.php?' . api_get_cidreq() . '&forum=' . $forumId . '&thread=' . $threadId . '&post=' . $rows[$display_post_id]['post_id'] . '&action=replymessage&origin=' . $origin . '">' . Display::return_icon('message_reply_forum.png', get_lang('ReplyToMessage')) . "</a>"; echo '<a href="reply.php?' . api_get_cidreq() . '&forum=' . $forumId . '&thread=' . $threadId . '&post=' . $rows[$display_post_id]['post_id'] . '&action=quote&origin=' . $origin . '">' . Display::return_icon('quote.gif', get_lang('QuoteMessage')) . "</a>"; } }
/** * 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; }