-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[23.0][Instrument] Fix freeze on completed instruments #7344
[23.0][Instrument] Fix freeze on completed instruments #7344
Conversation
@driusan Can you help with this? With the changes in this PR, the page still needs to be refreshed for freeze to take effect. |
I can't test very well because the 23 branch doesn't work with php 8, but it seems to work for me when I redirect in the process function if the Data Entry status changes. It doesn't work in the handle function because of the order of operations where the
|
@jesscall to pass test, you need to add "$this->DataEntryType = 'DirectEntry'; " into the setup function of "test/test_instrument/NDB_BVL_Instrument_testtest.class.inc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Why is testtest a DirectEntry instrument? AFAIK it's not used for testing surveys |
rebase after this #7369 |
a63c8a9
to
1d9ebe7
Compare
1d9ebe7
to
2a8070b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there seems to be hanges to files that are unrelated to the PR. I think this might be the result of a bad rebase.
@@ -42,6 +42,9 @@ class NDB_BVL_Instrument_testtest extends NDB_BVL_Instrument | |||
|
|||
// setup the form | |||
$this->_setupForm(); | |||
|
|||
// set data entry type | |||
$this->DataEntryType = 'DirectEntry'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this set to DirectEntry? As far as I know this test instrument isn't used as a survey instrument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is needed because the following logic was added in this PR and it affects testing.
@kongtiaowang can maybe provide more details
if ($this->preview !== true && $this->DataEntryType !== 'DirectEntry') {
$this->freeze();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have the following 5 conditions that would make the instrument be frozen
- Instrument is NOT in progress
- the user does not have data_entry permission
- the user does not have access to the timepoint at which the instrument is instantiated
- the instrument is not in preview mode
- the instrument is not a direct entry
Why choose to solve the problem with option 5 ? I would say options 1, 2 and 3 are your easy logical solutions !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Rida means "make the instrument not be frozen". Assuming he does, I agree. "Direct entry" means survey mode and doesn't get frozen because when it's set, the participant is entering data directly (after the entry is complete they can no longer access the URL..)
If the test doing data entry on an instrument that was supposed to be frozen and is now broken because the freeze bug is fixed, the solution should be to fix the test and/or data, not fake being a survey instrument for testing non-survey functionality in order to work around the freeze call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback.
I agree with Dave, it's likely an issue with the test doing data entry on an instrument meant to be frozen and this fix is messing with that. In that case the test case should be updated.
Pushing Rida's recent feedback and will monitor the test suite logs for indications of where the issue might be.
@@ -42,6 +42,9 @@ class NDB_BVL_Instrument_testtest extends NDB_BVL_Instrument | |||
|
|||
// setup the form | |||
$this->_setupForm(); | |||
|
|||
// set data entry type | |||
$this->DataEntryType = 'DirectEntry'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have the following 5 conditions that would make the instrument be frozen
- Instrument is NOT in progress
- the user does not have data_entry permission
- the user does not have access to the timepoint at which the instrument is instantiated
- the instrument is not in preview mode
- the instrument is not a direct entry
Why choose to solve the problem with option 5 ? I would say options 1, 2 and 3 are your easy logical solutions !
&& !in_array( | ||
$timepoint->getData("CenterID"), | ||
$user->getData("CenterIDs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the third argument true
to the in_array function to avoid unexpected behaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think $user->hasCenter($timepoint->getCenterID())
would be better so that it doesn't need to change after #7359 (and it's more explicit what it's trying to do..)
hi @jesscall, when the user has data_entry permission or status is in_progress, the form always is frozen. |
if ($status->getDataEntryStatus() != 'In Progress' | ||
|| !$user->hasPermission('data_entry') | ||
|| (isset($timepoint) | ||
&& !in_array( | ||
$timepoint->getData("CenterID"), | ||
$user->getData("CenterIDs"), | ||
true | ||
)) | ||
|| $this->preview !== true | ||
|| $this->DataEntryType !== 'DirectEntry' | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($status->getDataEntryStatus() != 'In Progress' | |
|| !$user->hasPermission('data_entry') | |
|| (isset($timepoint) | |
&& !in_array( | |
$timepoint->getData("CenterID"), | |
$user->getData("CenterIDs"), | |
true | |
)) | |
|| $this->preview !== true | |
|| $this->DataEntryType !== 'DirectEntry' | |
) { | |
if ($status->getDataEntryStatus() != 'In Progress' | |
|| !$user->hasPermission('data_entry') | |
|| (isset($timepoint) | |
&& !in_array( | |
$timepoint->getData("CenterID"), | |
$user->getData("CenterIDs"), | |
true | |
)) | |
&& $this->preview !== true | |
&& $this->DataEntryType !== 'DirectEntry' | |
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Move the if into the same statement", they said.
"That'll make it simpler," they said.
@jesscall please add "'Data_entry'=> 'In Progress', " into test/test_instrument/test_instrumentTest.php at line 58, it will pass the integration test. |
@jesscall this is in your court |
Brief summary of changes
Bugfix for disabling fields when instrument is set to complete.
Testing instructions (if applicable)
Complete