diff --git a/main/gradebook/gradebook_add_link.php b/main/gradebook/gradebook_add_link.php index 877c67d594..ab25e2655c 100644 --- a/main/gradebook/gradebook_add_link.php +++ b/main/gradebook/gradebook_add_link.php @@ -25,7 +25,9 @@ $course_info = api_get_course_info($_GET['course_code']); $tbl_forum_thread = Database :: get_course_table(TABLE_FORUM_THREAD); $tbl_link=Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); -$all_categories = Category :: load(); + +$session_id = api_get_session_id(); +$all_categories = Category :: load(null, null, api_get_course_id(), null, null, $session_id); $category = Category :: load($_GET['selectcat']); $url = api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']). '&newtypeselected=' . (isset($_GET['typeselected']) ? Security::remove_XSS($_GET['typeselected']) : ''). '&course_code=' . (empty($_GET['course_code'])?'':Security::remove_XSS($_GET['course_code'])); diff --git a/main/gradebook/lib/be/abstractlink.class.php b/main/gradebook/lib/be/abstractlink.class.php index f2f0b5174c..d706331898 100644 --- a/main/gradebook/lib/be/abstractlink.class.php +++ b/main/gradebook/lib/be/abstractlink.class.php @@ -211,7 +211,7 @@ abstract class AbstractLink implements GradebookItem { $row_testing=Database::fetch_array($result_testing); if ($row_testing[0]==0) { - $sql = 'INSERT INTO '.$tbl_grade_links.' (type,ref_id, user_id, course_code, category_id, weight, visible, created_at'; + $sql = 'INSERT INTO '.$tbl_grade_links.' (type, ref_id, user_id, course_code, category_id, weight, visible, created_at'; $sql .= ') VALUES (' .intval($this->get_type()) .','.intval($this->get_ref_id()) diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index b5e35320ca..0ea098a33b 100644 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -155,7 +155,7 @@ class Category implements GradebookItem * @param int session id (in case we are in a session) * @param bool Whether to show all "session" categories (true) or hide them (false) in case there is no session id */ - public function load ($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session_id = null, $show_session_categories = true) { + public function load ($id = null, $user_id = null, $course_code = null, $parent_id = null, $visible = null, $session_id = null, $show_session_categories = true) { //if the category given is explicitly 0 (not null), then create // a root category object (in memory) if ( isset($id) && (int)$id === 0 ) { @@ -220,7 +220,7 @@ class Category implements GradebookItem $sql .= ' visible = '.intval($visible); $paramcount ++; } - //var_dump($sql); + $result = Database::query($sql); $allcat = array(); if (Database::num_rows($result) > 0) { @@ -254,6 +254,7 @@ class Category implements GradebookItem $cat->set_parent_id($data['parent_id']); $cat->set_weight($data['weight']); $cat->set_visible($data['visible']); + $cat->set_session_id($data['session_id']); $cat->set_certificate_min_score($data['certif_min_score']); $allcat[]=$cat; } diff --git a/main/gradebook/lib/fe/linkaddeditform.class.php b/main/gradebook/lib/fe/linkaddeditform.class.php index 5fbba73556..0ed0acb245 100644 --- a/main/gradebook/lib/fe/linkaddeditform.class.php +++ b/main/gradebook/lib/fe/linkaddeditform.class.php @@ -72,8 +72,8 @@ class LinkAddEditForm extends FormValidator $select_gradebook = $this->addElement('select', 'select_gradebook', get_lang('SelectGradebook'), array(), array('id' => 'hide_category_id')); $default_weight = 0; - if (!empty($category_object)) { - foreach($category_object as $my_cat) { + if (!empty($category_object)) { + foreach ($category_object as $my_cat) { if ($my_cat->get_course_code() == api_get_course_id()) { if ($my_cat->get_parent_id() == 0 ) { $default_weight = $my_cat->get_weight();