Skip to content

Commit

Permalink
fixes for Lint and Unit Tests
Browse files Browse the repository at this point in the history
Signed-off-by: Timotheus Pokorra <timotheus.pokorra@solidcharity.com>
  • Loading branch information
tpokorra committed Aug 30, 2023
1 parent 5a81f1f commit 76b1260
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getOptions(int $questionId): array {
}
}

private function getAnswers(int $formId, int $submissionId, string $userId): array|false {
private function getAnswers(int $formId, int $submissionId, string $userId): array {

$answerList = [];
$answerEntities = $this->answerMapper->findBySubmission($submissionId);
Expand Down Expand Up @@ -230,18 +230,20 @@ public function getForm(int $id): array {
$result['questions'] = $this->getQuestions($id);

// add previous submission if there is one by this user for this form
if ($this->currentUser->getUID()) {
if ($this->currentUser->getUID() && form->getAllowEdit()) {
$submissionEntity = null;
try {
$submissionEntity = $this->submissionMapper->findByFormAndUser($id, $this->currentUser->getUID());
$answers = $this->getAnswers($id, $submissionEntity->getId(), $this->currentUser->getUID());
if ($answers !== false) {
if (!empty($answers)) {
$result['answers'] = $answers;
$result['newSubmission'] = false;
$result['submissionId'] = $submissionEntity->getId();
}
} catch (DoesNotExistException $e) {
// do nothing
} catch (MultipleObjectsReturnedException $e) {
// do nothing
}
}

Expand Down

0 comments on commit 76b1260

Please sign in to comment.