Skip to content

Commit

Permalink
[LINST] Remove '_date' only for Standard Format (aces#6923)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zaliqarosli authored and AlexandraLivadas committed Jun 29, 2021
1 parent af27a71 commit 8d0acc2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/unittests/NDB_BVL_Instrument_LINST_ToJSON_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,32 @@ 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";
$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";
=======
$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'";
Expand Down

0 comments on commit 8d0acc2

Please sign in to comment.