|
|
|
|
@ -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( |
|
|
|
|
|