Minor corrections in the certificate

skala
Julio Montoya 13 years ago
parent 6093f148b0
commit d157f55f56
  1. 7
      certificates/index.php
  2. 14
      main/gradebook/gradebook_display_certificate.php
  3. 2
      main/gradebook/lib/gradebook_functions.inc.php
  4. 27
      main/inc/lib/certificate.lib.php
  5. 17
      main/inc/lib/document.lib.php

@ -14,12 +14,7 @@ $language_file= array('admin', 'gradebook', 'document');
require_once '../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'certificate.lib.php';
/**
* Retrieve certificate
*/
$certificate = new Certificate($_GET['id']);
/**
* Show results
*/
//Show certificate HTML
$certificate->show();

@ -57,7 +57,6 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
//@todo replace all this code with something like get_total_weight()
$cats = Category :: load ($cat_id, null, null, null, null, null, false);
if (!empty($cats)) {
@ -97,8 +96,7 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
}
}
$certificate_list = get_list_users_certificates($cat_id);
$certificate_list = get_list_users_certificates($cat_id);
if (count($certificate_list)==0) {
echo Display::display_warning_message(get_lang('NoResultsAvailable'));
@ -106,7 +104,8 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
foreach ($certificate_list as $index=>$value) {
?>
<tr>
<td width="100%" class="actions"><?php echo get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']) ?>
<td width="100%" class="actions">
<?php echo get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ( '.$value['username'].')' ?>
</td>
</tr>
<tr>
@ -114,7 +113,7 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
<table class="data_table" width="100%" >
<?php
$list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'], $cat_id);
foreach ($list_certificate as $index_certificate => $value_certificate) {
foreach ($list_certificate as $value_certificate) {
?>
<tr >
<td width="50%"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td>
@ -127,7 +126,8 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
echo $certificates;
?>
<a onclick="return confirmation();" href="gradebook_display_certificate.php?action=delete&cat_id=<?php echo $cat_id; ?>&certificate_id=<?php echo $value_certificate['id'] ?>">
<?php echo Display::return_icon('delete.png',get_lang('Delete')); ?></a>
<?php echo Display::return_icon('delete.png',get_lang('Delete')); ?>
</a>
</td>
</tr>
<?php
@ -142,4 +142,4 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
?>
</table>
<?php
Display::display_footer();
Display::display_footer();

@ -572,7 +572,7 @@ function get_list_gradebook_certificates_by_user_id ($user_id,$cat_id=null) {
function get_user_certificate_content($user_id, $course_code, $is_preview = false) {
//generate document HTML
$content_html = DocumentManager::replace_user_info_into_html($user_id, $course_code, $is_preview);
$new_content = explode('</head>', $content_html['content']);
$new_content_html = $new_content[1];
$path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path($course_code).'/document/images/gallery';

@ -23,7 +23,8 @@ class Certificate extends Model {
var $user_id;
//If true every time we enter to the certificate URL we would generate a new certificate
var $force_certificate_generation = true;
// (good thing because we can edit the certificate and all users will have the latest certificate bad because we load everytime)
var $force_certificate_generation = true; //default true
public function __construct($certificate_id = null) {
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
@ -125,8 +126,7 @@ class Certificate extends Model {
//The user directory should be set
if (empty($this->certification_user_path) && $this->force_certificate_generation == false) {
return false;
}
}
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
@ -140,21 +140,21 @@ class Certificate extends Model {
$scorecourse = $my_category[0]->calc_score($this->user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
$cattotal = Category :: load($this->certificate_data['cat_id']);
$scoretotal= $cattotal[0]->calc_score($this->user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//$cattotal = Category :: load($this->certificate_data['cat_id']);
//$scoretotal= $cattotal[0]->calc_score($this->user_id);
//$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//Prepare all necessary variables:
$organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName');
//$portal_name = api_get_setting('siteName');
$stud_fn = $user['firstname'];
$stud_ln = $user['lastname'];
//@todo this code is not needed
$certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn.' '.$stud_ln, $my_category[0]->get_name(), $scorecourse_display);
$certif_text = str_replace("\\n","\n", $certif_text);
$date = date('d/m/Y', time());
//$date = date('d/m/Y', time());
//If the gradebook is related to skills we added the skills to the user
@ -164,7 +164,7 @@ class Certificate extends Model {
if (is_dir($this->certification_user_path)) {
if (!empty($this->certificate_data)) {
$new_content_html = get_user_certificate_content($this->user_id, $my_category[0]->get_course_code(), false);
if ($my_category[0]->get_id() == strval(intval($this->certificate_data['cat_id']))) {
$name = $this->certificate_data['path_certificate'];
$my_path_certificate = $this->certification_user_path.basename($name);
@ -180,6 +180,7 @@ class Certificate extends Model {
//Getting QR filename
$file_info = pathinfo($path_certificate);
$qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png';
$new_content_html['content'] = str_replace('((certificate_barcode))', Display::img($this->certification_web_user_path.$file_info['filename'].'_qr.png', 'QR'), $new_content_html['content']);
$my_new_content_html = $new_content_html['content'];
@ -187,8 +188,7 @@ class Certificate extends Model {
$my_new_content_html = mb_convert_encoding($my_new_content_html,'UTF-8', api_get_system_encoding());
$result = @file_put_contents($my_path_certificate, $my_new_content_html);
if ($result) {
if ($result) {
//Updating the path
self::update_user_info_about_certificate($this->certificate_data['cat_id'], $this->user_id, $path_certificate);
$this->certificate_data['path_certificate'] = $path_certificate;
@ -314,6 +314,5 @@ class Certificate extends Model {
Display :: display_warning_message(get_lang('NoCertificateAvailable'));
}
exit;
}
}
}

@ -1329,8 +1329,8 @@ return 'application/octet-stream';
* @return int The default certificate id
*/
function get_default_certificate_id($course_id) {
$tbl_category=Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id=api_get_session_id();
$tbl_category = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id = api_get_session_id();
if ($session_id==0 || is_null($session_id)) {
$sql_session='AND (session_id='.Database::escape_string($session_id).' OR isnull(session_id)) ';
} elseif ($session_id>0) {
@ -1338,9 +1338,9 @@ return 'application/octet-stream';
} else {
$sql_session='';
}
$sql='SELECT document_id FROM '.$tbl_category.' WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
$rs=Database::query($sql);
$row=Database::fetch_array($rs);
$sql = 'SELECT document_id FROM '.$tbl_category.' WHERE course_code="'.Database::escape_string($course_id).'" '.$sql_session;
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
return $row['document_id'];
}
@ -1355,10 +1355,9 @@ return 'application/octet-stream';
$tbl_document = Database::get_course_table(TABLE_DOCUMENT);
$course_id = $course_info['real_id'];
$document_id = self::get_default_certificate_id($course_code);
if ($document_id) {
$sql = "SELECT path FROM $tbl_document WHERE c_id = $course_id AND id = $document_id";
if ($document_id) {
$sql = "SELECT path FROM $tbl_document WHERE c_id = $course_id AND id = $document_id";
$rs = Database::query($sql);
$new_content = '';
$all_user_info = array();

Loading…
Cancel
Save