[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. 70
      main/gradebook/lib/fe/gradebooktable.class.php

@ -534,6 +534,7 @@ if (!empty($keyword))
}
else
*/
if (isset ($_GET['studentoverview'])) {
$cats= Category :: load($category);
$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();
}
$category = Category :: load ($_GET['cat']);
$category = Category :: load ($_GET['cat_id']);
if ($category[0]->is_certificate_available($user_id)) {
$user= get_user_info_from_id($user_id);
$scoredisplay = ScoreDisplay :: instance();
$scorecourse = $category[0]->calc_score($user_id);
$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_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')) {
$this->set_header($column++, get_lang('Weight'));
} 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'));
}
else {
@ -78,12 +78,14 @@ class GradebookTable extends SortableTable
'setvisible' => get_lang('SetVisible'),
'setinvisible' => get_lang('SetInvisible')));
} else {
$evals_links = array_merge($evals, $links);
if(count($evals_links)>0) {
$this->set_header($column++, get_lang('Results'), false);
}
if (!isset($_GET['selectcat']) ||(isset($_GET['isStudentView']) && $_GET['isStudentView']=='true') || !api_is_allowed_to_create_course()) {
if (empty($_GET['selectcat'])) {
$this->set_header($column++, get_lang('Certificates'),false);
} else {
$evals_links = array_merge($evals, $links);
if(count($evals_links)>0) {
$this->set_header($column++, get_lang('Results'), false);
}
}
}
}
@ -127,56 +129,54 @@ class GradebookTable extends SortableTable
} else {
$sorting |= GradebookDataGenerator :: GDG_SORT_ASC;
}
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
$data_array = $this->datagen->get_data($sorting, $from, $this->per_page);
// generate the data to display
$sortable_data = array();
foreach ($data_array as $data) {
$row = array ();
$item = $data[0];
if (!isset($_GET['selectcat'])) {
$certificate_min_score = $this->build_cetificate_min_score($item);
}
$id = $item->get_id();
if (empty($_GET['selectcat'])) {
$certificate_min_score = $this->build_cetificate_min_score($item);
}
//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_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')) {
$row[] = $this->build_id_column ($item);
}
$row[] = $this->build_type_column ($item);
$row[] = $invisibility_span_open . $this->build_name_link ($item) . $invisibility_span_close;
$row[] = $invisibility_span_open . $data[2] . $invisibility_span_close;
if (api_is_allowed_to_create_course()) {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
} else {
if (!isset($_GET['selectcat']) && isset($certificate_min_score)) {
// generating the total score for a course
$stud_id= api_get_user_id();
$cats_course = Category :: load (0, null, null, null, null, null, false);
if (empty($_GET['selectcat'])) {
// generating the total score for a course
$stud_id= api_get_user_id();
$cats_course = Category :: load ($id, null, null, null, null, null, false);
$alleval_course= $cats_course[0]->get_evaluations($stud_id,true);
$alllink_course= $cats_course[0]->get_links($stud_id,true);
$evals_links = array_merge($alleval_course, $alllink_course);
$alllink_course= $cats_course[0]->get_links($stud_id,true);
$evals_links = array_merge($alleval_course, $alllink_course);
$item_value=0;
$item_total=0;
for ($count=0; $count < count($evals_links); $count++) {
for ($count=0; $count < count($evals_links); $count++) {
$item = $evals_links[$count];
$score = $item->calc_score($stud_id);
$item_value+=$score[0]/$score[1]*$item->get_weight();
$item_total+=$item->get_weight();
}
$score = $item->calc_score($stud_id);
$item_value+=$score[0]/$score[1]*$item->get_weight();
$item_total+=$item->get_weight();
}
$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_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;
} else {
$row[] = $invisibility_span_open . $data[3] . $invisibility_span_close;
}
}
}
$row[] = $invisibility_span_open . str_replace(' ','&nbsp;',$data[4]) . $invisibility_span_close;
@ -188,9 +188,10 @@ class GradebookTable extends SortableTable
if (count($this->evals_links)>0) {
$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) {
$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 (empty($_GET['selectcat'])) {
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 {
$certificates = get_lang('NoResultsAvailable');
}
@ -198,13 +199,12 @@ class GradebookTable extends SortableTable
}
}
$sortable_data[] = $row;
}
}
return $sortable_data;
}
// Other functions
private function build_cetificate_min_score ($item) {
return $item->get_certificate_min_score();
}

Loading…
Cancel
Save