From 48688c97ee905a4e396bef930f71dcb5c55169f4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 17 Feb 2015 10:19:40 +0100 Subject: [PATCH] Minor - format code. --- main/gradebook/gradebook_display_certificate.php | 7 ++++++- main/gradebook/lib/be/category.class.php | 15 ++++++++++----- .../lib/flatview_data_generator.class.php | 5 ++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/main/gradebook/gradebook_display_certificate.php b/main/gradebook/gradebook_display_certificate.php index 3c83a54169..23a0659a40 100755 --- a/main/gradebook/gradebook_display_certificate.php +++ b/main/gradebook/gradebook_display_certificate.php @@ -107,7 +107,12 @@ if (!empty($cats)) { $total_resource_weight = 0; if (!empty($datagen)) { - $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); + $data_array = $datagen->get_data( + GradebookDataGenerator :: GDG_SORT_NAME, + 0, + null, + true + ); if (!empty($data_array)) { $newarray = array(); diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php index 0ffcb4b5c7..cb64bc9d55 100755 --- a/main/gradebook/lib/be/category.class.php +++ b/main/gradebook/lib/be/category.class.php @@ -697,14 +697,17 @@ class Category implements GradebookItem /** * Checks if the certificate is available for the given user in this category - * @param integer User ID - * @return boolean True if conditions match, false if fails + * @param integer $user_id User ID + * @return boolean True if conditions match, false if fails */ public function is_certificate_available($user_id) { $score = $this->calc_score($user_id, $this->course_code); + if (isset($score)) { - $certification_score = ($score[0]/$score[1])*100; //get a percentage score to compare to minimum certificate score + // Get a percentage score to compare to minimum certificate score + $certification_score = $score[0] / $score[1] * 100; + if ($certification_score >= $this->certificate_min_score) { return true; } @@ -1592,8 +1595,8 @@ class Category implements GradebookItem ); /** @var Category $category */ $category = $cats_course[0]; - $alleval_course = $category->get_evaluations($user_id, true); - $alllink_course = $category->get_links($user_id, true); + $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 @@ -1643,6 +1646,7 @@ class Category implements GradebookItem $item_total_value >= $certificate_min_score ) { $my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id); + if (empty($my_certificate)) { register_user_info_about_certificate( $category_id, @@ -1656,6 +1660,7 @@ class Category implements GradebookItem if (!empty($my_certificate)) { $certificate_obj = new Certificate($my_certificate['id']); $fileWasGenerated = $certificate_obj->html_file_is_generated(); + if (!empty($fileWasGenerated)) { $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id']; $certificates = Display::url( diff --git a/main/gradebook/lib/flatview_data_generator.class.php b/main/gradebook/lib/flatview_data_generator.class.php index d170923400..710cc6c3b2 100755 --- a/main/gradebook/lib/flatview_data_generator.class.php +++ b/main/gradebook/lib/flatview_data_generator.class.php @@ -200,6 +200,7 @@ class FlatViewDataGenerator } $headers[] = api_strtoupper(get_lang('GradebookQualificationTotal')); + return $headers; } @@ -358,7 +359,9 @@ class FlatViewDataGenerator } // Last name - if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) { + if (isset($this->params['join_firstname_lastname']) && + $this->params['join_firstname_lastname'] + ) { if ($export_to_pdf) { $row['name'] = api_get_person_name($user[3], $user[2]); } else {