/**
  * Get the previous lesson in row, or in the course, if specified
  *
  * @param EfrontLesson $lesson The lesson to account
  * @param mixed $course The course to regard, or false
  * @return int The id of the previous lesson in row
  * @since 3.6.3
  * @access public
  */
 public function getPreviousLesson($lesson, $course = false)
 {
     $previousLesson = false;
     if ($course) {
         $course instanceof EfrontCourse or $course = new EfrontCourse($course);
         $eligibility = new ArrayIterator($course->checkRules($_SESSION['s_login']));
         while ($eligibility->valid() && ($key = $eligibility->key()) != $lesson->lesson['id']) {
             $previous = $key;
             $eligibility->next();
         }
         if (isset($previous) && $previous) {
             $previousLesson = $previous;
         }
     } else {
         $directionsTree = new EfrontDirectionsTree();
         $userLessons = new ArrayIterator($directionsTree->getLessonsList($this->getUserLessons()));
         while ($userLessons->valid() && ($key = $userLessons->current()) != $lesson->lesson['id']) {
             $previous = $key;
             $userLessons->next();
         }
         if (isset($previous) && $previous) {
             $previousLesson = $previous;
         }
     }
     return $previousLesson;
 }
示例#2
0
    } else {
        if ($_GET['new_lessons_ID'] == $_SESSION['s_lessons_ID']) {
            $smarty->assign("T_SHOW_LOADED_LESSON_OPTIONS", 1);
        }
    }
}
/*This is the first time the professor enters this lesson, so register the lesson id to the session*/
if (isset($_GET['lessons_ID']) && eF_checkParameter($_GET['lessons_ID'], 'id')) {
    if (!isset($_SESSION['s_lessons_ID']) || $_GET['lessons_ID'] != $_SESSION['s_lessons_ID'] || isset($_GET['from_course']) && $_GET['from_course'] != $_SESSION['s_courses_ID']) {
        if (isset($_GET['course']) || isset($_GET['from_course'])) {
            if ($_GET['course']) {
                $course = new EfrontCourse($_GET['course']);
            } else {
                $course = new EfrontCourse($_GET['from_course']);
            }
            $eligibility = $course->checkRules($_SESSION['s_login']);
            if ($eligibility[$_GET['lessons_ID']] == 0) {
                unset($_GET['lessons_ID']);
                $message = _YOUCANNOTACCESSTHISLESSONBECAUSEOFCOURSERULES;
                eF_redirect("student.php?ctg=lessons&message=" . urlencode($message) . "&message_type=failure");
            }
            $_SESSION['s_courses_ID'] = $course->course['id'];
        } else {
            unset($_SESSION['s_courses_ID']);
        }
        if (in_array($_GET['lessons_ID'], array_keys($userLessons))) {
            $newLesson = new EfrontLesson($_GET['lessons_ID']);
            if (!isset($_GET['course']) && !isset($_GET['from_course']) && $roles[$userLessons[$_GET['lessons_ID']]] == 'student' && ($newLesson->lesson['from_timestamp'] && $newLesson->lesson['from_timestamp'] > time() || $newLesson->lesson['to_timestamp'] && $newLesson->lesson['to_timestamp'] < time())) {
                eF_redirect("student.php?ctg=lessons&message=" . urlencode(_YOUCANNOTACCESSTHISLESSONORITDOESNOTEXIST));
            }
            $_SESSION['s_lessons_ID'] = $_GET['lessons_ID'];