File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ public function getOptions(int $questionId): array {
150150 }
151151 }
152152
153- private function getAnswers (int $ formId , int $ submissionId , string $ userId ): array | false {
153+ private function getAnswers (int $ formId , int $ submissionId , string $ userId ): array {
154154
155155 $ answerList = [];
156156 $ answerEntities = $ this ->answerMapper ->findBySubmission ($ submissionId );
@@ -230,18 +230,20 @@ public function getForm(int $id): array {
230230 $ result ['questions ' ] = $ this ->getQuestions ($ id );
231231
232232 // add previous submission if there is one by this user for this form
233- if ($ this ->currentUser ->getUID ()) {
233+ if ($ this ->currentUser ->getUID () && form-> getAllowEdit () ) {
234234 $ submissionEntity = null ;
235235 try {
236236 $ submissionEntity = $ this ->submissionMapper ->findByFormAndUser ($ id , $ this ->currentUser ->getUID ());
237237 $ answers = $ this ->getAnswers ($ id , $ submissionEntity ->getId (), $ this ->currentUser ->getUID ());
238- if ($ answers !== false ) {
238+ if (! empty ( $ answers) ) {
239239 $ result ['answers ' ] = $ answers ;
240240 $ result ['newSubmission ' ] = false ;
241241 $ result ['submissionId ' ] = $ submissionEntity ->getId ();
242242 }
243243 } catch (DoesNotExistException $ e ) {
244244 // do nothing
245+ } catch (MultipleObjectsReturnedException $ e ) {
246+ // do nothing
245247 }
246248 }
247249
You can’t perform that action at this time.
0 commit comments