本文整理汇总了PHP中Topxia\Common\ArrayToolkit::group方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayToolkit::group方法的具体用法?PHP ArrayToolkit::group怎么用?PHP ArrayToolkit::group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topxia\Common\ArrayToolkit
的用法示例。
在下文中一共展示了ArrayToolkit::group方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findMarkersMetaByMediaId
public function findMarkersMetaByMediaId($mediaId)
{
$markers = $this->findMarkersByMediaId($mediaId);
if (empty($markers)) {
return array();
}
$markerIds = ArrayToolkit::column($markers, 'id');
$questionMarkers = $this->getQuestionMarkerService()->findQuestionMarkersByMarkerIds($markerIds);
$questionMarkerGroups = ArrayToolkit::group($questionMarkers, 'markerId');
foreach ($markers as $index => $marker) {
if (!empty($questionMarkerGroups[$marker['id']])) {
$markers[$index]['questionMarkers'] = $questionMarkerGroups[$marker['id']];
}
}
return $markers;
}
示例2: _findCoursesInClassrooms
private function _findCoursesInClassrooms($courseIds)
{
$conditions = array('parentIds' => $courseIds);
$childCourses = $this->getCourseService()->searchCourses($conditions, 'latest', 0, $this->getCourseService()->searchCourseCount($conditions));
$childCourseIds = ArrayToolkit::column($childCourses, 'id');
$classroomCourses = $this->getClassroomService()->findCoursesByCoursesIds($childCourseIds);
$classroomCourses = ArrayToolkit::index($classroomCourses, 'courseId');
$goupCourses = ArrayToolkit::group($childCourses, 'parentId');
$mapping = array();
$classroomIds = array();
foreach ($goupCourses as $parentId => $courses) {
foreach ($courses as $key => $course) {
if (!empty($classroomCourses[$course['id']])) {
$classroomId = $classroomCourses[$course['id']]['classroomId'];
$mapping[$parentId][] = $classroomId;
$classroomIds[] = $classroomId;
}
}
}
$classrooms = $this->getClassroomService()->findClassroomsByIds($classroomIds);
return array($mapping, $classrooms);
}
示例3: itemsAction
public function itemsAction(Request $request, $courseId, $testpaperId)
{
$course = $this->getCourseService()->tryManageCourse($courseId);
$testpaper = $this->getTestpaperService()->getTestpaper($testpaperId);
if (empty($testpaper)) {
throw $this->createNotFoundException('试卷不存在');
}
if ($request->getMethod() == 'POST') {
$data = $request->request->all();
if (empty($data['questionId']) || empty($data['scores'])) {
return $this->createMessageResponse('error', '试卷题目不能为空!');
}
if (count($data['questionId']) != count($data['scores'])) {
return $this->createMessageResponse('error', '试卷题目数据不正确');
}
$data['questionId'] = array_values($data['questionId']);
$data['scores'] = array_values($data['scores']);
$items = array();
foreach ($data['questionId'] as $index => $questionId) {
$items[] = array('questionId' => $questionId, 'score' => $data['scores'][$index]);
}
$this->getTestpaperService()->updateTestpaperItems($testpaper['id'], $items);
$this->setFlashMessage('success', '试卷题目保存成功!');
return $this->redirect($this->generateUrl('course_manage_testpaper', array('courseId' => $courseId)));
}
$items = $this->getTestpaperService()->getTestpaperItems($testpaper['id']);
$questions = $this->getQuestionService()->findQuestionsByIds(ArrayToolkit::column($items, 'questionId'));
$targets = $this->get('topxia.target_helper')->getTargets(ArrayToolkit::column($questions, 'target'));
$subItems = array();
foreach ($items as $key => $item) {
if ($item['parentId'] > 0) {
$subItems[$item['parentId']][] = $item;
unset($items[$key]);
}
}
return $this->render('TopxiaWebBundle:CourseTestpaperManage:items.html.twig', array('course' => $course, 'testpaper' => $testpaper, 'items' => ArrayToolkit::group($items, 'questionType'), 'subItems' => $subItems, 'questions' => $questions, 'targets' => $targets));
}
示例4: incomeAction
public function incomeAction(Request $request, $tab)
{
$data = array();
$incomeStartDate = "";
$condition = $request->query->all();
$timeRange = $this->getTimeRange($condition);
if (!$timeRange) {
$this->setFlashMessage("danger", "输入的日期有误!");
return $this->redirect($this->generateUrl('admin_operation_analysis_income', array('tab' => "trend")));
}
$incomeData = "";
if ($tab == "trend") {
$incomeData = $this->getOrderService()->analysisAmountDataByTime($timeRange['startTime'], $timeRange['endTime']);
$data = $this->fillAnalysisData($condition, $incomeData);
}
$paginator = new Paginator($request, $this->getOrderService()->searchOrderCount(array("paidStartTime" => $timeRange['startTime'], "paidEndTime" => $timeRange['endTime'], "status" => "paid", "amount" => "0.00")), 20);
$incomeDetail = $this->getOrderService()->searchOrders(array("paidStartTime" => $timeRange['startTime'], "paidEndTime" => $timeRange['endTime'], "status" => "paid", "amount" => "0.00"), "latest", $paginator->getOffsetCount(), $paginator->getPerPageCount());
$incomeDetailByGroup = ArrayToolkit::group($incomeDetail, 'targetType');
$courses = array();
if (isset($incomeDetailByGroup['course'])) {
$courseIds = ArrayToolkit::column($incomeDetailByGroup['course'], 'targetId');
$courses = $this->getCourseService()->findCoursesByIds($courseIds);
}
$classrooms = array();
if (isset($incomeDetailByGroup['classroom'])) {
$classroomIds = ArrayToolkit::column($incomeDetailByGroup['classroom'], 'targetId');
$classrooms = $this->getClassroomService()->findClassroomsByIds($classroomIds);
}
$userIds = ArrayToolkit::column($incomeDetail, 'userId');
$users = $this->getUserService()->findUsersByIds($userIds);
$incomeStartData = $this->getOrderService()->searchOrders(array("status" => "paid", "amount" => "0.00"), "early", 0, 1);
foreach ($incomeStartData as $key) {
$incomeStartDate = date("Y-m-d", $key['createdTime']);
}
$dataInfo = $this->getDataInfo($condition, $timeRange);
return $this->render("TopxiaAdminBundle:OperationAnalysis:income.html.twig", array('incomeDetail' => $incomeDetail, 'paginator' => $paginator, 'tab' => $tab, 'data' => $data, 'courses' => $courses, 'classrooms' => $classrooms, 'users' => $users, 'incomeStartDate' => $incomeStartDate, 'dataInfo' => $dataInfo));
}
示例5: getClassroomStudyMissions
private function getClassroomStudyMissions()
{
$user = $this->getCurrentUser();
$sortedClassrooms = array();
$memberConditions = array('userId' => $user->id, 'locked' => 0, 'role' => 'student');
$sort = array('createdTime', 'DESC');
$classroomMems = $this->getClassroomService()->searchMembers($memberConditions, $sort, 0, 5);
$classroomIds = ArrayToolkit::column($classroomMems, 'classroomId');
if (!empty($classroomIds)) {
$classrooms = $this->getClassroomService()->findClassroomsByIds($classroomIds);
foreach ($classroomMems as $member) {
if (empty($classrooms[$member['classroomId']])) {
continue;
}
$classroom = $classrooms[$member['classroomId']];
$sortedClassrooms[] = $classroom;
}
foreach ($sortedClassrooms as $key => &$classroom) {
$courses = $this->getClassroomService()->findActiveCoursesByClassroomId($classroom['id']);
if (!empty($courses)) {
$courseIds = ArrayToolkit::column($courses, 'id');
/**
* 找出学过的课时
*/
$learnedConditions = array('userId' => $user->id, 'courseIds' => $courseIds);
$sort = array('finishedTime', 'ASC');
$learnedCount = $this->getCourseService()->searchLearnCount($learnedConditions);
$learneds = $this->getCourseService()->searchLearns($learnedConditions, $sort, 0, $learnedCount);
$learnedsGroupStatus = ArrayToolkit::group($learneds, 'status');
$finishs = isset($learnedsGroupStatus['finished']) ? $learnedsGroupStatus['finished'] : array();
$finishIds = ArrayToolkit::column($finishs, 'lessonId');
$learnings = isset($learnedsGroupStatus['learning']) ? $learnedsGroupStatus['learning'] : array();
$learningsIds = ArrayToolkit::column($learnings, 'lessonId');
$notLearnedConditions = array('status' => 'published', 'courseIds' => $courseIds, 'notLearnedIds' => $finishIds);
$sort = array('seq', 'ASC');
$notLearnedLessons = $this->getCourseService()->searchLessons($notLearnedConditions, $sort, 0, 4);
$classroomLessonNum = 0;
foreach ($courses as $course) {
//迭代班级下课时总数
$classroomLessonNum += $course['lessonNum'];
}
if (empty($notLearnedLessons)) {
unset($sortedClassrooms[$key]);
} else {
foreach ($notLearnedLessons as &$notLearnedLesson) {
if (in_array($notLearnedLesson['id'], $learningsIds)) {
$notLearnedLesson['isLearned'] = 'learning';
} else {
$notLearnedLesson['isLearned'] = '';
}
}
$classroom['lessons'] = $notLearnedLessons;
$classroom['learnedLessonNum'] = count($finishIds);
$classroom['allLessonNum'] = $classroomLessonNum;
}
} else {
unset($sortedClassrooms[$key]);
}
}
}
return $sortedClassrooms;
}
示例6: canBuild
public function canBuild($options)
{
$questions = $this->getQuestions($options);
$typedQuestions = ArrayToolkit::group($questions, 'type');
return $this->canBuildWithQuestions($options, $typedQuestions);
}
示例7: sortCards
protected function sortCards($cards)
{
$cards = $this->getCardService()->sortArrayByfield($cards, 'createdTime');
$cards = ArrayToolkit::group($cards, 'status');
$sortedCards = array();
$currentTime = time();
$usedCards = isset($cards['used']) ? $cards['used'] : array();
$invalidCards = isset($cards['invalid']) ? $cards['invalid'] : array();
$outDateCards = array();
$receiveCards = array();
if (isset($cards['receive'])) {
foreach ($cards['receive'] as $card) {
if ($card['deadline'] + 86400 < $currentTime) {
$card['status'] = 'outdate';
$outDateCards[] = $card;
} else {
$card['status'] = 'useable';
$receiveCards[] = $card;
}
}
}
$sortedCards = array_merge($receiveCards, $usedCards, $outDateCards, $invalidCards);
return $sortedCards;
}
示例8: getCourseStudyMissions
private function getCourseStudyMissions()
{
$user = $this->getCurrentUser();
$sortedCourses = array();
$courseMemConditions = array('userId' => $user->id, 'locked' => 0, 'classroomId' => 0, 'role' => 'student');
$courseMem = $this->getCourseService()->searchMembers($courseMemConditions, array('createdTime', 'DESC'), 0, 5);
$courseIds = ArrayToolkit::column($courseMem, 'courseId');
if (!empty($courseIds)) {
$courseConditions = array('courseIds' => $courseIds, 'parentId' => 0);
$courses = $this->getCourseService()->searchCourses($courseConditions, 'default', 0, 5);
$courses = ArrayToolkit::index($courses, 'id');
foreach ($courseMem as $member) {
if (empty($courses[$member['courseId']])) {
continue;
}
$course = $courses[$member['courseId']];
$sortedCourses[] = $course;
}
foreach ($sortedCourses as $key => &$course) {
/**
* 找出学过的课时
*/
$learnedConditions = array('userId' => $user->id, 'status' => 'finished', 'courseId' => $course['id']);
$sort = array('finishedTime', 'ASC');
$learneds = $this->getCourseService()->findUserLearnedLessons($user->id, $course['id']);
/**
* 找出未学过的课时
*/
$learnedsGroupStatus = ArrayToolkit::group($learneds, 'status');
$finishs = isset($learnedsGroupStatus['finished']) ? $learnedsGroupStatus['finished'] : array();
$finishIds = ArrayToolkit::column($finishs, 'lessonId');
$learnings = isset($learnedsGroupStatus['learning']) ? $learnedsGroupStatus['learning'] : array();
$learningsIds = ArrayToolkit::column($learnings, 'lessonId');
$notLearnedConditions = array('status' => 'published', 'courseId' => $course['id'], 'notLearnedIds' => $finishIds);
$sort = array('seq', 'ASC');
$notLearnedLessons = $this->getCourseService()->searchLessons($notLearnedConditions, $sort, 0, 4);
if (empty($notLearnedLessons)) {
unset($sortedCourses[$key]);
} else {
foreach ($notLearnedLessons as &$notLearnedLesson) {
if (in_array($notLearnedLesson['id'], $learningsIds)) {
$notLearnedLesson['isLearned'] = 'learning';
} else {
$notLearnedLesson['isLearned'] = '';
}
}
$course['lessons'] = $notLearnedLessons;
$course['learnedLessonNum'] = count($finishIds);
$course['allLessonNum'] = $course['lessonNum'];
}
}
}
return $sortedCourses;
}