Skip to content

Commit

Permalink
testfile added for validation by exclusion criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
YUE YU committed Aug 29, 2024
1 parent b5cd1b0 commit 5bc1c0d
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 8 deletions.
13 changes: 11 additions & 2 deletions relis_app/helpers/tests/helpers/tests_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function screenPapers($screenPhaseField, $done = -1, $reviewPerpaper = 1, $inclu
}

//$done = Nbr of papers to screen; $include = Nbr of papers to include
function assignPapers_and_performScreening($userIds = array(), $screenPhaseField, $done = -1, $include = -1)
function assignPapers_and_performScreening($userIds = array(), $screenPhaseField, $done = -1, $include = -1, $criteria = -1)
{
$ci = get_instance();
$http_client = new Http_client();
Expand Down Expand Up @@ -422,7 +422,16 @@ function assignPapers_and_performScreening($userIds = array(), $screenPhaseField
$data = ["criteria_ex" => "", "criteria_in" => "", "note" => "", "screening_id" => $screening_paper['screening_id'], "decision" => "accepted", "operation_type" => "new", "screening_phase" => $screening_paper['screening_phase'], "operation_source" => "list_screen/mine_screen", "paper_id" => $screening_paper['paper_id'], "assignment_id" => $screening_paper['screening_id'], "screen_type" => "simple_screen"];
} else {
//exclude papers
$data = ["criteria_ex" => 1, "criteria_in" => "", "note" => "", "screening_id" => $screening_paper['screening_id'], "decision" => "excluded", "operation_type" => "new", "screening_phase" => $screening_paper['screening_phase'], "operation_source" => "list_screen/mine_screen", "paper_id" => $screening_paper['paper_id'], "assignment_id" => $screening_paper['screening_id'], "screen_type" => "simple_screen"];
if ($criteria == -1){//Validation normally
$data = ["criteria_ex" => 1, "criteria_in" => "", "note" => "", "screening_id" => $screening_paper['screening_id'], "decision" => "excluded", "operation_type" => "new", "screening_phase" => $screening_paper['screening_phase'], "operation_source" => "list_screen/mine_screen", "paper_id" => $screening_paper['paper_id'], "assignment_id" => $screening_paper['screening_id'], "screen_type" => "simple_screen"];
}else{//Validation by exclusion criteria
if ($i <= 3){
$data = ["criteria_ex" => 1, "criteria_in" => "", "note" => "", "screening_id" => $screening_paper['screening_id'], "decision" => "excluded", "operation_type" => "new", "screening_phase" => $screening_paper['screening_phase'], "operation_source" => "list_screen/mine_screen", "paper_id" => $screening_paper['paper_id'], "assignment_id" => $screening_paper['screening_id'], "screen_type" => "simple_screen"];
}//import 3 of criteria EC1
else{
$data = ["criteria_ex" => 2, "criteria_in" => "", "note" => "", "screening_id" => $screening_paper['screening_id'], "decision" => "excluded", "operation_type" => "new", "screening_phase" => $screening_paper['screening_phase'], "operation_source" => "list_screen/mine_screen", "paper_id" => $screening_paper['paper_id'], "assignment_id" => $screening_paper['screening_id'], "screen_type" => "simple_screen"];
}
}
}

save_screening($data);
Expand Down
75 changes: 69 additions & 6 deletions relis_app/helpers/tests/screening_ut_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function run_tests()
$this->saveAssignmentValidation_emptyUsers();
$this->saveAssignmentValidation_50percent();
$this->saveAssignmentValidation_100percent();
$this->saveAssignmentValidation_by1criteria();
$this->screenPaperValidation();
$this->screenValidationCompletion();
$this->screenValidationResult();
Expand Down Expand Up @@ -1781,6 +1782,68 @@ private function saveAssignmentValidation_100percent()

/*
* Test 39
* Action : save_assign_screen_validation
* Description : save the assignments of papers for screening validation by exclusion criteria EC1 with 100%.
* Expected Paper assignements :
* - All papers excluded by criteria EC1 are added in the project DB in screening_paper table
* - assign_papers_valida operation inserted in operations table in the project DB
*/
private function saveAssignmentValidation_by1criteria()
{
$action = "save_assign_screen_validation";
$test_name = "Save the assignments of papers for screening validation by exclusion criteria EC1 with 100%";

$test_assignement = "Paper assignements";
$expected_assignement = "Assigned";

//initialise the Database
$this->TestInitialize();
//add 5 papers to test Project
addBibtextPapersToProject("relis_app/helpers/tests/testFiles/paper/5_bibPapers.bib");
//select screening phase as active phase
$this->http_client->response("screening", "select_screen_phase" . "/" . getScreeningPhaseId("Title"));
//screening papers by excluding 5 papers with first 3 excluded by EC1
assignPapers_and_performScreening([getAdminUserId()], "Title", $done = 5, $include = 0, $criteria = 1);

$postData = [
"number_of_users" => 1,
"screening_phase" => getScreeningPhaseId("Title"),
"papers_sources" => 1,
"paper_source_status" => "Excluded",
"user_1" => getAdminUserId(),
"validation_by_exclusion_criteria_toggle" => "on",
"choose_exclusion_criteria" => array('0' => 'EC1: Too short'),
"percentage" => 100,
];
$response = $this->http_client->response($this->controller, $action, $postData, "POST");

if ($response['status_code'] >= 400) {
$actual_assignement = "<span style='color:red'>" . $response['content'] . "</span>";
} else {
$actual_assignement = "Not assigned";

// Check if all the papers have been assigned
$excludedPaperIds = $this->ci->db->query("SELECT paper_id FROM relis_dev_correct_" . getProjectShortName() . ".screening_paper WHERE screening_decision='Excluded' AND exclusion_criteria = '1'")->result_array();
$excludedPaperIdList = array();
foreach ($excludedPaperIds as $paperId) {
$excludedPaperIdList[] = $paperId['paper_id'];
}
$excludedPaperIdList = implode(',', $excludedPaperIdList);
$nbrOfAssignment = $this->ci->db->query("SELECT COUNT(*) AS row_count FROM relis_dev_correct_" . getProjectShortName() . ".screening_paper WHERE paper_id IN (" . $excludedPaperIdList . ") AND assignment_role = 'validation'")->row_array()['row_count'];

//Check if the assign_papers_valida operation is inserted in operations table in the project DB
$operation = $this->ci->db->query("SELECT * FROM relis_dev_correct_" . getProjectShortName() . ".operations WHERE operation_type = 'assign_papers_valida' AND operation_state = 'Active' AND operation_active = 1")->row_array();

if (count($excludedPaperIds) == $nbrOfAssignment && !empty($operation)) {
$actual_assignement = "Assigned";
}
}

run_test($this->controller, $action, $test_name, $test_assignement, $expected_assignement, $actual_assignement);
}

/*
* Test 40
* Action : screen_paper_validation
* Description : handle the display of a paper for screening validation
* Expected HTTP Response Code : 200 OK (indicating a successful response from the server).
Expand All @@ -1807,7 +1870,7 @@ private function screenPaperValidation()
}

/*
* Test 40
* Test 41
* Action : screen_completion
* Description : calculate and display the completion progress of screening validation for users.
* Expected HTTP Response Code : 200 OK (indicating a successful response from the server).
Expand All @@ -1834,7 +1897,7 @@ private function screenValidationCompletion()
}

/*
* Test 41
* Test 42
* Action : screen_validation_result
* Description : Display screening validation statistics and results.
* Expected HTTP Response Code : 200 OK (indicating a successful response from the server).
Expand All @@ -1861,7 +1924,7 @@ private function screenValidationResult()
}

/*
* Test 42
* Test 43
* Action : remove_screening
* Description : Remove a screening entry from the database.
* Expected update in DB
Expand Down Expand Up @@ -1891,7 +1954,7 @@ private function removeScreening()
}

/*
* Test 43
* Test 44
* Action : remove_screening_validation
* Description : Handle the removal of screening validation entries from the database.
* Expected update in DB
Expand Down Expand Up @@ -1921,7 +1984,7 @@ private function removeScreeningValidation()
}

/*
* Test 44
* Test 45
* Action : screening
* Description : Display screening home page with 4 papers screened.
* Expected result: check if displayed data is correct
Expand Down Expand Up @@ -1952,7 +2015,7 @@ private function screening_4papersScreened()
}

/*
* Test 45
* Test 46
* Action : screening
* Description : Display screening home page with 0 paper screened.
* Expected result: check if displayed data is correct
Expand Down

0 comments on commit 5bc1c0d

Please sign in to comment.