From 8d0acc2c071b1f4aa323329538c37e3a4f7e4ab1 Mon Sep 17 00:00:00 2001 From: Zaliqa Date: Mon, 21 Dec 2020 13:42:51 -0500 Subject: [PATCH] [LINST] Remove '_date' only for Standard Format (#6923) This fixes the removal of '_date' by only doing it for Standard Date formats. Currently, all date elements (standard, basic, and month/year) in linst instruments have their field names redefined as the substring appearing before '_date'. For example, if a date element is called 'enrolment_date_v2', the instrument field name becomes enrolment. This results in the save function trying to update a field called 'enrolment' in the instrument table which does not exist. The reason why this functionality existed is because the Standard Date format requires a field name ending with '_date'. Linst Standard Date formats are created by calling the NDB_BVL_Instrument class addDateElement() function which auto appends '_date' to the date element name. In order to avoid '_date' appearing twice, the NDB_BVL_Instrument_LINST class removes '_date' from the element name before calling addDateElement(). Basic Date and Month/Year formats call the NDB_Page class addBasicDate() function and the NDB_BVL_Instrument class addMonthYear) function respectively, both of which do not seem to auto append '_date' to the field name. With this change, if a Standard Date format field name does not already end with '_date' , a LorisException is thrown. --- .../NDB_BVL_Instrument_LINST_ToJSON_Test.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php b/test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php index ee2f159ce17..aa0adbce11f 100644 --- a/test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php +++ b/test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php @@ -138,6 +138,7 @@ function testAllElements() $instrument .= "header{@}{@}Header\n"; $instrument .= "static{@}{@}label\n"; $instrument .= "text{@}FieldName{@}Field Description\n"; +<<<<<<< af27a71670a60c43ee528c3c8c41345a27a35429 $instrument .= "select{@}texbox_status{@}{@}NULL=>''{-}'not_answered'=>'Not Answered'\n"; $instrument .= "textarea{@}FieldName{@}Field Description\n"; $instrument .= "select{@}textarea_status{@}{@}NULL=>''{-}'not_answered'=>'Not Answered'\n"; @@ -145,6 +146,24 @@ function testAllElements() $instrument .= "selectmultiple{@}FieldName{@}Field Description{@}NULL=>''{-}'option_1'=>'Option 1'{-}'option_2'=>'Option 2'{-}'option_3'=>'Option 3'{-}'option_4'=>'Option 4'{-}'not_answered'=>'Not Answered'\n"; $instrument .= "date{@}FieldName_date{@}Field Description{@}2003{@}2014\n"; $instrument .= "select{@}date_status{@}{@}NULL=>''{-}'not_answered'=>'Not Answered'\n"; +======= + $instrument .= "select{@}texbox_status{@}{@}NULL=>''{-}" + . "'not_answered'=>'Not Answered'\n"; + $instrument .= "textarea{@}FieldName{@}" + . "Field Description\n"; + $instrument .= "select{@}textarea_status{@}{@}NULL=>''{-}" + . "'not_answered'=>'Not Answered'\n"; + $instrument .= "select{@}FieldName{@}Field Description{@}NULL=>''{-}" + . "'option_1'=>'Option 1'{-}'option_2'=>'Option 2'{-}" + . "'option_3'=>'Option 3'{-}'not_answered'=>'Not Answered'\n"; + $instrument .= "selectmultiple{@}FieldName{@}Field Description{@}NULL=>''{-}" + . "'option_1'=>'Option 1'{-}'option_2'=>'Option 2'{-}" + . "'option_3'=>'Option 3'{-}'option_4'=>'Option 4'{-}" + . "'not_answered'=>'Not Answered'\n"; + $instrument .= "date{@}FieldName_date{@}Field Description{@}2003{@}2014\n"; + $instrument .= "select{@}date_status{@}{@}NULL=>''{-}" + . "'not_answered'=>'Not Answered'\n"; +>>>>>>> [LINST] Remove '_date' only for Standard Format (#6923) $instrument .= "numeric{@}FieldName{@}Field Description{@}0{@}20\n"; $instrument .= "select{@}numeric_status{@}{@}NULL=>''{-}" . "'not_answered'=>'Not Answered'";