Ejemplo n.º 1
0
 private function getRssSource($source, $mode, $lesson)
 {
     $feeds = $this->getProvidedFeeds();
     foreach ($feeds as $value) {
         if ($value['active'] && $value['mode'] == 'system') {
             $systemFeeds[$value['type']] = $value;
         } else {
             if ($value['active'] && $value['mode'] == 'lesson') {
                 $lessonFeeds[$value['type']] = $value;
             }
         }
     }
     if ($mode == 'system' && !in_array($source, array_keys($systemFeeds))) {
         return array();
     } elseif ($mode == 'lesson' && !in_array($source, array_keys($lessonFeeds))) {
         return array();
     }
     $data = array();
     switch ($source) {
         case 'announcements':
             if ($mode == 'system') {
                 $news = news::getNews(0, true);
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $news = news::getNews($lesson, true);
                 } else {
                     $lessons = eF_getTableDataFlat("lessons", "id, name");
                     $lessonNames = array_combine($lessons['id'], $lessons['name']);
                     $news = news::getNews($lessons['id'], true);
                 }
             }
             $count = 1;
             foreach ($news as $value) {
                 if ($mode == 'lesson' && !$lesson) {
                     $value['title'] = $lessonNames[$value['lessons_ID']] . ': ' . $value['title'];
                     $link = G_SERVERNAME . 'userpage.php?lessons_ID=' . $value['lessons_ID'] . '&ctg=news&view=' . $value['id'];
                 } else {
                     $link = G_SERVERNAME . 'userpage.php?ctg=news&view=' . $value['id'];
                 }
                 $data[] = array('title' => $value['title'], 'link' => $link, 'description' => $value['data']);
                 /*
                     				if ($count++ == $this -> feedLimit) {
                     					break;
                     				}
                 */
             }
             break;
         case 'catalog':
             $constraints = array("return_objects" => false, 'archive' => false, 'active' => true);
             $result = EfrontCourse::getAllCourses($constraints);
             $directionsTree = new EfrontDirectionsTree();
             $directionPaths = $directionsTree->toPathString();
             foreach ($result as $value) {
                 $pathString = $directionPaths[$value['directions_ID']] . ' → ' . $value['name'];
                 $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&amp;courses_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info'])));
             }
             $result = eF_getTableData("lessons", "id,name,directions_ID, info", "archive=0 and instance_source = 0 and active=1 and course_only=0", "name");
             foreach ($result as $value) {
                 $pathString = $directionPaths[$value['directions_ID']] . '&nbsp;&rarr;&nbsp;' . $value['name'];
                 $data[] = array('title' => $pathString, 'link' => G_SERVERNAME . 'index.php?ctg=lesson_info&amp;lessons_ID=' . $value['id'], 'description' => implode("<br>", unserialize($value['info'])));
             }
             $data = array_values(eF_multisort($data, 'title', 'asc'));
             //Sort results based on path string
             break;
         case 'calendar':
             if ($mode == 'system') {
                 $events = calendar::getGlobalCalendarEvents();
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $events = calendar::getLessonCalendarEvents($lesson);
                 } else {
                     $events = calendar::getCalendarEventsForAllLessons();
                 }
             }
             foreach ($events as $value) {
                 $value['name'] ? $title = formatTimestamp($value['timestamp']) . ' (' . $value['name'] . ')' : ($title = formatTimestamp($value['timestamp']));
                 $data[] = array('title' => $title, 'link' => G_SERVERNAME . 'userpage.php?ctg=calendar&amp;view_calendar=' . $value['timestamp'] . '&amp;type=0', 'description' => $value['data']);
             }
             break;
             /*
                 		case 'history':
                 			$currentUser = $this -> getCurrentUser();
             
             				$eventObjects = array();
                 			$result = eF_getTableData("events", "*", "", "timestamp DESC limit 100");
             				foreach ($result as $value) {
             					$eventObject = new EfrontEvent($value);
             					$eventObject -> createMessage();
             					pr($eventObject);
             				}
             
                 			break;
             */
         /*
             		case 'history':
             			$currentUser = $this -> getCurrentUser();
         
         				$eventObjects = array();
             			$result = eF_getTableData("events", "*", "", "timestamp DESC limit 100");
         				foreach ($result as $value) {
         					$eventObject = new EfrontEvent($value);
         					$eventObject -> createMessage();
         					pr($eventObject);
         				}
         
             			break;
         */
         case 'structure':
             if ($lesson) {
                 $contentTree = new EfrontContentTree($lesson);
                 $contentPath = $contentTree->toPathStrings();
                 foreach ($contentPath as $key => $value) {
                     $data[] = array('title' => $value, 'link' => G_SERVERNAME . 'userpage.php?lessons_ID=' . $lesson . '&amp;unit=' . $key, 'description' => $value);
                 }
             }
             break;
         case 'forum':
             if ($mode == 'system') {
                 $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id ", "fm.timestamp desc LIMIT 100");
             } elseif ($mode == 'lesson') {
                 if ($lesson) {
                     $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID = '" . $lesson . "'", "fm.timestamp desc LIMIT 100");
                 } else {
                     $result = eF_getTableData("f_messages fm JOIN f_topics ft JOIN f_forums ff LEFT OUTER JOIN lessons l ON ff.lessons_ID = l.id", "ff.title as forum_name, fm.body, fm.title, fm.id, ft.id as topic_id, ft.title as topic_title, fm.users_LOGIN, fm.timestamp, l.name as lessons_name, lessons_id as show_lessons_id", "ft.f_forums_ID=ff.id AND fm.f_topics_ID=ft.id AND ff.lessons_ID != 0", "fm.timestamp desc LIMIT 100");
                 }
             }
             foreach ($result as $value) {
                 $value['title'] = $value['forum_name'] . ' >> ' . $value['topic_title'] . ' >> ' . $value['title'];
                 if ($mode == 'system' && $value['lessons_name'] || $mode == 'lesson' && !$lesson) {
                     $value['title'] = $value['lessons_name'] . ': ' . $value['title'];
                 }
                 $data[] = array('title' => $value['title'], 'link' => G_SERVERNAME . 'userpage.php?ctg=forum&amp;topic=' . $value['topic_id'], 'description' => $value['body']);
             }
             break;
         default:
             break;
     }
     return $data;
 }
     }
     $form->addRule('scorm_size', _INVALIDFIELDDATA, 'checkParameter', 'id');
     $smarty->assign("T_SCORM", true);
 }
 //Set elements rules
 $form->addRule('name', _THEFIELD . ' "' . _UNITNAME . '" ' . _ISMANDATORY, 'required', null, 'client');
 //The name is mandatory
 //$form -> addRule('ctg_type', _THEFIELD.' '._CONTENTTYPE.' '._ISMANDATORY, 'required', null, 'client');       //The content type is mandatry
 if (!isset($_GET['edit'])) {
     // changed in case parent unit is inactive
     $form->addRule('parent_content_ID', _THEFIELD . ' ' . _UNITPARENT . ' ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('parent_content_ID', _INVALIDID, 'numeric');
 }
 //Add the content's questions, in order to setup "complete with question" field
 if (sizeof($currentLesson->getQuestions()) > 0) {
     $pathStrings = $currentContent->toPathStrings();
     foreach ($currentLesson->getQuestions() as $key => $value) {
         if ($value['type'] != 'raw_text' || $value['id'] == $currentUnit['options']['complete_question']) {
             $plainText = trim(strip_tags($value['text']));
             if (mb_strlen($plainText) > Question::maxQuestionText) {
                 $plainText = mb_substr($plainText, 0, Question::maxQuestionText) . '...';
             }
             $pathStrings[$value['content_ID']] ? $lessonQuestions[$value['id']] = $pathStrings[$value['content_ID']] . '&nbsp;&raquo;&nbsp;' . $plainText : ($lessonQuestions[$value['id']] = $plainText);
         }
     }
     if (!empty($lessonQuestions) || $currentUnit['options']['complete_unit_setting'] == EfrontUnit::COMPLETION_OPTIONS_COMPLETEWITHQUESTION) {
         $form->addElement('select', 'complete_question', _COMPLETEWITHQUESTION, $lessonQuestions, 'id = "complete_question"');
         $completeUnitSelect[EfrontUnit::COMPLETION_OPTIONS_COMPLETEWITHQUESTION] = _COMPLETEWITHQUESTION;
     }
 }
 ksort($completeUnitSelect);
Ejemplo n.º 3
0
            }
        }
        $smarty->assign('T_ALL_USERS', $testUsers);
        $smarty->display($_SESSION['s_type'] . '.tpl');
        exit;
    }
}
if (isset($_GET['ajax']) && $_GET['ajax'] == 'questionsTable') {
    // If no lesson then define the current lesson name => _SKILLGAPTESTS (used for correct filtering)
    $contentTrees = array();
    $difficultiesToWeights = array("low" => 1, "medium" => 2, "high" => 3, "very_high" => 4);
    foreach ($questions as $qid => $question) {
        if ($question['lessons_ID']) {
            if (!isset($contentTrees[$question['lessons_ID']])) {
                $temp = new EfrontContentTree($question['lessons_ID']);
                $contentTrees[$question['lessons_ID']] = $temp->toPathStrings();
            }
        }
        $questions[$qid]['text'] = strip_tags($question['text']);
        //If we ommit this line, then the questions list is html formatted, images are displayed etc, which is *not* the intended behaviour
        $questions[$qid]['parent_name'] = $unitNames[$question['content_ID']];
        $questions[$qid]['weight'] = !empty($testQuestions[$qid]['weight']) ? $testQuestions[$qid]['weight'] : $difficultiesToWeights[$question['difficulty']];
        $questions[$qid]['partof'] = 0;
        $questions[$qid]['estimate_interval'] = eF_convertIntervalToTime($question['estimate']);
        if ($question['lessons_ID'] == 0) {
            $questions[$qid]['name'] = _SKILLGAPTESTS;
        } else {
            $questions[$qid]['name'] = _LESSON . ': "' . $question['name'] . '"';
            $questions[$qid]['lesson_name'] = $lessons[$question['lessons_ID']]['name'];
            $questions[$qid]['parent_unit'] = $contentTrees[$question['lessons_ID']][$question['content_ID']];
        }