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


PHP GradebookUtils::get_certificate_by_user_id方法代码示例

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


在下文中一共展示了GradebookUtils::get_certificate_by_user_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUserCertificatesInSessions

 /**
  * Get the achieved certificates for a user in course sessions
  * @param int $userId The user id
  * @param type $includeNonPublicCertificates Whether include the non-plublic certificates
  * @return array
  */
 public static function getUserCertificatesInSessions($userId, $includeNonPublicCertificates = true)
 {
     $userId = intval($userId);
     $sessionList = [];
     $sessions = SessionManager::get_sessions_by_user($userId);
     foreach ($sessions as $session) {
         if (empty($session['courses'])) {
             continue;
         }
         $sessionCourses = SessionManager::get_course_list_by_session_id($session['session_id']);
         foreach ($sessionCourses as $course) {
             if (!$includeNonPublicCertificates) {
                 $allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']);
                 if (empty($allowPublicCertificates)) {
                     continue;
                 }
             }
             $courseGradebookCategory = Category::load(null, null, $course['code'], null, null, $session['session_id']);
             if (empty($courseGradebookCategory)) {
                 continue;
             }
             $courseGradebookId = $courseGradebookCategory[0]->get_id();
             $certificateInfo = GradebookUtils::get_certificate_by_user_id($courseGradebookId, $userId);
             if (empty($certificateInfo)) {
                 continue;
             }
             $sessionList[] = ['session' => $session['session_name'], 'course' => $course['title'], 'score' => $certificateInfo['score_certificate'], 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}"];
         }
     }
     return $sessionList;
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:37,代码来源:GradebookUtils.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


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