src/AppBundle/Controller/Activity/TestpaperController.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Controller\Activity;

use Biz\Course\Service\CourseService;
use Biz\Activity\Service\ActivityService;
use Biz\Testpaper\Service\TestpaperService;
use Symfony\Component\HttpFoundation\Request;
use Biz\Activity\Service\TestpaperActivityService;
use AppBundle\Common\Paginator;
use AppBundle\Common\ArrayToolkit;

class TestpaperController extends BaseActivityController implements ActivityActionInterface
{
    public function showAction(Request $request, $activity, $preview = 0)
    {
        if ($preview) {
            return $this->previewTestpaper($activity['id'], $activity['fromCourseId']);
        }

        $user = $this->getUser();
        $testpaperActivity = $this->getTestpaperActivityService()->getActivity($activity['mediaId']);
        $testpaper = $this->getTestpaperService()->getTestpaperByIdAndType($testpaperActivity['mediaId'], $activity['mediaType']);

        if (!$testpaper) {
            return $this->render('activity/testpaper/preview.html.twig', array(
                'paper' => null,
            ));
        }

        $testpaperResult = $this->getTestpaperService()->getUserLatelyResultByTestId($user['id'], $testpaperActivity['mediaId'], $activity['fromCourseId'], $activity['id'], $activity['mediaType']);

        if (!$testpaperResult || ($testpaperResult['status'] == 'doing' && !$testpaperResult['updateTime']) || $testpaper['status'] != 'open') {
            return $this->render('activity/testpaper/show.html.twig', array(
                'activity' => $activity,
                'testpaperActivity' => $testpaperActivity,
                'testpaperResult' => $testpaperResult,
                'testpaper' => $testpaper,
                'courseId' => $activity['fromCourseId'],
            ));
        } elseif ($testpaperResult['status'] === 'finished') {
            return $this->forward('AppBundle:Testpaper/Testpaper:showResult', array(
                'resultId' => $testpaperResult['id'],
            ));
        }

        return $this->forward('AppBundle:Testpaper/Testpaper:doTestpaper', array(
            'testId' => $testpaperActivity['mediaId'],
            'lessonId' => $activity['id'],
        ));
    }

    public function previewAction(Request $request, $task)
    {
        return $this->previewTestpaper($task['activityId'], $task['courseId']);
    }

    public function previewTestpaper($id, $courseId)
    {
        $activity = $this->getActivityService()->getActivity($id);

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。