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


PHP completion_info::get_completion方法代码示例

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


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

示例1: get_content

 public function get_content()
 {
     global $CFG, $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     // Create empty content
     $this->content = new stdClass();
     // Can edit settings?
     $can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
     // Get course completion data
     $info = new completion_info($this->page->course);
     // Don't display if completion isn't enabled!
     if (!completion_info::is_enabled_for_site()) {
         if ($can_edit) {
             $this->content->text = get_string('completionnotenabledforsite', 'completion');
         }
         return $this->content;
     } else {
         if (!$info->is_enabled()) {
             if ($can_edit) {
                 $this->content->text = get_string('completionnotenabledforcourse', 'completion');
             }
             return $this->content;
         }
     }
     // Get this user's data
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         if ($can_edit) {
             $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         }
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         $this->content->text = get_string('coursealreadycompleted', 'completion');
         return $this->content;
         // Check if the user has already marked themselves as complete
     } else {
         if ($completion->is_complete()) {
             $this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
             return $this->content;
             // If user is not complete, or has not yet self completed
         } else {
             $this->content->text = '';
             $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">';
             $this->content->footer .= get_string('completecourse', 'block_selfcompletion') . '</a>...';
         }
     }
     return $this->content;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:59,代码来源:block_selfcompletion.php

示例2: get_content

 public function get_content()
 {
     global $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG;
     // Create empty content
     $this->content = new stdClass();
     // Don't display if completion isn't enabled!
     if (!$this->page->course->enablecompletion) {
         $this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Get course completion data
     $info = new completion_info($this->page->course);
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         return $this->content;
     }
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Check if the user has already marked themselves as complete
     if ($completion->is_complete()) {
         return $this->content;
     } else {
         $this->content->text = '';
         $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">' . get_string('completecourse', 'block_selfcompletion') . '</a>...';
     }
     return $this->content;
 }
开发者ID:nfreear,项目名称:moodle,代码行数:41,代码来源:block_selfcompletion.php


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