📄 scormlib.php
字号:
} $objectivedata->objectiveid = ''; if (isset($objective['attrs']['OBJECTIVEID'])) { $objectivedata->objectiveid = $objective['attrs']['OBJECTIVEID']; } $objectivedata->minnormalizedmeasure = 1.0; if (!empty($objective['children'])) { $mapinfos = array(); foreach ($objective['children'] as $objectiveparam) { if ($objectiveparam['name']=='IMSSS:MINNORMALIZEDMEASURE') { if (isset($objectiveparam['tagData'])) { $objectivedata->minnormalizedmeasure = $objectiveparam['tagData']; } else { $objectivedata->minnormalizedmeasure = 0; } } if ($objectiveparam['name']=='IMSSS:MAPINFO') { $mapinfo = new stdClass(); $mapinfo->targetobjectiveid = ''; if (isset($objectiveparam['attrs']['TARGETOBJECTIVEID'])) { $mapinfo->targetobjectiveid = $objectiveparam['attrs']['TARGETOBJECTIVEID']; } $mapinfo->readsatisfiedstatus = 1; if (isset($objectiveparam['attrs']['READSATISFIEDSTATUS'])) { $mapinfo->readsatisfiedstatus = $objectiveparam['attrs']['READSATISFIEDSTATUS'] == 'true'?1:0; } $mapinfo->writesatisfiedstatus = 0; if (isset($objectiveparam['attrs']['WRITESATISFIEDSTATUS'])) { $mapinfo->writesatisfiedstatus = $objectiveparam['attrs']['WRITESATISFIEDSTATUS'] == 'true'?1:0; } $mapinfo->readnormalizemeasure = 1; if (isset($objectiveparam['attrs']['READNORMALIZEDMEASURE'])) { $mapinfo->readnormalizemeasure = $objectiveparam['attrs']['READNORMALIZEDMEASURE'] == 'true'?1:0; } $mapinfo->writenormalizemeasure = 0; if (isset($objectiveparam['attrs']['WRITENORMALIZEDMEASURE'])) { $mapinfo->writenormalizemeasure = $objectiveparam['attrs']['WRITENORMALIZEDMEASURE'] == 'true'?1:0; } array_push($mapinfos,$mapinfo); } } if (!empty($mapinfos)) { $objectivesdata->mapinfos = $mapinfos; } } break; }//print_object($objectivedata); array_push($objectives,$objectivedata); } $scoes->elements[$manifest][$parent->organization][$parent->identifier]->objectives = $objectives; } if ($sequencing['name']=='IMSSS:LIMITCONDITIONS') { if (isset($sequencing['attrs']['ATTEMPTLIMIT'])) { $scoes->elements[$manifest][$parent->organization][$parent->identifier]->attemptLimit = $sequencing['attrs']['ATTEMPTLIMIT']; } if (isset($sequencing['attrs']['ATTEMPTABSOLUTEDURATIONLIMIT'])) { $scoes->elements[$manifest][$parent->organization][$parent->identifier]->attemptAbsoluteDurationLimit = $sequencing['attrs']['ATTEMPTABSOLUTEDURATIONLIMIT']; } } if ($sequencing['name']=='IMSSS:ROLLUPRULES') { if (isset($sequencing['attrs']['ROLLUPOBJECTIVESATISFIED'])) { $scoes->elements[$manifest][$parent->organization][$parent->identifier]->rollupobjectivesatisfied = $sequencing['attrs']['ROLLUPOBJECTIVESATISFIED'] == 'true'?1:0;; } if (isset($sequencing['attrs']['ROLLUPPROGRESSCOMPLETION'])) { $scoes->elements[$manifest][$parent->organization][$parent->identifier]->rollupprogresscompletion = $sequencing['attrs']['ROLLUPPROGRESSCOMPLETION'] == 'true'?1:0; } if (isset($sequencing['attrs']['OBJECTIVEMEASUREWEIGHT'])) { $scoes->elements[$manifest][$parent->organization][$parent->identifier]->objectivemeasureweight = $sequencing['attrs']['OBJECTIVEMEASUREWEIGHT']; } if (!empty($sequencing['children'])){ $rolluprules = array(); foreach ($sequencing['children'] as $sequencingrolluprule) { if ($sequencingrolluprule['name']=='IMSSS:ROLLUPRULE' ) { $rolluprule = new stdClass(); $rolluprule->childactivityset = 'all'; if (isset($sequencingrolluprule['attrs']['CHILDACTIVITYSET'])) { $rolluprule->childactivityset = $sequencingrolluprule['attrs']['CHILDACTIVITYSET']; } $rolluprule->minimumcount = 0; if (isset($sequencingrolluprule['attrs']['MINIMUMCOUNT'])) { $rolluprule->minimumcount = $sequencingrolluprule['attrs']['MINIMUMCOUNT']; } $rolluprule->minimumpercent = 0.0000; if (isset($sequencingrolluprule['attrs']['MINIMUMPERCENT'])) { $rolluprule->minimumpercent = $sequencingrolluprule['attrs']['MINIMUMPERCENT']; } if (!empty($sequencingrolluprule['children'])) { foreach ($sequencingrolluprule['children'] as $rolluproleconditions) { if ($rolluproleconditions['name']=='IMSSS:ROLLUPCONDITIONS') { $conditions = array(); $rolluprule->conditioncombination = 'all'; if (isset($rolluproleconditions['attrs']['CONDITIONCOMBINATION'])) { $rolluprule->conditioncombination = $rolluproleconditions['attrs']['CONDITIONCOMBINATION']; } foreach ($rolluproleconditions['children'] as $rolluprulecondition) { if ($rolluprulecondition['name']=='IMSSS:ROLLUPCONDITION') { $condition = new stdClass(); if (isset($rolluprulecondition['attrs']['CONDITION'])) { $condition->cond = $rolluprulecondition['attrs']['CONDITION']; } $condition->operator = 'noOp'; if (isset($rolluprulecondition['attrs']['OPERATOR'])) { $condition->operator = $rolluprulecondition['attrs']['OPERATOR']; } array_push($conditions,$condition); } } $rolluprule->conditions = $conditions; } if ($rolluproleconditions['name']=='IMSSS:ROLLUPACTION') { $rolluprule->rollupruleaction = $rolluproleconditions['attrs']['ACTION']; } } } array_push($rolluprules, $rolluprule); } } $scoes->elements[$manifest][$parent->organization][$parent->identifier]->rolluprules = $rolluprules; } } if ($sequencing['name']=='IMSSS:SEQUENCINGRULES') { if (!empty($sequencing['children'])) { $sequencingrules = array(); foreach ($sequencing['children'] as $conditionrules) { $conditiontype = -1; switch($conditionrules['name']) { case 'IMSSS:PRECONDITIONRULE': $conditiontype = 0; break; case 'IMSSS:POSTCONDITIONRULE': $conditiontype = 1; break; case 'IMSSS:EXITCONDITIONRULE': $conditiontype = 2; break; } if (!empty($conditionrules['children'])) { $sequencingrule = new stdClass(); foreach ($conditionrules['children'] as $conditionrule) { if ($conditionrule['name']=='IMSSS:RULECONDITIONS') { $ruleconditions = array(); $sequencingrule->conditioncombination = 'all'; if (isset($conditionrule['attrs']['CONDITIONCOMBINATION'])) { $sequencingrule->conditioncombination = $conditionrule['attrs']['CONDITIONCOMBINATION']; } foreach ($conditionrule['children'] as $rulecondition) { if ($rulecondition['name']=='IMSSS:RULECONDITION') { $condition = new stdClass(); if (isset($rulecondition['attrs']['CONDITION'])) { $condition->cond = $rulecondition['attrs']['CONDITION']; } $condition->operator = 'noOp'; if (isset($rulecondition['attrs']['OPERATOR'])) { $condition->operator = $rulecondition['attrs']['OPERATOR']; } $condition->measurethreshold = 0.0000; if (isset($rulecondition['attrs']['MEASURETHRESHOLD'])) { $condition->measurethreshold = $rulecondition['attrs']['MEASURETHRESHOLD']; } $condition->referencedobjective = ''; if (isset($rulecondition['attrs']['REFERENCEDOBJECTIVE'])) { $condition->referencedobjective = $rulecondition['attrs']['REFERENCEDOBJECTIVE']; } array_push($ruleconditions,$condition); } } $sequencingrule->ruleconditions = $ruleconditions; } if ($conditionrule['name']=='IMSSS:RULEACTION') { $sequencingrule->action = $conditionrule['attrs']['ACTION']; } $sequencingrule->type = $conditiontype; } array_push($sequencingrules,$sequencingrule); } } $scoes->elements[$manifest][$parent->organization][$parent->identifier]->sequencingrules = $sequencingrules; } } } } break; } } } return $scoes;}function scorm_parse_scorm($pkgdir,$scormid) { global $CFG; $launch = 0; $manifestfile = $pkgdir.'/imsmanifest.xml'; if (is_file($manifestfile)) { $xmltext = file_get_contents($manifestfile); $pattern = '/&(?!\w{2,6};)/'; $replacement = '&'; $xmltext = preg_replace($pattern, $replacement, $xmltext); $objXML = new xml2Array(); $manifests = $objXML->parse($xmltext);//print_object($manifests); $scoes = new stdClass(); $scoes->version = ''; $scoes = scorm_get_manifest($manifests,$scoes);//print_object($scoes); if (count($scoes->elements) > 0) { $olditems = get_records('scorm_scoes','scorm',$scormid); foreach ($scoes->elements as $manifest => $organizations) { foreach ($organizations as $organization => $items) { foreach ($items as $identifier => $item) { // This new db mngt will support all SCORM future extensions $newitem = new stdClass(); $newitem->scorm = $scormid; $newitem->manifest = $manifest; $newitem->organization = $organization; $standarddatas = array('parent', 'identifier', 'launch', 'scormtype', 'title'); foreach ($standarddatas as $standarddata) { if (isset($item->$standarddata)) { $newitem->$standarddata = addslashes_js($item->$standarddata); } } // Insert the new SCO, and retain the link between the old and new for later adjustment $id = insert_record('scorm_scoes',$newitem); if (!empty($olditems) && ($olditemid = scorm_array_search('identifier',$newitem->identifier,$olditems))) { $olditems[$olditemid]->newid = $id; } if ($optionaldatas = scorm_optionals_data($item,$standarddatas)) { $data = new stdClass(); $data->scoid = $id; foreach ($optionaldatas as $optionaldata) { if (isset($item->$optionaldata)) { $data->name = $optionaldata; $data->value = addslashes_js($item->$optionaldata); $dataid = insert_record('scorm_scoes_data',$data); } } } if (isset($item->sequencingrules)) { foreach($item->sequencingrules as $sequencingrule) { $rule = new stdClass(); $rule->scoid = $id; $rule->ruletype = $sequencingrule->type; $rule->conditioncombination = $sequencingrule->conditioncombination; $rule->action = $sequencingrule->action; $ruleid = insert_record('scorm_seq_ruleconds',$rule); if (isset($sequencingrule->ruleconditions)) { foreach($sequencingrule->ruleconditions as $rulecondition) { $rulecond = new stdClass(); $rulecond->scoid = $id; $rulecond->ruleconditionsid = $ruleid; $rulecond->referencedobjective = $rulecondition->referencedobjective; $rulecond->measurethreshold = $rulecondition->measurethreshold; $rulecond->cond = $rulecondition->cond; $rulecondid = insert_record('scorm_seq_rulecond',$rulecond); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -