} catch (Exception $e) { $errors[] = $e->getMessage(); } } if ($_GET['cleanup'] != 'all') { if (!isset($errors)) { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=cleanup&message=" . urlencode(_SUCCESFULLYCLEANEDUPFOLDERS) . '&message_type=success'); } else { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=cleanup&message=" . urlencode(_THEFOLLOWINGFOLDERSCOULDNOTBEDELETED) . ': ' . implode(", ", $errors) . '&message_type=failure'); } } } if (isset($_GET['cleanup']) && ($_GET['cleanup'] == 'lessons_without_folders' || $_GET['cleanup'] == 'all')) { foreach ($orphan_lessons as $lesson_id) { try { $lesson = new EfrontLesson($lesson_id); $lesson->delete(); } catch (Exception $e) { $errors[] = $folder; } } if ($_GET['cleanup'] != 'all') { if (!isset($errors)) { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=cleanup&message=" . urlencode(_SUCCESFULLYCLEANEDUPLESSONS) . '&message_type=success'); } else { eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=maintenance&tab=cleanup&message=" . urlencode(_THEFOLLOWINGLESSONSCOULDNOTBEDELETED) . ': ' . implode(", ", $errors) . '&message_type=failure'); } } } if (isset($_GET['create']) && $_GET['create'] == 'user_folders') { foreach ($orphan_users as $login) {
$form->accept($renderer); $smarty->assign('T_CONTACT_FORM', $renderer->toArray()); } /* -------------------------------------------------------End of Contact part--------------------------------------------------------- */ /* -------------------------------------------------------Lesson information part--------------------------------------------------------- */ if (isset($_GET['ctg']) && $_GET['ctg'] == 'lesson_info') { //The user asked to display information on a lesson //session_start(); //Isn't needed here if the head session_start() is in place if (!$smarty->is_cached('index.tpl', $cacheId) || !$GLOBALS['configuration']['smarty_caching']) { include "directions_tree.php"; try { if (isset($_GET['lessons_ID'])) { if (isset($lessons[$_GET['lessons_ID']]) && $lessons[$_GET['lessons_ID']] instanceof EfrontLesson) { $smarty->assign("T_HAS_LESSON", $lessons[$_GET['lessons_ID']]->lesson['has_lesson']); } $lesson = new EfrontLesson($_GET['lessons_ID']); $lesson->lesson['price_string'] = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true); $lesson->lesson['num_students'] = sizeof($lesson->getStudentUsers()); $lesson->lesson['seats_remaining'] = $lesson->lesson['max_users'] - $lesson->lesson['num_students']; $lesson->lesson['seats_remaining'] >= 0 or $lesson->lesson['seats_remaining'] = 0; $smarty->assign("T_LESSON", $lesson); $lessonInformation = $lesson->getInformation(); $content = new EfrontContentTree($lesson); if (sizeof($content->tree) > 0) { $smarty->assign("T_CONTENT_TREE", $content->toHTML(false, 'dhtml_content_tree', array('noclick' => 1))); } $lessonInfo = new LearningObjectInformation(unserialize($lesson->lesson['info'])); $smarty->assign("T_LESSON_INFO", $lessonInfo); $additionalInfo = $lesson->getInformation(); $smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo); if ($lesson->lesson['course_only']) {
/** * Complete lesson * * This function is used to set the designated lesson's status * to 'completed' for the current user. * <br/>Example: * <code> * $user -> completeLesson(5, 87, 'Very good progress'); //Complete lesson with id 5 * </code> * * @param mixed $lesson Either the lesson id, or an EfrontLesson object * @param array $fields Extra fields containing the user score and any comments * @return boolean true if everything is ok * @since 3.5.0 * @access public */ public function completeLesson($lesson, $score = 100, $comments = '', $timestamp = '') { if (!$lesson instanceof EfrontLesson) { $lesson = new EfrontLesson($lesson); } if (in_array($lesson->lesson['id'], array_keys($this->getLessons()))) { $fields = array('completed' => 1, 'to_timestamp' => $timestamp ? $timestamp : time(), 'score' => str_replace(',', '.', $score), 'comments' => $comments); eF_updateTableData("users_to_lessons", $fields, "users_LOGIN = '******'login'] . "' and lessons_ID=" . $lesson->lesson['id']); //$cacheKey = "user_lesson_status:lesson:".$lesson -> lesson['id']."user:"******"type" => EfrontEvent::LESSON_COMPLETION, "users_LOGIN" => $this->user['login'], "lessons_ID" => $lesson->lesson['id'], "lessons_name" => $lesson->lesson['name'])); if (G_VERSIONTYPE == 'enterprise') { #cpp#ifdef ENTERPRISE if (!$this->aspects['hcd']) { $this->aspects['hcd'] = EfrontEmployeeFactory::factory($this->user['login']); } $employee = $this->aspects['hcd']; $newSkills = eF_getTableDataFlat("module_hcd_lesson_offers_skill", "skill_ID, specification", "lesson_ID = '" . $lesson->lesson['id'] . "'"); // The lesson associated skills will *complement* the existing ones - last argument = true $employee->addSkills($newSkills['skill_ID'], $newSkills['specification'], array_fill(0, sizeof($newSkills['skill_ID']), $score), true); } #cpp#endif //Get results in lessons $userLessons = array(); $result = eF_getTableData("users_to_lessons", "lessons_ID,completed,score", "users_LOGIN='******'login'] . "'"); foreach ($result as $value) { if ($userLessons[$value['lessons_ID']] = $value) { } } $lessonCourses = $lesson->getCourses(true); //Get the courses that this lesson is part of. This way, we can auto complete a course, if it should be auto completed //Filter out courses that the student doesn't have $result = eF_getTableDataFlat("users_to_courses", "courses_ID", "users_LOGIN='******'login'] . "'"); $userCourses = $result['courses_ID']; foreach ($lessonCourses as $id => $course) { if (!in_array($id, $userCourses)) { unset($lessonCourses[$id]); } } //$userStatus = EfrontStats :: getUsersCourseStatus(array_keys($courses), $this -> user['login']); foreach ($lessonCourses as $course) { if ($course->options['auto_complete']) { $constraints = array('archive' => false, 'active' => true, 'return_objects' => false); $courseLessons = $course->getCourseLessons($constraints); $completed = $score = array(); foreach ($courseLessons as $lessonId => $value) { $userLessons[$lessonId]['completed'] ? $completed[] = 1 : ($completed[] = 0); $score[] = $userLessons[$lessonId]['score']; } if (array_sum($completed) == sizeof($completed)) { //If all the course's lessons are completed, then auto complete the course, using the mean lessons score $this->completeCourse($course->course['id'], round(array_sum($score) / sizeof($score)), _AUTOCOMPLETEDCOURSE); } } } $modules = eF_loadAllModules(); foreach ($modules as $module) { $module->onCompleteLesson($lesson->lesson['id'], $this->user['login']); } return true; } else { return false; } }
echo "<status>error</status>"; echo "<message>Incomplete arguments</message>"; echo "</xml>"; } } else { echo "<xml>"; echo "<status>error</status>"; echo "<message>Invalid token</message>"; echo "</xml>"; } break; case 'lesson_info': if (isset($_GET['token']) && checkToken($_GET['token'])) { if (isset($_GET['lesson'])) { try { $lesson = new EfrontLesson($_GET['lesson']); $info = $lesson->getStatisticInformation(); echo "<xml>"; echo "<general_info>"; echo "<name>" . $lesson->lesson['name'] . "</name>"; echo "<direction>" . $info['direction'] . "</direction>"; echo "<price>" . $info['price_string'] . "</price>"; echo "<language>" . $info['language'] . "</language>"; echo "</general_info>"; echo "</xml>"; } catch (Exception $e) { echo "<xml>"; echo "<status>error</status>"; echo "<message>Lesson doesn't exist</message>"; echo "</xml>"; }
unset($copyPropertiesLesson->options['recurring_duration']); $fields_insert['options'] = serialize($copyPropertiesLesson->options); } //Create the new lesson $newLesson = EfrontLesson::createLesson($fields_insert); //If a recurring payment is set, set this up to the lesson properties if ($values['price'] && $values['recurring'] && in_array($values['recurring'], array_keys($recurringOptions))) { $newLesson->options['recurring'] = $values['recurring']; if ($newLesson->options['recurring']) { $newLesson->options['recurring_duration'] = $form->exportValue($newLesson->options['recurring'] . '_duration'); } $newLesson->persist(); } //Import file, if any specified if ($values['clone_lesson']) { $cloneLesson = new EfrontLesson($values['clone_lesson']); $file = $cloneLesson->export(); $exportedFile = $file->copy($newLesson->getDirectory() . '/' . $exportedFile['name']); } if (isset($exportedFile)) { $newLesson->import($exportedFile); } else { //There was no file imported, then it's safe to add a default completion condition $fields = array('lessons_ID' => $newLesson->lesson['id'], 'type' => 'all_units', 'relation' => 'and'); eF_insertTableData('lesson_conditions', $fields); } if ($newLesson->lesson['course_only']) { //For course-only lessons, redirect to lessons list, not to "edit lesson" page eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=lessons&message=" . urlencode(_SUCCESSFULLYCREATEDLESSON) . "&message_type=success"); } else { eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=lessons&edit_lesson=" . $newLesson->lesson['id'] . "&tab=users&message=" . urlencode(_SUCCESSFULLYCREATEDLESSON) . "&message_type=success");
/** * 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; }
/** * Create lesson instance * * This function is used to create a lesson instance. * <br/>Example: * <code> * $instance = EfrontLesson :: createInstance(43); * </code> * * @param mixed $instanceSource Either a lesson id or an EfrontLesson object. * @return EfrontLesson The new lesson instance * @since 3.6.1 * @access public * @static */ public static function createInstance($instanceSource, $originateCourse) { if (!$instanceSource instanceof EfrontLesson) { $instanceSource = new EfrontLesson($instanceSource); } if (!$originateCourse instanceof EfrontCourse) { $originateCourse = new EfrontCourse($originateCourse); } $result = eF_getTableData("lessons", "*", "id=" . $instanceSource->lesson['id']); unset($result[0]['id']); //unset($result[0]['directions_ID']); //Instances don't belong to a category if (!$result[0]['share_folder']) { $result[0]['share_folder'] = $instanceSource->lesson['id']; } //$result[0]['name'] .= ' ('._INSTANCE.')'; $result[0]['originating_course'] = $originateCourse->course['id']; $result[0]['instance_source'] = $instanceSource->lesson['id']; $file = $instanceSource->export(false, true, false); $instance = EfrontLesson::createLesson($result[0]); $instance->import($file, true, true, true); $instance->course['originating_course'] = $originateCourse->course['id']; $instance->course['instance_source'] = $instanceSource->lesson['id']; $instance->persist(); $modules = eF_loadAllModules(); foreach ($modules as $module) { $module->onCreateInstance($instance->lesson['id'], $instanceSource->lesson['id']); } return $instance; }
if ($isProfessor) { $lessons = $currentUser->getLessons(true, 'professor'); } } if (sizeof($lessons) == 1) { $infoLesson = array_pop($lessons); //get the current (first) lesson if (!$infoLesson instanceof EfrontLesson) { $infoLesson = new EfrontLesson($infoLesson['id']); } } else { if (isset($_GET['sel_lesson']) && in_array($_GET['sel_lesson'], array_keys($lessons))) { $infoLesson = new EfrontLesson($_GET['sel_lesson']); } else { if (isset($_SESSION['s_lessons_ID']) && in_array($_SESSION['s_lessons_ID'], array_keys($lessons))) { $infoLesson = new EfrontLesson($_SESSION['s_lessons_ID']); } } } $smarty->assign("T_INFO_LESSON", $infoLesson->lesson); //get the lesson information if (isset($infoLesson)) { try { $result = eF_getTableData("user_times ut join users_to_lessons ul on ut.users_LOGIN=ul.users_LOGIN and ut.lessons_ID=ul.lessons_ID", "sum(time) as sum, count(distinct ul.users_LOGIN) as count", "completed=1 and ul.archive=0 and ut.lessons_ID=" . $infoLesson->lesson['id'], "", ""); if ($result[0]['sum']) { $smarty->assign("T_AVERAGE_COMPLETION_TIME", EfrontTimes::formatTimeForReporting($result[0]['sum'] / $result[0]['count'])); } require_once $path . "includes/statistics/stats_filters.php"; $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(); $roles = EfrontLessonUser::getLessonsRoles(true);
function isWorkbookInstalledByUser($currentUser, $currentUserRole, $currentLessonID) { $userLessons = $currentUser->getLessons(false, $currentUserRole); $lessons = array(); unset($userLessons[$currentLessonID]); // do not use current lesson $lessons[-1] = array("id" => -1, "name" => _WORKBOOK_SWITCH_TO); $lessons[-2] = array("id" => -2, "name" => '-------------'); foreach ($userLessons as $key => $value) { $lesson = new EfrontLesson($key); $installed = $lesson->getOptions(array('module_workbook')); if (count($installed) != 0 && $installed['module_workbook'] == 1) { $lessons[$key] = array("id" => $key, "name" => $lesson->lesson['name']); } } return $lessons; }
<?php session_cache_limiter('none'); session_start(); $path = "../libraries/"; include_once $path . "configuration.php"; header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past try { $languages = EfrontSystem::getLanguages(true); if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) { $lesson = new EfrontLesson($_GET['lessons_ID']); $lessonInformation = $lesson->getInformation(); //$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']]; if ($lessonInformation['professors']) { foreach ($lessonInformation['professors'] as $value) { $professorsString[] = formatLogin($value['login']); } $lessonInformation['professors'] = implode(", ", $professorsString); } $lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false); $lessonInformation['price_string'] = $priceString; if ($lesson->lesson['max_users']) { $lessonInformation['max_users'] = $lesson->lesson['max_users']; $lessonInformation['seats_remaining'] = $lesson->lesson['max_users'] - sizeof($lesson->getStudentUsers()); $lessonInformation['seats_remaining'] >= 0 or $lessonInformation['seats_remaining'] = 0; } // if (!$lessonInformation['price']) { // unset($lessonInformation['price_string']);
$smarty->assign('T_EDIT_COURSE', $editCourse); //Perform ajax operations if ($_GET['ajax'] == 'skillsTable') { $skills = $editCourse->getSkills(); $dataSource = $skills; $tableName = 'skillsTable'; include "sorted_table.php"; } else { if ($_GET['ajax'] == 'lessonsTable') { $courseUsers = $editCourse->countCourseUsers(array('archive' => false)); $smarty->assign("T_COURSE_HAS_USERS", $courseUsers['count']); $constraints = array('archive' => false) + createConstraintsFromSortedTable(); $constraints['condition'] = 'l.creator_LOGIN="******"'; $lessons = $editCourse->getCourseLessonsIncludingUnassigned($constraints); $totalEntries = $editCourse->countCourseLessonsIncludingUnassigned($constraints); $dataSource = EfrontLesson::convertLessonObjectsToArrays($lessons); $directionsTree = new EfrontDirectionsTree(); $directionsPaths = $directionsTree->toPathString(); foreach ($dataSource as $key => $value) { $dataSource[$key]['directionsPath'] = $directionsPaths[$value['directions_ID']]; $dataSource[$key]['mode'] = 'shared'; if ($value['instance_source']) { if ($value['originating_course'] == $editCourse->course['id'] && $value['has_lesson']) { $dataSource[$key]['mode'] = 'unique'; $lessonsToRemove[] = $value['instance_source']; } else { $lessonsToRemove[] = $key; } } } foreach ($lessonsToRemove as $value) {
//Filemanager settings and inclusion if ($currentUser->getType() == "administrator") { $basedir = G_ADMINPATH; } else { $basedir = $currentLesson->getDirectory(); } if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') { $options = array('lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0); } else { $options = array('delete' => false, 'edit' => false, 'share' => false, 'upload' => false, 'create_folder' => false, 'zip' => false, 'lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0); } /** Get the suggested list in a form that javascript can then understand **/ if (isset($_GET['postAjaxRequest']) && isset($_GET['get_proposed_skills'])) { $question_lesson = eF_getTableData("questions", "lessons_ID", "id = " . $_GET['edit_question']); if (!empty($question_lesson) && $question_lesson[0]['lessons_ID'] != 0) { $lesson = new EfrontLesson($question_lesson[0]['lessons_ID']); $skills_to_propose = array(); // If the lesson belongs only to courses, get all skills of its courses if ($lesson->lesson['course_only']) { $lesson_belonging_courses = $lesson->getCourses(true); foreach ($lesson_belonging_courses as $course) { $course_skills = $course->getSkills(true); foreach ($course_skills as $skillID => $skill) { $skills_to_propose[] = $skillID; } } } else { // Else get only its own skills $lesson_skills = $lesson->getSkills(true); foreach ($lesson_skills as $skillID => $skill) { $skills_to_propose[] = $skillID;
function askInformation() { try { if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) { $lesson = new EfrontLesson($_GET['lessons_ID']); $lessonInformation = $lesson->getInformation(); $languages = EfrontSystem::getLanguages(true); //$lessonInformation['language'] = $languages[$lesson -> lesson['languages_NAME']]; if ($lessonInformation['professors']) { foreach ($lessonInformation['professors'] as $value) { $professorsString[] = $value['name'] . ' ' . $value['surname']; } $lessonInformation['professors'] = implode(", ", $professorsString); } $lesson->lesson['price'] ? $priceString = formatPrice($lesson->lesson['price'], array($lesson->options['recurring'], $lesson->options['recurring_duration']), true) : ($priceString = false); $lessonInformation['price_string'] = $priceString; // if (!$lessonInformation['price']) { // unset($lessonInformation['price_string']); // } try { if ($_GET['from_course']) { $course = new EfrontCourse($_GET['from_course']); $schedule = $course->getLessonScheduleInCourse($lesson); if ($schedule['start_date'] || $schedule['end_date']) { $lessonInformation['from_timestamp'] = $schedule['start_date']; $lessonInformation['to_timestamp'] = $schedule['end_date']; } else { $lessonInformation['from_timestamp'] = $schedule['active_in_lesson'] + 24 * 60 * 60 * $schedule['start_period']; $lessonInformation['to_timestamp'] = $lessonInformation['from_timestamp'] + 24 * 60 * 60 * $schedule['end_period']; } } } catch (Exception $e) { } foreach ($lessonInformation as $key => $value) { if ($value) { switch ($key) { case 'language': $GLOBALS['configuration']['onelanguage'] or $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>"; break; case 'professors': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>"; break; case 'content': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _CONTENTUNITS . "</span><span>: {$value}</span></div>"; break; case 'tests': EfrontUser::isOptionVisible('tests') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _TESTS . "</span><span>: {$value}</span></div>" : null; break; case 'projects': EfrontUser::isOptionVisible('projects') ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROJECTS . "</span><span>: {$value}</span></div>" : null; break; case 'course_dependency': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DEPENDSON . "</span><span>: {$value}</span></div>"; break; case 'from_timestamp': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEFROM . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>"; break; case 'to_timestamp': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _AVAILABLEUNTIL . "</span><span>: " . formatTimestamp($value, 'time_nosec') . "</span></div>"; break; case 'general_description': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>"; break; case 'assessment': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>"; break; case 'objectives': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>"; break; case 'lesson_topics': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONTOPICS . "</span><span>: {$value}</span></div>"; break; case 'resources': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>"; break; case 'other_info': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>"; break; case 'price_string': !$lesson->lesson['course_only'] ? $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>" : null; break; default: break; } } } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } if (isset($_GET['courses_ID']) && eF_checkParameter($_GET['courses_ID'], 'id')) { $course = new EfrontCourse($_GET['courses_ID']); $courseInformation = $course->getInformation(); $languages = EfrontSystem::getLanguages(true); if ($courseInformation['professors']) { foreach ($courseInformation['professors'] as $value) { $professorsString[] = $value['name'] . ' ' . $value['surname']; } $courseInformation['professors'] = implode(", ", $professorsString); } $course->course['price'] ? $priceString = formatPrice($course->course['price'], array($course->options['recurring'], $course->options['recurring_duration']), true) : ($priceString = false); $courseInformation['price_string'] = $priceString; foreach ($courseInformation as $key => $value) { if ($value) { switch ($key) { case 'language': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LANGUAGE . "</span><span>: {$languages[$value]}</span></div>"; break; case 'professors': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PROFESSORS . "</span><span>: {$value}</span></div>"; break; case 'lessons_number': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _LESSONS . "</span><span>: {$value}</span></div>"; break; case 'instances': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSEINSTANCES . "</span><span>: {$value}</span></div>"; break; case 'general_description': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _DESCRIPTION . "</span><span>: {$value}</span></div>"; break; case 'assessment': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _ASSESSMENT . "</span><span>: {$value}</span></div>"; break; case 'objectives': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OBJECTIVES . "</span><span>: {$value}</span></div>"; break; case 'lesson_topics': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _COURSETOPICS . "</span><span>: {$value}</span></div>"; break; case 'resources': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _RESOURCES . "</span><span>: {$value}</span></div>"; break; case 'other_info': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _OTHERINFO . "</span><span>: {$value}</span></div>"; break; case 'price_string': $tooltipInfo[] = '<div class = "infoEntry"><span>' . _PRICE . "</span><span>: {$value}</span></div>"; break; default: break; } } } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } // For eFront social if (isset($_GET['common_lessons']) && isset($_GET['user1']) && isset($_GET['user2'])) { $user1 = EfrontUserFactory::factory($_GET['user1']); if ($user1->getType() != "administrator") { $common_lessons = $user1->getCommonLessons($_GET['user2']); // pr($common_lessons); foreach ($common_lessons as $id => $lesson) { if (strlen($lesson['name']) > 25) { $lesson['name'] = substr($lesson['name'], 0, 22) . "..."; } $tooltipInfo[] = '<div class = "infoEntry"><span>' . $lesson['name'] . "</span><span></span></div>"; } if ($string = implode("", $tooltipInfo)) { echo $string; } else { echo _NODATAFOUND; } } else { echo _NODATAFOUND; } } } catch (Exception $e) { handleAjaxExceptions($e); } }
$user -> addLessons($lessons, $userType, 1); //active lessons } } } } */ if ($currentGroup->group['user_types_ID'] == '0') { foreach ($groupUsers as $user) { $user = EfrontUserFactory::factory($user); $user->user['user_types_ID'] ? $userType[] = $user->user['user_types_ID'] : ($userType[] = $user->user['user_type']); } } else { $userType = $currentGroup->group['user_types_ID']; } foreach ($lessonIds as $id) { $lesson = new EfrontLesson($id); $lesson->addUsers($groupUsers, $userType, true, true); } } } } } } } } } } } } exit; }
$currentTheme = new themes($_SESSION['s_theme']); $newTime = ''; $jsonValues = array(); if ($_SESSION['s_login']) { $entity = getUserTimeTarget($_GET['HTTP_REFERER']); //Update times for this entity if ($_SESSION['s_lesson_user_type'] == 'student' && isset($_POST['user_total_time_in_unit']) && current($entity) == 'unit' && eF_checkParameter(key($entity), 'id')) { $newTime = $_POST['user_total_time_in_unit']; $jsonValues['entity'] = current($entity); $jsonValues['entity_id'] = current($entity); if ($newTime && is_numeric($newTime)) { $result = eF_executeNew("insert into users_to_content (users_LOGIN, content_ID, lessons_ID) values('" . $_SESSION['s_login'] . "', " . key($entity) . ", " . $_SESSION['s_lessons_ID'] . ") on duplicate key update total_time={$newTime}"); $jsonValues['time_in_unit'] = EfrontTimes::formatTimeForReporting($newTime); } else { $jsonValues['old_time_in_unit'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInUnit($_SESSION['s_login'], key($entity))); $jsonValues['old_time_in_lesson'] = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($_SESSION['s_login'], $_SESSION['s_lessons_ID'])); } } if (empty($_SESSION['last_periodic_check']) || time() - $_SESSION['last_periodic_check'] >= ceil($GLOBALS['configuration']['updater_period'] / 1000)) { $result = eF_executeNew("update user_times set time=time+(" . time() . "-timestamp_now),timestamp_now=" . time() . "\r\n\t\t\t\t\t\twhere session_expired = 0 and session_custom_identifier = '" . $_SESSION['s_custom_identifier'] . "' and users_LOGIN = '******'s_login'] . "'\r\n\t\t\t\t\t\tand entity = '" . current($entity) . "' and entity_id = '" . key($entity) . "'"); $_SESSION['last_periodic_check'] = time(); if ($currentTheme->options['sidebar_interface'] == 0) { if (empty($_SESSION['last_periodic_check_users']) || time() - $_SESSION['last_periodic_check_users'] >= 300) { $_SESSION['last_periodic_check_users'] = $_SESSION['last_periodic_check']; $online = EfrontUser::getUsersOnline($GLOBALS['configuration']['autologout_time'] * 60); $_SESSION['online_users'] = $online; if ($currentTheme->options['sidebar_interface'] == 0) { $jsonValues['online'] = $online; } } else { if ($currentTheme->options['sidebar_interface'] == 0) {
/** * Get project files * * This function returns a list of file ids that have been posted * for this project. this list includes the user name and surname, * the id, full path and name of the file and finally the time it * was uploaded. * <br/>Example: * <code> * $project -> getFiles(); * </code> * * @return array The list of files posted for this project * @since 3.5.0 * @access public */ public function getFiles() { $files = eF_getTableData("files f, users u, users_to_projects up", "f.*, u.name, u.surname, u.login, up.upload_timestamp", "up.filename = f.id and up.users_LOGIN = u.login and up.projects_ID=" . $this->project['id']); $currentLesson = new EfrontLesson($GLOBALS['currentLesson']->lesson['id']); $lessonUsers = $currentLesson->getUsers('student'); foreach ($files as $key => $file) { if (!in_array($file['login'], array_keys($lessonUsers))) { unset($files[$key]); } } return $files; }
public function getSmartyTpl() { $smarty = $this->getSmartyVar(); $smarty->assign("T_RSS_MODULE_BASEURL", $this->moduleBaseUrl); $smarty->assign("T_RSS_MODULE_BASELINK", $this->moduleBaseLink); $smarty->assign("T_RSS_PROVIDED_FEEDS_MODES", $this->feedProviderModes); $smarty->assign("T_RSS_PROVIDED_FEEDS_TYPES", $this->providedFeeds); $smarty->assign("T_RSS_PROVIDED_FEEDS_LESSON_TYPES", $this->lessonProvidedFeeds); if (isset($_GET['delete_feed']) && eF_checkParameter($_GET['delete_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_deleteTableData("module_rss_provider", "id=" . $_GET['delete_feed']); } else { eF_deleteTableData("module_rss_feeds", "id=" . $_GET['delete_feed']); } } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['deactivate_feed']) && eF_checkParameter($_GET['deactivate_feed'], 'id')) { try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 0), "id=" . $_GET['deactivate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 0), "id=" . $_GET['deactivate_feed']); } echo 0; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } elseif (isset($_GET['activate_feed']) && eF_checkParameter($_GET['activate_feed'], 'file')) { //Although db operations do not support exceptions (yet), we leave this here for future support try { if ($_GET['type'] == 'provider') { eF_updateTableData("module_rss_provider", array("active" => 1), "id=" . $_GET['activate_feed']); } else { eF_updateTableData("module_rss_feeds", array("active" => 1), "id=" . $_GET['activate_feed']); } echo 1; } catch (Exception $e) { handleAjaxExceptions($e); } exit; } else { if (isset($_GET['add_feed']) || isset($_GET['edit_feed']) && eF_checkParameter($_GET['edit_feed'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getFeeds(); $lessons = array(-1 => _RSS_NONE, 0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } isset($_GET['add_feed']) ? $postTarget = "&add_feed=1" : ($postTarget = "&edit_feed=" . $_GET['edit_feed']); $form = new HTML_QuickForm("add_feed_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); $form->addElement('text', 'title', _RSS_FEEDTITLE, 'class = "inputText"'); $form->addElement('text', 'url', _RSS_FEEDURL, 'class = "inputText"'); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement("advcheckbox", "only_summary", _RSS_ONLYSUMMARY, null, 'class = "inputCheckBox"', array(0, 1)); $form->addRule('title', _THEFIELD . ' "' . _RSS_FEEDTITLE . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('url', _THEFIELD . ' "' . _RSS_FEEDURL . '" ' . _ISMANDATORY, 'required', null, 'client'); $form->addRule('title', _INVALIDFIELDDATA, 'checkParameter', 'text'); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed'])) { $editFeed = $feeds[$_GET['edit_feed']]; $form->setDefaults($editFeed); } if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("title" => $values['title'], "url" => $values['url'], "active" => $values['active'], "only_summary" => $values['only_summary'], "lessons_ID" => $values['lessons_ID']); if (isset($_GET['add_feed'])) { eF_insertTableData("module_rss_feeds", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_feeds", $fields, "id=" . $_GET['edit_feed']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); EfrontCache::getInstance()->deleteCache('rss_cache:' . $_GET['edit_feed']); } } $smarty->assign("T_RSS_ADD_RSS_FORM", $form->toArray()); } else { if (isset($_GET['add_feed_provider']) || isset($_GET['edit_feed_provider']) && eF_checkParameter($_GET['edit_feed_provider'], 'id')) { if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; } else { $type = $this->getCurrentUser()->getType(); } $smarty->assign("T_RSS_USERTYPE", $type); $feeds = $this->getProvidedFeeds(); isset($_GET['add_feed_provider']) ? $postTarget = "&add_feed_provider=1" : ($postTarget = "&edit_feed_provider=" . $_GET['edit_feed_provider']); !isset($_GET['lesson']) or $postTarget .= '&lesson=1'; $form = new HTML_QuickForm("add_feed_provider_form", "post", $this->moduleBaseUrl . $postTarget . '&tab=rss_provider', "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); if ($_GET['lesson']) { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->lessonProvidedFeeds); $form->addElement('select', 'lessons_ID', _LESSON, $lessons); if ($type != 'administrator' && $_SESSION['s_lessons_ID']) { $form->setDefaults(array('lessons_ID' => $_SESSION['s_lessons_ID'])); $form->freeze(array('lessons_ID')); } } else { $form->addElement('select', 'feeds_provided', _RSS_PROVIDEDFEEDS, $this->providedFeeds); } $form->addElement("advcheckbox", "active", _RSS_ACTIVE, null, 'class = "inputCheckBox"', array(0, 1)); $form->setDefaults(array('active' => 1)); $form->addElement('submit', 'submit', _SUBMIT, 'class = "flatButton"'); if (isset($_GET['edit_feed_provider'])) { $editFeed = $feeds[$_GET['edit_feed_provider']]; $form->setDefaults($editFeed); } try { if ($form->isSubmitted() && $form->validate()) { //If the form is submitted and validated $values = $form->exportValues(); $fields = array("mode" => $_GET['lesson'] ? 'lesson' : 'system', "type" => $values['feeds_provided'], "active" => $values['active'], "lessons_ID" => $values['lessons_ID']); foreach ($feeds as $feed) { if ($feed['type'] == $fields['type'] && $feed['mode'] == $fields['mode'] && $feed['lessons_ID'] == $fields['lessons_ID']) { throw new Exception(_FEEDALREADYEXISTS); } } if (isset($_GET['add_feed_provider'])) { eF_insertTableData("module_rss_provider", $fields); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYADDEDFEED); } else { eF_updateTableData("module_rss_provider", $fields, "id=" . $_GET['edit_feed_provider']); $smarty->assign("T_RSS_RSS_MESSAGE", _RSS_SUCCESSFULLYEDITEDFEED); } } } catch (Exception $e) { $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString()); $message = $e->getMessage() . ' (' . $e->getCode() . ') <a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>'; $message_type = 'failure'; } $smarty->assign("T_RSS_PROVIDE_RSS_FORM", $form->toArray()); } else { if (isset($_GET['ajax'])) { echo $this->getRssFeeds($_GET['refresh']); //echo $this -> getRssFeeds(true); exit; } else { $lessons = array(0 => _ALLLESSONS); $result = EfrontLesson::getLessons(); foreach ($result as $key => $lesson) { $lessons[$key] = $lesson['name']; } $smarty->assign("T_LESSON_NAMES", $lessons); if ($_SESSION['s_lesson_user_type']) { $type = $_SESSION['s_lesson_user_type']; $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds($_SESSION['s_lessons_ID'])); $smarty->assign("T_RSS_FEEDS", $this->getFeeds(false, $_SESSION['s_lessons_ID'])); } else { $type = $this->getCurrentUser()->getType(); $smarty->assign("T_RSS_PROVIDED_FEEDS", $this->getProvidedFeeds()); $smarty->assign("T_RSS_FEEDS", $this->getFeeds()); } $smarty->assign("T_RSS_USERTYPE", $type); } } } } if ($message) { $this->setMessageVar($message, $message_type); } return $this->moduleBaseDir . "module_rss.tpl"; }
/** * * @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']}"); }
$message_type = 'failure'; $smarty->assign("T_RULE_CHECK_FAILED", true); $ruleCheck = false; } $smarty->assign("T_USER_PROGRESS", $userProgress); } if ($_student_) { if (preg_match("#</object>#", $currentUnit['data']) || preg_match("#</applet>#", $currentUnit['data'])) { $smarty->assign("T_CONTAINS_FLASH", true); } //$smarty -> assign("T_NEXT_LESSON", $currentLesson -> getNextLesson()); //$userTimeInUnit = EfrontTimes::formatTimeForReporting($times->getUserSessionTimeInUnit($currentUser->user['login'], $currentUnit['id'])); $userTimeInUnit = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInUnit($currentUser->user['login'], $currentUnit['id'])); $smarty->assign("T_USER_TIME_IN_UNIT", $userTimeInUnit); //$smarty -> assign("T_USER_CURRENT_TIME_IN_UNIT", $times->getUserCurrentSessionTimeInUnit($currentUser->user['login'], $currentUnit['id'])); $userTimeInLesson = EfrontTimes::formatTimeForReporting(EfrontLesson::getUserActiveTimeInLesson($currentUser->user['login'], $currentLesson->lesson['id'])); $smarty->assign("T_USER_CURRENT_TIME_IN_LESSON", $userTimeInLesson['total_seconds']); $smarty->assign("T_USER_TIME_IN_LESSON", $userTimeInLesson); foreach ($currentLesson->getConditions() as $value) { if ($value['type'] == 'time_in_lesson') { $smarty->assign("T_REQUIRED_TIME_IN_LESSON", $value['options'][0] * 60); } } if ($_change_ && $currentLesson->options['tracking'] && $currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_AUTOCOMPLETE && $ruleCheck && !in_array($currentUnit['id'], array_keys($seenContent))) { $smarty->assign("T_AUTO_SET_SEEN_UNIT", true); } if ($_change_ && $currentLesson->options['tracking'] && $currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_COMPLETEAFTERSECONDS && $ruleCheck && !in_array($currentUnit['id'], array_keys($seenContent)) && $userTimeInUnit['total_seconds'] > $currentUnit['options']['complete_time']) { $smarty->assign("T_AUTO_SET_SEEN_UNIT", true); } /*$hideFeedback = false; foreach (new EfrontNoFeedbackFilterIterator(new EfrontVisitableAndEmptyFilterIterator($visitableIterator)) as $key => $value) {
<?php if (str_replace(DIRECTORY_SEPARATOR, "/", __FILE__) == $_SERVER['SCRIPT_FILENAME']) { exit; } try { if (!isset($lessons) || !$lessons && !is_array($lessons)) { $lessons = EfrontLesson::getLessons(true); foreach ($lessons as $key => $lesson) { if ($lesson->lesson['archive'] || !$lesson->lesson['active']) { unset($lessons[$key]); } } } if (!isset($courses) || !$courses && !is_array($courses)) { //$courses = EfrontCourse :: getCourses(true); $constraints = array('active' => true, 'archive' => false, 'instance' => false, 'sort' => 'name'); $constraints['required_fields'] = array('has_instances'); $courses = EfrontCourse::getAllCourses($constraints); if ($_SESSION['s_current_branch']) { //filter out courses that don't belong to the current branch url $stats_filters = array(); $branches = array($_SESSION['s_current_branch']); $branchesTree = new EfrontBranchesTree(); $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($branchesTree->getNodeChildren($_SESSION['s_current_branch'])), RecursiveIteratorIterator::SELF_FIRST)); foreach ($iterator as $key => $value) { $branches[] = $key; } $result = eF_getTableDataFlat("module_hcd_course_to_branch", "courses_ID", "branches_ID in (" . implode(",", $branches) . ")"); foreach ($courses as $key => $value) { if (!in_array($key, $result['courses_ID'])) {
protected function importData($line, $type, $data) { //pr($line);exit; try { switch ($type) { case "users": $newUser = EfrontUser::createUser($data); $this->log["success"][] = _LINE . " {$line}: " . _IMPORTEDUSER . " " . $newUser->login; break; case "users_to_courses": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $courses_name = trim($data['course_name']); $courses_ID = $this->getCourseByName($courses_name); unset($data['course_name']); if ($courses_ID) { foreach ($courses_ID as $course_ID) { $data['courses_ID'] = $course_ID; $course = new EfrontCourse($course_ID); if (is_null($this->course_users[$course_ID])) { $result = eF_getTableDataFlat("users_to_courses", "users_LOGIN", "courses_ID={$course_ID} AND archive=0"); $this->course_users[$course_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->course_users[$course_ID][$data['users_login']])) { throw new Exception("User is already assigned to the course", self::USER_TO_COURSE_EXISTS); } //$course -> addUsers($data['users_login'], (isset($data['user_type']) && $data['user_type']?$data['user_type']:"student")); $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $data['courses_ID']; $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); EfrontCourse::persistCourseUsers($data, $where, $data['courses_ID'], $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->course_users[$course_ID][$data['users_login']] = $data['users_login']; $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } } else { if ($courses_name != "") { $course = EfrontCourse::createCourse(array("name" => $courses_name)); $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSE . " " . $courses_name; $course->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $courses_ID = $course->course['id']; $this->courseNamesToIds[$courses_name] = array($courses_ID); $where = "users_login = '******'users_login'] . "' AND courses_ID = " . $courses_ID; EfrontCourse::persistCourseUsers($data, $where, $courses_ID, $data['users_login']); if ($data['active']) { $course->confirm($data['users_login']); } else { $course->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSEASSIGNMENT . " " . $courses_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDCOURSE . " " . $courses_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_lessons": //Check if a user exists and whether it has the same case $userFound = false; if (!in_array($data['users_login'], $this->allUserLogins)) { //For case-insensitive matches foreach ($this->allUserLogins as $login) { if (mb_strtolower($data['users_login']) == mb_strtolower($login)) { $data['users_login'] = $login; $userFound = true; } } } else { $userFound = true; } if ($userFound) { $lessons_name = trim($data['lesson_name']); $lessons_ID = $this->getLessonByName($lessons_name); unset($data['lesson_name']); if ($lessons_ID) { foreach ($lessons_ID as $lesson_ID) { $data['lessons_ID'] = $lesson_ID; $lesson = new EfrontLesson($lesson_ID); if (is_null($this->lesson_users[$lesson_ID])) { $result = eF_getTableDataFlat("users_to_lessons", "users_LOGIN", "lessons_ID={$lesson_ID} AND archive=0"); $this->lesson_users[$lesson_ID] = array_combine($result['users_LOGIN'], $result['users_LOGIN']); } if (isset($this->lesson_users[$lesson_ID][$data['users_login']])) { throw new Exception("User is already assigned to the lesson", self::USER_TO_LESSON_EXISTS); } if (!$lesson->lesson['course_only']) { $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); } $data['completed'] ? $data['completed'] = 1 : ($data['completed'] = 0); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $data['lessons_ID']); if (!$lesson->lesson['course_only']) { if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } } else { if ($lessons_name != "") { $lesson = EfrontLesson::createLesson(array("name" => $lessons_name, 'course_only' => false)); $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSON . " " . $lessons_name; $lesson->addUsers($data['users_login'], isset($data['user_type']) ? $data['user_type'] : "student"); $lessons_ID = $lesson->lesson['id']; $this->lessonNamesToIds[$lessons_name] = array($lessons_ID); eF_updateTableData("users_to_lessons", $data, "users_login = '******'users_login'] . "' AND lessons_ID = " . $lessons_ID); if ($data['active']) { $lesson->confirm($data['users_login']); } else { $lesson->unconfirm($data['users_login']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWLESSONASSIGNMENT . " " . $lessons_name . " - " . $data['users_login']; } else { $this->log["failure"][] = _LINE . " {$line}: " . _COULDNOTFINDLESSON . " " . $lessons_name; } } } else { $this->log["failure"][] = _LINE . " {$line}: " . _USERDOESNOTEXIST . ": " . $data['users_login']; } break; case "users_to_groups": //debug(); $groups_ID = $this->getGroupByName($data['groups.name']); $group_name = $data['groups.name']; unset($data['groups.name']); foreach ($groups_ID as $group_ID) { $data['groups_ID'] = $group_ID; $group = new EfrontGroup($group_ID); $group->addUsers(array($data['users_login'])); $this->log["success"][] = _LINE . " {$line}: " . _NEWGROUPASSIGNMENT . " " . $group_name . " - " . $data['users_login']; } break; //debug(false); #cpp#ifdef ENTERPRISE //debug(false); #cpp#ifdef ENTERPRISE case "employees": $this->cleanUpEmptyValues($data); // a bit customized here, based on the fact that employees are always created together AFTER users (so the object should exist) eF_updateTableData("module_hcd_employees", $data, "users_login='******'users_login'] . "'"); break; case "branches": // If no father defined - root, else we may need to create the father first $data['father_branch_ID'] = $this->getFatherBranchId($data['father_branch_name']); $father_name = $data['father_branch_name']; $branch_ID = $this->getBranchByName($data['name']); $branch_name = $data['name']; if (sizeof($branch_ID) > 0 && $data['name'] != $data['father_branch_name']) { //TODO unset($data['father_branch_name']); $data['branch_ID'] = $branch_ID[0]; throw new EfrontBranchException(_BRANCHALREADYEXISTS, EfrontBranchException::BRANCH_EXISTS); } else { unset($data['father_branch_name']); $data['url'] = EfrontBranch::getBranchUrl($data['name']); $branch = EfrontBranch::createBranch($data); $this->setBranchByName($branch_name, $branch->branch['branch_ID']); } $this->log["success"][] = _LINE . " {$line}: " . _NEWBRANCH . " " . $branch_name; break; case "job_descriptions": if ($data['branch_name'] == "") { $data['branch_ID'] = "all"; // this denotes to the createJob class to put the job in all branches } else { $data['branch_ID'] = $this->getBranchByName($data['branch_name']); if (sizeof($data['branch_ID']) > 0) { //TODO: maybe different handling when multiple branches are found $data['branch_ID'] = $data['branch_ID'][0]; } else { throw new EfrontJobException(_BRANCHDESIGNATEDFORTHISJOBDESCRIPTIONDOESNOTEXIST, EfrontJobException::BRANCH_NOT_EXISTS); } } unset($data['branch_name']); if ($data['description'] != "") { $job_ID = $this->getJobByName($data['description']); if (sizeof($job_ID) > 0) { $data['job_description_ID'] = $job_ID[0]; throw new EfrontJobException(_JOBDESCRIPTIONEXISTSALREADY, EfrontJobException::JOB_ALREADY_EXISTS); } else { EfrontJob::createJob($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOB . " " . $data['description']; } } else { $this->log["failure"][] = _LINE . " {$line}: " . _NOTITLEPROVIDEDFORNEWJOB; } break; case "skills": if ($data['skill_category'] == "") { throw new EfrontSkillException(_MISSINGSKILLCATEGORY, EfrontSkillException::INVALID_SKILL_CATEGORY); } else { $data['categories_ID'] = $this->getSkillCategoryByName($data['skill_category']); if ($data['categories_ID'][0] != "") { $data['categories_ID'] = $data['categories_ID'][0]; } else { // create skill category $data['categories_ID'] = eF_insertTableData("module_hcd_skill_categories", array('description' => $data['skill_category'])); $this->setSkillCategoryByName($data['skill_category'], $data['categories_ID']); } } unset($data['skill_category']); $skill_ID = $this->getSkillByName($data['description']); if ($skill_ID) { //TODO: another double issue $data['skill_ID'] = $skill_ID[0]; throw new EfrontSkillException(_SKILLALREADYEXISTS, EfrontSkillException::SKILL_EXISTS); } else { EfrontSkill::createSkill($data); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILL . " " . $data['description']; } break; case "users_to_jobs": // Get user $user = EfrontUserFactory::factory($data["users_login"]); // Get branch id $branch_ID = $this->getBranchByName($data['branch_name']); $branch_name = $data['branch_name']; if ($branch_ID[0] != "") { if (sizeof($branch_ID) == 1) { $branch_ID = $branch_ID[0]; } else { throw new EfrontBranchException(_BRANCHNAMEAMBIGUOUS, EfrontBranchException::BRANCH_AMBIGUOUS); } } else { throw new EfrontBranchException(_BRANCHDOESNOTEXIST, EfrontBranchException::BRANCH_NOT_EXISTS); } // Get job id $job_name = $data['description']; if ($job_name != "") { $new_job_description_ID = eF_getJobDescriptionId($job_name, $branch_ID); } else { throw new EfrontJobException(_MISSING_JOB_DESCRIPTION, EfrontJobException::MISSING_JOB_DESCRIPTION); } // Get hcd employee object if ($data['supervisor']) { $employee = new EfrontSupervisor(array("users_login" => $data["users_login"])); $position = 1; } else { $employee = new EfrontEmployee(array("users_login" => $data["users_login"])); $position = 0; } // Assign job try { $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } catch (Exception $e) { if ($this->options['replace_existing']) { $employee->removeJob($new_job_description_ID); $employee->addJob($user, $new_job_description_ID, $branch_ID, $position); $this->log["success"][] = _LINE . " {$line}: " . _NEWJOBASSIGNMENT . " " . $data["users_login"] . " - (" . $branch_name . " - " . $job_name . ") "; } } break; case "users_to_skills": $skill_ID = $this->getSkillByName($data['description']); $skill_name = $data['description']; if ($skill_ID[0] != "") { if (sizeof($skill_ID) == 1) { $skill_ID = $skill_ID[0]; } else { throw new EfrontSkillException(_SKILLNAMEAMBIGUOUS, EfrontSkillException::SKILL_AMBIGUOUS); } } else { throw new EfrontSkillException(_SKILLDOESNOTEXIST, EfrontSkillException::SKILL_NOT_EXISTS); } $skill = new EfrontSkill($skill_ID); $skill->assignToEmployee($data['users_login'], $data['specification']); $this->log["success"][] = _LINE . " {$line}: " . _NEWSKILLASSIGNMENT . " " . $data["users_login"] . " - " . $skill_name; break; case "courses_to_branches": $branchId = $this->getBranchByName($data['branch_name']); if (!$branchId[0]) { $fields = array('name' => $data['branch_name'], 'url' => EfrontBranch::getBranchUrl($data['branch_name'])); $branch = EfrontBranch::createBranch($fields); } else { $branch = new EfrontBranch($branchId[0]); } $courseId = $this->getCourseByName($data['course_name']); if ($courseId[0]) { $branch->addCoursesToBranch($courseId[0]); } $this->log["success"][] = _LINE . " {$line}: " . _NEWCOURSETOBRANCHASSIGNMENT . " " . $data['course_name'] . " - " . $data['branch_name']; break; #cpp#endif } } catch (Exception $e) { if ($this->options['replace_existing']) { if ($this->isAlreadyExistsException($e->getCode(), $type)) { $this->updateExistingData($line, $type, $data); } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } else { $this->log["failure"][] = _LINE . " {$line}: " . $e->getMessage(); // ." ". str_replace("\n", "<BR>", $e->getTraceAsString()); } } }
//echo $_SERVER['QUERY_STRING']; $load_editor = true; $form = new HTML_QuickForm("content_report_form", "post", "content_report.php", "", null, true); $form->registerRule('checkParameter', 'callback', 'eF_checkParameter'); //Register this rule for checking user input with our function, eF_checkParameter //$form -> addElement('text', 'topic', _TOPIC, 'class = "inputText"'); //$form -> addRule('topic', _THEFIELD.' "'._TOPIC.'" '._ISMANDATORY, 'required', null, 'client'); $form->addElement('hidden', 'page', htmlspecialchars_decode(http_build_query($_GET))); $form->addElement('textarea', 'notes', _NOTES, 'class = "inputTextArea" style="width:45em;height:15em;"'); //$form -> addRule('notes', _THEFIELD.' "'._NOTES.'" '._ISMANDATORY, 'required', null, 'client'); $form->addElement('submit', 'submit_report', _REPORT, 'class = "flatButton"'); if ($form->isSubmitted()) { if ($form->validate()) { $values = $form->exportValues(); $recipients = array(); $lesson = new EfrontLesson($_SESSION['s_lessons_ID']); $lessonProfs = $lesson->getUsers("professor"); foreach ($lessonProfs as $key => $value) { $recipients[] = $key; } if (strpos($values['page'], "glossary") !== false) { $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _GLOSSARY . ']'; } elseif (strpos($values['page'], "edit_question") !== false) { $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _QUESTION . ']'; } else { $contentId = mb_substr($values['page'], 10); preg_match("/.*view_unit=(\\d+).*/", $values['page'], $matches); $resultType = eF_getTableData("content", "ctg_type", "id=" . $matches[1]); if ($resultType[0]['ctg_type'] == "tests") { $title = _ERRORREPORTFOR . ' ' . $lesson->lesson['name'] . ' [' . _TESTS . ']'; } else {
if (isset($_SESSION['s_login']) && $_SESSION['s_password']) { 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) {
/** * 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; }
/** * Check whether a lesson is part of a course * * @param mixed lesson A lesson id or an EfrontLesson object * @since 3.6.3 * @access public */ public function isCourseLesson($lesson) { $lesson = EfrontLesson::convertArgumentToLessonObject($lesson); $result = eF_getTableData("lessons_to_courses", "*", "lessons_ID=" . $lesson->lesson['id'] . " and courses_ID=" . $this->course['id']); return !empty($result); }
} } $smarty->assign("T_LESSON_INFO", $lessonInformation); if (!$_admin_) { $seenContent = EfrontStats::getStudentsSeenContent($currentLesson->lesson['id'], $currentUser->user['login']); //Get the passing score for each "specific_test" rule $allTestsScore = eF_getTableDataFlat("tests", "content_ID,mastery_score"); if (sizeof($allTestsScore) > 0) { $allTestsScore = array_combine($allTestsScore['content_ID'], $allTestsScore['mastery_score']); } else { $allTestsScore = array(); } foreach ($conditions as $key => $condition) { if ($condition['type'] == 'specific_test') { $conditions[$key]['test_passing_score'] = $allTestsScore[$condition['options'][0]]; } } $times = new EfrontTimes(); list($conditionsStatus, $lessonPassed) = EfrontStats::checkConditions($seenContent[$currentLesson->lesson['id']][$currentUser->user['login']], $conditions, $visitableContentIds, $testsIds, EfrontLesson::getUserActiveTimeInLesson($currentUser->user['login'], $currentLesson->lesson['id'])); $smarty->assign("T_CONDITIONS", $conditions); $smarty->assign("T_CONDITIONS_STATUS", $conditionsStatus); //$smarty -> assign("T_LESSON_PASSED", $lessonPassed); foreach ($iterator = new EfrontAttributeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree)), array('id', 'name')) as $key => $value) { $key == 'id' ? $ids[] = $value : ($names[] = $value); } $smarty->assign("T_TREE_NAMES", array_combine($ids, $names)); $smarty->assign("T_BASE_URL", "ctg=lesson_information"); } else { $smarty->assign("T_BASE_URL", "ctg=lessons&lesson_info=" . $currentLesson->lesson['id']); } }
session_start(); $path = "../libraries/"; /** Configuration file.*/ include_once $path . "configuration.php"; try { $currentUser = EfrontUser::checkUserAccess(); } catch (Exception $e) { echo "<script>parent.location = 'index.php?logout=true&message=" . urlencode($e->getMessage() . ' (' . $e->getCode() . ')') . "&message_type=failure'</script>"; //This way the frameset will revert back to single frame, and the annoying effect of 2 index.php, one in each frame, will not happen exit; } try { if ($_SESSION['s_lessons_ID']) { $currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']); } elseif ($_POST['lessons_ID']) { $currentLesson = new EfrontLesson($_POST['lessons_ID']); } if (isset($currentUser->coreAccess['settings']) && $currentUser->coreAccess['settings'] != 'change') { throw new Exception(); } } catch (Exception $e) { eF_redirect("index.php?message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure"); exit; } try { $roles = EfrontUser::getRoles(); if (isset($_POST['firstlist']) && isset($_POST['secondlist'])) { parse_str($_POST['firstlist']); parse_str($_POST['secondlist']); parse_str($_POST['visibility']); mb_internal_encoding('utf-8');
if ($currentUser->user['user_type'] != 'administrator') { $userLessons = $infoUser->getUserLessons(); $lessons = array_intersect_key($lessons, $userLessons); } $lessons = EfrontLesson::convertLessonObjectsToArrays($lessons); foreach ($lessons as $key => $value) { $lessons[$key]['name'] = $directionsTreePaths[$value['directions_ID']] . ' → ' . $value['name']; } $dataSource = $lessons; } if (isset($_GET['ajax']) && $_GET['ajax'] == 'courseLessonsTable' && eF_checkParameter($_GET['courseLessonsTable_source'], 'id')) { $tableName = $_GET['ajax']; $smarty->assign("T_DATASOURCE_COLUMNS", array('name', 'location', 'user_type', 'num_lessons', 'status', 'active_in_lesson', 'completed', 'score', 'operations', 'sort_by_column' => 4)); $smarty->assign("T_DATASOURCE_OPERATIONS", array('progress')); $lessons = $infoUser->getUserStatusInCourseLessons(new EfrontCourse($_GET['courseLessonsTable_source']), true); $lessons = EfrontLesson::convertLessonObjectsToArrays($lessons); $dataSource = $lessons; if (!$_GET['sort']) { $_GET['sort'] = 'eliminate'; //Assign a default sort that does not exist, thus eliminating default sorting by name. This happens because $dataSource here is alread pre-sorted by course succession } } if ($_GET['ajax'] == 'coursesTable' || $_GET['ajax'] == 'instancesTable') { $smarty->assign("T_DATASOURCE_COLUMNS", array('name', 'location', 'user_type', 'num_lessons', 'active_in_course', 'status', 'completed', 'score', 'operations', 'sort_by_column' => 4)); $smarty->assign("T_DATASOURCE_OPERATIONS", array('progress')); $smarty->assign("T_DATASOURCE_SORT_BY", 0); $tableName = $_GET['ajax']; if (isset($_GET['ajax']) && $_GET['ajax'] == 'coursesTable') { //$constraints = array('archive' => false, 'active' => true, 'instance' => false) + createConstraintsFromSortedTable(); $constraints = array('archive' => false, 'instance' => false); if (!$show_inactive) {
$lessons_proposed = eF_getTableData("module_hcd_skills LEFT OUTER JOIN module_hcd_lesson_offers_skill ON module_hcd_skills.skill_ID = module_hcd_lesson_offers_skill.skill_ID JOIN lessons ON lessons.id = module_hcd_lesson_offers_skill.lesson_ID", "module_hcd_lesson_offers_skill.lesson_ID, lessons.*, count(module_hcd_lesson_offers_skill.skill_ID) as skills_offered", "module_hcd_lesson_offers_skill.skill_ID IN ('" . $skills_missing . "') AND module_hcd_lesson_offers_skill.lesson_ID NOT IN ('" . $alredy_attending . "')", "", "module_hcd_lesson_offers_skill.lesson_ID ORDER BY skills_offered DESC"); // And assign them foreach ($lessons_proposed as $lesson) { $editedUser->addLessons($lesson['lesson_ID']); } } } } } } exit; } } if (isset($_GET['ajax']) && $_GET['ajax'] == 'toggle_user' && $_GET['type'] == 'lesson' && $_change_lessons_) { $response = array('status' => 1); $editLesson = new EfrontLesson($_GET['id']); if ($editLesson->isUserActiveInLesson($editedUser)) { $editLesson->unConfirm($editedUser); $response['access'] = 0; } else { $editLesson->confirm($editedUser); $response['access'] = 1; } echo json_encode($response); exit; } else { if (isset($_GET['ajax']) && in_array($_GET['ajax'], array('lessonsTable'))) { $roles = EfrontLessonUser::getLessonsRoles(true); $smarty->assign("T_ROLES_ARRAY", $roles); $directionsTree = new EfrontDirectionsTree(); $smarty->assign("T_DIRECTION_PATHS", $directionsTree->toPathString());
public static function lightGetUserStatusInLesson($login, $currentLesson, $seenContent, $visitableIterator) { $visitableTestIds = $visitableUnits = array(); foreach ($visitableIterator as $key => $value) { if ($value['active']) { $visitableUnits[$key] = $key; if ($value['ctg_type'] == 'tests' || $value['ctg_type'] == 'scorm_test') { $visitableTestIds[$key] = $key; } } } $overallProgress = 0; if (sizeof($visitableUnits) > 0) { $overallProgress = round(100 * sizeof(array_intersect(array_keys($visitableUnits), array_keys($seenContent))) / sizeof($visitableUnits), 2); } $conditions = $currentLesson->getConditions(); foreach ($conditions as $condition) { if ($condition['time_in_lesson']) { $time_condition = true; } } if ($time_condition) { $usersTimesInLessonContent = EfrontLesson::getUserActiveTimeInLesson($login, $currentLesson->lesson['id']); } else { $usersTimesInLessonContent = null; } list($conditionsMet, $lessonPassed) = EfrontStats::checkConditions($seenContent, $conditions, $visitableUnits, $visitableTestIds, $usersTimesInLessonContent); $status = eF_getTableData("users_to_lessons", "*", "users_LOGIN='******' and lessons_ID={$currentLesson->lesson['id']}"); $userProgress = array('completed' => $status[0]['completed'], 'score' => $status[0]['score'], 'overall_progress' => $overallProgress, 'lesson_passed' => $lessonPassed, 'total_conditions' => sizeof($conditions), 'conditions_passed' => array_sum($conditionsMet)); return $userProgress; }