Example #1
0
}
!isset($currentUser->coreAccess['content']) || $currentUser->coreAccess['content'] == 'change' ? $_change_ = 1 : ($_change_ = 0);
$smarty->assign("_change_", $_change_);
if (!$_change_) {
    eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
    exit;
}
$loadScripts[] = 'includes/order';
try {
    $currentContent = new EfrontContentTree($currentLesson);
    $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST));
    //Legal values are the array of entities that the current user may actually edit or change.
    foreach ($iterator as $key => $value) {
        $legalValues[] = $key;
    }
    $smarty->assign("T_UNIT_ORDER_TREE", $currentContent->toHTML($iterator, 'dhtmlContentTree', array('delete' => true, 'noclick' => true, 'activate' => true, 'drag' => true, 'expand' => true)));
    $options = array(array('image' => '16x16/undo.png', 'text' => _REPAIRTREE, 'href' => 'javascript:void(0)', 'onClick' => 'if (confirm (\'' . _ORDERWILLPERMANENTLYCHANGE . '\')) repairTree(this);'));
    $smarty->assign("T_TABLE_OPTIONS", $options);
    try {
        if (isset($_POST['delete_nodes']) && $_POST['delete_nodes']) {
            //Needed in order to delete branches as well
            $_POST['delete_nodes'] = array_reverse($_POST['delete_nodes']);
            foreach ($_POST['delete_nodes'] as $value) {
                try {
                    if (in_array($value, $legalValues) && eF_checkParameter($value, 'id')) {
                        // Delete also linked units
                        $linked_units = eF_getTableData('content', 'id', 'linked_to=' . $value);
                        foreach ($linked_units as $unit) {
                            $lessons_IDs = eF_getTableData('content', 'lessons_ID', 'id=' . $unit['id']);
                            foreach ($lessons_IDs as $lessons_ID) {
                                $lessonsContent = new EfrontContentTree($lessons_ID['lessons_ID']);
Example #2
0
                    $unit = new EfrontUnit($_GET['id']);
                    $unit['ctg_type'] == 'scorm_test' ? $unit['ctg_type'] = 'scorm' : ($unit['ctg_type'] = 'scorm_test');
                    $unit->persist();
                    echo json_encode(array('id' => $unit['id'], 'ctg_type' => $unit['ctg_type']));
                    exit;
                }
                if (isset($_GET['reset_scorm']) && isset($_GET['id']) && in_array($_GET['id'], $valid12Units)) {
                    //eF_deleteTableData("scorm_data", "id=".$_GET['delete']);
                    //$user = EfrontUserFactory::factory($scormData[0]['users_LOGIN']);
                    //$user -> setSeenUnit($scormData[0]['content_ID'], $currentLesson, false);
                }
                //Reset scorm data
                if (isset($_GET['reset_scorm']) && isset($_GET['id']) && in_array($_GET['id'], $valid2004Units)) {
                    if (isset($_GET['login']) && eF_checkParameter($_GET['login'], 'login')) {
                        //EfrontContentTreeSCORM :: resetSCORMContentOrganization($currentLesson, $_GET['id'], $_GET['login']);
                    } else {
                        EfrontContentTreeSCORM::resetSCORMContentOrganization($currentLesson, $_GET['id']);
                    }
                }
            } catch (Exception $e) {
                header("HTTP/1.0 500 ");
                echo $e->getMessage() . ' (' . $e->getCode() . ')';
                exit;
            }
            $smarty->assign("T_SCORM_TREE", $currentContent->toHTML($iterator, false, $options));
        }
    }
}
//$scormOptions[] = array('text' => _SCORMEXPORT,       'image' => "32x32/export.png",         'href' => "scorm_export.php?lessons_ID=".$_SESSION['s_lessons_ID'], 'onClick' => "eF_js_showDivPopup(event, '"._SCORMEXPORT."',     2)", 'target' => 'POPUP_FRAME');
//$scormOptions[] = array('text' => _SCORMIMPORT,       'image' => "32x32/import.png",         'href' => "scorm_import.php?lessons_ID=".$_SESSION['s_lessons_ID'], 'onClick' => "eF_js_showDivPopup(event, '"._SCORMIMPORT."',     2)", 'target' => 'POPUP_FRAME');
//$scormOptions[] = array('text' => _REVIEWSCORMDATA,   'image' => "32x32/unit.png",   'href' => "scorm_review.php?lessons_ID=".$_SESSION['s_lessons_ID'], 'onClick' => "eF_js_showDivPopup(event, '"._REVIEWSCORMDATA."', 2)", 'target' => 'POPUP_FRAME');
             if (isset($_GET['type']) && $_GET['type'] == 'examples') {
                 $iterator = new EfrontExampleFilterIterator(new EfrontVisitableFilterIterator($basicIterator));
             } else {
                 $iterator = new EfrontVisitableAndEmptyFilterIterator($basicIterator);
             }
         }
     }
     //Find the parents of each of these units, so that we can keep them in the tree
     foreach ($iterator as $key => $value) {
         foreach ($currentContent->getNodeAncestors($key) as $parent) {
             $parents[$parent['id']] = $parent['id'];
         }
     }
     //This iterator keeps the special units (for example, tests or examples) plus their parents
     $iterator = new EfrontInArrayFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST))), $parents);
     $smarty->assign("T_THEORY_TREE", $currentContent->toHTML($iterator, 'dhtmlContentTree'));
 } else {
     if (G_VERSIONTYPE != 'community') {
         #cpp#ifndef COMMUNITY
         if (G_VERSIONTYPE != 'standard') {
             #cpp#ifndef STANDARD
             /*Check current unit*/
             if (isset($_GET['package_ID']) && $currentContent) {
                 if ($currentUser->coreAccess['content'] == 'hidden') {
                     eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
                 }
                 try {
                     //Needed at commit and initialize
                     $_SESSION['package_ID'] = $_GET['package_ID'];
                     //
                     //Set organization_ID and objectives_global_to_system
Example #4
0
 if (isset($_SESSION['s_type']) && $_SESSION['s_type'] == 'administrator' || in_array($_SESSION['s_login'], array_keys($course->getUsers()))) {
     $smarty->assign("T_HAS_COURSE", true);
 }
 if (G_VERSIONTYPE == 'enterprise') {
     #cpp#ifdef ENTERPRISE
     $result = eF_getTableData("module_hcd_course_to_branch mb, module_hcd_branch b", "mb.branches_ID, b.name", "mb.branches_ID=b.branch_ID and courses_ID=" . $course->course['id']);
     if (!empty($result)) {
         $course->course['location'] = $result[0]['name'];
     }
 }
 #cpp#endif
 $lessons = $course->getCourseLessons();
 foreach ($lessons as $key => $lesson) {
     $content = new EfrontContentTree($lesson);
     if (sizeof($content->tree) > 0) {
         $contentTree[$key] = $content->toHTML(false, 'dhtml_content_tree_' . $lesson->lesson['id'], array('noclick' => 1));
     }
     $lessonInfo[$key] = new LearningObjectInformation(unserialize($lesson->lesson['info']));
     $additionalInfo[$key] = $lesson->getInformation();
 }
 $smarty->assign("T_ADDITIONAL_LESSON_INFO", $additionalInfo);
 $smarty->assign("T_COURSE_LESSON_INFO", $lessonInfo);
 $smarty->assign("T_CONTENT_TREE", $contentTree);
 $smarty->assign("T_LANGUAGES", EfrontSystem::getLanguages(true));
 $smarty->assign("T_COURSE_LESSONS", $lessons);
 $constraints = array('archive' => false, 'active' => true, 'sort' => 'name', 'condition' => 'show_catalog=1');
 if ($course->course['instance_source']) {
     $parentCourse = new EfrontCourse($course->course['instance_source']);
     $instances = $parentCourse->getInstances($constraints);
     $instances[$parentCourse->course['id']] = $parentCourse;
 } else {
Example #5
0
         header("HTTP/1.0 500 ");
         echo $e->getMessage() . ' (' . $e->getCode() . ')';
     }
     exit;
     //We asked to copy content
 } else {
     $currentContent = new EfrontContentTree($currentLesson, true);
     $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST));
     if (sizeof($currentContent->tree) == 0) {
         $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML($iterator, 'dhtmlTargetTree', array('noclick' => true, 'drag' => false, 'tree_root' => true)));
     } else {
         $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML($iterator, 'dhtmlTargetTree', array('noclick' => true, 'drag' => false, 'expand' => true, 'truncateNames' => EfrontUnit::MAXIMUM_NAME_LENGTH)));
     }
     $sourceContent = new EfrontContentTree($_GET['from'], true);
     $sourceIterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($sourceContent->tree), RecursiveIteratorIterator::SELF_FIRST));
     $smarty->assign("T_SOURCE_TREE", $sourceContent->toHTML($sourceIterator, 'dhtmlSourceTree', array('noclick' => true, 'drag' => true, 'expand' => true)));
     $currentIds[] = 0;
     //0 is a valid parent node
     foreach ($iterator as $key => $value) {
         $currentIds[] = $value['id'];
     }
     //pr($currentIds);
     foreach ($sourceIterator as $key => $value) {
         $sourceIds[] = $value['id'];
     }
     try {
         if (isset($_GET['node_orders'])) {
             //Save new order through AJAX call
             $nodeOrders = explode(",", $_GET['node_orders']);
             $nodeOrders = array_unique($nodeOrders);
             $previousContentId = 0;
Example #6
0
 /**
  * Analyse completed test
  *
  * This function is used to analyse completed test. Scores are calculated for
  * each unit and subunit, based on the corresponding questions performance.
  * <br/>Example:
  * <code>
  * list($parentScores, $analysisCode) = $completedTest -> analyseTest();
  * </code>
  * The function returns an array with 2 separate elements: The first element is the array
  * of scores per unit, which is needed in order to display the chart. The second element
  * is the content tree, where the scores per unit are depicted.
  *
  * @return array A results array.
  * @since 3.5.2
  * @access public
  */
 public function analyseTest()
 {
     $parentScores = array();
     foreach ($this->questions as $question) {
         $questionIds[$question->question['content_ID']]['score'] += $question->score;
         $questionIds[$question->question['content_ID']]['total']++;
         $question->score > 0 ? $questionIds[$question->question['content_ID']]['correct'] += $question->score / 100 : null;
     }
     $questionsStats = EfrontStats::getQuestionsUnitStatistics($this->questions);
     //Get unit names and ids
     $content = new EfrontContentTree(key($this->getLesson()));
     if (isset($_GET['entity']) && $_GET['entity']) {
         $temp = $content->seekNode($_GET['entity']);
         $tree[0] = new EfrontUnit(array('id' => 0, 'name' => _NOUNIT, 'active' => 1, $temp['id'] => $temp));
         //Add a bogus unit to hold questions which do not belong to a unit
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($tree), RecursiveIteratorIterator::SELF_FIRST));
     } else {
         $tree = $content->tree;
         $tree[0] = new EfrontUnit(array('id' => 0, 'name' => _NOUNIT, 'active' => 1));
         //Add a bogus unit to hold questions which do not belong to a unit
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST));
     }
     foreach ($iterator as $key => $value) {
         if ($key != 0) {
             foreach ($content->getNodeAncestors($key) as $id => $foo) {
                 $parentScores[$foo['id']]['score'] += $questionIds[$key]['score'];
                 $parentScores[$foo['id']]['total'] += $questionIds[$key]['total'];
                 $parentScores[$foo['id']]['correct'] += $questionIds[$key]['correct'];
             }
             $parentScores[$key]['this_score'] += $questionIds[$key]['score'];
             $parentScores[$key]['this_total'] += $questionIds[$key]['total'];
             $parentScores[$key]['this_correct'] += $questionIds[$key]['correct'];
             $parentScores[$key]['name'] = $value['name'];
             // Check if this chapter is a parent one.
             if (isset($content->tree[$key])) {
                 $parentScores[$key]['top_level'] = 1;
             } else {
                 $parentScores[$key]['top_level'] = 0;
             }
         }
     }
     foreach ($parentScores as $id => $value) {
         if ($value['total']) {
             $parentScores[$id]['percentage'] = round($value['score'] / $value['total'], 2);
         }
         if ($value['this_total']) {
             $parentScores[$id]['this_percentage'] = round($value['this_score'] / $value['this_total'], 2);
         }
         if ($value['total']) {
             $options['custom'][$id] = '
                             <span style = "margin-left:20px;color:gray">' . $parentScores[$id]['percentage'] . '% [' . $value['correct'] . '/' . $value['total'] . ']</span>
                             <img src = "images/16x16/information.png" style = "vertical-align:middle" alt = "" title = "' . _THISLEVEL . ': ' . $parentScores[$id]['this_percentage'] . '% [' . $value['this_correct'] . '/' . $value['this_total'] . ']';
             if ($value['total'] - $value['this_total'] > 0) {
                 $options['custom'][$id] .= '/ ' . _BELOWLEVELS . ': ' . round(($value['score'] - $value['this_score']) / ($value['total'] - $value['this_total']), 2) . '% [' . ($value['correct'] - $value['this_correct']) . '/' . ($value['total'] - $value['this_total']) . '] ';
             }
             $options['custom'][$id] .= '">';
         } else {
             unset($parentScores[$id]);
         }
     }
     $iterator = new analyseTestFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST)), array_keys($parentScores));
     $options['show_hide'] = false;
     $options['noclick'] = true;
     //$options['tree_root'] = array('name' => _BACKTOTOP, 'class' => 'examples', 'onclick' => "$('analysis_frame').src = $('analysis_frame').src.replace(/selected_unit=(\d*)/, 'selected_unit='+Element.extend(this).up().id.replace(/node/, ''));");
     //$options['onclick']   = "re = new RegExp(this.up().id.replace(/node/, ''), 'g');if(treeObj.getNodeOrders().match(re).length > 1) $('analysis_frame').src = $('analysis_frame').src.replace(/selected_unit=(\d*)/, 'selected_unit='+Element.extend(this).up().id.replace(/node/, ''));";
     $options['onclick'] = "showGraph(\$('proto_chart'), 'graph_test_analysis', Element.extend(this).up().id.replace(/node/, ''));";
     return array($parentScores, $content->toHTML($iterator, false, $options));
 }
 //Content tree block
 if (EfrontUser::isOptionVisible('tests')) {
     $iterator = new EfrontVisitableAndEmptyFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1)));
     $firstNodeIterator = new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1)));
 } else {
     $iterator = new EfrontNoTestsFilterIterator(new EfrontVisitableAndEmptyFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1))));
     $firstNodeIterator = new EfrontNoTestsFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1))));
 }
 /*	$hideFeedback = false;
 			foreach (new EfrontNoFeedbackFilterIterator(new EfrontVisitableFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent -> tree), RecursiveIteratorIterator :: SELF_FIRST), array('active' => 1)))) as $key => $value) {
 				if (!$value['seen']) {
 					$hideFeedback = true;
 				}
 			} */
 if ($currentLesson->options['content_tree']) {
     $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML($iterator, false, array('truncateNames' => 60, 'hideFeedback' => $hideFeedback)));
 }
 //Progress, status and start/continue block
 if (!$currentLesson->options['tracking'] || $currentUser->coreAccess['content'] == 'hidden') {
     $currentLesson->options['lesson_info'] ? $controlPanelOptions[] = array('text' => _LESSONINFORMATION, 'image' => '32x32/information.png', 'href' => basename($_SERVER['PHP_SELF']) . '?ctg=lesson_information', 'onClick' => "eF_js_showDivPopup(event, '" . _LESSONINFORMATION . "', 2)", 'target' => 'POPUP_FRAME') : null;
 } else {
     $seenContent = EfrontStats::getStudentsSeenContent($currentLesson, $currentUser);
     $seenContent = $seenContent[$currentLesson->lesson['id']][$currentUser->user['login']];
     $userProgress = EfrontStats::lightGetUserStatusInLesson($_SESSION['s_login'], $currentLesson, $seenContent, $iterator);
     $result = eF_getTableData("users_to_lessons", "current_unit", "users_LOGIN = '******'login'] . "' and lessons_ID = " . $currentLesson->lesson['id']);
     sizeof($result) > 0 ? $userProgress['current_unit'] = $result[0]['current_unit'] : ($userProgress['current_unit'] = false);
     if ($userProgress['lesson_passed'] && !$userProgress['completed']) {
         if (!$userProgress['completed'] && $currentLesson->options['auto_complete']) {
             $userProgress = EfrontStats::getUsersLessonStatus($currentLesson, $currentUser->user['login']);
             $userProgress = $userProgress[$currentLesson->lesson['id']][$currentUser->user['login']];
             $userProgress['tests_avg_score'] ? $avgScore = $userProgress['tests_avg_score'] : ($avgScore = 100);
         }
         if (isset($_GET['preview_correct']) && $_SESSION['s_lesson_user_type'] != 'student') {
             $printTest->preview_correct = true;
         }
         $printTest->options['onebyone'] = 0;
         $testString = $printTest->toHTML($printTest->toHTMLQuickForm(new HTML_QuickForm(), false, false, false, true), false, true);
         //This way, even 1-1 tests are printed in a single page
     } else {
         $testString = $showTest->toHTML($showTest->toHTMLQuickForm(), false);
     }
     $smarty->assign("T_TEST_UNSOLVED", $testString);
     if (!$skillgap_tests) {
         //$smarty -> assign("T_CONTENT_TREE", $currentContent -> toHTML($iterator,       'dhtmlTargetTree', array('noclick' => true, 'drag' => false, 'selectedNode' => $currentUnit['id'])));
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($currentContent->tree), RecursiveIteratorIterator::SELF_FIRST), array('active' => 1));
         if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') {
             $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML($iterator, 'dhtmlContentTree', array('truncateNames' => 20, 'edit' => false, 'selectedNode' => $currentUnit['id'])));
         } else {
             $smarty->assign("T_CONTENT_TREE", $currentContent->toHTML($iterator, 'dhtmlContentTree', array('truncateNames' => 20, 'edit' => true, 'selectedNode' => $currentUnit['id'])));
         }
     }
 } elseif (isset($_GET['questions_order']) && in_array($_GET['questions_order'], $legalValues) && eF_checkParameter($_GET['questions_order'], 'id')) {
     if (!$_change_) {
         throw new EfrontUserException(_UNAUTHORIZEDACCESS, EfrontUserException::RESTRICTED_USER_TYPE);
     }
     $currentTest = new EfrontTest($_GET['questions_order']);
     $questions = $currentTest->getQuestions();
     foreach ($questions as $key => $question) {
         $questions[$key]['text'] = strip_tags($question['text']);
     }
     $smarty->assign("T_QUESTIONS", $questions);
     if (isset($_GET['ajax'])) {
Example #9
0
//General initializations and parameters
session_cache_limiter('none');
session_start();
$path = "../../libraries/";
/** The configuration file.*/
include_once $path . "configuration.php";
//Access is not allowed to users that are not logged in
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;
}
$loadScripts = array('scriptaculous/prototype', 'EfrontScripts', 'drag-drop-folder-tree');
$contentTree = new EfrontContentTree($_SESSION['s_lessons_ID']);
$visitableIterator = new EfrontVisitableAndEmptyFilterIterator(new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($contentTree->tree), RecursiveIteratorIterator::SELF_FIRST)));
$html = $contentTree->toHTML($visitableIterator, false, array('noclick' => true, 'onclick' => 'setLink(this)'));
$mainScripts = getMainScripts();
$smarty->assign("T_HEADER_MAIN_SCRIPTS", implode(",", $mainScripts));
$smarty->assign("T_CONTENT_TREE", $html);
$smarty->display("browsecontent.tpl");
?>