本文整理汇总了PHP中GradebookUtils::get_user_certificate_content方法的典型用法代码示例。如果您正苦于以下问题:PHP GradebookUtils::get_user_certificate_content方法的具体用法?PHP GradebookUtils::get_user_certificate_content怎么用?PHP GradebookUtils::get_user_certificate_content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GradebookUtils
的用法示例。
在下文中一共展示了GradebookUtils::get_user_certificate_content方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generates an HTML Certificate and fills the path_certificate field in the DB
**/
public function generate($params = array())
{
// The user directory should be set
if (empty($this->certification_user_path) && $this->force_certificate_generation == false) {
return false;
}
$params['hide_print_button'] = isset($params['hide_print_button']) ? true : false;
$my_category = Category::load($this->certificate_data['cat_id']);
if (isset($my_category[0]) && $my_category[0]->is_certificate_available($this->user_id)) {
$user = api_get_user_info($this->user_id);
$scoredisplay = ScoreDisplay::instance();
$scorecourse = $my_category[0]->calc_score($this->user_id);
$scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable');
// Prepare all necessary variables:
$organization_name = api_get_setting('platform.institution');
//$portal_name = api_get_setting('platform.site_name');
$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);
//If the gradebook is related to skills we added the skills to the user
$courseId = api_get_real_course_id();
$sessionId = api_get_session_id();
$skill = new Skill();
$skill->add_skill_to_user($this->user_id, $this->certificate_data['cat_id'], $courseId, $sessionId);
if (is_dir($this->certification_user_path)) {
if (!empty($this->certificate_data)) {
$new_content_html = GradebookUtils::get_user_certificate_content($this->user_id, $my_category[0]->get_course_code(), $my_category[0]->get_session_id(), false, $params['hide_print_button']);
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);
if (file_exists($my_path_certificate) && !empty($name) && !is_dir($my_path_certificate) && $this->force_certificate_generation == false) {
//Seems that the file was already generated
return true;
} else {
// Creating new name
$name = md5($this->user_id . $this->certificate_data['cat_id']) . '.html';
$my_path_certificate = $this->certification_user_path . $name;
$path_certificate = '/' . $name;
//Getting QR filename
$file_info = pathinfo($path_certificate);
$qr_code_filename = $this->certification_user_path . $file_info['filename'] . '_qr.png';
$my_new_content_html = 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 = 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) {
//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;
if ($this->html_file_is_generated()) {
if (!empty($file_info)) {
$text = $this->parse_certificate_variables($new_content_html['variables']);
$this->generate_qr($text, $qr_code_filename);
}
}
}
return $result;
}
}
}
}
}
return false;
}