src/Biz/Xapi/Type/AskQuestionType.php

(开头部分) 2KB

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

<?php

namespace Biz\Xapi\Type;

class AskQuestionType extends Type
{
    const TYPE = 'asked_question';

    public function packages($statements)
    {
        if (empty($statements)) {
            return array();
        }
        try {
            $threads = $this->findCourseThreads(
                array($statements, 'target_id'),
                array('type' => 'question')
            );

            $tasks = $this->findTasks(
                array($threads, 'taskId')
            );

            $courses = $this->findCourses(
                array($threads, 'courseId')
            );

            list($activities, $resources) = $this->findActivities(
                array($tasks, 'activityId')
            );

            $sdk = $this->createXAPIService();
            $pushStatements = array();

            foreach ($statements as $statement) {
                try {
                    $thread = $threads[$statement['target_id']];
                    $course = $courses[$thread['courseId']];
                    $task = empty($tasks[$thread['taskId']]) ? array() : $tasks[$thread['taskId']];
                    $activity = (empty($task) || empty($activities[$task['activityId']])) ? array() : $activities[$task['activityId']];
                    if (!empty($activity) && !empty($activity['ext']['mediaId'])) {
                        $resource = empty($resources[$activity['ext']['mediaId']]) ? array() : $resources[$activity['ext']['mediaId']];
                    } else {
                        $resource = array();
                    }

                    $object = array(
                        'id' => $thread['id'],
                        'course' => $course,
                        'definitionType' => empty($task['type']) ? 'course' : $this->convertMediaType($task['type']),
                        'resource' => empty($resource) ? array() : $resource,
                    );
                    $actor = $this->getActor($statement['user_id']);

                    $result = $thread;
                    $pushStatements[] = $sdk->askQuestion($actor, $object, $result, $statement['uuid'], $statement['occur_time'], false);
                } catch (\Exception $e) {
                    $this->biz['logger']->error($e);
                }
            }

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

AI 解读 AI

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

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