/** * Пересчитывает результат теста (вместо процентов - баллы) * @return void */ public function recalcAction() { if ($this->_authorize('test', 'edit')) { $link = $this->getRequest()->getParam('link'); $objApplicantTests = new ApplicantTests(); $applicantTest = $objApplicantTests->getTest($link); if (empty($applicantTest)) { exit; } $applicantId = $applicantTest->applicant_id; $testId = $applicantTest->test_id; $applicantTestId = $applicantTest->id; $objQuestion = new Questions(); $questions = $objQuestion->getQuestions($testId); $questions = $this->convertArr($questions, 'tq_id'); $objTestAnswers = new Answers(); $answers = $objTestAnswers->getAnswers(array_keys($questions)); // ключем $answers будет id вопроса $answers = $this->convertArr($answers, 'tq_id', true); $objApplicantAnswers = new ApplicantAnswers(); $applicantAnswers = $objApplicantAnswers->getAnswers($applicantTestId); $applicantAnswers = $this->convertArr($applicantAnswers, 'answer_id'); $result = $this->calcTestScore($questions, $answers, $applicantAnswers); $applicantTest->score = $result['score']; $applicantTest->percent = $result['percent']; $applicantTest->save(); } $this->_helper->redirector('testing', 'test', null, array('link' => $link)); }