Minor corrections in the certificate

skala
Julio Montoya 14 years ago
parent 6093f148b0
commit d157f55f56
  1. 7
      certificates/index.php
  2. 10
      main/gradebook/gradebook_display_certificate.php
  3. 17
      main/inc/lib/certificate.lib.php
  4. 13
      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 '../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'certificate.lib.php'; require_once api_get_path(LIBRARY_PATH).'certificate.lib.php';
/**
* Retrieve certificate
*/
$certificate = new Certificate($_GET['id']); $certificate = new Certificate($_GET['id']);
/** //Show certificate HTML
* Show results
*/
$certificate->show(); $certificate->show();

@ -58,7 +58,6 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
//@todo replace all this code with something like get_total_weight() //@todo replace all this code with something like get_total_weight()
$cats = Category :: load ($cat_id, null, null, null, null, null, false); $cats = Category :: load ($cat_id, null, null, null, null, null, false);
if (!empty($cats)) { if (!empty($cats)) {
//with this fix the teacher only can view 1 gradebook //with this fix the teacher only can view 1 gradebook
@ -99,14 +98,14 @@ 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) { if (count($certificate_list)==0) {
echo Display::display_warning_message(get_lang('NoResultsAvailable')); echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else { } else {
foreach ($certificate_list as $index=>$value) { foreach ($certificate_list as $index=>$value) {
?> ?>
<tr> <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> </td>
</tr> </tr>
<tr> <tr>
@ -114,7 +113,7 @@ echo Display::tag('h3', get_lang('GradebookListOfStudentsCertificates'));
<table class="data_table" width="100%" > <table class="data_table" width="100%" >
<?php <?php
$list_certificate = get_list_gradebook_certificates_by_user_id ($value['user_id'], $cat_id); $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 > <tr >
<td width="50%"><?php echo get_lang('Score').' : '.$value_certificate['score_certificate'] ?></td> <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; 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'] ?>"> <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> </td>
</tr> </tr>
<?php <?php

@ -23,7 +23,8 @@ class Certificate extends Model {
var $user_id; var $user_id;
//If true every time we enter to the certificate URL we would generate a new certificate //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) { public function __construct($certificate_id = null) {
$this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $this->table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
@ -126,7 +127,6 @@ class Certificate extends Model {
if (empty($this->certification_user_path) && $this->force_certificate_generation == false) { if (empty($this->certification_user_path) && $this->force_certificate_generation == false) {
return 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/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/gradebook_functions.inc.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php'; require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/scoredisplay.class.php';
@ -140,13 +140,13 @@ class Certificate extends Model {
$scorecourse = $my_category[0]->calc_score($this->user_id); $scorecourse = $my_category[0]->calc_score($this->user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
$cattotal = Category :: load($this->certificate_data['cat_id']); //$cattotal = Category :: load($this->certificate_data['cat_id']);
$scoretotal= $cattotal[0]->calc_score($this->user_id); //$scoretotal= $cattotal[0]->calc_score($this->user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); //$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//Prepare all necessary variables: //Prepare all necessary variables:
$organization_name = api_get_setting('Institution'); $organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName'); //$portal_name = api_get_setting('siteName');
$stud_fn = $user['firstname']; $stud_fn = $user['firstname'];
$stud_ln = $user['lastname']; $stud_ln = $user['lastname'];
@ -154,7 +154,7 @@ class Certificate extends Model {
$certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn.' '.$stud_ln, $my_category[0]->get_name(), $scorecourse_display); $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); $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 //If the gradebook is related to skills we added the skills to the user
@ -180,6 +180,7 @@ class Certificate extends Model {
//Getting QR filename //Getting QR filename
$file_info = pathinfo($path_certificate); $file_info = pathinfo($path_certificate);
$qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png'; $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']); $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']; $my_new_content_html = $new_content_html['content'];
@ -188,7 +189,6 @@ class Certificate extends Model {
$result = @file_put_contents($my_path_certificate, $my_new_content_html); $result = @file_put_contents($my_path_certificate, $my_new_content_html);
if ($result) { if ($result) {
//Updating the path //Updating the path
self::update_user_info_about_certificate($this->certificate_data['cat_id'], $this->user_id, $path_certificate); self::update_user_info_about_certificate($this->certificate_data['cat_id'], $this->user_id, $path_certificate);
$this->certificate_data['path_certificate'] = $path_certificate; $this->certificate_data['path_certificate'] = $path_certificate;
@ -315,5 +315,4 @@ class Certificate extends Model {
} }
exit; exit;
} }
} }

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

Loading…
Cancel
Save