src/AppBundle/Controller/HomeworkController.php
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace AppBundle\Controller;
use Biz\Task\Service\TaskService;
use Biz\User\Service\UserService;
use Biz\Course\Service\CourseService;
use Topxia\Service\Common\ServiceKernel;
use Biz\Activity\Service\ActivityService;
use Biz\Question\Service\QuestionService;
use Biz\Testpaper\Service\TestpaperService;
use Symfony\Component\HttpFoundation\Request;
class HomeworkController extends BaseController
{
public function startDoAction(Request $request, $lessonId, $homeworkId)
{
$homework = $this->getTestpaperService()->getTestpaperByIdAndType($homeworkId, 'homework');
if (empty($homework)) {
return $this->createMessageResponse('info', 'homework not found');
}
$activity = $this->getActivityService()->getActivity($lessonId);
if ($activity['mediaId'] != $homeworkId) {
//homeworkId not belong to activity(lessonId)
return $this->createMessageResponse('info', "homework#{$homeworkId} not found in activity#{$lessonId}");
}
list($course, $member) = $this->getCourseService()->tryTakeCourse($activity['fromCourseId']);
$result = $this->getTestpaperService()->startTestpaper($homeworkId, array('lessonId' => $lessonId, 'courseId' => $course['id']));
if ('doing' === $result['status']) {
return $this->redirect($this->generateUrl('homework_show', array(
'resultId' => $result['id'],
)));
}
return $this->redirect($this->generateUrl('homework_result_show', array(
'resultId' => $result['id'],
)));
}
public function doTestAction(Request $request, $resultId)
{
$result = $this->getTestpaperService()->getTestpaperResult($resultId);
if (!$result) {
return $this->createMessageResponse('info', 'homework result not found');
}
list($course, $member) = $this->getCourseService()->tryTakeCourse($result['courseId']);
$homework = $this->getTestpaperService()->getTestpaperByIdAndType($result['testId'], $result['type']);
if (!$homework) {
return $this->createMessageResponse('info', 'homework not found');
}
$questions = $this->getTestpaperService()->showTestpaperItems($homework['id'], $result['id']);
$activity = $this->getActivityService()->getActivity($result['lessonId']);
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。