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


PHP completion_info::aggregate_completion_states方法代码示例

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


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

示例1: facetoface_get_completion_state

/**
 * Obtains the automatic completion state for this face to face activity based on any conditions
 * in face to face settings.
 *
 * @param object $course Course
 * @param object $cm Course-module
 * @param int $userid User ID
 * @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
 * @return bool True if completed, false if not. (If no conditions, then return
 *   value depends on comparison type)
 */
function facetoface_get_completion_state($course, $cm, $userid, $type) {
    global $DB;

    $result = $type;

    // Get face to face.
    if (!$facetoface = $DB->get_record('facetoface', array('id' => $cm->instance))) {
        print_error('cannotfindfacetoface');
    }

    // Only check for existence of tracks and return false if completionstatusrequired.
    // This means that if only view is required we don't end up with a false state.
    if ($facetoface->completionstatusrequired) {
        $completionstatusrequired = json_decode($facetoface->completionstatusrequired, true);
        if (empty($completionstatusrequired)) {
            return $result;
        }
        list($insql, $inparams) = $DB->get_in_or_equal(array_keys($completionstatusrequired));

        // Get user's face to face status.
        $sql = "SELECT f2fss.id AS signupstatusid, f2fss.statuscode, f2fsd.timefinish
                FROM {facetoface_sessions} f2fses
                LEFT JOIN {facetoface_signups} f2fs ON (f2fs.sessionid = f2fses.id)
                LEFT JOIN {facetoface_signups_status} f2fss ON (f2fss.signupid = f2fs.id)
                LEFT JOIN {facetoface_sessions_dates} f2fsd ON (f2fsd.sessionid = f2fses.id)
                WHERE f2fses.facetoface = ? AND f2fs.userid = ?
                  AND f2fss.statuscode $insql
                ORDER BY f2fsd.timefinish";
        $params = array_merge(array($facetoface->id, $userid), $inparams);
        $status = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE);
        if ($status) {
            // Tell completion_criteria_activity::review exact time of completion, otherwise it will use time of review run.
            $cm->timecompleted = $status->timefinish;
            return completion_info::aggregate_completion_states($type, $result, true);
        }
        return completion_info::aggregate_completion_states($type, $result, false);
    }
    return $result;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:50,代码来源:lib.php

示例2: scorm_get_completion_state

/**
 * Obtains the automatic completion state for this scorm based on any conditions
 * in scorm settings.
 *
 * @param object $course Course
 * @param object $cm Course-module
 * @param int $userid User ID
 * @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
 * @return bool True if completed, false if not. (If no conditions, then return
 *   value depends on comparison type)
 */
function scorm_get_completion_state($course, $cm, $userid, $type)
{
    global $DB;
    $result = $type;
    // Get scorm.
    if (!($scorm = $DB->get_record('scorm', array('id' => $cm->instance)))) {
        print_error('cannotfindscorm');
    }
    // Only check for existence of tracks and return false if completionstatusrequired or completionscorerequired
    // this means that if only view is required we don't end up with a false state.
    if ($scorm->completionstatusrequired !== null || $scorm->completionscorerequired !== null) {
        // Get user's tracks data.
        $tracks = $DB->get_records_sql("\n            SELECT\n                id,\n                scoid,\n                element,\n                value\n            FROM\n                {scorm_scoes_track}\n            WHERE\n                scormid = ?\n            AND userid = ?\n            AND element IN\n            (\n                'cmi.core.lesson_status',\n                'cmi.completion_status',\n                'cmi.success_status',\n                'cmi.core.score.raw',\n                'cmi.score.raw'\n            )\n            ", array($scorm->id, $userid));
        if (!$tracks) {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }
    // Check for status.
    if ($scorm->completionstatusrequired !== null) {
        // Get status.
        $statuses = array_flip(scorm_status_options());
        $nstatus = 0;
        // Check any track for these values.
        $scostatus = array();
        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.lesson_status', 'cmi.completion_status', 'cmi.success_status'))) {
                continue;
            }
            if (array_key_exists($track->value, $statuses)) {
                $scostatus[$track->scoid] = true;
                $nstatus |= $statuses[$track->value];
            }
        }
        if (!empty($scorm->completionstatusallscos)) {
            // Iterate over all scos and make sure each has a lesson_status.
            $scos = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id, 'scormtype' => 'sco'));
            foreach ($scos as $sco) {
                if (empty($scostatus[$sco->id])) {
                    return completion_info::aggregate_completion_states($type, $result, false);
                }
            }
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            if ($scorm->completionstatusrequired & $nstatus) {
                return completion_info::aggregate_completion_states($type, $result, true);
            } else {
                return completion_info::aggregate_completion_states($type, $result, false);
            }
        }
    }
    // Check for score.
    if ($scorm->completionscorerequired !== null) {
        $maxscore = -1;
        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.score.raw', 'cmi.score.raw'))) {
                continue;
            }
            if (strlen($track->value) && floatval($track->value) >= $maxscore) {
                $maxscore = floatval($track->value);
            }
        }
        if ($scorm->completionscorerequired <= $maxscore) {
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }
    return $result;
}
开发者ID:dg711,项目名称:moodle,代码行数:80,代码来源:lib.php

示例3: scorm_get_completion_state

/**
 * Obtains the automatic completion state for this scorm based on any conditions
 * in scorm settings.
 *
 * @param object $course Course
 * @param object $cm Course-module
 * @param int $userid User ID
 * @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
 * @return bool True if completed, false if not. (If no conditions, then return
 *   value depends on comparison type)
 */
function scorm_get_completion_state($course, $cm, $userid, $type) {
    global $DB;

    $result = $type;

    // Get scorm.
    if (!$scorm = $DB->get_record('scorm', array('id' => $cm->instance))) {
        print_error('cannotfindscorm');
    }
    // Only check for existence of tracks and return false if completionstatusrequired or completionscorerequired
    // this means that if only view is required we don't end up with a false state.
    if ($scorm->completionstatusrequired !== null ||
        $scorm->completionscorerequired !== null) {
        // Get user's tracks data.
        $tracks = $DB->get_records_sql(
            "
            SELECT
                id,
                element,
                value
            FROM
                {scorm_scoes_track}
            WHERE
                scormid = ?
            AND userid = ?
            AND element IN
            (
                'cmi.core.lesson_status',
                'cmi.completion_status',
                'cmi.success_status',
                'cmi.core.score.raw',
                'cmi.score.raw'
            )
            ",
            array($scorm->id, $userid)
        );

        if (!$tracks) {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }

    // Check for status.
    if ($scorm->completionstatusrequired !== null) {

        // Get status.
        $statuses = array_flip(scorm_status_options());
        $nstatus = 0;

        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.lesson_status', 'cmi.completion_status', 'cmi.success_status'))) {
                continue;
            }

            if (array_key_exists($track->value, $statuses)) {
                $nstatus |= $statuses[$track->value];
            }
        }

        if ($scorm->completionstatusrequired & $nstatus) {
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            return completion_info::aggregate_completion_states($type, $result, false);
        }

    }

    // Check for score.
    if ($scorm->completionscorerequired !== null) {
        $maxscore = -1;

        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.score.raw', 'cmi.score.raw'))) {
                continue;
            }

            if (strlen($track->value) && floatval($track->value) >= $maxscore) {
                $maxscore = floatval($track->value);
            }
        }

        if ($scorm->completionscorerequired <= $maxscore) {
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }

    return $result;
//.........这里部分代码省略.........
开发者ID:ruddj,项目名称:moodle,代码行数:101,代码来源:lib.php

示例4: scorm_get_completion_state

/**
 * Obtains the automatic completion state for this scorm based on any conditions
 * in scorm settings.
 *
 * @param object $course Course
 * @param object $cm Course-module
 * @param int $userid User ID
 * @param bool $type Type of comparison (or/and; can be used as return value if no conditions)
 * @return bool True if completed, false if not. (If no conditions, then return
 *   value depends on comparison type)
 */
function scorm_get_completion_state($course, $cm, $userid, $type)
{
    global $DB;
    $result = $type;
    // Get scorm
    if (!($scorm = $DB->get_record('scorm', array('id' => $cm->instance)))) {
        print_error('cannotfindscorm');
    }
    // Get user's tracks data
    $tracks = $DB->get_records_sql("\n        SELECT\n            id,\n            element,\n            value\n        FROM\n            {scorm_scoes_track}\n        WHERE\n            scormid = ?\n        AND userid = ?\n        AND element IN\n        (\n            'cmi.core.lesson_status',\n            'cmi.completion_status',\n            'cmi.success_status',\n            'cmi.core.score.raw',\n            'cmi.score.raw'\n        )\n        ", array($scorm->id, $userid));
    if (!$tracks) {
        return completion_info::aggregate_completion_states($type, $result, false);
    }
    // Check for status
    if ($scorm->completionstatusrequired !== null) {
        // Get status
        $statuses = array_flip(scorm_status_options());
        $nstatus = 0;
        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.lesson_status', 'cmi.completion_status', 'cmi.success_status'))) {
                continue;
            }
            if (array_key_exists($track->value, $statuses)) {
                $nstatus |= $statuses[$track->value];
            }
        }
        if ($scorm->completionstatusrequired & $nstatus) {
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }
    // Check for score
    if ($scorm->completionscorerequired !== null) {
        $maxscore = -1;
        foreach ($tracks as $track) {
            if (!in_array($track->element, array('cmi.core.score.raw', 'cmi.score.raw'))) {
                continue;
            }
            if (strlen($track->value) && floatval($track->value) >= $maxscore) {
                $maxscore = floatval($track->value);
            }
        }
        if ($scorm->completionscorerequired <= $maxscore) {
            return completion_info::aggregate_completion_states($type, $result, true);
        } else {
            return completion_info::aggregate_completion_states($type, $result, false);
        }
    }
    return $result;
}
开发者ID:nmicha,项目名称:moodle,代码行数:62,代码来源:lib.php


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