diff --git a/main/gradebook/lib/be/abstractlink.class.php b/main/gradebook/lib/be/abstractlink.class.php index 9258c0e01e..cb700bff0c 100755 --- a/main/gradebook/lib/be/abstractlink.class.php +++ b/main/gradebook/lib/be/abstractlink.class.php @@ -228,6 +228,7 @@ abstract class AbstractLink implements GradebookItem $result = Database::query($sql); $links = AbstractLink::create_objects_from_sql_result($result); + return $links; } diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 9f751b6fb6..b704b148ff 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -1439,8 +1439,14 @@ class Category implements GradebookItem $sessionId ); if (!empty($subcats)) { + /** @var Category $subcat */ foreach ($subcats as $subcat) { - $sublinks = $subcat->get_links($stud_id, false, $course_code, $sessionId); + $sublinks = $subcat->get_links( + $stud_id, + false, + $course_code, + $sessionId + ); $links = array_merge($links, $sublinks); } } @@ -1567,10 +1573,19 @@ class Category implements GradebookItem public static function register_user_certificate($category_id, $user_id) { // Generating the total score for a course - $cats_course = Category::load($category_id, null, null, null, null, api_get_session_id(), false); - - $alleval_course = $cats_course[0]->get_evaluations($user_id, true); - $alllink_course = $cats_course[0]->get_links($user_id, true); + $cats_course = Category::load( + $category_id, + null, + null, + null, + null, + api_get_session_id(), + false + ); + /** @var Category $category */ + $category = $cats_course[0]; + $alleval_course = $category->get_evaluations($user_id, true); + $alllink_course = $category->get_links($user_id, true); $evals_links = array_merge($alleval_course, $alllink_course); //@todo move these in a function diff --git a/main/gradebook/lib/be/exerciselink.class.php b/main/gradebook/lib/be/exerciselink.class.php index f5b5b1743b..b5d5db16b8 100755 --- a/main/gradebook/lib/be/exerciselink.class.php +++ b/main/gradebook/lib/be/exerciselink.class.php @@ -340,14 +340,17 @@ class ExerciseLink extends AbstractLink } else { $tbl_exercise = $this->get_exercise_table(); } - if ($tbl_exercise=='') { + + $ref_id = intval($this->get_ref_id()); + + if ($tbl_exercise == '') { return false; } elseif (!isset($this->exercise_data)) { if ($this->is_hp == 1) { - $ref_id = intval($this->get_ref_id()); - $sql = "SELECT * FROM $tbl_exercise ex, $TBL_ITEM_PROPERTY ip + $sql = "SELECT * FROM $tbl_exercise ex + INNER JOIN $TBL_ITEM_PROPERTY ip + ON (ip.ref = ex.id AND ip.c_id = ex.c_id) WHERE - ip.ref = ex.id AND ip.c_id = $this->course_id AND ex.c_id = $this->course_id AND ip.ref = $ref_id AND @@ -359,7 +362,7 @@ class ExerciseLink extends AbstractLink $sql = 'SELECT * FROM '.$tbl_exercise.' WHERE c_id = '.$this->course_id.' AND - id = '.(int)$this->get_ref_id().' '; + id = '.$ref_id.' '; } $result = Database::query($sql); $this->exercise_data = Database::fetch_array($result); diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index 5d1011f71b..736411a315 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -163,9 +163,6 @@ class FlatViewDataGenerator foreach ($allcat as $sub_cat) { $sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1); $add_weight = " $sub_cat_weight %"; - /*if (isset($this->params['export_pdf']) && $this->params['export_pdf']) { - $add_weight = null; - }*/ $headers[] = Display::url( $sub_cat->get_name(), api_get_self().'?selectcat='.$sub_cat->get_id() @@ -190,7 +187,9 @@ class FlatViewDataGenerator for ($count = 0; ($count < $items_count) && ($items_start + $count < count($this->evals_links)); $count++) { /** @var AbstractLink $item */ $item = $this->evals_links[$count + $items_start]; - if ($mainCategoryId == $item->get_category_id() && !in_array($item->get_id(), $evaluationsAdded)) { + if ($mainCategoryId == $item->get_category_id() && + !in_array($item->get_id(), $evaluationsAdded) + ) { $weight = round(100 * $item->get_weight() / $main_weight, 1); $headers[] = $item->get_name() . ' ' . $weight . ' % '; }