当前位置: 首页>>代码示例>>PHP>>正文


PHP Skill::add_skill_to_user方法代码示例

本文整理汇总了PHP中Skill::add_skill_to_user方法的典型用法代码示例。如果您正苦于以下问题:PHP Skill::add_skill_to_user方法的具体用法?PHP Skill::add_skill_to_user怎么用?PHP Skill::add_skill_to_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Skill的用法示例。


在下文中一共展示了Skill::add_skill_to_user方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
     }
     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';
     $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('Institution');
         //$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);
         //If the gradebook is related to skills we added the skills to the user
         $skill = new Skill();
         $skill->add_skill_to_user($this->user_id, $this->certificate_data['cat_id']);
         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, $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;
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:69,代码来源:certificate.lib.php

示例2: register_user_certificate

 /**
  * @param int $category_id
  * @param int $user_id
  * @return bool|string
  */
 public static function register_user_certificate($category_id, $user_id)
 {
     $courseId = api_get_course_int_id();
     $courseCode = api_get_course_id();
     $sessionId = api_get_session_id();
     // Generating the total score for a course
     $cats_course = Category::load($category_id, null, null, null, null, $sessionId, false);
     /** @var Category $category */
     $category = $cats_course[0];
     //@todo move these in a function
     $sum_categories_weight_array = array();
     if (isset($cats_course) && !empty($cats_course)) {
         $categories = Category::load(null, null, null, $category_id);
         if (!empty($categories)) {
             foreach ($categories as $subCategory) {
                 $sum_categories_weight_array[$subCategory->get_id()] = $subCategory->get_weight();
             }
         } else {
             $sum_categories_weight_array[$category_id] = $cats_course[0]->get_weight();
         }
     }
     $main_weight = $cats_course[0]->get_weight();
     $cattotal = Category::load($category_id);
     $scoretotal = $cattotal[0]->calc_score($user_id);
     // Do not remove this the gradebook/lib/fe/gradebooktable.class.php
     // file load this variable as a global
     $scoredisplay = ScoreDisplay::instance();
     $my_score_in_gradebook = $scoredisplay->display_score($scoretotal, SCORE_SIMPLE);
     // A student always sees only the teacher's repartition
     $scoretotal_display = $scoredisplay->display_score($scoretotal, SCORE_DIV_PERCENT);
     if (!self::userFinishedCourse($user_id, $cats_course[0], 0, $courseCode, $sessionId, true)) {
         return false;
     }
     $skillToolEnabled = api_get_setting('skill.allow_skills_tool') == 'true';
     $userHasSkills = false;
     if ($skillToolEnabled) {
         if (!$category->getGenerateCertificates()) {
             $skill = new Skill();
             $skill->add_skill_to_user($user_id, $category_id, $courseId, $sessionId);
         }
         $objSkillRelUser = new SkillRelUser();
         $userSkills = $objSkillRelUser->get_user_skills($user_id, $courseId, $sessionId);
         $userHasSkills = !empty($userSkills);
         if (!$category->getGenerateCertificates() && $userHasSkills) {
             return ['badge_link' => Display::url(get_lang('DownloadBadges'), api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user={$user_id}", array('target' => '_blank', 'class' => 'btn btn-default'))];
         }
     }
     $my_certificate = GradebookUtils::get_certificate_by_user_id($cats_course[0]->get_id(), $user_id);
     if (empty($my_certificate)) {
         GradebookUtils::register_user_info_about_certificate($category_id, $user_id, $my_score_in_gradebook, api_get_utc_datetime());
         $my_certificate = GradebookUtils::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();
         if (!empty($fileWasGenerated)) {
             $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $my_certificate['id'];
             $certificates = Display::url(Display::returnFontAwesomeIcon('download') . ' ' . get_lang('DownloadCertificate'), $url, array('target' => '_blank', 'class' => 'btn btn-sm btn-primary'));
             $exportToPDF = Display::url(Display::return_icon('pdf.png', get_lang('ExportToPDF'), array(), ICON_SIZE_MEDIUM), "{$url}&action=export");
             $hideExportLink = api_get_setting('hide_certificate_export_link');
             $hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
             if ($hideExportLink === 'true' || api_is_student() && $hideExportLinkStudent === 'true') {
                 $exportToPDF = null;
             }
             $html = array('certificate_link' => $certificates, 'pdf_link' => $exportToPDF, 'pdf_url' => "{$url}&action=export");
             if ($skillToolEnabled && $userHasSkills) {
                 $html['badge_link'] = Display::url(get_lang('DownloadBadges'), api_get_path(WEB_CODE_PATH) . "gradebook/get_badges.php?user={$user_id}", array('target' => '_blank', 'class' => 'btn btn-default'));
             }
         }
         return $html;
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:78,代码来源:category.class.php


注:本文中的Skill::add_skill_to_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。