/** * Set the lesson mode to 'unique' in the course * * @param EfrontLesson $lesson The lesson to set the mode for * @since 3.6.1 * @access private */ private function setUniqueLessonMode($lesson) { $courseUsers = $this->countCourseUsers(array('archive' => false)); if ($courseUsers['count'] > 0) { throw new Exception(_YOUCANNOTCHANGEMODECOURSENOTEMPTY, EfrontCourseException::COURSE_NOT_EMPTY); } //First, search for any instances that where already defined for this lesson and course in the past $result = eF_getTableData("lessons", "*", "instance_source=" . $lesson->lesson['id'] . " and originating_course=" . $this->course['id']); $coursedata = eF_getTableData("lessons_to_courses", "*", "lessons_ID=" . $lesson->lesson['id'] . " and courses_ID=" . $this->course['id']); if (sizeof($result) > 0) { $lessonInstance = new EfrontLesson($result[0]); $lessonsSchedule[$lessonInstance->lesson['id']] = array('start_date' => $coursedata[0]['start_date'], 'end_date' => $coursedata[0]['end_date'], 'start_period' => $coursedata[0]['start_period'], 'end_period' => $coursedata[0]['end_period']); $this->addLessons($lessonInstance, $lessonsSchedule); } else { $lessonInstance = EfrontLesson::createInstance($lesson, $this); $lessonsSchedule[$lessonInstance->lesson['id']] = array('start_date' => $coursedata[0]['start_date'], 'end_date' => $coursedata[0]['end_date'], 'start_period' => $coursedata[0]['start_period'], 'end_period' => $coursedata[0]['end_period']); $this->addLessons($lessonInstance, $lessonsSchedule); } $this->replaceLessonInCourseOrder($lesson, $lessonInstance); $this->replaceLessonInCourseRules($lesson, $lessonInstance); //Must be put *before* removeLessons() //$this -> removeLessons($lesson); //commented out because it was messing up with order eF_deleteTableData("lessons_to_courses", "courses_ID=" . $this->course['id'] . " and lessons_ID=" . $lesson->lesson['id']); }