本文整理汇总了PHP中scorm_status_options函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_status_options函数的具体用法?PHP scorm_status_options怎么用?PHP scorm_status_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_status_options函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例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;
}
示例3: add_completion_rules
public function add_completion_rules()
{
$mform =& $this->_form;
$items = array();
// Require score.
$group = array();
$group[] =& $mform->createElement('text', 'completionscorerequired', '', array('size' => 5));
$group[] =& $mform->createElement('checkbox', 'completionscoredisabled', null, get_string('disable'));
$mform->setType('completionscorerequired', PARAM_INT);
$mform->addGroup($group, 'completionscoregroup', get_string('completionscorerequired', 'scorm'), '', false);
$mform->addHelpButton('completionscoregroup', 'completionscorerequired', 'scorm');
$mform->disabledIf('completionscorerequired', 'completionscoredisabled', 'checked');
$mform->setDefault('completionscorerequired', 0);
$items[] = 'completionscoregroup';
// Require status.
$first = true;
$firstkey = null;
foreach (scorm_status_options(true) as $key => $value) {
$name = null;
$key = 'completionstatusrequired[' . $key . ']';
if ($first) {
$name = get_string('completionstatusrequired', 'scorm');
$first = false;
$firstkey = $key;
}
$mform->addElement('checkbox', $key, $name, $value);
$mform->setType($key, PARAM_BOOL);
$items[] = $key;
}
$mform->addHelpButton($firstkey, 'completionstatusrequired', 'scorm');
return $items;
}
示例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;
}