diff --git a/main/gradebook/index.php b/main/gradebook/index.php
index 48c12ab243..ac7d2d2714 100755
--- a/main/gradebook/index.php
+++ b/main/gradebook/index.php
@@ -734,7 +734,7 @@ if (isset($_GET['cidReq']) && $_GET['cidReq']!='') {
$no_qualification = false;
// Show certificate link.
-
+$certificate = array();
if ($category != '0') {
$cat = new Category();
$category_id = intval($_GET['selectcat']);
@@ -744,12 +744,14 @@ if ($category != '0') {
if ($show_message == '') {
// Student
if (!api_is_allowed_to_edit()) {
- $certificate_html = Category::register_user_certificate(
+ $certificate = Category::register_user_certificate(
$category_id,
$stud_id
);
- if ($certificate_html) {
- echo $certificate_html;
+ if (!empty($certificate)) {
+ echo '
';
+ echo $certificate['pdf_link'];
+ echo '
';
}
}
}
@@ -759,11 +761,24 @@ if (api_is_allowed_to_edit(null, true)) {
// Tool introduction
Display::display_introduction_section(TOOL_GRADEBOOK, array('ToolbarSet' => 'AssessmentsIntroduction'));
- if ( (isset ($_GET['selectcat']) && $_GET['selectcat']<>0)) {
+ if ((isset ($_GET['selectcat']) && $_GET['selectcat']<>0)) {
//
} else {
- if (((isset ($_GET['selectcat']) && $_GET['selectcat']==0) || ((isset($_GET['cidReq']) && $_GET['cidReq']!==''))) || isset($_GET['isStudentView']) && $_GET['isStudentView']=='false') {
- $cats = Category :: load(null, null, $course_code, null, null, $session_id, false);
+ if ((
+ (isset ($_GET['selectcat']) && $_GET['selectcat'] == 0) || (
+ (isset($_GET['cidReq']) && $_GET['cidReq'] !== ''))
+ ) ||
+ isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false'
+ ) {
+ $cats = Category:: load(
+ null,
+ null,
+ $course_code,
+ null,
+ null,
+ $session_id,
+ false
+ );
}
}
}
@@ -775,10 +790,11 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (!empty($cats)) {
if ((api_get_setting('gradebook_enable_grade_model') == 'true') &&
- (api_is_platform_admin() || (api_is_allowed_to_edit(null, true) &&
- api_get_setting('teachers_can_change_grade_model_settings') == 'true'))
+ (
+ api_is_platform_admin() || (api_is_allowed_to_edit(null, true) &&
+ api_get_setting('teachers_can_change_grade_model_settings') == 'true')
+ )
) {
-
// Getting grade models.
$obj = new GradeModel();
$grade_models = $obj->get_all();
@@ -848,7 +864,8 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$is_platform_admin,
$simple_search_form,
false,
- true
+ true,
+ $certificate
);
if (api_is_allowed_to_edit(null,true) &&
diff --git a/main/gradebook/lib/be/category.class.php b/main/gradebook/lib/be/category.class.php
index 66b5654fc4..ba35de86c6 100755
--- a/main/gradebook/lib/be/category.class.php
+++ b/main/gradebook/lib/be/category.class.php
@@ -1615,10 +1615,10 @@ class Category implements GradebookItem
register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime());
$my_certificate = get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
}
+ $html = array();
if (!empty($my_certificate)) {
$certificate_obj = new Certificate($my_certificate['id']);
$fileWasGenerated = $certificate_obj->html_file_is_generated();
- $html = null;
if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
$certificates = Display::url(
@@ -1640,9 +1640,10 @@ class Category implements GradebookItem
),
"$url&action=export"
);
- $html = '';
- $html .= $certificates . $exportToPDF;
- $html .= '
';
+ $html = array(
+ 'certificate_link' => $certificates,
+ 'pdf_link' => $exportToPDF
+ );
}
return $html;
}
diff --git a/main/gradebook/lib/fe/displaygradebook.php b/main/gradebook/lib/fe/displaygradebook.php
index fa1c862ef0..d8a7fd7bca 100755
--- a/main/gradebook/lib/fe/displaygradebook.php
+++ b/main/gradebook/lib/fe/displaygradebook.php
@@ -372,7 +372,8 @@ class DisplayGradebook
$is_platform_admin,
$simple_search_form,
$show_add_qualification = true,
- $show_add_link = true
+ $show_add_link = true,
+ $certificateLinkInfo = null
) {
// Student.
$status = CourseManager::get_user_in_course_status(api_get_user_id(), api_get_course_id());
@@ -434,7 +435,13 @@ class DisplayGradebook
$total_score = array($item_value_total, $item_total);
$scorecourse_display = $scoredisplay->display_score($total_score, SCORE_DIV_PERCENT);
if ((!$catobj->get_id() == '0') && (!isset($_GET['studentoverview'])) && (!isset($_GET['search']))) {
- $scoreinfo .= '' . get_lang('Total') . ' : ' . $scorecourse_display . '
';
+ $certificateLink = null;
+ if (!empty($certificateLinkInfo) && isset($certificateLinkInfo['certificate_link'])) {
+ $certificateLink .= ' ' . $certificateLinkInfo['certificate_link']."";
+ }
+
+ $scoreinfo .= '' . get_lang('Total') . ' : ' . $scorecourse_display . $certificateLink. '
';
+
}
Display :: display_normal_message($scoreinfo, false);
}