$legalValues[] = $key; } if (isset($_GET['add']) || isset($_GET['edit']) && in_array($_GET['edit'], $legalValues) && eF_checkParameter($_GET['edit'], 'id') && $_change_) { try { if ($_GET['edit']) { $currentUnit = $currentContent->seekNode($_GET['edit']); //The content tree does not hold data, so assign this unit its data $unitData = new EfrontUnit($_GET['edit']); $currentUnit['data'] = $unitData['data']; $currentUnitName = $unitData['name']; } else { unset($currentUnit); //Needed because we might have the &view_unit specified in the parameters } //This page has a file manager, so bring it on with the correct options $basedir = $currentLesson->getDirectory(); //Default options for the file manager if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') { $options = array('lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0); if (!$currentLesson->options['digital_library']) { $options['share'] = false; } } else { $options = array('delete' => false, 'edit' => false, 'share' => false, 'upload' => false, 'create_folder' => false, 'zip' => false, 'lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0); } //Default url for the file manager $url = basename($_SERVER['PHP_SELF']) . '?ctg=content&' . (isset($_GET['edit']) ? 'edit=' . $_GET['edit'] : 'add=1'); $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor')); /**The file manager*/ include "file_manager.php"; //This page also needs an editor and ASCIIMathML
try { $currentUser = EfrontUserFactory::factory($_SESSION['s_login']); } catch (EfrontException $e) { $message = $e->getMessage() . ' (' . $e->getCode() . ')'; eF_redirect("index.php?message=" . urlencode($message) . "&message_type=failure"); exit; } } else { eF_redirect("index.php?message=" . urlencode(_YOUCANNOTACCESSTHISPAGE) . "&message_type=failure"); exit; } try { //There are 2 legal modes: 'lessons' and 'external'. In the first case, we read the legitimate directory from the session. In the second case, we take it from global constant if ($_GET['mode'] == 'lesson') { $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']); $rootDir = new EfrontDirectory($currentLesson->getDirectory()); $filesBaseUrl = $currentLesson->getDirectoryUrl(); } elseif ($_GET['mode'] == 'external') { $rootDir = new EfrontDirectory(G_EXTERNALPATH); $filesBaseUrl = G_EXTERNALURL; } elseif ($_GET['mode'] == 'upload') { $rootDir = new EfrontDirectory(G_UPLOADPATH . $_SESSION['s_login']); $filesBaseUrl = G_UPLOADPATH . $_SESSION['s_login']; } else { throw new Exception(_ILLEGALMODE); } //We are inside a directory. Verify that this directory is below the $rootDir, as defined previously if (isset($_GET['directory'])) { $directory = new EfrontDirectory($_GET['directory']); if (strpos($directory['path'], $rootDir['path']) === false) { $directory = $rootDir;
/** * Copy simple unit * * This function copies a unit (NOT its children) into the current content tree * <br/>Example: * <code> * $currentContent = new EfrontContentTree(5); //Initialize content for lesson with id 5 * $sourceUnit = new EfrontUnit(20); //Get the unit with id = 20 * $currentContent -> copySimpleUnit($sourceUnit, false); //Copy the source unit into the content tree (at its end) * </code> * * @param EfrontUnit $sourceUnit The unit object to be copied * @param mixed $targetUnit The id of the parent unit (or the parent EfrontUnit)in which the new unit will be copied, or false (the unit will be appended at the end) * @param mixed $previousUnit The id of the previous unit (or the unit itself) of the new unit, or false (the unit will be put to the end of the units) * @param boolean $copyFiles whether to copy files as well. * @param boolean $copyQuestions Whether to copy questions as well * @return EfrontUnit The newly created unit object * @since 3.5.0 * @access public */ public function copySimpleUnit($sourceUnit, $targetUnit = false, $previousUnit = false, $copyFiles = true, $copyQuestions = true) { if (!$sourceUnit instanceof EfrontUnit) { $sourceUnit = new EfrontUnit($sourceUnit); } $newUnit['name'] = $sourceUnit->offsetGet('name'); $newUnit['ctg_type'] = $sourceUnit->offsetGet('ctg_type'); $newUnit['data'] = $sourceUnit->offsetGet('data'); $options = $sourceUnit->offsetGet('options'); $newOptions['complete_unit_setting'] = $options['complete_unit_setting']; $newOptions['hide_navigation'] = $options['hide_navigation']; $newOptions['maximize_viewport'] = $options['maximize_viewport']; $newOptions['object_ids'] = $options['object_ids']; $newUnit['options'] = serialize($newOptions); $newUnit['lessons_ID'] = $this->lessonId; if ($targetUnit) { if ($targetUnit instanceof EfrontUnit) { $newUnit['parent_content_ID'] = $targetUnit->offsetGet('id'); } else { if (eF_checkParameter($targetUnit, 'id')) { $newUnit['parent_content_ID'] = $targetUnit; } } if ($previousUnit instanceof EfrontUnit) { $newUnit['previous_content_ID'] = $previousUnit->offsetGet('id'); } else { if (eF_checkParameter($previousUnit, 'id')) { $newUnit['previous_content_ID'] = $previousUnit; } } $unit = $this->insertNode($newUnit); } else { $unit = $this->appendUnit($newUnit); } if ($copyFiles) { $files = $unit->getFiles(); $lesson = new EfrontLesson($this->lessonId); $data = $unit->offsetGet('data'); foreach ($files as $file) { try { $sourceFile = new EfrontFile($file); $sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']); $position = strpos($sourceFileOffset, "/"); //check case that the file is in a subfolder of the lesson if ($position !== false) { $sourceLink = mb_substr($sourceFileOffset, $position + 1); mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true); $destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']); $copiedFile = $sourceFile->copy($destinationPath, false); } else { $destinationPath = $lesson->getDirectory() . basename($sourceFile['path']); $copiedFile = $sourceFile->copy($destinationPath, false); } //@todo view_file.php?action=download&file=10410 //$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data); //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data); //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data); $data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data); $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id']; $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data); } catch (EfrontFileException $e) { if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) { $copiedFile = new EfrontFile($destinationPath); //$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data); //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data); //$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data); $data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data); $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id']; $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data, -1, $count); } } //this means that the file already exists } $unit->offsetSet('data', $data); if ($file && $unit['ctg_type'] == 'scorm' || $unit['ctg_type'] == 'scorm_test') { $d = new EfrontDirectory(dirname($file)); $d->copy($lesson->getDirectory() . basename(dirname($file)), true); } } $unit->persist(); // copying questions that belong to this unit if ($copyQuestions) { $questions = eF_getTableData("questions", "*", "content_ID=" . $sourceUnit->offsetGet('id')); if ($copyFiles) { $folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id']; } for ($k = 0; $k < sizeof($questions); $k++) { if ($copyFiles) { $questions[$k]['text'] = replaceQuestionPaths($questions[$k]['text'], $questions[$k]['lessons_ID'], $folderId); $questions[$k]['explanation'] = replaceQuestionPaths($questions[$k]['explanation'], $questions[$k]['lessons_ID'], $folderId); } $questions[$k]['content_ID'] = $unit->offsetGet('id'); $questions[$k]['lessons_ID'] = $unit->offsetGet('lessons_ID'); unset($questions[$k]['id']); eF_insertTableData("questions", $questions[$k]); } } return $unit; }
/** * Parse the html and remove <head></head> part if present into html * * @param String $html * @return void * @access Private */ function _parseHtml($html) { $html = preg_replace("/<!DOCTYPE((.|\n)*?)>/ims", "", $html); $html = preg_replace("/<script((.|\n)*?)>((.|\n)*?)<\\/script>/ims", "", $html); preg_match("/<head>((.|\n)*?)<\\/head>/ims", $html, $matches); $head = $matches[1]; preg_match("/<title>((.|\n)*?)<\\/title>/ims", $head, $matches); $this->title = $matches[1]; $html = preg_replace("/<head>((.|\n)*?)<\\/head>/ims", "", $html); $head = preg_replace("/<title>((.|\n)*?)<\\/title>/ims", "", $head); $head = preg_replace("/<\\/?head>/ims", "", $head); $html = preg_replace("/<\\/?body((.|\n)*?)>/ims", "", $html); $this->htmlHead = $head; $DOM = new DOMDocument(); $DOM->loadHTML($html); $imgs = $DOM->getElementsByTagName('img'); foreach ($imgs as $img) { $src = $img->getAttribute('src'); if (strpos($src, "http://") === false) { //local image if (strpos($src, 'content/lessons') !== false) { $pos = strrpos($src, '/'); $tmp_img = substr($src, $pos + 1); $path = substr($src, 0, strlen($src) - strlen($tmp_img)); $this->localimgs[] = array('src' => $tmp_img, 'path' => G_ROOTPATH . "www/" . $path); $src = $tmp_img; } if (strpos($src, 'images/16x16') !== false) { $pos = strrpos($src, '/'); $tmp_img = substr($src, $pos + 1); $path = substr($src, 0, strlen($src) - strlen($tmp_img)); $this->localimgs[] = array('src' => $tmp_img, 'path' => G_DEFAULTTHEMEPATH . "www/" . $path); $src = $tmp_img; } } $img->setAttribute('src', $src); } $html = $DOM->saveHTML(); $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $this->lessonDirectory = $lesson->getDirectory(); $this->htmlBody = $html; return; }
/** * * @param unknown_type $file * @return unknown_type */ public static function import($lesson, $manifestFile, $scormFolderName, $parameters, $iframe_parameters) { if ($lesson instanceof EfrontLesson) { $currentLesson = $lesson; } else { $currentLesson = new EfrontLesson($lesson); } $lessons_ID = $currentLesson->lesson['id']; $currentContent = new EfrontContentTree($currentLesson); $manifestXML = file_get_contents($manifestFile['path']); $tagArray = EfrontScorm::parseManifest($manifestXML); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD /** * We must merge sequencingCollection general rules with local sequencing rules * The rule is the following: There can be 0 or 1 <imsss:sequencingCollection> tags in the end of the manifest. * If one exists, it may contain 1 or more <imsss:sequencing> tags, each with an ID, like: * <imsss:sequencing ID = "seqCol-CM07d-1"> * Each of these will contain inner rules, for example: * <imsss:sequencing ID = "seqCol-CM07d-3"> * <imsss:limitConditions attemptLimit="1"/> * <imsss:rollupRules rollupObjectiveSatisfied="false"/> * </imsss:sequencing> * Now, for every <item> element in the manifest, there may be inline <imsss:sequencing> declarations. These may specify * <imsss:XXX> rules like above, that have local scope, or they may be having the IDRef attribute, pointing to a sequencingCollection's * <imsss:sequencing>, or both. In the last case, the <imsss:XXX> rules must be merged for each item. In the case that a rule exists * in both parts, the inline <item>'s rule takes precedence. * * The code below does this merge: * 1. Parse the manifest array to find the general <sequencingCollection> rules. * 2. Get all the rules contained in the collection, in an ID => <imsss rules> array * 3. Walk through the manifest array to find all <item> elements that reference an ID. Get the existing <imsss> rules it might * have. Merge the general collection rules with local, but bypass those that already exist * */ //$collections array holds the sequencing tags that are in the manifest, as keys in the array $collections = array(); foreach ($tagArray as $key => $value) { if (strcasecmp($value['tag'], 'IMSSS:SEQUENCINGCOLLECTION') === 0) { $sequencingCollection = $key; $collections = array_merge($collections, $value['children']); } } //$rules is an array that holds subarrays, where each has a key that is the ID (for example, 'seqCol-CM07d-3') //and its values are the keys of the rules, for example array(132,133,134) $rules = array(); foreach ($collections as $key => $sequencing) { $node = $tagArray[$sequencing]; $id = EfrontContentTreeSCORM::form_id($node['attributes']['ID']); $rules[$id] = $node['children']; } //Parse the manifest to get the <imsss:sequencing> rules (that are not inside the $collections) foreach ($tagArray as $key => $value) { if (strcasecmp($value['tag'], 'IMSSS:SEQUENCING') === 0 && !in_array($key, $collections)) { //Check whether this rule references an item in the collection if (in_array(EfrontContentTreeSCORM::form_id($id), array_keys($rules))) { $tagArray[] = array('tag' => 'IMSSS:SEQUENCING', 'parent_index' => $value['parent_index']); //end($tagArray); //$tagArray[$key]['children'][] = key($tagArray); //Get the existing rules of the sequencing, to compare them later with referenced ones $existingRules = array(); foreach ($value['children'] as $inrule) { $existingRules[] = $tagArray[$inrule]['tag']; } //echo "<br>----------Existing----------------<br>"; //pr($existingRules); //Compare referenced rules with local. If they don't overlap, create a new node in the tagArray, and set him to be //referenced by the item's sequencing //echo "<br>----------Collection----------------<br>"; //pr($rules); //pr($existingRules); foreach ($rules[$value['attributes']['IDREF']] as $rule) { if (!in_array($tagArray[$rule]['tag'], $existingRules)) { self::copyNodeChildren($tagArray, $rule, $key); /* $newRule = $tagArray[$rule]; $newRule['parent_index'] = $key; $tagArray[] = $newRule; end($tagArray); $tagArray[$key]['children'][] = key($tagArray); */ /* $part1 = (array_slice($tagArray, 0, $count, true)); $part2 = (array_slice($tagArray, $count, -1, true)); $tagArray = ($part1 + array($k => $tagArray[$k]) + $part2); */ } } } } } /** * We need to unset all the sequencingCollection rules, since they tend to mess up with <item>'s rules in * complete XML parsing below. So, this piece of code finds the sequencingCollection (1 at most), and recursively * unsets it and all of its children from the $tagArray, as if they never existed. */ if ($sequencingCollection) { $removeNode = $tagArray[$sequencingCollection]; $children = array($sequencingCollection); $count = 1; while (sizeof($children) > 0 && $count < 1000) { $children = array_merge($children, $removeNode['children']); $removeNode = $tagArray[$children[$count]]; unset($tagArray[$children[$count++]]); } unset($tagArray[$sequencingCollection]); } } #cpp#endif } #cpp#endif /** * Now parse XML file as usual */ foreach ($tagArray as $key => $value) { $fields = array(); switch ($value['tag']) { case 'SCHEMAVERSION': $scormVersion = $value['value']; if (stripos($scormVersion, '2004') !== false && (G_VERSIONTYPE == 'community' || G_VERSIONTYPE == 'standard')) { //This additional line is used in case we have the community edition throw new EfrontContentException(_SCORM2004NOTSUPPORTED, EfrontContentException::UNSUPPORTED_CONTENT); } if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD $scorm2004 = in_array($scormVersion, EfrontContentTreeSCORM::$scorm2004Versions); } #cpp#endif } #cpp#endif break; case 'TITLE': $cur = $value['parent_index']; $total_fields[$cur]['name'] = $value['value'] ? $value['value'] : " "; break; case 'ORGANIZATION': $item_key = $key; if ($scorm2004) { $total_fields[$key]['lessons_ID'] = $lessons_ID; $total_fields[$key]['timestamp'] = time(); $total_fields[$key]['ctg_type'] = 'scorm'; $total_fields[$key]['active'] = 1; $total_fields[$key]['scorm_version'] = $scormVersion; $total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER']; $organizations[$key]['id'] = $value['attributes']['IDENTIFIER']; $organizations[$key]['structure'] = $value['attributes']['STRUCTURE']; $organizations[$key]['objectives_global_to_system'] = $value['attributes']['ADLSEQ:OBJECTIVESGLOBALTOSYSTEM']; $organizations[$key]['shared_data_global_to_system'] = $value['attributes']['ADLCP:SHAREDDATAGLOBALTOSYSTEM']; $organization = $value['attributes']['IDENTIFIER']; $hide_lms_ui[$key]['is_visible'] = $value['attributes']['ISVISIBLE']; $content_to_organization[$item_key] = $organization; } break; case 'ITEM': $item_key = $key; $total_fields[$key]['lessons_ID'] = $lessons_ID; $total_fields[$key]['timestamp'] = time(); $total_fields[$key]['ctg_type'] = 'scorm'; $total_fields[$key]['active'] = 1; $total_fields[$key]['scorm_version'] = $scormVersion; $total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER']; $hide_lms_ui[$key]['is_visible'] = $value['attributes']['ISVISIBLE']; if ($scorm2004) { $references[$key]['IDENTIFIERREF'] = EfrontContentTreeSCORM::form_id($value['attributes']['IDENTIFIERREF']); /*SCORM 2004: params in element items must be appended to the url*/ $references[$key]['PARAMETERS'] = $value['attributes']['PARAMETERS']; } else { $references[$key]['IDENTIFIERREF'] = $value['attributes']['IDENTIFIERREF']; $references[$key]['PARAMETERS'] = $value['attributes']['PARAMETERS']; } $content_to_organization[$item_key] = $organization; break; case 'RESOURCE': if ($scorm2004) { $resources[$key] = EfrontContentTreeSCORM::form_id($value['attributes']['IDENTIFIER']); } else { $resources[$key] = $value['attributes']['IDENTIFIER']; } break; case 'FILE': $files[$key] = $value['attributes']['HREF']; break; case 'ADLCP:MAXTIMEALLOWED': $maxtimeallowed[$key] = $value['value']; break; case 'ADLCP:TIMELIMITACTION': $timelimitaction[$key] = $value['value']; break; case 'ADLCP:MASTERYSCORE': $masteryscore[$key] = $value['value']; break; case 'ADLCP:DATAFROMLMS': $datafromlms[$key] = $value['value']; break; case 'ADLCP:PREREQUISITES': $prerequisites[$key] = $value['value']; break; case 'ADLCP:COMPLETIONTHRESHOLD': $completion_threshold[$item_key][$key]['min_progress_measure'] = $value['attributes']['MINPROGRESSMEASURE']; $completion_threshold[$item_key][$key]['completed_by_measure'] = $value['attributes']['COMPLETEDBYMEASURE']; $completion_threshold[$item_key][$key]['progress_weight'] = $value['attributes']['PROGRESSWEIGHT']; break; case 'IMSSS:SEQUENCING': $item_key = $value['parent_index']; break; case 'IMSSS:LIMITCONDITIONS': $limit_conditions[$item_key][$key]['attempt_limit'] = $value['attributes']['ATTEMPTLIMIT']; $limit_conditions[$item_key][$key]['attempt_absolute_duration_limit'] = $value['attributes']['ATTEMPTABSOLUTEDURATIONLIMIT']; break; case 'IMSSS:ROLLUPRULES': $rollup_controls[$item_key][$key]['rollup_objective_satisfied'] = $value['attributes']['ROLLUPOBJECTIVESATISFIED']; $rollup_controls[$item_key][$key]['rollup_objective_measure_weight'] = $value['attributes']['OBJECTIVEMEASUREWEIGHT']; $rollup_controls[$item_key][$key]['rollup_progress_completion'] = $value['attributes']['ROLLUPPROGRESSCOMPLETION']; break; case 'ADLSEQ:ROLLUPCONSIDERATIONS': $rollup_considerations[$item_key][$key]['required_for_satisfied'] = $value['attributes']['REQUIREDFORSATISFIED']; $rollup_considerations[$item_key][$key]['required_for_not_satisfied'] = $value['attributes']['REQUIREDFORNOTSATISFIED']; $rollup_considerations[$item_key][$key]['required_for_completed'] = $value['attributes']['REQUIREDFORCOMPLETED']; $rollup_considerations[$item_key][$key]['required_for_incomplete'] = $value['attributes']['REQUIREDFORINCOMPLETE']; $rollup_considerations[$item_key][$key]['measure_satisfaction_if_active'] = $value['attributes']['MEASURESATISFACTIONIFACTIVE']; break; case 'IMSSS:PRECONDITIONRULE': $cond_key = $key; $rule_conditions[$item_key][$cond_key]['rule_type'] = 0; break; case 'IMSSS:POSTCONDITIONRULE': $cond_key = $key; $rule_conditions[$item_key][$cond_key]['rule_type'] = 1; break; case 'IMSSS:EXITCONDITIONRULE': $cond_key = $key; $rule_conditions[$item_key][$cond_key]['rule_type'] = 2; break; case 'IMSSS:RULECONDITIONS': $rule_conditions[$item_key][$cond_key]['condition_combination'] = $value['attributes']['CONDITIONCOMBINATION']; break; case 'IMSSS:RULEACTION': $rule_conditions[$item_key][$cond_key]['rule_action'] = $value['attributes']['ACTION']; break; case 'IMSSS:RULECONDITION': $rule_condition[$cond_key][$key]['referenced_objective'] = $value['attributes']['REFERENCEDOBJECTIVE']; $rule_condition[$cond_key][$key]['measure_threshold'] = $value['attributes']['MEASURETHRESHOLD']; $rule_condition[$cond_key][$key]['operator'] = $value['attributes']['OPERATOR']; $rule_condition[$cond_key][$key]['condition'] = $value['attributes']['CONDITION']; break; case 'IMSSS:PRIMARYOBJECTIVE': $obj_key = $key; $objective_ID = $value['attributes']['OBJECTIVEID']; $objective[$item_key][$obj_key]['is_primary'] = '1'; $objective[$item_key][$obj_key]['satisfied_by_measure'] = $value['attributes']['SATISFIEDBYMEASURE']; /* if($objective_ID == '') { $objective_ID = 'empty_obj_id'; } */ $objective[$item_key][$obj_key]['objective_ID'] = $objective_ID; //pr($objective); break; case 'IMSSS:OBJECTIVE': $obj_key = $key; $objective_ID = $value['attributes']['OBJECTIVEID']; $objective[$item_key][$obj_key]['is_primary'] = '0'; $objective[$item_key][$obj_key]['satisfied_by_measure'] = $value['attributes']['SATISFIEDBYMEASURE']; $objective[$item_key][$obj_key]['objective_ID'] = $value['attributes']['OBJECTIVEID']; break; case 'IMSSS:MINNORMALIZEDMEASURE': $objective[$item_key][$obj_key]['min_normalized_measure'] = $value['value']; break; case 'IMSSS:MAPINFO': $map_info[$item_key][$key]['objective_ID'] = $objective_ID; $map_info[$item_key][$key]['target_objective_ID'] = $value['attributes']['TARGETOBJECTIVEID']; $map_info[$item_key][$key]['read_satisfied_status'] = $value['attributes']['READSATISFIEDSTATUS']; $map_info[$item_key][$key]['read_normalized_measure'] = $value['attributes']['READNORMALIZEDMEASURE']; $map_info[$item_key][$key]['write_satisfied_status'] = $value['attributes']['WRITESATISFIEDSTATUS']; $map_info[$item_key][$key]['write_normalized_measure'] = $value['attributes']['WRITENORMALIZEDMEASURE']; break; case 'ADLSEQ:OBJECTIVE': $objective_ID = $value['attributes']['OBJECTIVEID']; break; case 'ADLSEQ:MAPINFO': $adl_seq_map_info[$item_key][$key]['objective_ID'] = $objective_ID; $adl_seq_map_info[$item_key][$key]['target_objective_ID'] = $value['attributes']['TARGETOBJECTIVEID']; $adl_seq_map_info[$item_key][$key]['read_raw_score'] = $value['attributes']['READRAWSCORE']; $adl_seq_map_info[$item_key][$key]['read_min_score'] = $value['attributes']['READMINSCORE']; $adl_seq_map_info[$item_key][$key]['read_max_score'] = $value['attributes']['READMAXSCORE']; $adl_seq_map_info[$item_key][$key]['read_completion_status'] = $value['attributes']['READCOMPLETIONSTATUS']; $adl_seq_map_info[$item_key][$key]['read_progress_measure'] = $value['attributes']['READPROGRESSMEASURE']; $adl_seq_map_info[$item_key][$key]['write_raw_score'] = $value['attributes']['WRITERAWSCORE']; $adl_seq_map_info[$item_key][$key]['write_min_score'] = $value['attributes']['WRITEMINSCORE']; $adl_seq_map_info[$item_key][$key]['write_max_score'] = $value['attributes']['WRITEMAXSCORE']; $adl_seq_map_info[$item_key][$key]['write_completion_status'] = $value['attributes']['WRITECOMPLETIONSTATUS']; $adl_seq_map_info[$item_key][$key]['write_progress_measure'] = $value['attributes']['WRITEPROGRESSMEASURE']; break; case 'IMSSS:ROLLUPRULE': $rollup_rule_key = $key; $rollup_rules[$item_key][$key]['child_activity_set'] = $value['attributes']['CHILDACTIVITYSET']; $rollup_rules[$item_key][$key]['minimum_count'] = $value['attributes']['MINIMUMCOUNT']; $rollup_rules[$item_key][$key]['minimum_percent'] = $value['attributes']['MINIMUMPERCENT']; $rollup_rules[$item_key][$key]['action'] = $value['attributes']['ACTION']; break; case 'IMSSS:ROLLUPCONDITIONS': $rollup_rules[$item_key][$rollup_rule_key]['condition_combination'] = $value['attributes']['CONDITIONCOMBINATION']; break; case 'IMSSS:ROLLUPACTION': $rollup_rules[$item_key][$rollup_rule_key]['rule_action'] = $value['attributes']['ACTION']; break; case 'IMSSS:ROLLUPCONDITION': $rollup_rule_conditions[$rollup_rule_key][$key]['operator'] = $value['attributes']['OPERATOR']; $rollup_rule_conditions[$rollup_rule_key][$key]['condition'] = $value['attributes']['CONDITION']; break; case 'ADLNAV:PRESENTATION': $item_key = $value['parent_index']; break; case 'ADLNAV:HIDELMSUI': $hide_lms_ui[$item_key][$value['value']] = 'true'; break; case 'IMSSS:CONTROLMODE': $control_mode[$item_key][$key]['choice'] = $value['attributes']['CHOICE']; $control_mode[$item_key][$key]['choice_exit'] = $value['attributes']['CHOICEEXIT']; $control_mode[$item_key][$key]['flow'] = $value['attributes']['FLOW']; $control_mode[$item_key][$key]['forward_only'] = $value['attributes']['FORWARDONLY']; $control_mode[$item_key][$key]['use_current_attempt_objective_info'] = $value['attributes']['USECURRENTATTEMPTOBJECTIVEINFO']; $control_mode[$item_key][$key]['use_current_attempt_progress_info'] = $value['attributes']['USECURRENTATTEMPTPROGRESSINFO']; break; case 'ADLSEQ:CONSTRAINEDCHOICECONSIDERATIONS': $constrained_choice[$item_key]['prevent_activation'] = $value['attributes']['PREVENTACTIVATION']; $constrained_choice[$item_key]['constrain_choice'] = $value['attributes']['CONSTRAINCHOICE']; break; case 'IMSSS:DELIVERYCONTROLS': $delivery_controls[$item_key][$key]['objective_set_by_content'] = $value['attributes']['OBJECTIVESETBYCONTENT']; $delivery_controls[$item_key][$key]['completion_set_by_content'] = $value['attributes']['COMPLETIONSETBYCONTENT']; $delivery_controls[$item_key][$key]['tracked'] = $value['attributes']['TRACKED']; break; case 'ADLCP:MAP': $maps[$item_key][$key]['target_ID'] = $value['attributes']['TARGETID']; $maps[$item_key][$key]['read_shared_data'] = $value['attributes']['READSHAREDDATA']; $maps[$item_key][$key]['write_shared_data'] = $value['attributes']['WRITESHAREDDATA']; break; default: break; } } // exit(); if (G_VERSIONTYPE != 'community') { #cpp#ifndef COMMUNITY if (G_VERSIONTYPE != 'standard') { #cpp#ifndef STANDARD if ($scorm2004) { foreach ($references as $key => $value) { $ref = array_search($value['IDENTIFIERREF'], $resources); if ($ref !== false && !is_null($ref)) { /*SCORM 2004: The xml:base attribute provides a relative path offset for the content file(s) contained in the manifest*/ $path_offset = $tagArray[$ref]['attributes']['XML:BASE']; $data = file_get_contents($scormPath . "/" . $path_offset . $tagArray[$ref]['attributes']['HREF']); $primitive_hrefs[$ref] = str_replace("\\", "/", $path_offset . $tagArray[$ref]['attributes']['HREF']); $path_part[$ref] = dirname($primitive_hrefs[$ref]); foreach ($tagArray[$ref]['children'] as $value2) { if ($tagArray[$value2]['tag'] == 'DEPENDENCY') { $idx = array_search($tagArray[$value2]['attributes']['IDENTIFIERREF'], $resources); foreach ($tagArray[$idx]['children'] as $value3) { if ($tagArray[$value3]['tag'] == 'FILE') { $data = preg_replace("#(\\.\\.\\/(\\w+\\/)*)?" . $tagArray[$value3]['attributes']['HREF'] . "#", $currentLesson->getDirectory() . "/" . $scormFolderName . '/' . $path_part[$ref] . "/\$1" . $tagArray[$value3]['attributes']['HREF'], $data); } } } } //$total_fields[$key]['data'] = eF_postProcess(str_replace("'","'",$data)); //$total_fields$adl_seq_map_info[$item_key][$key]['target_objective_ID'[$key]['data'] = '<iframe height = "100%" width = "100%" frameborder = "no" name = "scormFrameName" id = "scormFrameID" src = "'.G_RELATIVELESSONSLINK.$lessons_ID."/".$scormFolderName.'/'.$primitive_hrefs[$ref]. $value['PARAMETERS']. '" onload = "eF_js_setCorrectIframeSize()"></iframe><iframe name = "commitFrame" frameborder = "no" id = "commitFrame" width = "1" height = "1" style = "display:none"></iframe>'; // // // if ($parameters['embed_type'] == 'iframe') { $total_fields[$key]['data'] = '<iframe ' . $parameters['iframe_parameters'] . ' name = "scormFrameName" id = "scormFrameID" src = "' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . $scormFolderName . '/' . $primitive_hrefs[$ref] . $value['PARAMETERS'] . '" onload = "if (window.eF_js_setCorrectIframeSize) {eF_js_setCorrectIframeSize();} else {setIframeSize = true;}"></iframe>'; } else { $total_fields[$key]['data'] = ' <div style = "text-align:center;height:300px"> <span>##CLICKTOSTARTUNIT##</span><br/> <input type = "button" value = "##STARTUNIT##" class = "flatButton" onclick = \'window.open("' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . rawurlencode($scormFolderName) . '/' . rawurlencode($primitive_hrefs[$ref]) . $value['PARAMETERS'] . '", "scormFrameName", "' . $parameters['popup_parameters'] . '")\' > </div>'; } /* $total_fields[$key]['data'] = ' <style> iframe.scormCommitFrame{width:100%;height:500px;border:1px solid red;} </style> <iframe name = "scormFrameName" id = "scormFrameID" class = "scormFrame" src = "'.$currentLesson -> getDirectoryUrl()."/".$scormFolderName.'/'.$primitive_hrefs[$ref]. $value['PARAMETERS']. '" onload = "eF_js_setCorrectIframeSize()"></iframe> <iframe name = "commitFrame" id = "commitFrame" class = "scormCommitFrame">Sorry, but your browser needs to support iframes to see this</iframe>'; */ } } $lastUnit = $currentContent->getLastNode(); $lastUnit ? $this_id = $lastUnit['id'] : ($this_id = 0); //$this_id = $tree[sizeof($tree) - 1]['id']; foreach ($total_fields as $key => $value) { if (isset($value['ctg_type'])) { $total_fields[$key]['previous_content_ID'] = $this_id; if (!isset($total_fields[$key]['parent_content_ID'])) { $total_fields[$key]['parent_content_ID'] = 0; } $total_fields[$key]['options'] = serialize(array('hide_navigation' => 1, 'complete_unit_setting' => EfrontUnit::COMPLETION_OPTIONS_HIDECOMPLETEUNITICON)); $this_id = eF_insertTableData("content", $total_fields[$key]); //we want to have entry at scorm data even if all values are null $fields_insert[$this_id]['content_ID'] = $this_id; if (!empty($organizations[$key])) { $organization_content_ID = $this_id; $fields_insert1 = array(); $fields_insert1['content_ID'] = $this_id; $fields_insert1['lessons_ID'] = $lessons_ID; $fields_insert1['organization_ID'] = $organizations[$key]['id']; $fields_insert1['structure'] = $organizations[$key]['structure'] ? $organizations[$key]['structure'] : 'hierarchical'; $fields_insert1['objectives_global_to_system'] = $organizations[$key]['objectives_global_to_system'] ? $organizations[$key]['objectives_global_to_system'] : 'true'; $fields_insert1['shared_data_global_to_system'] = $organizations[$key]['shared_data_global_to_system'] ? $organizations[$key]['shared_data_global_to_system'] : 'true'; eF_insertTableData("scorm_sequencing_organizations", $fields_insert1); } eF_insertTableData("scorm_sequencing_content_to_organization", array('lessons_ID' => $lessons_ID, 'content_ID' => $this_id, 'organization_content_ID' => $organization_content_ID)); $fields_insert1 = array(); foreach ($rule_conditions[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['condition_combination'] = $value1['condition_combination'] ? $value1['condition_combination'] : 'all'; $fields_insert1['rule_action'] = $value1['rule_action']; $scorm_sequencing_rules_ID = eF_insertTableData("scorm_sequencing_rules", $fields_insert1); $fields_insert2 = array(); foreach ($rule_condition[$key1] as $key2 => $value2) { $fields_insert2['scorm_sequencing_rules_ID'] = $scorm_sequencing_rules_ID; $fields_insert2['referenced_objective'] = EfrontContentTreeSCORM::form_id($value2['referenced_objective']); $fields_insert2['measure_threshold'] = $value2['measure_threshold']; $fields_insert2['operator'] = $value2['operator']; $fields_insert2['rule_condition'] = $value2['condition']; eF_insertTableData("scorm_sequencing_rule", $fields_insert2); } } $fields_insert1 = array(); $primary_found = false; //to do foreach ($objective[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['objective_ID'] = EfrontContentTreeSCORM::form_id($value1['objective_ID']); $fields_insert1['is_primary'] = $value1['is_primary']; $fields_insert1['satisfied_by_measure'] = $value1['satisfied_by_measure'] ? $value1['satisfied_by_measure'] : 'false'; $fields_insert1['min_normalized_measure'] = $value1['min_normalized_measure'] ? $value1['min_normalized_measure'] : '1.0'; if ($value1['is_primary'] == 1) { $primary_found = true; } $scorm_sequencing_objectives_ID = eF_insertTableData("scorm_sequencing_objectives", $fields_insert1); } //IMSSS:Each activity must have one, and only one, objective that contributes to rollup. $fields_insert1 = array(); if (!$primary_found) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['is_primary'] = '1'; $fields_insert1['satisfied_by_measure'] = 'false'; $fields_insert1['objective_ID'] = ''; $fields_insert1['min_normalized_measure'] = '1'; eF_insertTableData("scorm_sequencing_objectives", $fields_insert1); } $shared_objectives = array(); $fields_insert1 = array(); foreach ($map_info[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['objective_ID'] = EfrontContentTreeSCORM::form_id($value1['objective_ID']); $fields_insert1['target_objective_ID'] = EfrontContentTreeSCORM::form_id($value1['target_objective_ID']); $fields_insert1['read_satisfied_status'] = $value1['read_satisfied_status'] ? $value1['read_satisfied_status'] : 'true'; $fields_insert1['read_normalized_measure'] = $value1['read_normalized_measure'] ? $value1['read_normalized_measure'] : 'true'; $fields_insert1['write_satisfied_status'] = $value1['write_satisfied_status'] ? $value1['write_satisfied_status'] : 'false'; $fields_insert1['write_normalized_measure'] = $value1['write_normalized_measure'] ? $value1['write_normalized_measure'] : 'false'; $shared_objective[] = EfrontContentTreeSCORM::form_id($value1['target_objective_ID']); eF_insertTableData("scorm_sequencing_map_info", $fields_insert1); } $fields_insert1 = array(); foreach ($adl_seq_map_info[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['lessons_ID'] = $_SESSION['s_lessons_ID']; $fields_insert1['objective_ID'] = EfrontContentTreeSCORM::form_id($value1['objective_ID']); $fields_insert1['target_objective_ID'] = EfrontContentTreeSCORM::form_id($value1['target_objective_ID']); $fields_insert1['read_raw_score'] = $value1['read_raw_score'] ? $value1['read_raw_score'] : 'true'; $fields_insert1['read_min_score'] = $value1['read_min_score'] ? $value1['read_min_score'] : 'true'; $fields_insert1['read_max_score'] = $value1['read_max_score'] ? $value1['read_max_score'] : 'true'; $fields_insert1['read_completion_status'] = $value1['read_completion_status'] ? $value1['read_completion_status'] : 'true'; $fields_insert1['read_progress_measure'] = $value1['read_progress_measure'] ? $value1['read_progress_measure'] : 'true'; $fields_insert1['write_raw_score'] = $value1['write_raw_score'] ? $value1['write_raw_score'] : 'false'; $fields_insert1['write_min_score'] = $value1['write_min_score'] ? $value1['write_min_score'] : 'false'; $fields_insert1['write_max_score'] = $value1['write_max_score'] ? $value1['write_max_score'] : 'false'; $fields_insert1['write_completion_status'] = $value1['write_completion_status'] ? $value1['write_completion_status'] : 'false'; $fields_insert1['write_progress_measure'] = $value1['write_progress_measure'] ? $value1['write_progress_measure'] : 'false'; $shared_objective[] = EfrontContentTreeSCORM::form_id($value1['target_objective_ID']); eF_insertTableData("scorm_sequencing_adlseq_map_info", $fields_insert1); } $fields_insert1 = array(); $default_activity_flag = true; $default_objective_flag = true; foreach ($rollup_rules[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['child_activity_set'] = $value1['child_activity_set'] ? $value1['child_activity_set'] : 'all'; $fields_insert1['minimum_count'] = $value1['minimum_count'] ? $value1['minimum_count'] : '0'; $fields_insert1['minimum_percent'] = $value1['minimum_percent'] ? $value1['minimum_percent'] : '0.0000'; $fields_insert1['condition_combination'] = $value1['condition_combination'] ? $value1['condition_combination'] : 'any'; $fields_insert1['rule_action'] = $value1['rule_action']; $scorm_sequencing_rollup_rules_ID = eF_insertTableData("scorm_sequencing_rollup_rules", $fields_insert1); if (in_array($fields_insert1['rule_action'], array('completed', 'incomplete'))) { $default_activity_flag = false; } if (in_array($fields_insert1['rule_action'], array('satisfied', 'notSatisfied'))) { $default_objective_flag = false; } $fields_insert2 = array(); foreach ($rollup_rule_conditions[$key1] as $key2 => $value2) { $fields_insert2['scorm_sequencing_rollup_rules_ID'] = $scorm_sequencing_rollup_rules_ID; $fields_insert2['operator'] = $value2['operator']; $fields_insert2['rule_condition'] = $value2['condition']; eF_insertTableData("scorm_sequencing_rollup_rule", $fields_insert2); } } $default_activity_flag = false; //Default activity rollup rules if ($default_activity_flag) { $rollup_rules_satisfied = array('content_ID' => $this_id, 'child_activity_set' => 'all', 'rule_action' => 'completed', 'minimum_count' => '0', 'minimum_percent' => '0', 'condition_combination' => 'any'); ${$rollup_rule_satisfied} = array('scorm_sequencing_rollup_rules_ID' => $rollup_rule_ID, 'rule_condition' => 'completed'); //eF_insertTableData("scorm_sequencing_rollup_rule", $rollup_rule_satisfied); $rollup_rules_not_satisfied = array('content_ID' => $this_id, 'child_activity_set' => 'all', 'rule_action' => 'incomplete', 'minimum_count' => '0', 'minimum_percent' => '0', 'condition_combination' => 'any'); //$rollup_rule_ID = eF_insertTableData("scorm_sequencing_rollup_rules", $rollup_rules_not_satisfied); $rollup_rule_not_satisfied = array('scorm_sequencing_rollup_rules_ID' => $rollup_rule_ID, 'rule_condition' => 'activityProgressKnown'); //eF_insertTableData("scorm_sequencing_rollup_rule", $rollup_rule_not_satisfied); } $default_objective_flag = false; //Default objective rollup rules if ($default_objective_flag) { $rollup_rules_satisfied = array('content_ID' => $this_id, 'child_activity_set' => 'all', 'rule_action' => 'satisfied', 'minimum_count' => '0', 'minimum_percent' => '0', 'condition_combination' => 'any'); //$rollup_rule_ID = eF_insertTableData("scorm_sequencing_rollup_rules", $rollup_rules_satisfied); $rollup_rule_satisfied = array('scorm_sequencing_rollup_rules_ID' => $rollup_rule_ID, 'rule_condition' => 'satisfied'); //eF_insertTableData("scorm_sequencing_rollup_rule", $rollup_rule_satisfied); $rollup_rules_not_satisfied = array('content_ID' => $this_id, 'child_activity_set' => 'all', 'rule_action' => 'notSatisfied', 'minimum_count' => '0', 'minimum_percent' => '0', 'condition_combination' => 'any'); //$rollup_rule_ID = eF_insertTableData("scorm_sequencing_rollup_rules", $rollup_rules_not_satisfied); $rollup_rule_not_satisfied = array('scorm_sequencing_rollup_rules_ID' => $rollup_rule_ID, 'rule_condition' => 'objectiveStatusKnown'); //eF_insertTableData("scorm_sequencing_rollup_rule", $rollup_rule_not_satisfied); } //pr($constrained_choice[$key]); $fields_insert1 = array(); if ($constrained_choice[$key]) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['prevent_activation'] = $constrained_choice[$key]['prevent_activation'] ? $constrained_choice[$key]['prevent_activation'] : 'false'; $fields_insert1['constrain_choice'] = $constrained_choice[$key]['constrain_choice'] ? $constrained_choice[$key]['constrain_choice'] : 'false'; eF_insertTableData("scorm_sequencing_constrained_choice", $fields_insert1); } if (empty($control_mode[$key])) { $control_mode[$key][0]['choice'] = 'true'; $control_mode[$key][0]['choice_exit'] = 'true'; $control_mode[$key][0]['flow'] = 'false'; $control_mode[$key][0]['forward_only'] = 'false'; $control_mode[$key][0]['use_current_attempt_objective_info'] = 'true'; $control_mode[$key][0]['use_current_attempt_progress_info'] = 'true'; } //echo $key; //pr($control_mode); $fields_insert1 = array(); foreach ($control_mode[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['choice'] = $value1['choice'] ? $value1['choice'] : 'true'; $fields_insert1['choice_exit'] = $value1['choice_exit'] ? $value1['choice_exit'] : 'true'; $fields_insert1['flow'] = $value1['flow'] ? $value1['flow'] : 'false'; $fields_insert1['forward_only'] = $value1['forward_only'] ? $value1['forward_only'] : 'false'; $fields_insert1['use_current_attempt_objective_info'] = $value1['use_current_attempt_objective_info'] ? $value1['use_current_attempt_objective_info'] : 'true'; $fields_insert1['use_current_attempt_progress_info'] = $value1['use_current_attempt_progress_info'] ? $value1['use_current_attempt_progress_info'] : 'true'; eF_insertTableData("scorm_sequencing_control_mode", $fields_insert1); } if (empty($delivery_controls[$key])) { $delivery_controls[$key][0]['objective_set_by_content'] = 'false'; $delivery_controls[$key][0]['completion_set_by_content'] = 'false'; $delivery_controls[$key][0]['tracked'] = 'true'; } $fields_insert1 = array(); foreach ($delivery_controls[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['objective_set_by_content'] = $value1['objective_set_by_content'] ? $value1['objective_set_by_content'] : 'false'; $fields_insert1['completion_set_by_content'] = $value1['completion_set_by_content'] ? $value1['completion_set_by_content'] : 'false'; $fields_insert1['tracked'] = $value1['tracked'] ? $value1['tracked'] : 'true'; eF_insertTableData("scorm_sequencing_delivery_controls", $fields_insert1); } $fields_insert1 = array(); foreach ($maps[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['target_ID'] = $value1['target_ID']; $fields_insert1['read_shared_data'] = $value1['read_shared_data'] ? $value1['read_shared_data'] : 'true'; $fields_insert1['write_shared_data'] = $value1['write_shared_data'] ? $value1['write_shared_data'] : 'true'; eF_insertTableData("scorm_sequencing_maps", $fields_insert1); } $fields_insert1 = array(); foreach ($limit_conditions[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['attempt_limit'] = $value1['attempt_limit']; $fields_insert1['attempt_absolute_duration_limit'] = $value1['attempt_absolute_duration_limit']; eF_insertTableData("scorm_sequencing_limit_conditions", $fields_insert1); } if (empty($completion_threshold[$key])) { $completion_threshold[$key][0]['completed_by_measure'] = 'false'; $completion_threshold[$key][0]['min_progress_measure'] = '1.0'; $completion_threshold[$key][0]['progress_weight'] = '1.0'; } $fields_insert1 = array(); foreach ($completion_threshold[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['completed_by_measure'] = $value1['completed_by_measure'] ? $value1['completed_by_measure'] : 'false'; $fields_insert1['min_progress_measure'] = $value1['min_progress_measure'] ? $value1['min_progress_measure'] : '1.0'; $fields_insert1['progress_weight'] = $value1['progress_weight'] ? $value1['progress_weight'] : '1.0'; eF_insertTableData("scorm_sequencing_completion_threshold", $fields_insert1); } if (empty($rollup_considerations[$key])) { $rollup_considerations[$key][0]['required_for_satisfied'] = 'always'; $rollup_considerations[$key][0]['required_for_not_satisfied'] = 'always'; $rollup_considerations[$key][0]['required_for_completed'] = 'always'; $rollup_considerations[$key][0]['required_for_incomplete'] = 'always'; $rollup_considerations[$key][0]['measure_satisfaction_if_active'] = 'true'; } $fields_insert1 = array(); foreach ($rollup_considerations[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['required_for_satisfied'] = $value1['required_for_satisfied'] ? $value1['required_for_satisfied'] : 'always'; $fields_insert1['required_for_not_satisfied'] = $value1['required_for_not_satisfied'] ? $value1['required_for_not_satisfied'] : 'always'; $fields_insert1['required_for_completed'] = $value1['required_for_completed'] ? $value1['required_for_completed'] : 'always'; $fields_insert1['required_for_incomplete'] = $value1['required_for_incomplete'] ? $value1['required_for_incomplete'] : 'always'; $fields_insert1['measure_satisfaction_if_active'] = $value1['measure_satisfaction_if_active'] ? $value1['measure_satisfaction_if_active'] : 'true'; eF_insertTableData("scorm_sequencing_rollup_considerations", $fields_insert1); } if (empty($rollup_controls[$key])) { $rollup_controls[$key][0]['rollup_objective_satisfied'] = 'true'; $rollup_controls[$key][0]['rollup_objective_measure_weight'] = '1.0'; $rollup_controls[$key][0]['rollup_progress_completion'] = 'true'; } $fields_insert1 = array(); foreach ($rollup_controls[$key] as $key1 => $value1) { $fields_insert1['content_ID'] = $this_id; $fields_insert1['rollup_objective_satisfied'] = $value1['rollup_objective_satisfied'] ? $value1['rollup_objective_satisfied'] : 'true'; $fields_insert1['rollup_objective_measure_weight'] = $value1['rollup_objective_measure_weight'] ? $value1['rollup_objective_measure_weight'] : '1.0'; $fields_insert1['rollup_progress_completion'] = $value1['rollup_progress_completion'] ? $value1['rollup_progress_completion'] : 'true'; eF_insertTableData("scorm_sequencing_rollup_controls", $fields_insert1); } $fields_insert1 = array(); foreach ($control_mode[$tagArray[$key]['parent_index']] as $key1 => $value1) { $hide_lms_ui[$key]['choice'] = $value1['choice']; } $fields_insert1[$key]['content_ID'] = $this_id; $fields_insert1[$key]['options'] = serialize($hide_lms_ui[$key]); eF_insertTableData("scorm_sequencing_hide_lms_ui", $fields_insert1[$key]); $tagArray[$key]['this_id'] = $this_id; foreach ($tagArray[$key]['children'] as $key2 => $value2) { if (isset($total_fields[$value2])) { $total_fields[$value2]['parent_content_ID'] = $this_id; } } } else { unset($total_fields[$key]); } } /* $fields_insert1 = array(); foreach (array_unique($shared_objective) as $key1=>$value1) { //$fields_insert1['lessons_ID'] = $_SESSION['s_lessons_ID']; $fields_insert1['content_ID'] = 0; $fields_insert1['is_primary'] = '1'; $fields_insert1['satisfied_by_measure'] = 'false'; $fields_insert1['objective_ID'] = EfrontContentTreeSCORM :: form_id($value1); $fields_insert1['min_normalized_measure'] = '1'; eF_insertTableData("scorm_sequencing_objectives", $fields_insert1); }*/ //$directory = new EfrontDirectory(G_SCORMPATH); //$directory -> copy(EfrontDirectory :: normalize($currentLesson -> getDirectory()).'/'.$scormFolderName, true); //foreach ($files as $key => $value) { //$newhref = $tagArray[$tagArray[$key]['parent_index']]['attributes']['XML:BASE']; //copy(G_SCORMPATH."/".rtrim($newhref,"/")."/".rtrim($value,"/"), rtrim($currentLesson -> getDirectory(), "/")."/$this_id/".rtrim($newhref,"/")."/".rtrim($value,"/")); //$this_id is put here so we can be sure that the files are put in a unique folder //} foreach ($timelimitaction as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['timelimitaction'] = $value; } foreach ($maxtimeallowed as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['maxtimeallowed'] = $value; } foreach ($masteryscore as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['masteryscore'] = $value; } foreach ($datafromlms as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['datafromlms'] = $value; } foreach ($fields_insert as $key => $value) { eF_insertTableData("scorm_data_2004", $value); if (isset($value['masteryscore']) && $value['masteryscore']) { eF_updateTableData("content", array("ctg_type" => "scorm_test"), "id=" . $value['content_ID']); } } foreach ($prerequisites as $key => $value) { foreach ($tagArray as $key2 => $value2) { if (isset($value2['attributes']['IDENTIFIER']) && $value2['attributes']['IDENTIFIER'] == $value) { unset($fields_insert); $fields_insert['users_LOGIN'] = "******"; $fields_insert['content_ID'] = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert['rule_type'] = "hasnot_seen"; $fields_insert['rule_content_ID'] = $value2['this_id']; $fields_insert['rule_option'] = 0; eF_insertTableData("rules", $fields_insert); } } } } } #cpp#endif } #cpp#endif if (!$scorm2004) { foreach ($references as $key => $value) { //$ref = array_search($value, $resources); $ref = array_search($value['IDENTIFIERREF'], $resources); if ($ref !== false && !is_null($ref)) { $data = file_get_contents($scormPath . "/" . $tagArray[$ref]['attributes']['HREF']); $primitive_hrefs[$ref] = str_replace("\\", "/", $tagArray[$ref]['attributes']['HREF']); $path_part[$ref] = dirname($primitive_hrefs[$ref]); foreach ($tagArray[$ref]['children'] as $value2) { if ($tagArray[$value2]['tag'] == 'DEPENDENCY') { $idx = array_search($tagArray[$value2]['attributes']['IDENTIFIERREF'], $resources); foreach ($tagArray[$idx]['children'] as $value3) { if ($tagArray[$value3]['tag'] == 'FILE') { $data = preg_replace("#(\\.\\.\\/(\\w+\\/)*)?" . $tagArray[$value3]['attributes']['HREF'] . "#", $currentLesson->getDirectory() . "/" . $scormFolderName . '/' . $path_part[$ref] . "/\$1" . $tagArray[$value3]['attributes']['HREF'], $data); } } } } //$total_fields[$key]['data'] = eF_postProcess(str_replace("'","'",$data)); if ($parameters['embed_type'] == 'iframe') { //$total_fields[$key]['data'] = '<iframe height = "100%" width = "100%" frameborder = "no" name = "scormFrameName" id = "scormFrameID" src = "'.$currentLesson -> getDirectoryUrl()."/".$scormFolderName.'/'.$primitive_hrefs[$ref].'" onload = "if (window.eF_js_setCorrectIframeSize) {eF_js_setCorrectIframeSize();} else {setIframeSize = true;}"></iframe>'; $total_fields[$key]['data'] = '<iframe ' . $parameters['iframe_parameters'] . ' name = "scormFrameName" id = "scormFrameID" src = "' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . $scormFolderName . '/' . $primitive_hrefs[$ref] . $value['PARAMETERS'] . '" onload = "if (window.eF_js_setCorrectIframeSize) {eF_js_setCorrectIframeSize();} else {setIframeSize = true;}"></iframe>'; } else { $total_fields[$key]['data'] = ' <div style = "text-align:center;height:300px"> <span>##CLICKTOSTARTUNIT##</span><br/> <input type = "button" value = "##STARTUNIT##" class = "flatButton" onclick = \'window.open("' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . rawurlencode($scormFolderName) . '/' . rawurlencode($primitive_hrefs[$ref]) . $value['PARAMETERS'] . '", "scormFrameName", "' . $parameters['popup_parameters'] . '")\' > </div>'; } } } $lastUnit = $currentContent->getLastNode(); $lastUnit ? $this_id = $lastUnit['id'] : ($this_id = 0); //$this_id = $tree[sizeof($tree) - 1]['id']; foreach ($total_fields as $key => $value) { if (isset($value['ctg_type'])) { $total_fields[$key]['previous_content_ID'] = $this_id; if (!isset($total_fields[$key]['parent_content_ID'])) { $total_fields[$key]['parent_content_ID'] = 0; } $total_fields[$key]['options'] = serialize(array('complete_unit_setting' => EfrontUnit::COMPLETION_OPTIONS_HIDECOMPLETEUNITICON)); $this_id = eF_insertTableData("content", $total_fields[$key]); $tagArray[$key]['this_id'] = $this_id; foreach ($tagArray[$key]['children'] as $key2 => $value2) { if (isset($total_fields[$value2])) { $total_fields[$value2]['parent_content_ID'] = $this_id; } } } else { unset($total_fields[$key]); } } //$directory = new EfrontDirectory(G_SCORMPATH); //$directory -> copy(EfrontDirectory :: normalize($currentLesson -> getDirectory()).'/'.$scormFolderName, true); //foreach ($files as $key => $value) { //$newhref = $tagArray[$tagArray[$key]['parent_index']]['attributes']['XML:BASE']; //copy(G_SCORMPATH."/".rtrim($newhref,"/")."/".rtrim($value,"/"), rtrim($currentLesson -> getDirectory(), "/")."/$this_id/".rtrim($newhref,"/")."/".rtrim($value,"/")); //$this_id is put here so we can be sure that the files are put in a unique folder //} foreach ($timelimitaction as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['timelimitaction'] = $value; } foreach ($maxtimeallowed as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['maxtimeallowed'] = $value; } foreach ($masteryscore as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['masteryscore'] = $value; } foreach ($datafromlms as $key => $value) { $content_ID = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert[$content_ID]['content_ID'] = $content_ID; $fields_insert[$content_ID]['datafromlms'] = $value; } foreach ($fields_insert as $key => $value) { eF_insertTableData("scorm_data", $value); if (isset($value['masteryscore']) && $value['masteryscore']) { eF_updateTableData("content", array("ctg_type" => "scorm_test"), "id=" . $value['content_ID']); } } foreach ($prerequisites as $key => $parts) { foreach (explode("&", $parts) as $value) { foreach ($tagArray as $key2 => $value2) { if (isset($value2['attributes']['IDENTIFIERREF']) && $value2['attributes']['IDENTIFIERREF'] == $value) { //pr($value2); unset($fields_insert); $fields_insert['users_LOGIN'] = "******"; $fields_insert['content_ID'] = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert['rule_type'] = "hasnot_seen"; $fields_insert['rule_content_ID'] = $value2['this_id']; $fields_insert['rule_option'] = 0; eF_insertTableData("rules", $fields_insert); } } } } } //exit; EfrontCache::getInstance()->deleteCache("content_tree:{$lesson->lesson['id']}"); }
function replaceQuestionPaths($data, $sourceId, $newId) { //$data = $question['text']; preg_match_all("/view_file\\.php\\?file=(\\d+)/", $data, $matchesId); $filesId = $matchesId[1]; preg_match_all("#(" . G_SERVERNAME . ")*content/lessons/(.*)\"#U", $data, $matchesPath); $filesPath = $matchesPath[2]; foreach ($filesId as $file) { $files[] = $file; } foreach ($filesPath as $file) { $files[] = G_LESSONSPATH . html_entity_decode($file); } $lesson = new EfrontLesson($newId); //$data = $unit -> offsetGet('data'); foreach ($files as $file) { try { $sourceFile = new EfrontFile($file); $sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']); $position = strpos($sourceFileOffset, "/"); //check case that the file is in a subfolder of the lesson if ($position !== false) { $sourceLink = mb_substr($sourceFileOffset, $position + 1); mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true); $destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']); $copiedFile = $sourceFile->copy($lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']), false); } else { $destinationPath = $lesson->getDirectory() . basename($sourceFile['path']); $copiedFile = $sourceFile->copy($lesson->getDirectory() . basename($sourceFile['path']), false); } str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data); $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data); } catch (EfrontFileException $e) { if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) { $copiedFile = new EfrontFile($destinationPath); str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data); $data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data, -1, $count); } } //this means that the file already exists } //$question['text'] = $data; return $data; }
/** * * @param unknown_type $file * @return unknown_type */ public static function import($lesson, $manifestFile, $scormFolderName, $parameters) { if ($lesson instanceof EfrontLesson) { $currentLesson = $lesson; } else { $currentLesson = new EfrontLesson($lesson); } $lessons_ID = $currentLesson->lesson['id']; $currentContent = new EfrontContentTree($currentLesson); $manifestXML = file_get_contents($manifestFile['path']); $tagArray = EfrontIMS::parseManifest($manifestXML); /** * Now parse XML file as usual */ foreach ($tagArray as $key => $value) { $fields = array(); switch ($value['tag']) { case 'SCHEMAVERSION': $scormVersion = $value['value']; break; case 'TITLE': $cur = $value['parent_index']; $total_fields[$cur]['name'] = $value['value'] ? $value['value'] : " "; break; case 'ORGANIZATION': $item_key = $key; $total_fields[$key]['lessons_ID'] = $lessons_ID; $total_fields[$key]['timestamp'] = time(); $total_fields[$key]['ctg_type'] = 'theory'; $total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER']; $total_fields[$key]['active'] = !isset($value['attributes']['ISVISIBLE']) || $value['attributes']['ISVISIBLE'] == 'true' ? 1 : 0; break; case 'ITEM': $item_key = $key; $total_fields[$key]['lessons_ID'] = $lessons_ID; $total_fields[$key]['timestamp'] = time(); $total_fields[$key]['ctg_type'] = 'theory'; $total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER']; $total_fields[$key]['active'] = !isset($value['attributes']['ISVISIBLE']) || $value['attributes']['ISVISIBLE'] == 'true' ? 1 : 0; $references[$key]['IDENTIFIERREF'] = EfrontIMS::formID($value['attributes']['IDENTIFIERREF']); $references[$key]['PARAMETERS'] = $value['attributes']['PARAMETERS']; break; case 'RESOURCE': $resources[$key] = EfrontIMS::formID($value['attributes']['IDENTIFIER']); break; case 'FILE': $files[$key] = $value['attributes']['HREF']; break; default: break; } } foreach ($references as $key => $value) { $ref = array_search($value['IDENTIFIERREF'], $resources); if ($ref !== false && !is_null($ref)) { /*SCORM 2004: The xml:base attribute provides a relative path offset for the content file(s) contained in the manifest*/ $path_offset = $tagArray[$ref]['attributes']['XML:BASE']; if ($tagArray[$ref]['attributes']['TYPE'] == 'imswl_xmlv1p2') { foreach ($tagArray[$ref]['children'] as $node) { if ($tagArray[$node]['tag'] == 'FILE') { $href = $tagArray[$node]['attributes']['HREF']; //debug(); //pr($currentLesson -> getDirectory()."/".$scormFolderName."/".$path_offset.$href); $data = file_get_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . $href); file_put_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . dirname($href) . '/weblink.html', self::createWebLink($data)); $href = dirname($href) . '/weblink.html'; //exit; //pr($data);exit; } } } else { if (!$tagArray[$ref]['attributes']['HREF']) { foreach ($tagArray[$ref]['children'] as $node) { if ($tagArray[$node]['tag'] == 'FILE') { $href = $tagArray[$node]['attributes']['HREF']; } } } else { $href = $tagArray[$ref]['attributes']['HREF']; } } $data = file_get_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . $href); $primitive_hrefs[$ref] = $path_offset . $href; $path_part[$ref] = dirname($primitive_hrefs[$ref]); foreach ($tagArray[$ref]['children'] as $value2) { if ($tagArray[$value2]['tag'] == 'DEPENDENCY') { $idx = array_search($tagArray[$value2]['attributes']['IDENTIFIERREF'], $resources); foreach ($tagArray[$idx]['children'] as $value3) { if ($tagArray[$value3]['tag'] == 'FILE') { $data = preg_replace("#(\\.\\.\\/(\\w+\\/)*)?" . $tagArray[$value3]['attributes']['HREF'] . "#", $currentLesson->getDirectory() . "/" . $scormFolderName . '/' . $path_part[$ref] . "/\$1" . $tagArray[$value3]['attributes']['HREF'], $data); } } } } if ($parameters['embed_type'] == 'iframe') { $total_fields[$key]['data'] = '<iframe height = "100%" width = "100%" frameborder = "no" name = "scormFrameName" id = "scormFrameID" src = "' . $currentLesson->getDirectoryUrl() . "/" . $scormFolderName . '/' . $primitive_hrefs[$ref] . $value['PARAMETERS'] . '" onload = "if (window.eF_js_setCorrectIframeSize) eF_js_setCorrectIframeSize(); else setIframeSize = true;"></iframe>'; } else { $total_fields[$key]['data'] = ' <div style = "text-align:center;height:300px"> <span>##CLICKTOSTARTUNIT##</span><br/> <input type = "button" value = "##STARTUNIT##" class = "flatButton" onclick = \'window.open("' . $currentLesson->getDirectoryUrl() . "/" . $scormFolderName . '/' . $primitive_hrefs[$ref] . $value['PARAMETERS'] . '", "scormFrameName", "' . $parameters['popup_parameters'] . '")\' > </div>'; } } } //pr($tagArray);exit; $lastUnit = $currentContent->getLastNode(); $lastUnit ? $this_id = $lastUnit['id'] : ($this_id = 0); //$this_id = $tree[sizeof($tree) - 1]['id']; foreach ($total_fields as $key => $value) { if (isset($value['ctg_type']) && $value['name']) { $total_fields[$key]['previous_content_ID'] = $this_id; if (!isset($total_fields[$key]['parent_content_ID'])) { $total_fields[$key]['parent_content_ID'] = 0; } $this_id = eF_insertTableData("content", $total_fields[$key]); //we want to have entry at scorm data even if all values are null $fields_insert[$this_id]['content_ID'] = $this_id; $tagArray[$key]['this_id'] = $this_id; foreach ($tagArray[$key]['children'] as $key2 => $value2) { if (isset($total_fields[$value2])) { $total_fields[$value2]['parent_content_ID'] = $this_id; } } } else { unset($total_fields[$key]); } } //$directory = new EfrontDirectory(G_SCORMPATH); //$directory -> copy(EfrontDirectory :: normalize($currentLesson -> getDirectory()).'/'.$scormFolderName, true); //foreach ($files as $key => $value) { //$newhref = $tagArray[$tagArray[$key]['parent_index']]['attributes']['XML:BASE']; //copy(G_SCORMPATH."/".rtrim($newhref,"/")."/".rtrim($value,"/"), rtrim($currentLesson -> getDirectory(), "/")."/$this_id/".rtrim($newhref,"/")."/".rtrim($value,"/")); //$this_id is put here so we can be sure that the files are put in a unique folder //} foreach ($prerequisites as $key => $value) { foreach ($tagArray as $key2 => $value2) { if (isset($value2['attributes']['IDENTIFIER']) && $value2['attributes']['IDENTIFIER'] == $value) { unset($fields_insert); $fields_insert['users_LOGIN'] = "******"; $fields_insert['content_ID'] = $tagArray[$tagArray[$key]['parent_index']]['this_id']; $fields_insert['rule_type'] = "hasnot_seen"; $fields_insert['rule_content_ID'] = $value2['this_id']; $fields_insert['rule_option'] = 0; eF_insertTableData("rules", $fields_insert); } } } }