public function mobileAction(Request $request) { $mobile = $this->getSettingService()->get('mobile', array()); $default = array('enabled' => 0, 'about' => '', 'logo' => '', 'splash1' => '', 'splash2' => '', 'splash3' => '', 'splash4' => '', 'splash5' => '', 'banner1' => '', 'banner2' => '', 'banner3' => '', 'banner4' => '', 'banner5' => '', 'bannerUrl1' => '', 'bannerUrl2' => '', 'bannerUrl3' => '', 'bannerUrl4' => '', 'bannerUrl5' => '', 'bannerClick1' => '', 'bannerClick2' => '', 'bannerClick3' => '', 'bannerClick4' => '', 'bannerClick5' => '', 'bannerJumpToCourseId1' => ' ', 'bannerJumpToCourseId2' => ' ', 'bannerJumpToCourseId3' => ' ', 'bannerJumpToCourseId4' => ' ', 'bannerJumpToCourseId5' => ' ', 'notice' => '', 'courseIds' => ''); $mobile = array_merge($default, $mobile); if ($request->getMethod() == 'POST') { $mobile = $request->request->all(); $this->getSettingService()->set('mobile', $mobile); $this->getLogService()->info('system', 'update_settings', "更新移动客户端设置", $mobile); $this->setFlashMessage('success', '移动客户端设置已保存!'); } $courseIds = explode(",", $mobile['courseIds']); $courses = $this->getCourseService()->findCoursesByIds($courseIds); $courses = ArrayToolkit::index($courses, 'id'); $sortedCourses = array(); foreach ($courseIds as $value) { if (!empty($value)) { $sortedCourses[] = $courses[$value]; } } $bannerCourse1 = $mobile['bannerJumpToCourseId1'] != " " ? $this->getCourseService()->getCourse($mobile['bannerJumpToCourseId1']) : null; $bannerCourse2 = $mobile['bannerJumpToCourseId2'] != " " ? $this->getCourseService()->getCourse($mobile['bannerJumpToCourseId2']) : null; $bannerCourse3 = $mobile['bannerJumpToCourseId3'] != " " ? $this->getCourseService()->getCourse($mobile['bannerJumpToCourseId3']) : null; $bannerCourse4 = $mobile['bannerJumpToCourseId4'] != " " ? $this->getCourseService()->getCourse($mobile['bannerJumpToCourseId4']) : null; $bannerCourse5 = $mobile['bannerJumpToCourseId5'] != " " ? $this->getCourseService()->getCourse($mobile['bannerJumpToCourseId5']) : null; return $this->render('TopxiaAdminBundle:System:mobile.html.twig', array('mobile' => $mobile, 'courses' => $sortedCourses, "bannerCourse1" => $bannerCourse1, "bannerCourse2" => $bannerCourse2, "bannerCourse3" => $bannerCourse3, "bannerCourse4" => $bannerCourse4, "bannerCourse5" => $bannerCourse5)); }
public function coursesAction(Request $request, $filter) { $user = $this->getCurrentUser(); if (!$user->isTeacher()) { return $this->createMessageResponse('error', '您不是老师,不能查看此页面!'); } $conditions = array('userId' => $user['id']); if ($filter == 'normal') { $conditions["parentId"] = 0; } if ($filter == 'classroom') { $conditions["parentId_GT"] = 0; } $paginator = new Paginator($this->get('request'), $this->getCourseService()->findUserTeachCourseCount($conditions, false), 12); $courses = $this->getCourseService()->findUserTeachCourses($conditions, $paginator->getOffsetCount(), $paginator->getPerPageCount(), false); $classrooms = array(); if ($filter == 'classroom') { $classrooms = $this->getClassroomService()->findClassroomsByCoursesIds(ArrayToolkit::column($courses, 'id')); $classrooms = ArrayToolkit::index($classrooms, 'courseId'); foreach ($classrooms as $key => $classroom) { $classroomInfo = $this->getClassroomService()->getClassroom($classroom['classroomId']); $classrooms[$key]['classroomTitle'] = $classroomInfo['title']; } } $courseSetting = $this->getSettingService()->get('course', array()); return $this->render('TopxiaWebBundle:MyTeaching:teaching.html.twig', array('courses' => $courses, 'classrooms' => $classrooms, 'paginator' => $paginator, 'live_course_enabled' => empty($courseSetting['live_course_enabled']) ? 0 : $courseSetting['live_course_enabled'], 'filter' => $filter)); }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $type = $request->query->get('type'); $type = in_array($type, array('courselesson', 'coursematerial')) ? $type : 'courselesson'; $conditions = array('targetType' => $type, 'targetId' => $course['id']); if (array_key_exists('targetId', $conditions) && !empty($conditions['targetId'])) { $course = $this->getCourseService()->getCourse($conditions['targetId']); if ($course['parentId'] > 0 && $course['locked'] == 1) { $conditions['targetId'] = $course['parentId']; } } $paginator = new Paginator($request, $this->getUploadFileService()->searchFileCount($conditions), 20); $files = $this->getUploadFileService()->searchFiles($conditions, 'latestCreated', $paginator->getOffsetCount(), $paginator->getPerPageCount()); foreach ($files as $key => $file) { $files[$key]['metas2'] = json_decode($file['metas2'], true) ?: array(); $files[$key]['convertParams'] = json_decode($file['convertParams']) ?: array(); $useNum = $this->getCourseService()->searchLessonCount(array('mediaId' => $file['id'])); $manageFilesUseNum = $this->getMaterialService()->getMaterialCountByFileId($file['id']); if ($files[$key]['targetType'] == 'coursematerial') { $files[$key]['useNum'] = $manageFilesUseNum; } else { $files[$key]['useNum'] = $useNum; } } $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($files, 'updatedUserId')); $storageSetting = $this->getSettingService()->get("storage"); return $this->render('TopxiaWebBundle:CourseFileManage:index.html.twig', array('type' => $type, 'course' => $course, 'courseLessons' => $files, 'users' => ArrayToolkit::index($users, 'id'), 'paginator' => $paginator, 'now' => time(), 'storageSetting' => $storageSetting)); }
public function indexAction(Request $request, $courseId) { $course = $this->getCourseService()->getCourse($courseId); $lessons = $this->getCourseService()->getCourseLessons($courseId); $lessons = ArrayToolkit::index($lessons, 'homeworkId'); $homeworks = array(); $homeworkService = $this->getHomeworkService(); $conditions = array(); $conditions['course_id'] = $course['id']; $orderBy = array(); $orderBy[] = 'create_at'; $orderBy[] = 'DESC'; $count = $homeworkService->searchHomeworksCount($conditions); $page_size = 20; $paginator = new Paginator($request, $count, $page_size); $start = $paginator->getOffsetCount(); $limit = $paginator->getPerPageCount(); $homeworks = $homeworkService->searchHomeworks($conditions, $orderBy, $start, $limit); $homeworks = $this->addLessonName($homeworks, $lessons); $storageSetting = $this->getSettingService()->get("storage"); $tpl = 'HomeworkBundle:Homework:index.html.twig'; $assignBox = array(); $assignBox['course'] = $course; $assignBox['homeworks'] = $homeworks; $assignBox['paginator'] = $paginator; $assignBox['now'] = $_SERVER['REQUEST_TIME']; $assignBox['storageSetting'] = $storageSetting; return $this->render($tpl, $assignBox); }
public function popularCoursesAction(Request $request) { $dateType = $request->query->get('dateType'); $currentDay = $this->weekday(time()); if ($dateType == "today") { $startTime = strtotime('today'); $endTime = strtotime('tomorrow'); } if ($dateType == "yesterday") { $startTime = strtotime('yesterday'); $endTime = strtotime('today'); } if ($dateType == "this_week") { if ($currentDay == '星期日') { $startTime = strtotime('Monday last week'); $endTime = strtotime('Monday this week'); } else { $startTime = strtotime('Monday this week'); $endTime = strtotime('Monday next week'); } } if ($dateType == "last_week") { if ($currentDay == '星期日') { $startTime = strtotime('Monday last week') - 7 * 24 * 60 * 60; $endTime = strtotime('Monday this week') - 7 * 24 * 60 * 60; } else { $startTime = strtotime('Monday last week'); $endTime = strtotime('Monday this week'); } } if ($dateType == "this_month") { $startTime = strtotime('first day of this month midnight'); $endTime = strtotime('first day of next month midnight'); } if ($dateType == "last_month") { $startTime = strtotime('first day of last month midnight'); $endTime = strtotime('first day of this month midnight'); } $members = $this->getCourseService()->countMembersByStartTimeAndEndTime($startTime, $endTime); $courseIds = ArrayToolkit::column($members, "courseId"); $courses = $this->getCourseService()->findCoursesByIds($courseIds); $courses = ArrayToolkit::index($courses, "id"); $sortedCourses = array(); $orders = $this->getOrderService()->sumOrderAmounts($startTime, $endTime, $courseIds); $orders = ArrayToolkit::index($orders, "targetId"); foreach ($members as $key => $value) { $course = array(); $course['title'] = $courses[$value["courseId"]]['title']; $course['courseId'] = $courses[$value["courseId"]]['id']; $course['addedStudentNum'] = $value['co']; $course['studentNum'] = $courses[$value["courseId"]]['studentNum']; if (isset($orders[$value["courseId"]])) { $course['addedMoney'] = $orders[$value["courseId"]]['amount']; } else { $course['addedMoney'] = 0; } $sortedCourses[] = $course; } return $this->render('TopxiaAdminBundle:Default:popular-courses-table.html.twig', array('sortedCourses' => $sortedCourses)); }
public function indexAction(Request $request, $status) { $courses = $this->getCourseService()->searchCourses(array('type' => 'live', 'status' => 'published'), $sort = 'latest', 0, 1000); $courseIds = ArrayToolkit::column($courses, 'id'); $courses = ArrayToolkit::index($courses, 'id'); $conditions['type'] = "live"; switch ($status) { case 'coming': $conditions['startTimeGreaterThan'] = time(); break; case 'end': $conditions['endTimeLessThan'] = time(); break; case 'underway': $conditions['startTimeLessThan'] = time(); $conditions['endTimeGreaterThan'] = time(); break; } $conditions['courseIds'] = $courseIds; $conditions['status'] = 'published'; $paginator = new Paginator($request, $this->getCourseService()->searchLessonCount($conditions), 20); if ($status == 'end') { $lessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'DESC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); } else { $lessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); } return $this->render('TopxiaAdminBundle:LiveCourse:index.html.twig', array('status' => $status, 'lessons' => $lessons, 'courses' => $courses, 'paginator' => $paginator)); }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $courseItems = $this->getCourseService()->getCourseItems($course['id']); $lessonIds = ArrayToolkit::column($courseItems, 'id'); if ($this->isPluginInstalled('Homework')) { $exercises = $this->getServiceKernel()->createService('Homework:Homework.ExerciseService')->findExercisesByLessonIds($lessonIds); $homeworks = $this->getServiceKernel()->createService('Homework:Homework.HomeworkService')->findHomeworksByCourseIdAndLessonIds($course['id'], $lessonIds); } $mediaMap = array(); foreach ($courseItems as $item) { if ($item['itemType'] != 'lesson') { continue; } if (empty($item['mediaId'])) { continue; } if (empty($mediaMap[$item['mediaId']])) { $mediaMap[$item['mediaId']] = array(); } $mediaMap[$item['mediaId']][] = $item['id']; } $mediaIds = array_keys($mediaMap); $files = $this->getUploadFileService()->findFilesByIds($mediaIds); foreach ($files as $file) { $lessonIds = $mediaMap[$file['id']]; foreach ($lessonIds as $lessonId) { $courseItems["lesson-{$lessonId}"]['mediaStatus'] = $file['convertStatus']; } } $default = $this->getSettingService()->get('default', array()); return $this->render('TopxiaWebBundle:CourseLessonManage:index.html.twig', array('course' => $course, 'items' => $courseItems, 'exercises' => empty($exercises) ? array() : $exercises, 'homeworks' => empty($homeworks) ? array() : $homeworks, 'files' => ArrayToolkit::index($files, 'id'), 'default' => $default)); }
public function exploreAction(Request $request, $category) { $conditions = array('status' => 'published', 'private' => 0); $categoryArray = array(); if (!empty($category)) { $categoryArray = $this->getCategoryService()->getCategoryByCode($category); $childrenIds = $this->getCategoryService()->findCategoryChildrenIds($categoryArray['id']); $categoryIds = array_merge($childrenIds, array($categoryArray['id'])); $conditions['categoryIds'] = $categoryIds; } $paginator = new Paginator($this->get('request'), $this->getClassroomService()->searchClassroomsCount($conditions), 9); $classrooms = $this->getClassroomService()->searchClassrooms($conditions, array('createdTime', 'desc'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); // $classroomIds = ArrayToolkit::column($classrooms, 'id'); $allClassrooms = ArrayToolkit::index($classrooms, 'id'); if (!$categoryArray) { $categoryArrayDescription = array(); } else { $categoryArrayDescription = $categoryArray['description']; $categoryArrayDescription = strip_tags($categoryArrayDescription, ''); $categoryArrayDescription = preg_replace("/ /", "", $categoryArrayDescription); $categoryArrayDescription = substr($categoryArrayDescription, 0, 100); } if (!$categoryArray) { $CategoryParent = ''; } else { if (!$categoryArray['parentId']) { $CategoryParent = ''; } else { $CategoryParent = $this->getCategoryService()->getCategory($categoryArray['parentId']); } } return $this->render("ClassroomBundle:Classroom:explore.html.twig", array('paginator' => $paginator, 'classrooms' => $classrooms, 'allClassrooms' => $allClassrooms, 'path' => 'classroom_explore', 'category' => $category, 'categoryArray' => $categoryArray, 'categoryArrayDescription' => $categoryArrayDescription, 'CategoryParent' => $CategoryParent)); }
/** * Do the magic. * * @param InteractiveLoginEvent $event */ public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) { $user = ServiceKernel::instance()->getCurrentUser(); list($courses, $courseMembers) = $this->getCourseService()->findWillOverdueCourses(); $courseMembers = ArrayToolkit::index($courseMembers, "courseId"); foreach ($courses as $key => $course) { $message = array('courseId' => $course['id'], 'courseTitle' => $course['title'], 'endtime' => date("Y年m月d日", $courseMembers[$course["id"]]["deadline"])); $this->getNotificationService()->notify($user["id"], "course-deadline", $message); $courseMemberId = $courseMembers[$course["id"]]["id"]; $this->getCourseService()->updateCourseMember($courseMemberId, array("deadlineNotified" => 1)); } $vipApp = $this->getAppService()->findInstallApp('Vip'); if (!empty($vipApp) && version_compare($vipApp['version'], "1.0.5", ">=")) { $vipSetting = $this->getSettingService()->get('vip', array()); if (array_key_exists("deadlineNotify", $vipSetting) && $vipSetting["deadlineNotify"] == 1) { $vip = $this->getVipService()->getMemberByUserId($user["id"]); $currentTime = time(); if ($vip["deadlineNotified"] != 1 && $currentTime < $vip["deadline"] && $currentTime + $vipSetting["daysOfNotifyBeforeDeadline"] * 24 * 60 * 60 > $vip["deadline"]) { $message = array('endtime' => date("Y年m月d日", $vip["deadline"])); $this->getNotificationService()->notify($user["id"], "vip-deadline", $message); $this->getVipService()->updateDeadlineNotified($vip["id"], 1); } } } }
public function listAction(Request $request, $classroomId) { $classroom = $this->getClassroomService()->getClassroom($classroomId); $headTeacher = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'headTeacher', 0, 1); $assistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'assistant', 0, PHP_INT_MAX); $studentAssistants = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'studentAssistant', 0, PHP_INT_MAX); $members = $this->getClassroomService()->findClassroomMembersByRole($classroomId, 'teacher', 0, PHP_INT_MAX); $members = array_merge($headTeacher, $members, $assistants, $studentAssistants); $members = ArrayToolkit::index($members, 'userId'); $teacherIds = ArrayToolkit::column($members, 'userId'); $teachers = $this->getUserService()->findUsersByIds($teacherIds); $teachers = $this->sort($teachers, $members); $profiles = $this->getUserService()->findUserProfilesByIds($teacherIds); $user = $this->getCurrentUser(); $myfollowings = $this->getUserService()->filterFollowingIds($user['id'], $teacherIds); $member = $user ? $this->getClassroomService()->getClassroomMember($classroom['id'], $user['id']) : null; $layout = 'ClassroomBundle:Classroom:layout.html.twig'; if ($member && !$member['locked']) { $layout = 'ClassroomBundle:Classroom:join-layout.html.twig'; } if (!$classroom) { $classroomDescription = array(); } else { $classroomDescription = $classroom['about']; $classroomDescription = strip_tags($classroomDescription, ''); $classroomDescription = preg_replace("/ /", "", $classroomDescription); } return $this->render('ClassroomBundle:Classroom\\Teacher:list.html.twig', array('layout' => $layout, 'canLook' => $this->getClassroomService()->canLookClassroom($classroom['id']), 'classroom' => $classroom, 'teachers' => $teachers, 'profiles' => $profiles, 'member' => $member, 'members' => $members, 'Myfollowings' => $myfollowings, 'classroomDescription' => $classroomDescription)); }
public function defaultCoursePictureCropAction(Request $request) { if ($request->getMethod() == 'POST') { $options = $request->request->all(); $data = $options["images"]; $fileIds = ArrayToolkit::column($data, "id"); $files = $this->getFileService()->getFilesByIds($fileIds); $files = ArrayToolkit::index($files, "id"); $fileIds = ArrayToolkit::index($data, "type"); $setting = $this->getSettingService()->get("default", array()); $oldAvatars = array('course.png' => !empty($setting['course.png']) ? $setting['course.png'] : null); $setting['defaultCoursePicture'] = 1; unset($setting['defaultCoursePictureFileName']); $setting['course.png'] = $files[$fileIds["course.png"]["id"]]["uri"]; $this->getSettingService()->set("default", $setting); $fileService = $this->getFileService(); array_map(function ($oldAvatar) use($fileService) { if (!empty($oldAvatar)) { $fileService->deleteFileByUri($oldAvatar); } }, $oldAvatars); return $this->redirect($this->generateUrl('admin_setting_course_avatar')); } $fileId = $request->getSession()->get("fileId"); list($pictureUrl, $naturalSize, $scaledSize) = $this->getFileService()->getImgFileMetaInfo($fileId, 480, 270); return $this->render('TopxiaAdminBundle:System:default-course-picture-crop.html.twig', array('pictureUrl' => $pictureUrl, 'naturalSize' => $naturalSize, 'scaledSize' => $scaledSize)); }
public function getQuestionCountGroupByTypesAction(Request $request, $courseId) { $params = $request->query->all(); $course = $this->getCourseService()->tryManageCourse($courseId); if (empty($course)) { return $this->createJsonResponse(array()); } $typeNames = $this->get('topxia.twig.web_extension')->getDict('questionType'); $types = array(); foreach ($typeNames as $type => $name) { $typeObj = QuestionTypeFactory::create($type); $types[] = array('key' => $type, 'name' => $name, 'hasMissScore' => $typeObj->hasMissScore()); } $conditions["types"] = ArrayToolkit::column($types, "key"); if ($params["range"] == "course") { $conditions["courseId"] = $course["id"]; } else { if ($params["range"] == "lesson") { $targets = $params["targets"]; $targets = explode(',', $targets); $conditions["targets"] = $targets; } } $questionNums = $this->getQuestionService()->getQuestionCountGroupByTypes($conditions); $questionNums = ArrayToolkit::index($questionNums, "type"); return $this->createJsonResponse($questionNums); }
/** * 获取一个分类下的课程成员列表 * * 可传入的参数: * categoryId 选填 分类ID * count 必需 学员数量,取值不能超过100 * * @param array $arguments 参数 * @return array 课程成员列表 */ public function getData(array $arguments) { $this->checkCount($arguments); if (empty($arguments['categoryId'])) { $conditions = array('status' => 'published'); } else { $conditions = array('status' => 'published', 'categoryId' => $arguments['categoryId']); } $courses = $this->getCourseService()->searchCourses($conditions, 'latest', 0, 1000); $courseIds = ArrayToolkit::column($courses, 'id'); $conditions = array('courseIds' => $courseIds, 'unique' => true, 'role' => 'student'); $members = $this->getCourseService()->searchMembers($conditions, array('createdTime', 'DESC'), 0, $arguments['count']); $courseIds = ArrayToolkit::column($members, 'courseId'); $userIds = ArrayToolkit::column($members, 'userId'); $users = $this->getUserService()->findUsersByIds($userIds); $users = ArrayToolkit::index($users, 'id'); $this->unsetUserPasswords($users); $courses = $this->getCourseService()->findCoursesByIds($courseIds); $courses = ArrayToolkit::index($courses, 'id'); foreach ($members as &$member) { $member['course'] = $courses[$member["courseId"]]; $member['user'] = $users[$member["userId"]]; } return $members; }
public function mobileSelectAction(Request $request) { $operationMobile = $this->getSettingService()->get('operation_mobile', array()); $courseGrids = $this->getSettingService()->get('operation_course_grids', array()); $settingMobile = $this->getSettingService()->get('mobile', array()); $default = array('courseIds' => ''); $mobile = array_merge($default, $courseGrids); if ($request->getMethod() == 'POST') { $courseGrids = $request->request->all(); $mobile = array_merge($operationMobile, $settingMobile, $courseGrids); $this->getSettingService()->set('operation_mobile', $operationMobile); $this->getSettingService()->set('operation_course_grids', $courseGrids); $this->getSettingService()->set('mobile', $mobile); $this->getLogService()->info('system', 'update_settings', "更新移动客户端设置", $mobile); $this->setFlashMessage('success', '移动客户端设置已保存!'); } $courseIds = explode(",", $mobile['courseIds']); $courses = $this->getCourseService()->findCoursesByIds($courseIds); $courses = ArrayToolkit::index($courses, 'id'); $sortedCourses = array(); foreach ($courseIds as $value) { if (!empty($value)) { $sortedCourses[] = $courses[$value]; } } return $this->render('TopxiaAdminBundle:System:course-select.html.twig', array('mobile' => $mobile, 'courses' => $sortedCourses)); }
public function approvedAction(Request $request) { $paginator = new Paginator($this->get('request'), $this->getUserService()->getUserCountByApprovalStatus('approved'), 20); $users = $this->getUserService()->getUsersByApprovalStatus('approved', $paginator->getOffsetCount(), $paginator->getPerPageCount()); $userProfiles = $this->getUserService()->findUserProfilesByIds(ArrayToolkit::column($users, 'id')); $userProfiles = ArrayToolkit::index($userProfiles, 'id'); return $this->render('TopxiaAdminBundle:User:approved.html.twig', array('users' => $users, 'paginator' => $paginator, 'userProfiles' => $userProfiles)); }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $courseItems = $this->getCourseService()->getCourseItems($course['id']); $lessonIds = ArrayToolkit::index($courseItems, 'id'); $default = $this->getSettingService()->get('default', array()); return $this->render('TopxiaWebBundle:CourseLessonManage:index.html.twig', array('course' => $course, 'items' => $courseItems)); }
public function exportCsvAction(Request $request) { $conditions = $request->query->all(); if (isset($conditions['keywordType'])) { if ($conditions['keywordType'] == 'userName') { $conditions['keywordType'] = 'userId'; $userFindbyNickName = $this->getUserService()->getUserByNickname($conditions['keyword']); $conditions['keyword'] = $userFindbyNickName ? $userFindbyNickName['id'] : -1; } } if (isset($conditions['keywordType'])) { $conditions[$conditions['keywordType']] = $conditions['keyword']; unset($conditions['keywordType']); unset($conditions['keyword']); } if (!empty($conditions['startTime']) && !empty($conditions['endTime'])) { $conditions['startTime'] = strtotime($conditions['startTime']); $conditions['endTime'] = strtotime($conditions['endTime']); } $status = array('created' => '未付款', 'paid' => '已付款', 'cancelled' => '已关闭'); $payment = array('alipay' => '支付宝', 'wxpay' => '微信支付', 'heepay' => '网银支付', 'quickpay' => '快捷支付', 'coin' => '虚拟币支付', 'none' => '--'); $orders = $this->getCashOrdersService()->searchOrders($conditions, array('createdTime', 'DESC'), 0, PHP_INT_MAX); $studentUserIds = ArrayToolkit::column($orders, 'userId'); $users = $this->getUserService()->findUsersByIds($studentUserIds); $users = ArrayToolkit::index($users, 'id'); $profiles = $this->getUserService()->findUserProfilesByIds($studentUserIds); $profiles = ArrayToolkit::index($profiles, 'id'); $str = "订单号,订单状态,订单名称,购买者,姓名,实付价格,支付方式,创建时间,付款时间"; $str .= "\r\n"; $results = array(); foreach ($orders as $key => $orders) { $member = ""; $member .= $orders['sn'] . ","; $member .= $status[$orders['status']] . ","; $member .= $orders['title'] . ","; $member .= $users[$orders['userId']]['nickname'] . ","; $member .= $profiles[$orders['userId']]['truename'] ? $profiles[$orders['userId']]['truename'] . "," : "-" . ","; $member .= $orders['amount'] . ","; $member .= $payment[$orders['payment']] . ","; $member .= date('Y-n-d H:i:s', $orders['createdTime']) . ","; if ($orders['paidTime'] != 0) { $member .= date('Y-n-d H:i:s', $orders['paidTime']) . ","; } else { $member .= "-" . ","; } $results[] = $member; } $str .= implode("\r\n", $results); $str = chr(239) . chr(187) . chr(191) . $str; $filename = sprintf("coin-order-(%s).csv", date('Y-n-d')); $response = new Response(); $response->headers->set('Content-type', 'text/csv'); $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); $response->headers->set('Content-length', strlen($str)); $response->setContent($str); return $response; }
public function updateAction(Request $request) { $currentUser = $this->getCurrentUser(); $paginator = new Paginator($this->get('request'), $this->getCourseService()->findUserLeaningCourseCount($currentUser['id']), 12); $courses = $this->getCourseService()->findUserLeaningCourses($currentUser['id'], $paginator->getOffsetCount(), $paginator->getPerPageCount()); $courses = ArrayToolkit::index($courses, 'id'); $latestLessons = $this->getCourseService()->searchLessons(array('courseIds' => ArrayToolkit::column($courses, 'id')), array('createdTime', 'desc'), 0, 30); return $this->render("TopxiaWebBundle:MyCourse:update.html.twig", array('latestLessons' => $latestLessons)); }
public function indexAction(Request $request, $id) { list($course, $member, $response) = $this->buildLayoutDataWithTakenAccess($request, $id); if ($response) { return $response; } $paginator = new Paginator($request, $this->getMaterialService()->getMaterialCount($id), 20); $materials = $this->getMaterialService()->findCourseMaterials($id, $paginator->getOffsetCount(), $paginator->getPerPageCount()); $lessons = $this->getCourseService()->getCourseLessons($course['id']); $lessons = ArrayToolkit::index($lessons, 'id'); return $this->render("TopxiaWebBundle:CourseMaterial:index.html.twig", array('course' => $course, 'member' => $member, 'lessons' => $lessons, 'materials' => $materials, 'paginator' => $paginator)); }
public function searchMoneyRecords($conditions, $sort, $start, $limit) { $orderBy = array(); if ($sort == 'latest') { $orderBy = array('transactionTime', 'DESC'); } else { $orderBy = array('transactionTime', 'DESC'); } $conditions = array_filter($conditions); $moneyRecords = $this->getMoneyRecordsDao()->searchMoneyRecords($conditions, $orderBy, $start, $limit); return ArrayToolkit::index($moneyRecords, 'id'); }
public function freeAction(Request $request) { $conditions = array('free' => 1); $courseId = $request->query->get('courseId'); $course = null; if (!empty($courseId)) { $conditions['courseId'] = $courseId; $course = $this->getCourseService()->getCourse($courseId); } $lessons = ArrayToolkit::index($this->getCourseService()->searchLessons($conditions, array('createdTime', 'ASC'), 0, 18), 'id'); return $this->render('TopxiaWebBundle:Course:course-free.html.twig', array('lessons' => $lessons, 'course' => $course)); }
public function getNavigationsTreeByType($type) { $count = $this->getNavigationsCountByType($type); $navigations = $this->findNavigationsByType($type, 0, $count); $navigations = ArrayToolkit::index($navigations, 'id'); foreach ($navigations as $index => $nav) { if ($nav['parentId'] == 0) { continue; } $navigations[$nav['parentId']]['children'][] = $nav; unset($navigations[$index]); } return $navigations; }
public function approvedAction(Request $request) { $fields = $request->query->all(); $conditions = array('roles' => '', 'keywordType' => '', 'keyword' => '', 'approvalStatus' => 'approved'); if (empty($fields)) { $fields = array(); } $conditions = array_merge($conditions, $fields); $paginator = new Paginator($this->get('request'), $this->getUserService()->searchUserCount($conditions), 20); $users = $this->getUserService()->searchUsers($conditions, array('createdTime', 'DESC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $userProfiles = $this->getUserService()->findUserProfilesByIds(ArrayToolkit::column($users, 'id')); $userProfiles = ArrayToolkit::index($userProfiles, 'id'); return $this->render('TopxiaAdminBundle:User:approved.html.twig', array('users' => $users, 'paginator' => $paginator, 'userProfiles' => $userProfiles)); }
public function indexAction(Request $request) { $fields = $request->query->all(); $conditions = array('content' => '', 'nickname' => '', 'startDate' => 0, 'endDate' => time()); if (!empty($fields)) { $conditions = $this->convertConditions($fields); } $paginator = new Paginator($request, $this->getMessageService()->searchMessagesCount($conditions), 20); $messages = $this->getMessageService()->searchMessages($conditions, null, $paginator->getOffsetCount(), $paginator->getPerPageCount()); $usersFromId = $this->getUserService()->findUsersByIds(ArrayToolkit::column($messages, 'fromId')); $usersToId = $this->getUserService()->findUsersByIds(ArrayToolkit::column($messages, 'toId')); $users = ArrayToolkit::index(array_merge($usersFromId, $usersToId), 'id'); return $this->render('TopxiaAdminBundle:Message:index.html.twig', array('users' => $users, 'messages' => $messages, 'paginator' => $paginator)); }
public function exploreAction(Request $request, $category) { $conditions = array('status' => 'published', 'private' => 0); if (!empty($category)) { $categoryArray = $this->getCategoryService()->getCategoryByCode($category); $childrenIds = $this->getCategoryService()->findCategoryChildrenIds($categoryArray['id']); $categoryIds = array_merge($childrenIds, array($categoryArray['id'])); $conditions['categoryIds'] = $categoryIds; } $paginator = new Paginator($this->get('request'), $this->getClassroomService()->searchClassroomsCount($conditions), 9); $classrooms = $this->getClassroomService()->searchClassrooms($conditions, array('createdTime', 'desc'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $classroomIds = ArrayToolkit::column($classrooms, 'id'); $allClassrooms = ArrayToolkit::index($classrooms, 'id'); return $this->render("ClassroomBundle:Classroom:explore.html.twig", array('paginator' => $paginator, 'classrooms' => $classrooms, 'allClassrooms' => $allClassrooms, 'path' => 'classroom_explore', 'category' => $category)); }
public function indexAction(Request $request, $id) { $course = $this->getCourseService()->tryManageCourse($id); $type = $request->query->get('type'); $type = in_array($type, array('courselesson', 'coursematerial')) ? $type : 'courselesson'; $conditions = array('targetType' => $type, 'targetId' => $course['id']); $paginator = new Paginator($request, $this->getUploadFileService()->searchFileCount($conditions), 20); $files = $this->getUploadFileService()->searchFiles($conditions, 'latestCreated', $paginator->getOffsetCount(), $paginator->getPerPageCount()); foreach ($files as $key => $file) { $files[$key]['metas2'] = json_decode($file['metas2']) ?: array(); $files[$key]['convertParams'] = json_decode($file['convertParams']) ?: array(); } $users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($files, 'updatedUserId')); return $this->render('TopxiaWebBundle:CourseFileManage:index.html.twig', array('type' => $type, 'course' => $course, 'courseLessons' => $files, 'users' => ArrayToolkit::index($users, 'id'), 'paginator' => $paginator, 'now' => time())); }
public function result(Application $app, Request $request, $id) { $homeworkResult = $this->getHomeworkService()->getResult($id); $homework = $this->getHomeworkService()->getHomework($homeworkResult['homeworkId']); $course = $this->getCorrseService()->getCourse($homework['courseId']); $homework['courseTitle'] = $course['title']; $lesson = $this->getCorrseService()->getLesson($homework['lessonId']); $homework['lessonTitle'] = $lesson['title']; $items = $this->getHomeworkService()->findItemsByHomeworkId($homework['id']); $indexdItems = ArrayToolkit::index($items, 'questionId'); $questions = $this->getQuestionService()->findQuestionsByIds(array_keys($indexdItems)); $itemSetResults = $this->getHomeworkService()->findItemResultsbyHomeworkResultId($homeworkResult['id']); $itemSetResults = ArrayToolkit::index($itemSetResults, 'questionId'); $homework['items'] = $this->filterItem($questions, $itemSetResults); return $this->filter($homework); }
protected function fillQuestionsToNeedCount($selectedQuestions, $allQuestions, $needCount) { $indexedQuestions = ArrayToolkit::index($allQuestions, 'id'); foreach ($selectedQuestions as $question) { unset($indexedQuestions[$question['id']]); } if (count($selectedQuestions) < $needCount) { $stillNeedCount = $needCount - count($selectedQuestions); } else { $stillNeedCount = 0; } if ($stillNeedCount) { $questions = array_slice(array_values($indexedQuestions), 0, $stillNeedCount); $selectedQuestions = array_merge($selectedQuestions, $questions); } return $selectedQuestions; }
public function showFavoriteQuestionAction(Request $request) { $user = $this->getCurrentUser(); $paginator = new Paginator($request, $this->getQuestionService()->findFavoriteQuestionsCountByUserId($user['id']), 10); $favoriteQuestions = $this->getQuestionService()->findFavoriteQuestionsByUserId($user['id'], $paginator->getOffsetCount(), $paginator->getPerPageCount()); $questionIds = ArrayToolkit::column($favoriteQuestions, 'questionId'); $questions = $this->getQuestionService()->findQuestionsByIds($questionIds); $myTestpaperIds = array(); $targets = $this->get('topxia.target_helper')->getTargets(ArrayToolkit::column($favoriteQuestions, 'target')); foreach ($favoriteQuestions as $key => $value) { if ($targets[$value['target']]['type'] == 'testpaper') { array_push($myTestpaperIds, $targets[$value['target']]['id']); } } $myTestpapers = $this->getTestpaperService()->findTestpapersByIds($myTestpaperIds); return $this->render('TopxiaWebBundle:MyQuiz:my-favorite-question.html.twig', array('favoriteActive' => 'active', 'user' => $user, 'favoriteQuestions' => ArrayToolkit::index($favoriteQuestions, 'id'), 'testpapers' => ArrayToolkit::index($myTestpapers, 'id'), 'questions' => ArrayToolkit::index($questions, 'id'), 'targets' => $targets, 'paginator' => $paginator)); }
public function indexAction(Request $request) { $currentUser = $this->getCurrentUser(); $courses = $this->getCourseService()->findUserLeaningCourses($currentUser['id'], 0, 1000); $courseIds = ArrayToolkit::column($courses, 'id'); $conditions = array('status' => 'published', 'startTimeGreaterThan' => time(), 'courseIds' => $courseIds); $paginator = new Paginator($this->get('request'), $this->getCourseService()->searchLessonCount($conditions), 10); $lessons = $this->getCourseService()->searchLessons($conditions, array('startTime', 'ASC'), $paginator->getOffsetCount(), $paginator->getPerPageCount()); $newCourses = array(); $courses = ArrayToolkit::index($courses, 'id'); if (!empty($courses)) { foreach ($lessons as $key => &$lesson) { $newCourses[$key] = $courses[$lesson['courseId']]; $newCourses[$key]['lesson'] = $lesson; } } return $this->render('TopxiaWebBundle:MyLiveCourse:index.html.twig', array('courses' => $newCourses, 'paginator' => $paginator)); }