src/Topxia/MobileBundleV2/Processor/Impl/TestpaperProcessorImpl.php

(开头部分) 2KB

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

<?php

namespace Topxia\MobileBundleV2\Processor\Impl;

use AppBundle\Common\ArrayToolkit;
use Biz\Task\Service\TaskService;
use Topxia\MobileBundleV2\Processor\BaseProcessor;
use Topxia\MobileBundleV2\Processor\TestpaperProcessor;

class TestpaperProcessorImpl extends BaseProcessor implements TestpaperProcessor
{
    public function reDoTestpaper()
    {
        $testId = $this->getParam('testId');
        $targetType = $this->getParam('targetType');
        $targetId = $this->getParam('targetId');

        $user = $this->controller->getUserByToken($this->request);
        if (!$user->isLogin()) {
            return $this->createErrorResponse('not_login', '您尚未登录,不能查看该课时');
        }

        $task = $this->getTaskService()->getTask($targetId);
        if (!$task) {
            return $this->createErrorResponse('error', '试卷所属课时不存在!');
        }

        $testpaper = $this->getTestpaperService()->getTestpaper($testId);

        if (empty($testpaper)) {
            return $this->createErrorResponse('error', '试卷不存在!或已删除!');
        }

        if ('draft' == $testpaper['status']) {
            return $this->createErrorResponse('error', '该试卷未发布,如有疑问请联系老师!!');
        }

        if ('closed' == $testpaper['status']) {
            return $this->createErrorResponse('error', '该试卷已关闭,如有疑问请联系老师!!');
        }

        $course = $this->getCourseService()->getCourse($task['courseId']);

        if (empty($course)) {
            return $this->createErrorResponse('error', '试卷所属课程不存在!');
        }

        if (!$this->getCourseService()->canTakeCourse($course)) {
            return $this->createErrorResponse('error', '不是试卷所属课程老师或学生');
        }

        $activity = $this->getActivityService()->getActivity($task['activityId']);
        $testpaperActivity = $this->getTestpaperActivityService()->getActivity($activity['mediaId']);

        $testpaperResult = $this->getTestpaperService()->getUserLatelyResultByTestId($user['id'], $testpaper['id'], $activity['fromCourseSetId'], $activity['id'], $testpaper['type']);

        if ($testpaperActivity['doTimes'] && $testpaperResult && 'finished' == $testpaperResult['status']) {
            return $this->createErrorResponse('error', '该试卷只能考一次,不能再考!');
        } elseif ($testpaperActivity['redoInterval']) {
            $nextDoTime = $testpaperResult['checkedTime'] + $testpaperActivity['redoInterval'] * 3600;

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

AI 解读 AI

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

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