api/src/Topxia/Api/Resource/ThreadManager.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Topxia\Api\Resource;
use Silex\Application;
use AppBundle\Common\ArrayToolkit;
use Topxia\Service\Common\ServiceKernel;
use Symfony\Component\HttpFoundation\Request;
class ThreadManager extends BaseResource
{
public function question(Application $app, Request $request)
{
$courseId = $request->query->get('courseId', 0);
$start = $request->query->get('start', 5);
$user = $this->getCurrentUser();
$course = $this->getCourseService()->getCourse($courseId);
if (empty($course)) {
return $this->error('error', '课程信息不存在!');
}
if (!$this->getCourseMemberService()->isCourseTeacher($courseId, $user['id'])) {
return $this->error('error', '您不是老师,不能查看此页面!!');
}
$myTeachingCourseCount = $this->getCourseService()->findUserTeachCourseCount(array('userId' => $user['id']), true);
if (empty($myTeachingCourseCount)) {
return array(
'threadCount' => 0,
'users' => array(),
'threads' => array(),
);
}
$myTeachingCourses = $this->getCourseService()->findUserTeachCourses(array('userId' => $user['id']), 0, $myTeachingCourseCount, true);
$conditions = array(
'courseIds' => array($courseId),
'type' => 'question',
);
$threadCount = $this->getCourseThreadService()->searchThreadCountInCourseIds($conditions);
$threads = $this->getCourseThreadService()->searchThreadInCourseIds(
$conditions,
'posted',
0,
500
);
$threads = $this->sortThreads($threads, $start);
$users = $this->getUserService()->findUsersByIds(ArrayToolkit::column($threads, 'userId'));
$lessons = $this->getTaskService()->findTasksByIds(ArrayToolkit::column($threads, 'taskId'));
$lessons = ArrayToolkit::index($lessons, 'id');
foreach ($threads as $key => &$thread) {
$lesson = empty($lessons[$thread['taskId']]) ? array() : $lessons[$thread['taskId']];
$lessonTitle = empty($lesson) ? '课程提问' : '课时:'.$lesson['number'].$lesson['title'];
$thread['lessonTitle'] = $lessonTitle;
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。