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


PHP completion_info::is_enabled方法代码示例

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


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

示例1: test_is_enabled

    function test_is_enabled() {
        global $CFG;

        // Config alone
        $CFG->enablecompletion = COMPLETION_DISABLED;
        $this->assertEquals(COMPLETION_DISABLED, completion_info::is_enabled_for_site());
        $CFG->enablecompletion = COMPLETION_ENABLED;
        $this->assertEquals(COMPLETION_ENABLED, completion_info::is_enabled_for_site());

        // Course
        $course = (object)array('id' =>13);
        $c = new completion_info($course);
        $course->enablecompletion = COMPLETION_DISABLED;
        $this->assertEquals(COMPLETION_DISABLED, $c->is_enabled());
        $course->enablecompletion = COMPLETION_ENABLED;
        $this->assertEquals(COMPLETION_ENABLED, $c->is_enabled());
        $CFG->enablecompletion = COMPLETION_DISABLED;
        $this->assertEquals(COMPLETION_DISABLED, $c->is_enabled());

        // Course and CM
        $cm = new stdClass();
        $cm->completion = COMPLETION_TRACKING_MANUAL;
        $this->assertEquals(COMPLETION_DISABLED, $c->is_enabled($cm));
        $CFG->enablecompletion = COMPLETION_ENABLED;
        $course->enablecompletion = COMPLETION_DISABLED;
        $this->assertEquals(COMPLETION_DISABLED, $c->is_enabled($cm));
        $course->enablecompletion = COMPLETION_ENABLED;
        $this->assertEquals(COMPLETION_TRACKING_MANUAL, $c->is_enabled($cm));
        $cm->completion = COMPLETION_TRACKING_NONE;
        $this->assertEquals(COMPLETION_TRACKING_NONE, $c->is_enabled($cm));
        $cm->completion = COMPLETION_TRACKING_AUTOMATIC;
        $this->assertEquals(COMPLETION_TRACKING_AUTOMATIC, $c->is_enabled($cm));
    }
开发者ID:nigeli,项目名称:moodle,代码行数:33,代码来源:completionlib_test.php

示例2: execute

 public function execute()
 {
     global $DB, $CFG;
     $result = $DB->get_records_sql('SELECT ba.id, ba.bookingid, ba.optionid, ba.userid, b.course
         FROM {booking_answers} AS ba
         LEFT JOIN {booking_options} AS bo 
         ON bo.id = ba.optionid
         LEFT JOIN {booking} AS b
         ON b.id = bo.bookingid
         WHERE bo.removeafterminutes > 0
         AND ba.completed = 1
         AND IF(ba.timemodified < (UNIX_TIMESTAMP() - (bo.removeafterminutes*60)), 1, 0) = 1;');
     require_once $CFG->libdir . '/completionlib.php';
     foreach ($result as $value) {
         $course = $DB->get_record('course', array('id' => $value->course));
         $completion = new \completion_info($course);
         $cm = get_coursemodule_from_instance('booking', $value->bookingid);
         $userData = $DB->get_record('booking_answers', array('id' => $value->id));
         $booking = $DB->get_record('booking', array('id' => $value->bookingid));
         $userData->completed = '0';
         $userData->timemodified = time();
         $DB->update_record('booking_answers', $userData);
         if ($completion->is_enabled($cm) && $booking->enablecompletion) {
             $completion->update_state($cm, COMPLETION_INCOMPLETE, $userData->userid);
         }
     }
 }
开发者ID:375michael40veit,项目名称:moodle-mod_booking,代码行数:27,代码来源:remove_activity_completion.php

示例3: navbuttons_activity_showbuttons

/**
 * Check if an activity is configured to only show navbuttons when
 * complete and then check if the activity is complete
 * @param cm_info $cm the course module for the activity
 * @return boolean true if the navbuttons should be shown
 */
function navbuttons_activity_showbuttons($cm)
{
    $modname = $cm->modname;
    $show = get_config('block_navbuttons', 'activity' . $modname);
    if ($show === false || $show == NAVBUTTONS_ACTIVITY_ALWAYS) {
        return true;
        // No config or 'always show'
    }
    if ($show == NAVBUTTONS_ACTIVITY_NEVER) {
        return false;
    }
    if ($show == NAVBUTTONS_ACTIVITY_COMPLETE) {
        $completion = new completion_info($cm->get_course());
        if (!$completion->is_enabled($cm)) {
            return true;
            // No completion tracking - show the buttons
        }
        $cmcompletion = $completion->get_data($cm);
        if ($cmcompletion->completionstate == COMPLETION_INCOMPLETE) {
            return false;
        }
        return true;
    }
    if (!isloggedin() || isguestuser()) {
        return true;
        // Always show the buttons if not logged in
    }
    // NAVBUTTONS_ACTIVITY_CUSTOM
    $funcname = 'navbuttons_mod_' . $modname . '_showbuttons';
    if (!function_exists($funcname)) {
        return true;
        // Shouldn't have got to here, but allow the buttons anyway
    }
    return $funcname($cm);
}
开发者ID:kbwebsolutions,项目名称:moodle-navbuttons,代码行数:41,代码来源:activityready.php

示例4: toc_progress

 /**
  * toc progress percentage
  * @param stdClass $section
  * @param stdClass $course
  * @param boolean $perc - display as a percentage if true
  * @return string
  *
  * @Author Guy Thomas
  * @Date 2014-05-23
  */
 protected function toc_progress($section, $course, $perc = false)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/completionlib.php';
     $completioninfo = new completion_info($course);
     if (!$completioninfo->is_enabled()) {
         return '';
         // Completion tracking not enabled.
     }
     $sac = snap_shared::section_activity_summary($section, $course, null);
     if (!empty($sac->progress)) {
         if ($perc) {
             $percentage = $sac->progress->percentage != null ? round($sac->progress->percentage, 0) . '%' : '';
             return '<span class="completionstatus percentage">' . $percentage . '</span>';
         } else {
             if ($sac->progress->total > 0) {
                 $progress = get_string('progresstotal', 'completion', $sac->progress);
                 $completed = '';
                 if ($sac->progress->complete === $sac->progress->total) {
                     $winbadge = $OUTPUT->pix_url('i/completion-manual-y');
                     $completedstr = s(get_string('completed', 'completion'));
                     $completed = "<img class=snap-section-complete src='{$winbadge}' alt='{$completedstr}' />";
                 }
                 $printprogress = "<span class='completionstatus outoftotal'>{$completed} {$progress}</span>";
                 return $printprogress;
             } else {
                 return '';
             }
         }
     }
 }
开发者ID:nadavkav,项目名称:moodle-theme_snap,代码行数:41,代码来源:toc_renderer.php

示例5: section_activity_summary

 /**
  * Taken from /format/renderer.php
  * Generate a summary of the activites in a section
  *
  * @param stdClass $section The course_section entry from DB
  * @param stdClass $course the course record from DB
  * @param array    $mods (argument not used)
  * @return string HTML to output.
  */
 public static function section_activity_summary($section, $course, $mods)
 {
     global $CFG;
     require_once $CFG->libdir . '/completionlib.php';
     $modinfo = get_fast_modinfo($course);
     if (empty($modinfo->sections[$section->section])) {
         return '';
     }
     // Generate array with count of activities in this section.
     $sectionmods = array();
     $total = 0;
     $complete = 0;
     $cancomplete = isloggedin() && !isguestuser();
     $completioninfo = new completion_info($course);
     foreach ($modinfo->sections[$section->section] as $cmid) {
         $thismod = $modinfo->cms[$cmid];
         if ($thismod->uservisible) {
             if (isset($sectionmods[$thismod->modname])) {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modplural;
                 $sectionmods[$thismod->modname]['count']++;
             } else {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
                 $sectionmods[$thismod->modname]['count'] = 1;
             }
             if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                 $total++;
                 $completiondata = $completioninfo->get_data($thismod, true);
                 if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
                     $complete++;
                 }
             }
         }
     }
     if (empty($sectionmods)) {
         // No sections.
         return '';
     }
     // Output section activities summary.
     $o = '';
     $o .= "<div class='section-summary-activities mdl-right'>";
     foreach ($sectionmods as $mod) {
         $o .= "<span class='activity-count'>";
         $o .= $mod['name'] . ': ' . $mod['count'];
         $o .= "</span>";
     }
     $o .= "</div>";
     $a = false;
     // Output section completion data.
     if ($total > 0) {
         $a = new stdClass();
         $a->complete = $complete;
         $a->total = $total;
         $a->percentage = $complete / $total * 100;
         $o .= "<div class='section-summary-activities mdl-right'>";
         $o .= "<span class='activity-count'>" . get_string('progresstotal', 'completion', $a) . "</span>";
         $o .= "</div>";
     }
     $retobj = (object) array('output' => $o, 'progress' => $a, 'complete' => $complete, 'total' => $total);
     return $retobj;
 }
开发者ID:nbartley,项目名称:moodle-theme_snap,代码行数:69,代码来源:snap_shared.php

示例6: update_activity_completion_status_manually

 /**
  * Update completion status for the current user in an activity, only for activities with manual tracking.
  * @param  int $cmid      Course module id
  * @param  bool $completed Activity completed or not
  * @return array            Result and possible warnings
  * @since Moodle 2.9
  * @throws moodle_exception
  */
 public static function update_activity_completion_status_manually($cmid, $completed)
 {
     // Validate and normalize parameters.
     $params = self::validate_parameters(self::update_activity_completion_status_manually_parameters(), array('cmid' => $cmid, 'completed' => $completed));
     $cmid = $params['cmid'];
     $completed = $params['completed'];
     $warnings = array();
     $context = context_module::instance($cmid);
     self::validate_context($context);
     list($course, $cm) = get_course_and_cm_from_cmid($cmid);
     // Set up completion object and check it is enabled.
     $completion = new completion_info($course);
     if (!$completion->is_enabled()) {
         throw new moodle_exception('completionnotenabled', 'completion');
     }
     // Check completion state is manual.
     if ($cm->completion != COMPLETION_TRACKING_MANUAL) {
         throw new moodle_exception('cannotmanualctrack', 'error');
     }
     $targetstate = $completed ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
     $completion->update_state($cm, $targetstate);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:34,代码来源:external.php

示例7: 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

示例8: completion_report_extend_navigation

/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function completion_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    if (has_capability('coursereport/completion:view', $context)) {
        $completion = new completion_info($course);
        if ($completion->is_enabled() && $completion->has_criteria()) {
            $url = new moodle_url('/course/report/completion/index.php', array('course' => $course->id));
            $navigation->add(get_string('pluginname', 'coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
        }
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:18,代码来源:lib.php

示例9: allow_add

 protected function allow_add($course, \cm_info $cm = null, \section_info $section = null)
 {
     global $CFG;
     // Check if completion is enabled for the course.
     require_once $CFG->libdir . '/completionlib.php';
     $info = new \completion_info($course);
     if (!$info->is_enabled()) {
         return false;
     }
     // Check if there's at least one other module with completion info.
     $params = $this->get_javascript_init_params($course, $cm, $section);
     return (array) $params[0] != false;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:frontend.php

示例10: course_completion_gauge

 public function course_completion_gauge(&$course, $div, $width = 160, $height = 160, $type = 'progressbar')
 {
     global $USER, $PAGE;
     $str = '';
     $completion = new completion_info($course);
     if ($completion->is_enabled(null)) {
         $alltracked = count($completion->get_activities());
         $progressinfo = $completion->get_progress_all('u.id = :userid', array('userid' => $USER->id));
         $completed = 0;
         if (!empty($progressinfo)) {
             if (!empty($progressinfo[$USER->id]->progress)) {
                 foreach ($progressinfo[$USER->id]->progress as $progressrecord) {
                     if ($progressrecord->completionstate) {
                         $completed++;
                     }
                 }
             }
         }
         $ratio = $alltracked == 0 ? 0 : round($completed / $alltracked * 100);
         $jqwrenderer = $PAGE->get_renderer('local_vflibs');
         if ($div == 'div') {
             $str .= '<div class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
         } else {
             $str .= '<td class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
         }
         if ($type == 'gauge') {
             $properties = array('width' => $width, 'height' => $height, 'max' => 100, 'crop' => 120);
             $str .= $jqwrenderer->jqw_bargauge_simple('completion-jqw-' . $course->id, array($ratio), $properties);
         } else {
             $properties = array('width' => $width, 'height' => $height, 'animation' => 300, 'template' => 'success');
             $str .= $jqwrenderer->jqw_progress_bar('completion-jqw-' . $course->id, $ratio, $properties);
         }
         if ($div == 'div') {
             $str .= '</div>';
         } else {
             $str .= '</td>';
         }
     } else {
         if ($div == 'div') {
             $str .= '<div class="course-completion">';
         } else {
             $str .= '<td class="course-completion">';
         }
         if ($div == 'div') {
             $str .= '</div>';
         } else {
             $str .= '</td>';
         }
     }
     return $str;
 }
开发者ID:vfremaux,项目名称:moodle-local_my,代码行数:51,代码来源:renderer.php

示例11: progress_report_extend_navigation

/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function progress_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    $showonnavigation = has_capability('coursereport/progress:view', $context);
    $group = groups_get_course_group($course, true);
    // Supposed to verify group
    if ($group === 0 && $course->groupmode == SEPARATEGROUPS) {
        $showonnavigation = $showonnavigation && has_capability('moodle/site:accessallgroups', $context);
    }
    $completion = new completion_info($course);
    $showonnavigation = $showonnavigation && $completion->is_enabled() && count($completion->get_activities()) > 0;
    if ($showonnavigation) {
        $url = new moodle_url('/course/report/progress/index.php', array('course' => $course->id));
        $navigation->add(get_string('pluginname', 'coursereport_progress'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:23,代码来源:lib.php

示例12: mod_stopwatch_update_timer

/**
 *
 * @param cm_info $cm
 * @param stdClass $stopwatch
 * @param int $duration
 */
function mod_stopwatch_update_timer(cm_info $cm, $stopwatch, $duration)
{
    global $USER, $DB, $CFG;
    require_once $CFG->libdir . '/completionlib.php';
    $record = $DB->get_record('stopwatch_user', array('stopwatchid' => $cm->instance, 'courseid' => $cm->course, 'userid' => $USER->id));
    if ($record) {
        $data = array('id' => $record->id, 'timemodified' => time(), 'duration' => $duration);
        $DB->update_record('stopwatch_user', $data);
    } else {
        $data = array('courseid' => $cm->course, 'stopwatchid' => $cm->instance, 'userid' => $USER->id, 'timecreated' => time(), 'timemodified' => time(), 'duration' => $duration);
        $DB->insert_record('stopwatch_user', $data);
    }
    // Update completion state
    $completion = new completion_info($cm->get_course());
    if ($completion->is_enabled($cm) && $stopwatch->completiontimed) {
        $completion->update_state($cm, COMPLETION_COMPLETE);
    }
}
开发者ID:marinaglancy,项目名称:moodle-mod_stopwatch,代码行数:24,代码来源:locallib.php

示例13: update_require_specific_grade

 /**
  * Updates activity completion status.
  *
  * @return void
  */
 public static function update_require_specific_grade(\core\event\base $event)
 {
     global $DB;
     $entryuserid = $event->relateduserid;
     $giid = $event->other['itemid'];
     if (!($gitem = \grade_item::fetch(array('id' => $giid, 'itemmodule' => 'dataform')))) {
         return;
     }
     $dataformid = $gitem->iteminstance;
     $df = \mod_dataform_dataform::instance($dataformid);
     // Currently only completion by require entries.
     if ($df->completionspecificgrade) {
         $completion = new \completion_info($df->course);
         if ($completion->is_enabled($df->cm) != COMPLETION_TRACKING_AUTOMATIC) {
             return;
         }
         $completion->update_state($df->cm, COMPLETION_UNKNOWN, $entryuserid);
     }
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:24,代码来源:completion.php

示例14: get_activity_tree

/**
 * get_activity_tree :: course_modinfo -> integer -> context -> array
 * @param \course_modinfo $modinfo
 * @param integer $section_number
 * @param \context $context
 * @return array
 */
function get_activity_tree(\course_modinfo $modinfo, $section_number, \context $context)
{
    $completion_info = new \completion_info($modinfo->get_course());
    return F\map(F\filter($modinfo->get_section_info_all(), function (\section_info $section_info) {
        return $section_info->visible;
    }), function (\section_info $section_info) use($completion_info, $section_number, $context) {
        $mods = F\map(F\filter($section_info->modinfo->cms, function (\cm_info $cm_info) use($section_info) {
            global $CFG;
            return ($cm_info->uservisible || $CFG->enableavailability && !empty($cm_info->availableinfo)) && (int) $cm_info->sectionnum === (int) $section_info->section;
        }), function (\cm_info $cm_info) use($completion_info, $context) {
            global $CFG;
            $canComplete = $CFG->enablecompletion && isloggedin() && !isguestuser() && (int) $completion_info->is_enabled($cm_info) === COMPLETION_TRACKING_MANUAL;
            $hasCompleted = false;
            if ($canComplete) {
                $completion_data = $completion_info->get_data($cm_info, true);
                $hasCompleted = F\contains([COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS], (int) $completion_data->completionstate);
            }
            return (object) ['id' => (int) $cm_info->id, 'name' => $cm_info->name, 'modname' => $cm_info->modname, 'current' => is_current_mod($cm_info, $context), 'available' => $cm_info->available, 'canComplete' => $canComplete, 'hasCompleted' => $hasCompleted];
        });
        return (object) ['id' => (int) $section_info->id, 'section' => (int) $section_info->section, 'name' => \get_section_name($section_info->modinfo->courseid, $section_info->section), 'current' => is_current_section($section_info, $section_number, $context), 'activities' => array_values($mods)];
    });
}
开发者ID:robologo3000,项目名称:block-activity-tree,代码行数:29,代码来源:lib.php

示例15: __construct

 /**
  * Set properties from course and section.
  * @param \stdClass $course
  * @param \stdClass $section
  */
 public function __construct($course, $section)
 {
     global $OUTPUT;
     static $compinfos = [];
     if (isset($compinfos[$course->id])) {
         $completioninfo = $compinfos[$course->id];
     } else {
         $completioninfo = new \completion_info($course);
         $compinfos[$course->id] = $completioninfo;
     }
     if (!$completioninfo->is_enabled()) {
         return '';
         // Completion tracking not enabled.
     }
     $sac = shared::section_activity_summary($section, $course, null);
     if (empty($sac->progress)) {
         return;
     }
     $this->progress = (object) ['complete' => $sac->progress->complete, 'total' => $sac->progress->total];
     $this->pixcompleted = $OUTPUT->pix_url('i/completion-manual-y');
     $this->completed = $sac->progress->complete === $sac->progress->total;
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:27,代码来源:course_toc_progress.php


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