Skip to content

Commit

Permalink
[LINST] skip metadatafields for surveys (#8961)
Browse files Browse the repository at this point in the history
Skip over metadatafields and calculate ages in surveys

This is not a big change, one way or another the fields were either being skipped with an empty check, through a project override or through code in the module itself handling the submission. this is just an explicit check to make everything clearer
  • Loading branch information
zaliqarosli committed Nov 24, 2023
1 parent d746654 commit c1f25c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
11 changes: 7 additions & 4 deletions php/libraries/NDB_BVL_Instrument.class.inc
Expand Up @@ -298,6 +298,12 @@ abstract class NDB_BVL_Instrument extends NDB_Page
$base . "project/instruments/$instrument.meta"
);
}
// Set DataEntryType to normal or DirectEntry
if (isset($_REQUEST['key'])) {
$obj->DataEntryType = 'DirectEntry';
} else {
$obj->DataEntryType = 'normal';
}
// Adds all of the form element and form rules to the page after
// having instantiated the form above
$obj->loadInstrumentFile(
Expand Down Expand Up @@ -477,10 +483,7 @@ abstract class NDB_BVL_Instrument extends NDB_Page
{
// ALWAYS INCLUDE THESE!

if (isset($_REQUEST['key'])) {
$this->DataEntryType = 'DirectEntry';
} else {
$this->DataEntryType = 'normal';
if ($this->DataEntryType === 'normal') {
// These are required for Save Data to work properly, but not when it's
// a direct data entry page
$this->addHidden(
Expand Down
4 changes: 3 additions & 1 deletion php/libraries/NDB_BVL_Instrument_LINST.class.inc
Expand Up @@ -556,7 +556,9 @@ class NDB_BVL_Instrument_LINST extends \NDB_BVL_Instrument
'instrument_title',
$pieces[1]
);
$this->_addMetadataFields();
if ($this->DataEntryType!=="DirectEntry") {
$this->_addMetadataFields();
}
}
break;
case 'begingroup':
Expand Down
12 changes: 7 additions & 5 deletions test/unittests/NDB_BVL_Instrument_Test.php
Expand Up @@ -1335,10 +1335,11 @@ function testSaveValueAndSave()
{
$this->_setUpMockDB();
$this->_setTableData();
$this->_instrument->commentID = 'commentID1';
$this->_instrument->table = 'medical_history';
$this->_instrument->testName = 'Test';
$this->_instrument->formType = "XIN";
$this->_instrument->commentID = 'commentID1';
$this->_instrument->table = 'medical_history';
$this->_instrument->testName = 'Test';
$this->_instrument->formType = "XIN";
$this->_instrument->DataEntryType = "normal";
$values = ['Date_taken' => '2005-06-06',
'arthritis_age' => 2,
'arthritis_age_status' => 'status'
Expand Down Expand Up @@ -1791,7 +1792,8 @@ function testDisplay()
$this->_setUpMockDB();
$this->_setTableData();
$this->_instrument->setup("commentID1", "page");
$this->_instrument->table = 'medical_history';
$this->_instrument->table = 'medical_history';
$this->_instrument->DataEntryType = "normal";
$this->assertStringContainsString(
"<input name=\"candID\" value=\"\" type=\"hidden\">\n",
$this->_instrument->display()
Expand Down

0 comments on commit c1f25c9

Please sign in to comment.