Skip to content
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

[Survey Accounts] Batch send surveys #8985

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 43 additions & 37 deletions modules/survey_accounts/php/addsurvey.class.inc
Expand Up @@ -150,16 +150,18 @@ class AddSurvey extends \NDB_Form
);
$reminder = " already exists for given candidate for visit ";
foreach ($instrument_list as $instrument) {
if ($values['Test_name'] == $instrument['Test_name']) {
$instrument_instance = \NDB_BVL_Instrument::factory(
$this->loris,
$instrument['Test_name']
);
return [
'Test_name' => "Instrument ".
$instrument_instance->getFullName().
$reminder. $values['VL'],
];
foreach ($values['Test_name'] as $testName){
if ($testName == $instrument['Test_name']) {
$instrument_instance = \NDB_BVL_Instrument::factory(
$this->loris,
$instrument['Test_name']
);
return [
'Test_name' => "Instrument ".
$instrument_instance->getFullName().
$reminder. $values['VL'],
];
}
}
}

Expand Down Expand Up @@ -200,14 +202,16 @@ class AddSurvey extends \NDB_Form
]
);

$InstrumentExists = $db->pselectOne(
"SELECT 'x' FROM participant_accounts
foreach ($values['Test_name'] as $testName) {
$InstrumentExists = $db->pselectOne(
"SELECT 'x' FROM participant_accounts
WHERE Test_name=:TN AND SessionID=:SID",
[
'TN' => $values['Test_name'],
'SID' => $SessionID,
]
);
[
'TN' => $testName,
'SID' => $SessionID,
]
);
}
if ($InstrumentExists == 'x') {
return;
}
Expand All @@ -216,7 +220,7 @@ class AddSurvey extends \NDB_Form
new \SessionID($SessionID)
);

$commentID = $battery->addInstrument($this->loris, $values['Test_name']);


$key = $this->_generateSurveyKey();

Expand All @@ -229,21 +233,23 @@ class AddSurvey extends \NDB_Form
} else {
$status = 'Created';
}

try {
$db->insert(
"participant_accounts",
[
'SessionID' => $SessionID,
'Test_name' => $values['Test_name'],
'Status' => $status,
'OneTimePassword' => $key,
'CommentID' => $commentID,
]
);
} catch (\DatabaseException $e) {
error_log($e->getMessage());
$this->tpl_data['success'] = false;
foreach ($values['Test_name'] as $testName) {
$commentID = $battery->addInstrument($this->loris, $testName);
try {
$db->insert(
"participant_accounts",
[
'SessionID' => $SessionID,
'Test_name' => $testName,
'Status' => $status,
'OneTimePassword' => $key,
'CommentID' => $commentID,
]
);
} catch (\DatabaseException $e) {
error_log($e->getMessage());
$this->tpl_data['success'] = false;
}
}
$this->tpl_data['success'] = true;

Expand Down Expand Up @@ -289,10 +295,10 @@ class AddSurvey extends \NDB_Form
$this->addSelect(
"Test_name",
"Instrument",
array_merge(
['' => ''],
\Utility::getDirectInstruments()
)
\Utility::getDirectInstruments(),
[
'multiple' => 'multiple',
]
);
$this->addBasicText("Email", "Email address");
$this->addBasicText("Email2", "Confirm Email address");
Expand Down
3 changes: 2 additions & 1 deletion modules/survey_accounts/test/TestPlan.md
Expand Up @@ -20,14 +20,15 @@
* Once you hit “Email Survey” you should get a blank page where you can customize an email to go along with the URL –
enter in a message and make sure it sends (also try the "Close" button on this page).
The email can be pre-populated for each instrument using participant_emails table.
* Ensure that the instrument being sent is what you get (and that the URL brings you to the correct survey).
* Ensure that the instruments being sent are what you get (and that the URL brings you to the correct survey).
* Use the `Create Survey` button (no email address should be specified).
* Use the `Email survey` button by specifying email address.
* Check that the survey list shows the newly created survey with all the correct information.
* Try creating a survey for a candidate in a Project that the user is not affiliated with. This should not be allowed.
* Try mismatched PSCID and DCCID and should get an error message.
* Try creating duplicate instrument for a candidate for a visit, should get an error message.
* Try creating instrument for a candidate in a non-existing visit, should get an error message.
* Try creating a batch of surveys by selecting multiple instruments
[Manual Testing]
7. Enable a new instrument for Survey module and verify survey can be created. (IsDirectEntry set to 1 in test_names table).
[Manual Testing]
Expand Down