Add session_id in gradebook.

1.10.x
Julio Montoya 11 years ago
parent 0e088a1a3d
commit 545330d922
  1. 4
      main/gradebook/gradebook.php
  2. 64
      main/gradebook/index.php
  3. 55
      main/gradebook/lib/be/category.class.php
  4. 63
      main/gradebook/lib/fe/displaygradebook.php
  5. 10
      main/gradebook/lib/fe/gradebooktable.class.php

@ -576,7 +576,7 @@ if (((empty ($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_plat
} }
// Here we are in a sub category // Here we are in a sub category
if ($category != '0') { if ($category != '0') {
DisplayGradebook:: display_header_gradebook( DisplayGradebook:: header(
$cats[0], $cats[0],
1, 1,
$_GET['selectcat'], $_GET['selectcat'],
@ -586,7 +586,7 @@ if ($category != '0') {
); );
} else { } else {
// This is the root category // This is the root category
DisplayGradebook:: display_header_gradebook( DisplayGradebook:: header(
$cats[0], $cats[0],
(((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1), (((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1),
0, 0,

@ -96,6 +96,7 @@ $filter_confirm_msg = true;
$filter_warning_msg = true; $filter_warning_msg = true;
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); $cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
$first_time = null; $first_time = null;
if (empty($cats)) { if (empty($cats)) {
@ -151,7 +152,7 @@ if ((isset($_GET['selectcat']) && $_GET['selectcat']>0) &&
// ACTIONS // ACTIONS
//this is called when there is no data for the course admin //this is called when there is no data for the course admin
if (isset ($_GET['createallcategories'])) { if (isset($_GET['createallcategories'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories($stud_id); $coursecat= Category :: get_not_created_course_categories($stud_id);
if (!count($coursecat) == 0) { if (!count($coursecat) == 0) {
@ -173,13 +174,13 @@ if (isset ($_GET['createallcategories'])) {
} }
//show logs evaluations //show logs evaluations
if (isset ($_GET['visiblelog'])) { if (isset($_GET['visiblelog'])) {
header('Location: ' . api_get_self().'/gradebook_showlog_eval.php'); header('Location: ' . api_get_self().'/gradebook_showlog_eval.php');
exit; exit;
} }
//move a category //move a category
if (isset ($_GET['movecat'])) { if (isset($_GET['movecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$cats= Category :: load($_GET['movecat']); $cats= Category :: load($_GET['movecat']);
if (!isset ($_GET['targetcat'])) { if (!isset ($_GET['targetcat'])) {
@ -196,7 +197,7 @@ if (isset ($_GET['movecat'])) {
exit; exit;
} }
} else { } else {
$targetcat= Category :: load($_GET['targetcat']); $targetcat = Category :: load($_GET['targetcat']);
$course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
if (!($course_to_crsind && !isset($_GET['confirm']))) { if (!($course_to_crsind && !isset($_GET['confirm']))) {
@ -210,7 +211,7 @@ if (isset ($_GET['movecat'])) {
} }
//move an evaluation //move an evaluation
if (isset ($_GET['moveeval'])) { if (isset($_GET['moveeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$evals= Evaluation :: load($_GET['moveeval']); $evals= Evaluation :: load($_GET['moveeval']);
if (!isset ($_GET['targetcat'])) { if (!isset ($_GET['targetcat'])) {
@ -244,7 +245,7 @@ if (isset ($_GET['moveeval'])) {
} }
//move a link //move a link
if (isset ($_GET['movelink'])) { if (isset($_GET['movelink'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$link= LinkFactory :: load($_GET['movelink']); $link= LinkFactory :: load($_GET['movelink']);
$move_form = new LinkForm( $move_form = new LinkForm(
@ -266,7 +267,7 @@ if (isset ($_GET['movelink'])) {
} }
//parameters for categories //parameters for categories
if (isset ($_GET['visiblecat'])) { if (isset($_GET['visiblecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) { if (isset ($_GET['set_visible'])) {
@ -274,7 +275,7 @@ if (isset ($_GET['visiblecat'])) {
} else { } else {
$visibility_command= 0; $visibility_command= 0;
} }
$cats= Category :: load($_GET['visiblecat']); $cats = Category :: load($_GET['visiblecat']);
$cats[0]->set_visible($visibility_command); $cats[0]->set_visible($visibility_command);
$cats[0]->save(); $cats[0]->save();
$cats[0]->apply_visibility_to_children(); $cats[0]->apply_visibility_to_children();
@ -302,8 +303,9 @@ if (isset($_GET['deletecat'])) {
$confirmation_message = get_lang('CategoryDeleted'); $confirmation_message = get_lang('CategoryDeleted');
$filter_confirm_msg = false; $filter_confirm_msg = false;
} }
//parameters for evaluations //parameters for evaluations
if (isset ($_GET['visibleeval'])) { if (isset($_GET['visibleeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) { if (isset ($_GET['set_visible'])) {
$visibility_command= 1; $visibility_command= 1;
@ -322,6 +324,7 @@ if (isset ($_GET['visibleeval'])) {
$filter_confirm_msg = false; $filter_confirm_msg = false;
} }
} }
//parameters for evaluations //parameters for evaluations
if (isset($_GET['lockedeval'])) { if (isset($_GET['lockedeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
@ -339,9 +342,9 @@ if (isset($_GET['lockedeval'])) {
} }
$filter_confirm_msg = false; $filter_confirm_msg = false;
} }
if (isset ($_GET['deleteeval'])) {
if (isset($_GET['deleteeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']); $eval= Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) { if ($eval[0] != null) {
@ -350,8 +353,9 @@ if (isset ($_GET['deleteeval'])) {
$confirmation_message = get_lang('GradebookEvaluationDeleted'); $confirmation_message = get_lang('GradebookEvaluationDeleted');
$filter_confirm_msg = false; $filter_confirm_msg = false;
} }
//parameters for links //parameters for links
if (isset ($_GET['visiblelink'])) { if (isset($_GET['visiblelink'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
if (isset ($_GET['set_visible'])) { if (isset ($_GET['set_visible'])) {
$visibility_command= 1; $visibility_command= 1;
@ -441,7 +445,7 @@ switch ($action) {
} }
//actions on the sortabletable //actions on the sortabletable
if (isset ($_POST['action'])) { if (isset($_POST['action'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']); $number_of_selected_items= count($_POST['id']);
@ -450,8 +454,7 @@ if (isset ($_POST['action'])) {
$filter_warning_msg = false; $filter_warning_msg = false;
} else { } else {
switch ($_POST['action']) { switch ($_POST['action']) {
case 'deleted':
case 'deleted' :
$number_of_deleted_categories= 0; $number_of_deleted_categories= 0;
$number_of_deleted_evaluations= 0; $number_of_deleted_evaluations= 0;
$number_of_deleted_links= 0; $number_of_deleted_links= 0;
@ -486,10 +489,10 @@ if (isset ($_POST['action'])) {
$confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>'; $confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>';
$filter_confirm_msg = false; $filter_confirm_msg = false;
break; break;
case 'setvisible' : case 'setvisible':
foreach ($_POST['id'] as $indexstr) { foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') { if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4)); $cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(1); $cats[0]->set_visible(1);
$cats[0]->save(); $cats[0]->save();
$cats[0]->apply_visibility_to_children(); $cats[0]->apply_visibility_to_children();
@ -508,10 +511,10 @@ if (isset ($_POST['action'])) {
$confirmation_message = get_lang('ItemsVisible'); $confirmation_message = get_lang('ItemsVisible');
$filter_confirm_msg = false; $filter_confirm_msg = false;
break; break;
case 'setinvisible' : case 'setinvisible':
foreach ($_POST['id'] as $indexstr) { foreach ($_POST['id'] as $indexstr) {
if (substr($indexstr, 0, 4) == 'CATE') { if (substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(substr($indexstr, 4)); $cats = Category :: load(substr($indexstr, 4));
$cats[0]->set_visible(0); $cats[0]->set_visible(0);
$cats[0]->save(); $cats[0]->save();
$cats[0]->apply_visibility_to_children(); $cats[0]->apply_visibility_to_children();
@ -609,15 +612,15 @@ $is_course_admin = api_is_allowed_to_edit(null, true);
//load data for category, evaluation and links //load data for category, evaluation and links
if (empty($_GET['selectcat'])) { if (empty($_GET['selectcat'])) {
$category= 0; $category = 0;
} else { } else {
$category= $_GET['selectcat']; $category = $_GET['selectcat'];
} }
$simple_search_form=''; $simple_search_form='';
if (isset($_GET['studentoverview'])) { if (isset($_GET['studentoverview'])) {
//@todo this code also seems to be deprecated ... //@todo this code also seems to be deprecated ...
$cats= Category :: load($category); $cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : $stud_id); $stud_id= (api_is_allowed_to_edit() ? null : $stud_id);
$allcat= array (); $allcat= array ();
$alleval= $cats[0]->get_evaluations($stud_id, true); $alleval= $cats[0]->get_evaluations($stud_id, true);
@ -656,6 +659,7 @@ if (isset($_GET['studentoverview'])) {
//if $category = 0 (which happens when GET['selectcat'] is undefined) //if $category = 0 (which happens when GET['selectcat'] is undefined)
// then Category::load() will create a new 'root' category with empty // then Category::load() will create a new 'root' category with empty
// course and session fields in memory (Category::create_root_category()) // course and session fields in memory (Category::create_root_category())
if ($_in_course === true) { if ($_in_course === true) {
// When *inside* a course, we want to make sure there is one (and only // When *inside* a course, we want to make sure there is one (and only
// one) category for this course or for this session. // one) category for this course or for this session.
@ -671,7 +675,7 @@ if (isset($_GET['studentoverview'])) {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); $cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
if (empty($cats)) { if (empty($cats)) {
// There is no category for this course+session, so create one // There is no category for this course+session, so create one
$cat= new Category(); $cat = new Category();
if (!empty($session_id)) { if (!empty($session_id)) {
$s_name = api_get_session_name($session_id); $s_name = api_get_session_name($session_id);
$cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name); $cat->set_name($course_code.' - '.get_lang('Session').' '.$s_name);
@ -690,10 +694,11 @@ if (isset($_GET['studentoverview'])) {
if ($can_edit) { if ($can_edit) {
$cat->add(); $cat->add();
} }
unset ($cat); unset($cat);
} }
unset($cats); unset($cats);
} }
$cats = Category::load($category, null, null, null, null, null, false); $cats = Category::load($category, null, null, null, null, null, false);
//with this fix the teacher only can view 1 gradebook //with this fix the teacher only can view 1 gradebook
@ -706,19 +711,17 @@ if (isset($_GET['studentoverview'])) {
$allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id);
$alleval = $cats[0]->get_evaluations($stud_id); $alleval = $cats[0]->get_evaluations($stud_id);
$alllink = $cats[0]->get_links($stud_id); $alllink = $cats[0]->get_links($stud_id);
//whether we found a category or not, we now have a category object with
// empty or full subcats
} }
// add params to the future links (in the table shown) // add params to the future links (in the table shown)
$addparams = array ('selectcat' => $cats[0]->get_id()); $addparams = array('selectcat' => $cats[0]->get_id());
if (isset ($_GET['studentoverview'])) { if (isset($_GET['studentoverview'])) {
$addparams['studentoverview'] = ''; $addparams['studentoverview'] = '';
} }
//$addparams['cidReq']=''; //$addparams['cidReq']='';
if (isset($_GET['cidReq']) && $_GET['cidReq']!='') { if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$addparams['cidReq']=Security::remove_XSS($_GET['cidReq']); $addparams['cidReq'] = Security::remove_XSS($_GET['cidReq']);
} else { } else {
$addparams['cidReq']=''; $addparams['cidReq']='';
} }
@ -849,8 +852,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
} else { } else {
// This is the father // This is the father
// Create gradebook/add gradebook links. // Create gradebook/add gradebook links.
DisplayGradebook::header(
DisplayGradebook::display_header_gradebook(
$cat, $cat,
0, 0,
$cat->get_id(), $cat->get_id(),

@ -807,7 +807,12 @@ class Category implements GradebookItem
*/ */
public function is_certificate_available($user_id) public function is_certificate_available($user_id)
{ {
$score = $this->calc_score($user_id, null, $this->course_code); $score = $this->calc_score(
$user_id,
null,
$this->course_code,
$this->session_id
);
if (isset($score) && isset($score[0])) { if (isset($score) && isset($score[0])) {
// Get a percentage score to compare to minimum certificate score // Get a percentage score to compare to minimum certificate score
@ -1487,13 +1492,15 @@ class Category implements GradebookItem
* @param int $stud_id student id (default: all students) * @param int $stud_id student id (default: all students)
* @param boolean $recursive process subcategories (default: no recursion) * @param boolean $recursive process subcategories (default: no recursion)
* @param string $course_code * @param string $course_code
* @param int $sessionId
* *
* @return array * @return array
*/ */
public function get_evaluations( public function get_evaluations(
$stud_id = null, $stud_id = null,
$recursive = false, $recursive = false,
$course_code = '' $course_code = '',
$sessionId = 0
) { ) {
$evals = array(); $evals = array();
@ -1501,18 +1508,30 @@ class Category implements GradebookItem
$course_code = api_get_course_id(); $course_code = api_get_course_id();
} }
if (empty($sessionId)) {
$sessionId = api_get_session_id();
}
// 1 student // 1 student
if (isset($stud_id) && !empty($stud_id)) { if (isset($stud_id) && !empty($stud_id)) {
// Special case: this is the root // Special case: this is the root
if ($this->id == 0) { if ($this->id == 0) {
$evals = Evaluation::get_evaluations_with_result_for_student(0, $stud_id); $evals = Evaluation::get_evaluations_with_result_for_student(0, $stud_id);
} else { } else {
$evals = Evaluation::load(null,null, $course_code, $this->id, api_is_allowed_to_edit() ? null : 1); $evals = Evaluation::load(
null,
null,
$course_code,
$this->id,
api_is_allowed_to_edit() ? null : 1
);
} }
} else { } else {
// All students // All students
// course admin // course admin
if ((api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) && !api_is_platform_admin()) { if ((api_is_allowed_to_edit() || api_is_drh() || api_is_session_admin()) &&
!api_is_platform_admin()
) {
// root // root
if ($this->id == 0) { if ($this->id == 0) {
$evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null); $evals = Evaluation::load(null, api_get_user_id(), null, $this->id, null);
@ -1529,11 +1548,11 @@ class Category implements GradebookItem
} }
if ($recursive) { if ($recursive) {
$subcats = $this->get_subcategories($stud_id, $course_code); $subcats = $this->get_subcategories($stud_id, $course_code, $sessionId);
if (!empty($subcats)) { if (!empty($subcats)) {
foreach ($subcats as $subcat) { foreach ($subcats as $subcat) {
$subevals = $subcat->get_evaluations($stud_id, true, $course_code); $subevals = $subcat->get_evaluations($stud_id, true, $course_code);
//$this->debugprint($subevals);
$evals = array_merge($evals, $subevals); $evals = array_merge($evals, $subevals);
} }
} }
@ -1555,7 +1574,7 @@ class Category implements GradebookItem
$stud_id = null, $stud_id = null,
$recursive = false, $recursive = false,
$course_code = '', $course_code = '',
$sessionId = null $sessionId = 0
) { ) {
$links = array(); $links = array();
@ -1737,6 +1756,7 @@ class Category implements GradebookItem
*/ */
public static function register_user_certificate($category_id, $user_id) public static function register_user_certificate($category_id, $user_id)
{ {
$sessionId = api_get_session_id();
// Generating the total score for a course // Generating the total score for a course
$cats_course = Category::load( $cats_course = Category::load(
$category_id, $category_id,
@ -1744,19 +1764,21 @@ class Category implements GradebookItem
null, null,
null, null,
null, null,
api_get_session_id(), $sessionId,
false false
); );
/** @var Category $category */ /** @var Category $category */
$category = $cats_course[0]; $category = $cats_course[0];
if (!$category->getGenerateCetificates()) { if (!$category->getGenerateCetificates()) {
$skill = new Skill(); $skill = new Skill();
$skill->add_skill_to_user( $skill->add_skill_to_user(
$user_id, $user_id,
$category_id, $category_id,
api_get_course_int_id(), api_get_course_int_id(),
api_get_session_id() $sessionId
); );
return false; return false;
@ -1792,7 +1814,11 @@ class Category implements GradebookItem
return false; return false;
} }
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); $my_certificate = GradebookUtils::get_certificate_by_user_id(
$cats_course[0]->get_id(),
$user_id
);
if (empty($my_certificate)) { if (empty($my_certificate)) {
GradebookUtils::register_user_info_about_certificate( GradebookUtils::register_user_info_about_certificate(
$category_id, $category_id,
@ -1800,8 +1826,12 @@ class Category implements GradebookItem
$my_score_in_gradebook, $my_score_in_gradebook,
api_get_utc_datetime() api_get_utc_datetime()
); );
$my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); $my_certificate = GradebookUtils::get_certificate_by_user_id(
$cats_course[0]->get_id(),
$user_id
);
} }
$html = array(); $html = array();
if (!empty($my_certificate)) { if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']); $certificate_obj = new Certificate($my_certificate['id']);
@ -1809,6 +1839,7 @@ class Category implements GradebookItem
if (!empty($fileWasGenerated)) { if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id']; $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
$certificates = Display::url( $certificates = Display::url(
'&nbsp;'.get_lang('DownloadCertificate'), '&nbsp;'.get_lang('DownloadCertificate'),
$url, $url,
@ -1817,6 +1848,7 @@ class Category implements GradebookItem
'class' => 'btn' 'class' => 'btn'
) )
); );
$exportToPDF = Display::url( $exportToPDF = Display::url(
Display::return_icon( Display::return_icon(
'pdf.png', 'pdf.png',
@ -1826,6 +1858,7 @@ class Category implements GradebookItem
), ),
"$url&action=export" "$url&action=export"
); );
$html = array( $html = array(
'certificate_link' => $certificates, 'certificate_link' => $certificates,
'pdf_link' => $exportToPDF 'pdf_link' => $exportToPDF

@ -341,8 +341,10 @@ class DisplayGradebook
$my_course_id = api_get_course_id(); $my_course_id = api_get_course_id();
$my_file = substr($_SESSION['gradebook_dest'], 0, 5); $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_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' .
$header .= '<td style="vertical-align: top;"><a href="gradebook_display_certificate.php?' . $my_api_cidreq . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' . Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>'; 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 . '&amp;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_icon = ($catobj->is_visible() == 0) ? 'invisible' : 'visible';
$visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible'; $visibility_command = ($catobj->is_visible() == 0) ? 'set_visible' : 'set_invisible';
@ -380,7 +382,7 @@ class DisplayGradebook
* where we have only one calification per course or session) * where we have only one calification per course or session)
* @return void Everything is printed on screen upon closing * @return void Everything is printed on screen upon closing
*/ */
static function display_header_gradebook( static function header(
$catobj, $catobj,
$showtree, $showtree,
$selectcat, $selectcat,
@ -391,8 +393,22 @@ class DisplayGradebook
$show_add_link = true, $show_add_link = true,
$certificateLinkInfo = null $certificateLinkInfo = null
) { ) {
$userId = api_get_user_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
// Student. // Student.
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id()); $status = CourseManager::get_user_in_course_status($userId, $courseCode);
if (!empty($sessionId)) {
$sessionStatus = SessionManager::get_user_status_in_course_session(
$userId,
$courseCode,
$sessionId
);
}
$objcat = new Category(); $objcat = new Category();
$course_id = CourseManager::get_course_by_category($selectcat); $course_id = CourseManager::get_course_by_category($selectcat);
$message_resource = $objcat->show_message_resource_delete($course_id); $message_resource = $objcat->show_message_resource_delete($course_id);
@ -403,7 +419,15 @@ class DisplayGradebook
$sum_categories_weight_array = array(); $sum_categories_weight_array = array();
if (isset($catobj) && !empty($catobj)) { if (isset($catobj) && !empty($catobj)) {
$categories = Category::load(null, null, null, $catobj->get_id()); $categories = Category::load(
null,
null,
null,
$catobj->get_id(),
null,
$sessionId
);
if (!empty($categories)) { if (!empty($categories)) {
foreach ($categories as $category) { foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight(); $sum_categories_weight_array[$category->get_id()] = $category->get_weight();
@ -413,23 +437,15 @@ class DisplayGradebook
} }
} }
if (!$is_course_admin && $status <> 1 && $selectcat <> 0) { if (!$is_course_admin && ($status <> 1 || $sessionStatus == 0) && $selectcat <> 0) {
$user_id = api_get_user_id();
$catcourse = Category::load($catobj->get_id()); $catcourse = Category::load($catobj->get_id());
$main_weight = $catcourse[0]->get_weight(); /** @var Category $category */
$category = $catcourse[0];
$main_weight = $category->get_weight();
$scoredisplay = ScoreDisplay :: instance(); $scoredisplay = ScoreDisplay :: instance();
//$categories = Category::getCategories($catcourse[0]->get_id()); $allevals = $category->get_evaluations($userId, true);
// generating the total score for a course $alllinks = $category->get_links($userId, true);
/*if (count($categories) > 0) {
foreach ($categories as $category) {
$allevals = $category->get_evaluations($user_id, true);
$alllinks = $category->get_links($user_id, true);
$catEvalsLinks = array_merge($allevals, $alllinks);
}
}*/
$allevals = $catcourse[0]->get_evaluations($user_id, true);
$alllinks = $catcourse[0]->get_links($user_id, true);
$allEvalsLinks = array_merge($allevals, $alllinks); $allEvalsLinks = array_merge($allevals, $alllinks);
@ -438,13 +454,10 @@ class DisplayGradebook
for ($count = 0; $count < count($allEvalsLinks); $count++) { for ($count = 0; $count < count($allEvalsLinks); $count++) {
$item = $allEvalsLinks[$count]; $item = $allEvalsLinks[$count];
$score = $item->calc_score($user_id); $score = $item->calc_score($userId);
if (!empty($score)) { if (!empty($score)) {
$divide = $score[1] == 0 ? 1 : $score[1]; $divide = $score[1] == 0 ? 1 : $score[1];
//$sub_cat_percentage = $sum_categories_weight_array[$item->get_category_id()];
//$item_value = $score[0] / $divide * $item->get_weight() / $sub_cat_percentage * $sub_cat_percentage / $main_weight * $main_weight;
$item_value = $score[0] / $divide * $item->get_weight(); $item_value = $score[0] / $divide * $item->get_weight();
//var_dump($score[0], $divide, $item->get_weight(), $sub_cat_percentage, $main_weight, $item_value);
$item_value_total += $item_value; $item_value_total += $item_value;
} }
} }
@ -600,8 +613,6 @@ class DisplayGradebook
if ($isDrhOfCourse) { if ($isDrhOfCourse) {
$header .= '<td style="vertical-align: top;"><a href="gradebook_flatview.php?' . $my_api_cidreq . '&selectcat=' . $catobj->get_id() . '">' . $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>'; 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 . '&amp;cat_id=' . (int) $_GET['selectcat'] . '">' .
Display::return_icon('certificate_list.png', get_lang('GradebookSeeListOfStudentsCertificates'), '', ICON_SIZE_MEDIUM) . '</a>';*/
} }
$header .= '</div>'; $header .= '</div>';
@ -609,7 +620,7 @@ class DisplayGradebook
echo $header; echo $header;
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$weight = ((intval($catobj->get_weight()) > 0) ? $catobj->get_weight() : 0); $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
$weight = get_lang('TotalWeight') . ' : ' . $weight; $weight = get_lang('TotalWeight') . ' : ' . $weight;
$min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0); $min_certification = (intval($catobj->get_certificate_min_score() > 0) ? $catobj->get_certificate_min_score() : 0);

@ -221,7 +221,7 @@ class GradebookTable extends SortableTable
$row[] = $invisibility_span_open.$data[2].$invisibility_span_close; $row[] = $invisibility_span_open.$data[2].$invisibility_span_close;
// Weight. // Weight.
$average = $scoredisplay->display_score( $weight = $scoredisplay->display_score(
array( array(
$data['3'], $data['3'],
$this->currentcat->get_weight() $this->currentcat->get_weight()
@ -231,11 +231,10 @@ class GradebookTable extends SortableTable
true true
); );
// Weight
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$row[] = $invisibility_span_open .Display::tag('h4', $average).$invisibility_span_close; $row[] = $invisibility_span_open .Display::tag('h4', $weight).$invisibility_span_close;
} else { } else {
$row[] = $invisibility_span_open .$average.$invisibility_span_close; $row[] = $invisibility_span_open .$weight.$invisibility_span_close;
} }
$category_weight = $item->get_weight(); $category_weight = $item->get_weight();
@ -270,7 +269,8 @@ class GradebookTable extends SortableTable
} }
// Students get the results and certificates columns // Students get the results and certificates columns
if (count($this->evals_links) > 0 && $status_user != 1) { //if (count($this->evals_links) > 0 && $status_user != 1) {
if ($status_user != 1) {
$value_data = isset($data[4]) ? $data[4] : null; $value_data = isset($data[4]) ? $data[4] : null;
$best = isset($data['best']) ? $data['best'] : null; $best = isset($data['best']) ? $data['best'] : null;
$average = isset($data['average']) ? $data['average'] : null; $average = isset($data['average']) ? $data['average'] : null;

Loading…
Cancel
Save