[svn r17114] implemented certificate creation in gradebook (see FS#2622)

skala
Cristian Fasanando 16 years ago
parent 9f4cd3b92c
commit 207b69afea
  1. 5
      main/gradebook/index.php
  2. 34
      main/gradebook/lib/fe/gradebooktable.class.php

@ -534,6 +534,7 @@ if (!empty($keyword))
} }
else else
*/ */
if (isset ($_GET['studentoverview'])) { if (isset ($_GET['studentoverview'])) {
$cats= Category :: load($category); $cats= Category :: load($category);
$stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id()); $stud_id= (api_is_allowed_to_create_course() ? null : api_get_user_id());
@ -567,14 +568,14 @@ if (isset ($_GET['studentoverview'])) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
$category = Category :: load ($_GET['cat']); $category = Category :: load ($_GET['cat_id']);
if ($category[0]->is_certificate_available($user_id)) { if ($category[0]->is_certificate_available($user_id)) {
$user= get_user_info_from_id($user_id); $user= get_user_info_from_id($user_id);
$scoredisplay = ScoreDisplay :: instance(); $scoredisplay = ScoreDisplay :: instance();
$scorecourse = $category[0]->calc_score($user_id); $scorecourse = $category[0]->calc_score($user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
$cattotal = Category :: load(0); $cattotal = Category :: load($_GET['cat_id']);
$scoretotal= $cattotal[0]->calc_score($user_id); $scoretotal= $cattotal[0]->calc_score($user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));

@ -58,7 +58,7 @@ class GradebookTable extends SortableTable
if (api_is_allowed_to_create_course() && $_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false')) { if (api_is_allowed_to_create_course() && $_SESSION['studentview']<>'studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false')) {
$this->set_header($column++, get_lang('Weight')); $this->set_header($column++, get_lang('Weight'));
} else { } else {
if (!isset($_GET['selectcat']) || ($_SESSION['studentview']=='studentview' || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='true')) || !api_is_allowed_to_create_course()) { if (empty($_GET['selectcat'])) {
$this->set_header($column++, get_lang('Evaluation')); $this->set_header($column++, get_lang('Evaluation'));
} }
else { else {
@ -78,12 +78,14 @@ class GradebookTable extends SortableTable
'setvisible' => get_lang('SetVisible'), 'setvisible' => get_lang('SetVisible'),
'setinvisible' => get_lang('SetInvisible'))); 'setinvisible' => get_lang('SetInvisible')));
} else { } else {
if (empty($_GET['selectcat'])) {
$this->set_header($column++, get_lang('Certificates'),false);
} else {
$evals_links = array_merge($evals, $links); $evals_links = array_merge($evals, $links);
if(count($evals_links)>0) { if(count($evals_links)>0) {
$this->set_header($column++, get_lang('Results'), false); $this->set_header($column++, get_lang('Results'), false);
} }
if (!isset($_GET['selectcat']) ||(isset($_GET['isStudentView']) && $_GET['isStudentView']=='true') || !api_is_allowed_to_create_course()) {
$this->set_header($column++, get_lang('Certificates'),false);
} }
} }
} }
@ -132,32 +134,30 @@ class GradebookTable extends SortableTable
$sortable_data = array(); $sortable_data = array();
foreach ($data_array as $data) { foreach ($data_array as $data) {
$row = array (); $row = array ();
$item = $data[0]; $item = $data[0];
if (!isset($_GET['selectcat'])) { $id = $item->get_id();
if (empty($_GET['selectcat'])) {
$certificate_min_score = $this->build_cetificate_min_score($item); $certificate_min_score = $this->build_cetificate_min_score($item);
} }
//if the item is invisible, wrap it in a span with class invisible //if the item is invisible, wrap it in a span with class invisible
$invisibility_span_open = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '<span class="invisible">' : ''; $invisibility_span_open = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '<span class="invisible">' : '';
$invisibility_span_close = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '</span>' : ''; $invisibility_span_close = (api_is_allowed_to_create_course() && $item->is_visible() == '0') ? '</span>' : '';
if (api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false')) { if (api_is_allowed_to_create_course() && ($_SESSION['studentview']<>'studentview') || (isset($_GET['isStudentView']) && $_GET['isStudentView']=='false')) {
$row[] = $this->build_id_column ($item); $row[] = $this->build_id_column ($item);
} }
$row[] = $this->build_type_column ($item); $row[] = $this->build_type_column ($item);
$row[] = $invisibility_span_open . $this->build_name_link ($item) . $invisibility_span_close; $row[] = $invisibility_span_open . $this->build_name_link ($item) . $invisibility_span_close;
$row[] = $invisibility_span_open . $data[2] . $invisibility_span_close; $row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
if (api_is_allowed_to_create_course()) { if (api_is_allowed_to_create_course()) {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close; $row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
} else { } else {
if (!isset($_GET['selectcat']) && isset($certificate_min_score)) { if (empty($_GET['selectcat'])) {
// generating the total score for a course // generating the total score for a course
$stud_id= api_get_user_id(); $stud_id= api_get_user_id();
$cats_course = Category :: load ($id, null, null, null, null, null, false);
$cats_course = Category :: load (0, null, null, null, null, null, false);
$alleval_course= $cats_course[0]->get_evaluations($stud_id,true); $alleval_course= $cats_course[0]->get_evaluations($stud_id,true);
$alllink_course= $cats_course[0]->get_links($stud_id,true); $alllink_course= $cats_course[0]->get_links($stud_id,true);
$evals_links = array_merge($alleval_course, $alllink_course); $evals_links = array_merge($alleval_course, $alllink_course);
@ -170,9 +170,9 @@ class GradebookTable extends SortableTable
$item_total+=$item->get_weight(); $item_total+=$item->get_weight();
} }
$item_value = number_format($item_value, 2, '.', ' '); $item_value = number_format($item_value, 2, '.', ' ');
$cattotal = Category :: load(0); $cattotal = Category :: load($id);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id()); $scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal) ? $scoretotal[0].'/'.$scoretotal[1].'('.round(($scoretotal[0] / $scoretotal[1]) * 100) . ' %)': get_lang('NoResultsAvailable')); $scoretotal_display = (isset($scoretotal)? $scoretotal[0].'/'.$scoretotal[1].'('.round(($scoretotal[0] / $scoretotal[1]) * 100) . ' %)': get_lang('NoResultsAvailable'));
$row[] = $item_value; $row[] = $item_value;
} else { } else {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close; $row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
@ -188,9 +188,10 @@ class GradebookTable extends SortableTable
if (count($this->evals_links)>0) { if (count($this->evals_links)>0) {
$row[] = $data[5]; $row[] = $data[5];
} }
if (!isset($_GET['selectcat']) && isset($certificate_min_score) && !api_is_allowed_to_create_course) {
if ((int)$item_value >= (int)$certificate_min_score) { if (empty($_GET['selectcat'])) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/index.php?export_certificate=yes"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display; if (isset($certificate_min_score) && (int)$item_value >= (int)$certificate_min_score) {
$certificates = '<a href="'.api_get_path(WEB_CODE_PATH) .'gradebook/index.php?export_certificate=yes&cat_id='.$id.'"><img src="'.api_get_path(WEB_CODE_PATH) . 'img/dokeos.gif" /></a>&nbsp;'.$scoretotal_display;
} else { } else {
$certificates = get_lang('NoResultsAvailable'); $certificates = get_lang('NoResultsAvailable');
} }
@ -199,11 +200,10 @@ class GradebookTable extends SortableTable
} }
$sortable_data[] = $row; $sortable_data[] = $row;
} }
return $sortable_data; return $sortable_data;
} }
// Other functions
// Other functions
private function build_cetificate_min_score ($item) { private function build_cetificate_min_score ($item) {
return $item->get_certificate_min_score(); return $item->get_certificate_min_score();

Loading…
Cancel
Save