From d8765566b51aa63385ab5e7ed82817463a2ef4dc Mon Sep 17 00:00:00 2001 From: Christian Hartmann Date: Fri, 30 Aug 2024 19:46:42 +0200 Subject: [PATCH] fix duplicate method Signed-off-by: Christian Hartmann --- lib/Controller/ApiController.php | 60 -------------------------------- 1 file changed, 60 deletions(-) diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index afb300a2e..fe16ae96d 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -2169,66 +2169,6 @@ public function getSubmissionsLegacy(string $hash): DataResponse { return new DataResponse($response); } - /** - * Insert answers for a question - * - * @param Form $form - * @param int $submissionId - * @param array $question - * @param string[]|array $answerArray - */ - private function storeAnswersForQuestion(Form $form, $submissionId, array $question, array $answerArray) { - foreach ($answerArray as $answer) { - $answerEntity = new Answer(); - $answerEntity->setSubmissionId($submissionId); - $answerEntity->setQuestionId($question['id']); - - $answerText = ''; - $uploadedFile = null; - // Are we using answer ids as values - if (in_array($question['type'], Constants::ANSWER_TYPES_PREDEFINED)) { - // Search corresponding option, skip processing if not found - $optionIndex = array_search($answer, array_column($question['options'], 'id')); - if ($optionIndex !== false) { - $answerText = $question['options'][$optionIndex]['text']; - } elseif (!empty($question['extraSettings']['allowOtherAnswer']) && strpos($answer, Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX) === 0) { - $answerText = str_replace(Constants::QUESTION_EXTRASETTINGS_OTHER_PREFIX, '', $answer); - } - } elseif ($question['type'] === Constants::ANSWER_TYPE_FILE) { - $uploadedFile = $this->uploadedFileMapper->getByUploadedFileId($answer['uploadedFileId']); - $answerEntity->setFileId($uploadedFile->getFileId()); - - $userFolder = $this->storage->getUserFolder($form->getOwnerId()); - $path = $this->formsService->getUploadedFilePath($form, $submissionId, $question['id'], $question['name'], $question['text']); - - if ($userFolder->nodeExists($path)) { - $folder = $userFolder->get($path); - } else { - $folder = $userFolder->newFolder($path); - } - /** @var \OCP\Files\Folder $folder */ - - $file = $userFolder->getById($uploadedFile->getFileId())[0]; - $name = $folder->getNonExistingName($file->getName()); - $file->move($folder->getPath() . '/' . $name); - - $answerText = $name; - } else { - $answerText = $answer; // Not a multiple-question, answerText is given answer - } - - if ($answerText === '') { - continue; - } - - $answerEntity->setText($answerText); - $this->answerMapper->insert($answerEntity); - if ($uploadedFile) { - $this->uploadedFileMapper->delete($uploadedFile); - } - } - } - /** * @CORS * @NoAdminRequired