Esempio n. 1
0
 public function updateLesson($courseId, $lessonId, $fields)
 {
     $argument = $fields;
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'number' => 0, 'seq' => 0, 'chapterId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0, 'testMode' => 'normal', 'testStartTime' => 0, 'suggestHours' => '1.0', 'replayStatus' => 'ungenerated'));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live' && isset($fields['startTime'])) {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
         $fields['suggestHours'] = $fields['length'] / 60;
     }
     if (array_key_exists('media', $fields)) {
         $this->fillLessonMediaFields($fields);
     }
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     if (array_key_exists('mediaId', $fields)) {
         if ($fields['mediaId'] != $lesson['mediaId']) {
             // Incease the link count of the new selected lesson file
             if (!empty($fields['mediaId'])) {
                 $this->getUploadFileService()->waveUploadFile($fields['mediaId'], 'usedCount', 1);
             }
             // Decrease the link count of the original lesson file
             if (!empty($lesson['mediaId'])) {
                 $this->getUploadFileService()->waveUploadFile($lesson['mediaId'], 'usedCount', -1);
             }
         }
     }
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     $updatedLesson['fields'] = $lesson;
     $this->dispatchEvent("course.lesson.update", array('argument' => $argument, 'lesson' => $updatedLesson));
     return $updatedLesson;
 }
Esempio n. 2
0
 public function editLesson($lessonId, $fields)
 {
     return $this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields));
 }
Esempio n. 3
0
 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live') {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
     }
     $this->fillLessonMediaFields($fields);
     $lesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$lesson['title']}》({$lesson['id']})", $lesson);
     return $lesson;
 }
Esempio n. 4
0
 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'summary' => '', 'content' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0));
     if (isset($fields['title'])) {
         $fields['title'] = $this->purifyHtml($fields['title']);
     }
     $fields['type'] = $lesson['type'];
     if ($fields['type'] == 'live') {
         $fields['endTime'] = $fields['startTime'] + $fields['length'] * 60;
     }
     $this->fillLessonMediaFields($fields);
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     if ($fields['mediaId'] != $lesson['mediaId']) {
         // Incease the link count of the new selected lesson file
         if (!empty($fields['mediaId'])) {
             $this->getUploadFileService()->increaseFileUsedCount(array($fields['mediaId']));
         }
         // Decrease the link count of the original lesson file
         if (!empty($lesson['mediaId'])) {
             $this->getUploadFileService()->decreaseFileUsedCount(array($lesson['mediaId']));
         }
     }
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     return $updatedLesson;
 }
 public function updateLesson($courseId, $lessonId, $fields)
 {
     $course = $this->getCourse($courseId);
     if (empty($course)) {
         throw $this->createServiceException("课程(#{$courseId})不存在!");
     }
     $lesson = $this->getCourseLesson($courseId, $lessonId);
     if (empty($lesson)) {
         throw $this->createServiceException("课时(#{$lessonId})不存在!");
     }
     $fields = ArrayToolkit::filter($fields, array('title' => '', 'content' => '', 'summary' => '', 'media' => array(), 'mediaId' => 0, 'free' => 0, 'length' => 0, 'startTime' => 0, 'giveCredit' => 0, 'requireCredit' => 0, 'homeworkId' => 0, 'exerciseId' => 0, 'first_image' => ''));
     if (isset($fields['content'])) {
         $fields['content'] = $this->purifyHtml($fields['content']);
     }
     $updatedLesson = LessonSerialize::unserialize($this->getLessonDao()->updateLesson($lessonId, LessonSerialize::serialize($fields)));
     $this->updateCourseCounter($course['id'], array('giveCredit' => $this->getLessonDao()->sumLessonGiveCreditByCourseId($course['id'])));
     // Update link count of the course lesson file, if the lesson file is changed
     $this->getLogService()->info('course', 'update_lesson', "更新课时《{$updatedLesson['title']}》({$updatedLesson['id']})", $updatedLesson);
     return $updatedLesson;
 }