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


PHP rating_manager::get_component_ratings_since方法代码示例

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


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

示例1: course_check_module_updates_since

/**
 * Check module updates since a given time.
 * This function checks for updates in the module config, file areas, completion, grades, comments and ratings.
 *
 * @param  cm_info $cm        course module data
 * @param  int $from          the time to check
 * @param  array $fileareas   additional file ares to check
 * @param  array $filter      if we need to filter and return only selected updates
 * @return stdClass object with the different updates
 * @since  Moodle 3.2
 */
function course_check_module_updates_since($cm, $from, $fileareas = array(), $filter = array())
{
    global $DB, $CFG, $USER;
    $context = $cm->context;
    $mod = $DB->get_record($cm->modname, array('id' => $cm->instance), '*', MUST_EXIST);
    $updates = new stdClass();
    $course = get_course($cm->course);
    $component = 'mod_' . $cm->modname;
    // Check changes in the module configuration.
    if (isset($mod->timemodified) and (empty($filter) or in_array('configuration', $filter))) {
        $updates->configuration = (object) array('updated' => false);
        if ($updates->configuration->updated = $mod->timemodified > $from) {
            $updates->configuration->timeupdated = $mod->timemodified;
        }
    }
    // Check for updates in files.
    if (plugin_supports('mod', $cm->modname, FEATURE_MOD_INTRO)) {
        $fileareas[] = 'intro';
    }
    if (!empty($fileareas) and (empty($filter) or in_array('fileareas', $filter))) {
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, $component, $fileareas, false, "filearea, timemodified DESC", false, $from);
        foreach ($fileareas as $filearea) {
            $updates->{$filearea . 'files'} = (object) array('updated' => false);
        }
        foreach ($files as $file) {
            $updates->{$file->get_filearea() . 'files'}->updated = true;
            $updates->{$file->get_filearea() . 'files'}->itemids[] = $file->get_id();
        }
    }
    // Check completion.
    $supportcompletion = plugin_supports('mod', $cm->modname, FEATURE_COMPLETION_HAS_RULES);
    $supportcompletion = $supportcompletion or plugin_supports('mod', $cm->modname, FEATURE_COMPLETION_TRACKS_VIEWS);
    if ($supportcompletion and (empty($filter) or in_array('completion', $filter))) {
        $updates->completion = (object) array('updated' => false);
        $completion = new completion_info($course);
        // Use wholecourse to cache all the modules the first time.
        $completiondata = $completion->get_data($cm, true);
        if ($updates->completion->updated = !empty($completiondata->timemodified) && $completiondata->timemodified > $from) {
            $updates->completion->timemodified = $completiondata->timemodified;
        }
    }
    // Check grades.
    $supportgrades = plugin_supports('mod', $cm->modname, FEATURE_GRADE_HAS_GRADE);
    $supportgrades = $supportgrades or plugin_supports('mod', $cm->modname, FEATURE_GRADE_OUTCOMES);
    if ($supportgrades and (empty($filter) or (in_array('gradeitems', $filter) or in_array('outcomes', $filter)))) {
        require_once $CFG->libdir . '/gradelib.php';
        $grades = grade_get_grades($course->id, 'mod', $cm->modname, $mod->id, $USER->id);
        if (empty($filter) or in_array('gradeitems', $filter)) {
            $updates->gradeitems = (object) array('updated' => false);
            foreach ($grades->items as $gradeitem) {
                foreach ($gradeitem->grades as $grade) {
                    if ($grade->datesubmitted > $from or $grade->dategraded > $from) {
                        $updates->gradeitems->updated = true;
                        $updates->gradeitems->itemids[] = $gradeitem->id;
                    }
                }
            }
        }
        if (empty($filter) or in_array('outcomes', $filter)) {
            $updates->outcomes = (object) array('updated' => false);
            foreach ($grades->outcomes as $outcome) {
                foreach ($outcome->grades as $grade) {
                    if ($grade->datesubmitted > $from or $grade->dategraded > $from) {
                        $updates->outcomes->updated = true;
                        $updates->outcomes->itemids[] = $outcome->id;
                    }
                }
            }
        }
    }
    // Check comments.
    if (plugin_supports('mod', $cm->modname, FEATURE_COMMENT) and (empty($filter) or in_array('comments', $filter))) {
        $updates->comments = (object) array('updated' => false);
        require_once $CFG->dirroot . '/comment/lib.php';
        require_once $CFG->dirroot . '/comment/locallib.php';
        $manager = new comment_manager();
        $comments = $manager->get_component_comments_since($course, $context, $component, $from, $cm);
        if (!empty($comments)) {
            $updates->comments->updated = true;
            $updates->comments->itemids = array_keys($comments);
        }
    }
    // Check ratings.
    if (plugin_supports('mod', $cm->modname, FEATURE_RATE) and (empty($filter) or in_array('ratings', $filter))) {
        $updates->ratings = (object) array('updated' => false);
        require_once $CFG->dirroot . '/rating/lib.php';
        $manager = new rating_manager();
        $ratings = $manager->get_component_ratings_since($context, $component, $from);
//.........这里部分代码省略.........
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:101,代码来源:lib.php


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