public function editAction(Request $request, $courseId, $lessonId) { $liveCourse = $this->getCourseService()->tryManageCourse($courseId); $liveLesson = $this->getCourseService()->getCourseLesson($liveCourse['id'], $lessonId); if ($request->getMethod() == 'POST') { $editLiveLesson = $request->request->all(); $liveLesson['type'] = 'live'; $liveLesson['title'] = $editLiveLesson['title']; $liveLesson['summary'] = $editLiveLesson['summary']; $liveLesson['courseId'] = $liveCourse['id']; $liveLesson['startTime'] = empty($editLiveLesson['startTime']) ? $liveLesson['startTime'] : strtotime($editLiveLesson['startTime']); $liveLesson['free'] = empty($editLiveLesson['free']) ? 0 : $editLiveLesson['free']; $liveLesson['length'] = empty($editLiveLesson['timeLength']) ? $liveLesson['length'] : $editLiveLesson['timeLength']; $speakerId = current($liveCourse['teacherIds']); $speaker = $speakerId ? $this->getUserService()->getUser($speakerId) : null; $speaker = $speaker ? $speaker['nickname'] : '老师'; $liveParams = array('liveId' => $liveLesson['mediaId'], 'provider' => $liveLesson['liveProvider'], 'summary' => $editLiveLesson['summary'], 'title' => $editLiveLesson['title'], 'speaker' => $speaker, 'authUrl' => $this->generateUrl('live_auth', array(), true), 'jumpUrl' => $this->generateUrl('live_jump', array('id' => $liveLesson['courseId']), true)); if (array_key_exists('startTime', $editLiveLesson)) { $liveParams['startTime'] = strtotime($editLiveLesson['startTime']); } if (array_key_exists('startTime', $editLiveLesson) && array_key_exists('timeLength', $editLiveLesson)) { $liveParams['endTime'] = strtotime($editLiveLesson['startTime']) + $editLiveLesson['timeLength'] * 60 . ''; } $client = LiveClientFactory::createClient(); $live = $client->updateLive($liveParams); $liveLesson = $this->getCourseService()->updateLesson($courseId, $lessonId, $liveLesson); return $this->render('TopxiaWebBundle:CourseLessonManage:list-item.html.twig', array('course' => $liveCourse, 'lesson' => $liveLesson)); } return $this->render('TopxiaWebBundle:LiveCourseLessonManage:live-lesson-modal.html.twig', array('liveCourse' => $liveCourse, 'liveLesson' => $liveLesson)); }
public function baseAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $courseSetting = $this->getSettingService()->get('course', array()); if ($request->getMethod() == 'POST') { $data = $request->request->all(); $this->getCourseService()->updateCourse($id, $data); $this->setFlashMessage('success', '课程基本信息已保存!'); return $this->redirect($this->generateUrl('course_manage_base', array('id' => $id))); } $tags = $this->getTagService()->findTagsByIds($course['tags']); if ($course['type'] == 'live') { $client = LiveClientFactory::createClient(); $liveCapacity = $client->getCapacity(); } else { $liveCapacity = null; } return $this->render('TopxiaWebBundle:CourseManage:base.html.twig', array('course' => $course, 'tags' => ArrayToolkit::column($tags, 'name'), 'liveCapacity' => empty($liveCapacity['capacity']) ? 0 : $liveCapacity['capacity'])); }
public function createAction(Request $request, $id) { $liveCourse = $this->getCourseService()->tryManageCourse($id); $parentId = $request->query->get('parentId'); if ($request->getMethod() == 'POST') { $liveLesson = $request->request->all(); $liveLesson['type'] = 'live'; $liveLesson['courseId'] = $liveCourse['id']; $liveLesson['startTime'] = strtotime($liveLesson['startTime']); $liveLesson['length'] = $liveLesson['timeLength']; $speakerId = current($liveCourse['teacherIds']); $speaker = $speakerId ? $this->getUserService()->getUser($speakerId) : null; $speaker = $speaker ? $speaker['nickname'] : '老师'; $client = LiveClientFactory::createClient(); $live = $client->createLive(array('title' => $liveLesson['title'], 'speaker' => $speaker, 'startTime' => $liveLesson['startTime'] . '', 'endTime' => $liveLesson['startTime'] + $liveLesson['length'] * 60 . '', 'authUrl' => $this->generateUrl('live_auth', array(), true), 'jumpUrl' => $this->generateUrl('live_jump', array('id' => $liveLesson['courseId']), true))); if (empty($live) or isset($live['error'])) { throw new \RuntimeException('创建直播教室失败,请重试!'); } $liveLesson['mediaId'] = $live['id']; $liveLesson = $this->getCourseService()->createLesson($liveLesson); return $this->render('TopxiaWebBundle:CourseLessonManage:list-item.html.twig', array('course' => $liveCourse, 'lesson' => $liveLesson)); } return $this->render('TopxiaWebBundle:LiveCourseLessonManage:live-lesson-modal.html.twig', array('liveCourse' => $liveCourse, 'parentId' => $parentId)); }
public function liveCourseSettingAction(Request $request) { $courseSetting = $this->getSettingService()->get('course', array()); $liveCourseSetting = $this->getSettingService()->get('live-course', array()); $client = LiveClientFactory::createClient(); $capacity = $client->getCapacity(); $default = array('live_course_enabled' => '0'); $this->getSettingService()->set('course', $courseSetting); $this->getSettingService()->set('live-course', $liveCourseSetting); $setting = array_merge($default, $liveCourseSetting); if ($request->getMethod() == 'POST') { $liveCourseSetting = $request->request->all(); $liveCourseSetting['live_student_capacity'] = empty($capacity['capacity']) ? 0 : $capacity['capacity']; $setting = array_merge($courseSetting, $liveCourseSetting); $this->getSettingService()->set('live-course', $liveCourseSetting); $this->getSettingService()->set('course', $setting); $hiddenMenus = $this->getSettingService()->get('menu_hiddens', array()); if ($liveCourseSetting['live_course_enabled']) { unset($hiddenMenus['admin_live_course_add']); unset($hiddenMenus['admin_live_course']); } else { $hiddenMenus['admin_live_course_add'] = true; $hiddenMenus['admin_live_course'] = true; } $this->getSettingService()->set('menu_hiddens', $hiddenMenus); $this->getLogService()->info('system', 'update_settings', "更新课程设置", $setting); $this->setFlashMessage('success', '课程设置已保存!'); } $setting['live_student_capacity'] = empty($capacity['capacity']) ? 0 : $capacity['capacity']; return $this->render('TopxiaAdminBundle:System:live-course-setting.html.twig', array('courseSetting' => $setting, 'capacity' => $capacity)); }
public function entryAction(Request $request, $courseId, $lessonId) { $user = $this->getCurrentUser(); if (!$user->isLogin()) { return $this->createMessageResponse('info', '你好像忘了登录哦?', null, 3000, $this->generateUrl('login')); } $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId); if (empty($lesson)) { return $this->createMessageResponse('info', '课时不存在!'); } if (empty($lesson['mediaId'])) { return $this->createMessageResponse('info', '直播教室不存在!'); } if ($lesson['startTime'] - time() > 7200) { return $this->createMessageResponse('info', '直播还没开始!'); } if ($lesson['endTime'] < time()) { return $this->createMessageResponse('info', '直播已结束!'); } if ($this->getCourseService()->isCourseTeacher($courseId, $user['id'])) { // 老师登录 $client = LiveClientFactory::createClient(); $params = array('liveId' => $lesson['mediaId'], 'provider' => $lesson['liveProvider'], 'user' => $user['email'], 'nickname' => $user['nickname'], 'role' => 'teacher'); $result = $client->startLive($params); if (empty($result) || isset($result['error'])) { return $this->createMessageResponse('info', '进入直播教室失败,请重试!'); } return $this->render("TopxiaWebBundle:LiveCourse:classroom.html.twig", array('lesson' => $lesson, 'url' => $result['url'], 'param' => isset($result['param']) ? $result['param'] : null)); } if ($this->getCourseService()->isCourseStudent($courseId, $user['id'])) { // http://webinar.vhall.com/appaction.php?module=inituser&pid=***&email=***&name=****&k=****&refer=**** // $matched = preg_match('/^c(\d+)u(\d+)t(\d+)s(\w+)$/', $k, $matches); $now = time(); $params = array(); $params['email'] = 'live-' . $user['id'] . '@edusoho.net'; $params['nickname'] = $user['nickname']; $params['sign'] = "c{$lesson['courseId']}u{$user['id']}t{$now}"; $params['sign'] .= 's' . $this->makeSign($params['sign']); $params['liveId'] = $lesson['mediaId']; $params['provider'] = $lesson["liveProvider"]; $params['role'] = 'student'; $client = LiveClientFactory::createClient(); $params['user'] = $params['email']; $result = $client->entryLive($params); if (isset($result["error"]) && $result["error"]) { return $this->createMessageResponse('error', $result["errorMsg"]); } return $this->render("TopxiaWebBundle:LiveCourse:classroom.html.twig", array('lesson' => $lesson, 'url' => $result['url'], 'param' => isset($result['param']) ? $result['param'] : null)); } return $this->createMessageResponse('info', '您不是课程学员,不能参加直播!'); }
public function courseSettingAction(Request $request) { $courseSetting = $this->getSettingService()->get('course', array()); $client = LiveClientFactory::createClient(); $capacity = $client->getCapacity(); $default = array('welcome_message_enabled' => '0', 'welcome_message_body' => '{{nickname}},欢迎加入课程{{course}}', 'buy_fill_userinfo' => '0', 'teacher_modify_price' => '1', 'teacher_manage_student' => '0', 'teacher_export_student' => '0', 'student_download_media' => '0', 'free_course_nologin_view' => '1', 'relatedCourses' => '0', 'coursesPrice' => '0', 'allowAnonymousPreview' => '1', 'live_course_enabled' => '0', 'userinfoFields' => array(), "userinfoFieldNameArray" => array(), "copy_enabled" => '0'); $this->getSettingService()->set('course', $courseSetting); $courseSetting = array_merge($default, $courseSetting); if ($request->getMethod() == 'POST') { $courseSetting = $request->request->all(); if (!isset($courseSetting['userinfoFields'])) { $courseSetting['userinfoFields'] = array(); } if (!isset($courseSetting['userinfoFieldNameArray'])) { $courseSetting['userinfoFieldNameArray'] = array(); } $courseSetting['live_student_capacity'] = empty($capacity['capacity']) ? 0 : $capacity['capacity']; $this->getSettingService()->set('course', $courseSetting); $this->getLogService()->info('system', 'update_settings', "更新课程设置", $courseSetting); $this->setFlashMessage('success', '课程设置已保存!'); } $courseSetting['live_student_capacity'] = empty($capacity['capacity']) ? 0 : $capacity['capacity']; $userFields = $this->getUserFieldService()->getAllFieldsOrderBySeqAndEnabled(); if ($courseSetting['userinfoFieldNameArray']) { foreach ($userFields as $key => $fieldValue) { if (!in_array($fieldValue['fieldName'], $courseSetting['userinfoFieldNameArray'])) { $courseSetting['userinfoFieldNameArray'][] = $fieldValue['fieldName']; } } } return $this->render('TopxiaAdminBundle:System:course-setting.html.twig', array('courseSetting' => $courseSetting, 'capacity' => $capacity, 'userFields' => $userFields, 'capacity' => $capacity)); }
public function entryReplay($lessonId, $courseLessonReplayId) { $lesson = $this->getLessonDao()->getLesson($lessonId); list($course, $member) = $this->tryTakeCourse($lesson['courseId']); $courseLessonReplay = $this->getCourseLessonReplayDao()->getCourseLessonReplay($courseLessonReplayId); $user = $this->getCurrentUser(); $args = array('liveId' => $lesson["mediaId"], 'replayId' => $courseLessonReplay["replayId"], 'provider' => $lesson["liveProvider"], 'user' => $user['email'], 'nickname' => $user['nickname']); $client = LiveClientFactory::createClient(); $result = $client->entryReplay($args); return $result; }
public function entryReplay($lessonId, $courseLessonReplayId) { $lesson = $this->getLessonDao()->getLesson($lessonId); $mediaId = $lesson["mediaId"]; $client = LiveClientFactory::createClient(); $email = $this->getCurrentUser()->email; $courseLessonReplay = $this->getCourseLessonReplayDao()->getCourseLessonReplay($courseLessonReplayId); $url = $client->entryReplay($mediaId, $courseLessonReplay["replayId"]); return $url; }
public function getClassroomUrlAction(Request $request, $courseId, $lessonId) { $user = $this->getCurrentUser(); $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId); if ($this->getCourseService()->isCourseTeacher($courseId, $user['id'])) { // 老师登录 $client = LiveClientFactory::createClient(); $params = array('liveId' => $lesson['mediaId'], 'provider' => $lesson['liveProvider'], 'user' => $user['email'], 'nickname' => $user['nickname'], 'role' => 'teacher'); $result = $client->startLive($params); if (empty($result) || isset($result['error'])) { return $this->createAccessDeniedException('进入直播教室失败,请重试!'); } return $this->createJsonResponse(array('url' => $result['url'], 'param' => isset($result['param']) ? $result['param'] : null)); } if ($this->getCourseService()->isCourseStudent($courseId, $user['id'])) { // http://webinar.vhall.com/appaction.php?module=inituser&pid=***&email=***&name=****&k=****&refer=**** // $matched = preg_match('/^c(\d+)u(\d+)t(\d+)s(\w+)$/', $k, $matches); $now = time(); $params = array(); $params['email'] = 'live-' . $user['id'] . '@edusoho.net'; $params['nickname'] = $user['nickname']; $params['sign'] = "c{$lesson['courseId']}u{$user['id']}t{$now}"; $params['sign'] .= 's' . $this->makeSign($params['sign']); $params['liveId'] = $lesson['mediaId']; $params['provider'] = $lesson["liveProvider"]; $params['role'] = 'student'; $client = LiveClientFactory::createClient(); $params['user'] = $params['email']; $result = $client->entryLive($params); if (isset($result["error"]) && $result["error"]) { return $this->createAccessDeniedException($result["errorMsg"]); } return $this->createJsonResponse(array('url' => $result['url'], 'param' => isset($result['param']) ? $result['param'] : null)); } return $this->createMessageResponse('info', '您不是课程学员,不能参加直播!'); }
public function createAction(Request $request) { $user = $this->getUserService()->getCurrentUser(); $userProfile = $this->getUserService()->getUserProfile($user['id']); $isLive = $request->query->get('flag'); $type = $isLive == "isLive" ? 'live' : 'normal'; if ($type == 'live') { $courseSetting = $this->setting('course', array()); if (!empty($courseSetting['live_course_enabled'])) { $client = LiveClientFactory::createClient(); $capacity = $client->getCapacity(); } else { $capacity = array(); } if (empty($courseSetting['live_course_enabled'])) { return $this->createMessageResponse('info', '请前往后台开启直播,尝试创建!'); } if (empty($capacity['capacity']) && !empty($courseSetting['live_course_enabled'])) { return $this->createMessageResponse('info', '请联系EduSoho官方购买直播教室,然后才能开启直播功能!'); } } if (false === $this->get('security.context')->isGranted('ROLE_TEACHER')) { throw $this->createAccessDeniedException(); } if ($request->getMethod() == 'POST') { $course = $request->request->all(); $course = $this->getCourseService()->createCourse($course); return $this->redirect($this->generateUrl('course_manage', array('id' => $course['id']))); } return $this->render('TopxiaWebBundle:Course:create.html.twig', array('userProfile' => $userProfile, 'type' => $type)); }
public function deleteAction(Request $request, $courseId, $lessonId) { $course = $this->getCourseService()->tryManageCourse($courseId); $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId); if ($course['type'] == 'live') { $client = LiveClientFactory::createClient(); if ($lesson['type'] == 'live') { $result = $client->deleteLive($lesson['mediaId'], $lesson['liveProvider']); } $this->getCourseService()->deleteCourseLessonReplayByLessonId($lessonId); } $this->getCourseService()->deleteLesson($course['id'], $lessonId); $this->getCourseMaterialService()->deleteMaterialsByLessonId($lessonId); if ($this->isPluginInstalled('Homework')) { //如果安装了作业插件那么也删除作业和练习 $homework = $this->getHomeworkService()->getHomeworkByLessonId($lessonId); if (!empty($homework)) { $this->getHomeworkService()->removeHomework($homework['id']); } $this->getExerciseService()->deleteExercisesByLessonId($lesson['id']); } return $this->createJsonResponse(true); }
public function getLiveCourse() { $user = $this->controller->getUserByToken($this->request); if (!$user->isLogin()) { return $this->createErrorResponse('not_login', "您尚未登录!"); } $courseId = $this->getParam("courseId", 0); $lessonId = $this->getParam("lessonId", 0); $lesson = $this->controller->getCourseService()->getCourseLesson($courseId, $lessonId); $now = time(); $params = array(); $params['email'] = 'live-' . $user['id'] . '@edusoho.net'; $params['nickname'] = $user['nickname']; $params['sign'] = "c{$lesson['courseId']}u{$user['id']}t{$now}"; $params['sign'] .= 's' . $this->makeSign($params['sign']); $params['liveId'] = $lesson['mediaId']; $params['provider'] = $lesson["liveProvider"]; $params['role'] = 'student'; $client = LiveClientFactory::createClient(); $params['user'] = $params['email']; $result = $client->entryLive($params); return array('data' => array('lesson' => $lesson, 'result' => $result)); }
public function deleteAction(Request $request, $courseId, $lessonId) { $course = $this->getCourseService()->tryManageCourse($courseId); $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId); $client = LiveClientFactory::createClient(); $client->deleteLive($lesson['mediaId']); $this->getCourseService()->deleteLesson($course['id'], $lessonId); $this->getCourseMaterialService()->deleteMaterialsByLessonId($lessonId); if ($course['type'] == 'live') { $this->getCourseService()->deleteCourseLessonReplayByLessonId($lessonId); } return $this->createJsonResponse(true); }
public function deleteAction(Request $request, $courseId, $lessonId) { $course = $this->getCourseService()->tryManageCourse($courseId); $lesson = $this->getCourseService()->getCourseLesson($courseId, $lessonId); $player = new PolyvVideo(); echo $lesson['vid']; $remoteLessonDelete = $player->deleteRemoteLesson($lesson['vid']); var_dump($remoteLessonDelete); if ($course['type'] == 'live') { $client = LiveClientFactory::createClient(); $result = $client->deleteLive($lesson['mediaId'], $lesson['liveProvider']); $this->getCourseService()->deleteCourseLessonReplayByLessonId($lessonId); } $this->getCourseService()->deleteLesson($course['id'], $lessonId); //$this->getCourseMaterialService()->deleteMaterialsByLessonId($lessonId); return $this->createJsonResponse(true); }