本文整理汇总了PHP中scorm_array_search函数的典型用法代码示例。如果您正苦于以下问题:PHP scorm_array_search函数的具体用法?PHP scorm_array_search怎么用?PHP scorm_array_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scorm_array_search函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scorm_find_common_ancestor
function scorm_find_common_ancestor($ancestors, $sco)
{
$pos = scorm_array_search('identifier', $sco->parent, $ancestors);
if ($sco->parent != '/') {
if ($pos === false) {
return scorm_find_common_ancestor($ancestors, scorm_get_parent($sco));
}
}
return $pos;
}
示例2: scorm_parse_aicc
//.........这里部分代码省略.........
$launch = 0;
if (isset($courses)) {
foreach ($courses as $course) {
$sco = new object();
$sco->identifier = $course->id;
$sco->scorm = $scormid;
$sco->organization = '';
$sco->title = $course->title;
$sco->parent = '/';
$sco->launch = '';
$sco->scormtype = '';
//print_r($sco);
if (get_record('scorm_scoes', 'scorm', $scormid, 'identifier', $sco->identifier)) {
$id = update_record('scorm_scoes', addslashes_recursive($sco));
unset($oldscoes[$id]);
} else {
$id = insert_record('scorm_scoes', addslashes_recursive($sco));
}
if ($launch == 0) {
$launch = $id;
}
if (isset($course->elements)) {
foreach ($course->elements as $element) {
unset($sco);
$sco->identifier = $element->system_id;
$sco->scorm = $scormid;
$sco->organization = $course->id;
$sco->title = $element->title;
if (!isset($element->parent) || strtolower($element->parent) == 'root') {
$sco->parent = '/';
} else {
$sco->parent = $element->parent;
}
if (isset($element->file_name)) {
$sco->launch = $element->file_name;
$sco->scormtype = 'sco';
$sco->previous = 0;
$sco->next = 0;
$id = null;
if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
$sco->id = $oldscoid;
if (update_record('scorm_scoes', addslashes_recursive($sco))) {
$id = $oldscoid;
}
delete_records('scorm_scoes_data', 'scoid', $oldscoid);
unset($oldscoes[$oldscoid]);
} else {
$id = insert_record('scorm_scoes', addslashes_recursive($sco));
}
if (!empty($id)) {
unset($scodata);
$scodata->scoid = $id;
if (isset($element->web_launch)) {
$scodata->name = 'parameters';
$scodata->value = $element->web_launch;
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
if (isset($element->prerequisites)) {
$scodata->name = 'prerequisites';
$scodata->value = $element->prerequisites;
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
if (isset($element->max_time_allowed)) {
$scodata->name = 'max_time_allowed';
$scodata->value = $element->max_time_allowed;
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
if (isset($element->time_limit_action)) {
$scodata->name = 'time_limit_action';
$scodata->value = $element->time_limit_action;
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
if (isset($element->mastery_score)) {
$scodata->name = 'mastery_score';
$scodata->value = $element->mastery_score;
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
if (isset($element->core_vendor)) {
$scodata->name = 'datafromlms';
$scodata->value = eregi_replace('<cr>', "\r\n", $element->core_vendor);
$dataid = insert_record('scorm_scoes_data', addslashes_recursive($scodata));
}
}
if ($launch == 0) {
$launch = $id;
}
}
}
}
}
}
if (!empty($oldscoes)) {
foreach ($oldscoes as $oldsco) {
delete_records('scorm_scoes', 'id', $oldsco->id);
delete_records('scorm_scoes_track', 'scoid', $oldsco->id);
}
}
set_field('scorm', 'version', 'AICC', 'id', $scormid);
return $launch;
}
示例3: scorm_parse_aicc
//.........这里部分代码省略.........
$launch = 0;
if (isset($courses)) {
foreach ($courses as $course) {
$sco = new object();
$sco->identifier = $course->id;
$sco->scorm = $scorm->id;
$sco->organization = '';
$sco->title = $course->title;
$sco->parent = '/';
$sco->launch = '';
$sco->scormtype = '';
//print_r($sco);
if ($ss = $DB->get_record('scorm_scoes', array('scorm' => $scorm->id, 'identifier' => $sco->identifier))) {
$id = $ss->id;
$DB->update_record('scorm_scoes', $sco);
unset($oldscoes[$id]);
} else {
$id = $DB->insert_record('scorm_scoes', $sco);
}
if ($launch == 0) {
$launch = $id;
}
if (isset($course->elements)) {
foreach ($course->elements as $element) {
unset($sco);
$sco->identifier = $element->system_id;
$sco->scorm = $scorm->id;
$sco->organization = $course->id;
$sco->title = $element->title;
if (!isset($element->parent) || strtolower($element->parent) == 'root') {
$sco->parent = '/';
} else {
$sco->parent = $element->parent;
}
if (isset($element->file_name)) {
$sco->launch = $element->file_name;
$sco->scormtype = 'sco';
$sco->previous = 0;
$sco->next = 0;
$id = null;
if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
$sco->id = $oldscoid;
$id = $DB->update_record('scorm_scoes', $sco);
$DB->delete_records('scorm_scoes_data', array('scoid' => $oldscoid));
unset($oldscoes[$oldscoid]);
} else {
$id = $DB->insert_record('scorm_scoes', $sco);
}
if (!empty($id)) {
unset($scodata);
$scodata->scoid = $id;
if (isset($element->web_launch)) {
$scodata->name = 'parameters';
$scodata->value = $element->web_launch;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->prerequisites)) {
$scodata->name = 'prerequisites';
$scodata->value = $element->prerequisites;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->max_time_allowed)) {
$scodata->name = 'max_time_allowed';
$scodata->value = $element->max_time_allowed;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->time_limit_action)) {
$scodata->name = 'time_limit_action';
$scodata->value = $element->time_limit_action;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->mastery_score)) {
$scodata->name = 'mastery_score';
$scodata->value = $element->mastery_score;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->core_vendor)) {
$scodata->name = 'datafromlms';
$scodata->value = eregi_replace('<cr>', "\r\n", $element->core_vendor);
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
}
if ($launch == 0) {
$launch = $id;
}
}
}
}
}
}
if (!empty($oldscoes)) {
foreach ($oldscoes as $oldsco) {
$DB->delete_records('scorm_scoes', array('id' => $oldsco->id));
$DB->delete_records('scorm_scoes_track', array('scoid' => $oldsco->id));
}
}
$scorm->version = 'AICC';
$scorm->launch = $launch;
return true;
}
示例4: scorm_parse_aicc
//.........这里部分代码省略.........
} else {
$id = $DB->insert_record('scorm_scoes', $sco);
}
if ($launch == 0) {
$launch = $id;
}
if (isset($course->elements)) {
foreach ($course->elements as $element) {
unset($sco);
$sco = new stdClass();
$sco->identifier = $element->system_id;
$sco->scorm = $scorm->id;
$sco->organization = $course->id;
$sco->title = $element->title;
if (!isset($element->parent)) {
$sco->parent = '/';
} else {
if (strtolower($element->parent) == 'root') {
$sco->parent = $course->id;
} else {
$sco->parent = $element->parent;
}
}
$sco->launch = '';
$sco->scormtype = '';
$sco->previous = 0;
$sco->next = 0;
$id = null;
// Is it an Assignable Unit (AU)?
if (isset($element->file_name)) {
$sco->launch = $element->file_name;
$sco->scormtype = 'sco';
}
if ($oldscoid = scorm_array_search('identifier', $sco->identifier, $oldscoes)) {
$sco->id = $oldscoid;
$DB->update_record('scorm_scoes', $sco);
$id = $oldscoid;
$DB->delete_records('scorm_scoes_data', array('scoid' => $oldscoid));
unset($oldscoes[$oldscoid]);
} else {
$id = $DB->insert_record('scorm_scoes', $sco);
}
if (!empty($id)) {
$scodata = new stdClass();
$scodata->scoid = $id;
if (isset($element->web_launch)) {
$scodata->name = 'parameters';
$scodata->value = $element->web_launch;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->prerequisites)) {
$scodata->name = 'prerequisites';
$scodata->value = $element->prerequisites;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->max_time_allowed)) {
$scodata->name = 'max_time_allowed';
$scodata->value = $element->max_time_allowed;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->time_limit_action)) {
$scodata->name = 'time_limit_action';
$scodata->value = $element->time_limit_action;
$dataid = $DB->insert_record('scorm_scoes_data', $scodata);
}
if (isset($element->mastery_score)) {
示例5: scorm_parse_tincan
/**
*
* Parse the TCAPI resource.
*
* @param object $scorm
* @param object $manifest
*/
function scorm_parse_tincan($scorm, $manifest) {
global $CFG, $DB;
// load manifest into string
if ($manifest instanceof stored_file) {
$xmltext = $manifest->get_content();
} else {
require_once("$CFG->libdir/filelib.php");
$xmltext = download_file_content($manifest);
}
$launch = 0;
$pattern = '/&(?!\w{2,6};)/';
$replacement = '&';
$xmltext = preg_replace($pattern, $replacement, $xmltext);
$objXML = new xml2Array();
$manifests = $objXML->parse($xmltext);
$scoes = new stdClass();
$scoes->version = 'TCAPI';
$scoes = scorm_get_tincan_manifest($manifests, $scoes);
if (count($scoes->elements) > 0) {
$olditems = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id));
foreach ($scoes->elements as $manifest => $organizations) {
foreach ($organizations as $organization => $items) {
foreach ($items as $identifier => $item) {
$newitem = new stdClass();
$newitem->scorm = $scorm->id;
$newitem->manifest = $manifest;
$newitem->organization = $organization;
$standarddatas = array('parent', 'identifier', 'launch', 'scormtype', 'title');
foreach ($standarddatas as $standarddata) {
if (isset($item->$standarddata)) {
$newitem->$standarddata = $item->$standarddata;
}
}
// Insert the new SCO, and retain the link between the old and new for later adjustment
$id = $DB->insert_record('scorm_scoes', $newitem);
if (!empty($olditems) && ($olditemid = scorm_array_search('identifier', $newitem->identifier, $olditems))) {
$olditems[$olditemid]->newid = $id;
}
if ($optionaldatas = scorm_tincan_optionals_data($item, $standarddatas)) {
$data = new stdClass();
$data->scoid = $id;
foreach ($optionaldatas as $optionaldata) {
if (isset($item->$optionaldata)) {
$data->name = $optionaldata;
$data->value = $item->$optionaldata;
$dataid = $DB->insert_record('scorm_scoes_data', $data);
}
}
}
if (($launch == 0) && ((empty($scoes->defaultorg)) || ($scoes->defaultorg == $identifier))) {
$launch = $id;
}
}
}
}
if (!empty($olditems)) {
foreach ($olditems as $olditem) {
$DB->delete_records('scorm_scoes', array('id'=>$olditem->id));
$DB->delete_records('scorm_scoes_data', array('scoid'=>$olditem->id));
if (isset($olditem->newid)) {
$DB->set_field('scorm_scoes_track', 'scoid', $olditem->newid, array('scoid' => $olditem->id));
}
$DB->delete_records('scorm_scoes_track', array('scoid'=>$olditem->id));
}
}
$DB->set_field('scorm', 'version', $scoes->version, array('id'=>$scorm->id));
$scorm->version = $scoes->version;
}
$scorm->launch = $launch;
return true;
}