From bffcae307029e468da4b3cec6b47444c6bc7eec4 Mon Sep 17 00:00:00 2001 From: Rida Abou-Haidar Date: Tue, 12 Dec 2023 12:04:56 -0500 Subject: [PATCH] [LINST] fix survey and date issues (#8858) Add fields to XIN validation which are not parts of groups --- .../NDB_BVL_Instrument_LINST.class.inc | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/php/libraries/NDB_BVL_Instrument_LINST.class.inc b/php/libraries/NDB_BVL_Instrument_LINST.class.inc index ff8f50e0e05..12ea564aaf7 100644 --- a/php/libraries/NDB_BVL_Instrument_LINST.class.inc +++ b/php/libraries/NDB_BVL_Instrument_LINST.class.inc @@ -677,7 +677,10 @@ class NDB_BVL_Instrument_LINST extends \NDB_BVL_Instrument // The question should be added to the LinstQuestions in this // order, before the _date is stripped below for standard // dates to allow XINValidation to recognize the field name - $this->LinstQuestions[$pieces[1]] = ['type' => 'date']; + $this->LinstQuestions[$pieces[1]] = [ + 'type' => 'date', + 'dateFormat' => $dateFormat, + ]; if ($dateFormat === 'MonthYear') { // Shows date without day of month @@ -980,15 +983,27 @@ class NDB_BVL_Instrument_LINST extends \NDB_BVL_Instrument $q['UserRules'] = true; switch ($q['type']) { + // Selects (including multiselects), Basic Dates and MonthYears + // are the only type of rules that aren't part of a group + // the rest include a _status element case 'select': - // Selects are the only type of rules that aren't part - // of a group, the rest include a _status element $this->XINRegisterRule($question, $rules, $message); break; + case 'date': + if ($q['dateFormat'] === 'BasicDate' + || $q['dateFormat'] === 'MonthYear' + ) { + $this->XINRegisterRule($question, $rules, $message); + break; + } default: + $rules_array = array_merge( + $rules, + [$question.'_status{@}=={@}'] + ); $this->XINRegisterRule( $question, - $rules, + $rules_array, $message, $question . "_group" );