/** * Get the users script for specified language, userKey and tool * * @param Request $request * @param string $sessionKey * @param string $tool * @return Response The script content */ public static function registerResult(Request $request) { $origin = $request->headers->get('Origin'); $response = static::getResponse('application/json', $origin); if (!$origin) { return $response; } $user = static::getUser(); if ($user && $user->hasLicense() && $user->is_enabled) { $evaluation = static::getEvaluation($request->sessionKey); $results = $request->get('results', null); if (!$evaluation || !$results) { return $response; } foreach ($results as $result) { $result['evaluation_id'] = $evaluation->id; Result::create($result); } $response->setContent(json_encode(['error' => 0])); } return $response; }
/** * Store a newly created resource in storage. * * @return Response */ public function store(ResultRequest $request, Exam $exam) { $input = $request->all(); $input['exam_id'] = $exam->id; return Result::create($input)->toJson(); }