/** * detect the conflicts by * 1) instantiating the instrument for each given commmentid * 2) and then taking the diff * * @param String $test_name The instrument been searched * @param Array $commentids An array of commentids used as haystack * @param Array $current_conflicts An array of current conflicts detected * * @return Array $detected_conflicts List of newly detected conflicts */ function detectConflicts($test_name, $commentids, $current_conflicts) { $detected_conflicts = array(); /** * Go through each commentid */ foreach ($commentids as $cid) { /** * Detect new conflicts */ $diff = ConflictDetector::detectConflictsForCommentIds($test_name, $cid['CommentID'], $cid['DDECommentID']); if ($diff != null) { foreach ($diff as $row) { $detected_conflicts[] = $row; } } } return $detected_conflicts; }
return; } /** * Get cmd-line arguments */ // get $action argument $action = $argv[1]; $ddeInstruments = $config->getSetting('DoubleDataEntryInstruments'); if ($action == 'all') { $allInstruments = Utility::getAllInstruments(); } else { $allInstruments = array($action => $action); } // clear the unresolved conflicts for all the instruments foreach ($allInstruments as $instrument => $Full_name) { $clear_conflicts = $db->pselect("SELECT CommentID, Test_name,\n CONCAT('DDE_', CommentID)\n AS DDECommentID\n FROM flag\n JOIN session s ON (s.ID=flag.SessionID)\n JOIN candidate c ON (c.CandID=s.CandID)\n WHERE Test_name=:testname AND CommentID\n NOT LIKE 'DDE%' AND s.Active='Y'\n AND c.Active='Y'", array('testname' => $instrument)); foreach ($clear_conflicts as $conflict) { ConflictDetector::clearConflictsForInstance($conflict['CommentID']); } } foreach ($ddeInstruments as $test) { $instruments = $db->pselect("SELECT CommentID, Test_name, CONCAT('DDE_',\n CommentID) AS DDECommentID\n FROM flag sde\n JOIN session s ON (s.ID=sde.SessionID)\n JOIN candidate c ON (c.CandID=s.CandID)\n WHERE sde.Test_name=:testname AND sde.CommentID\n NOT LIKE 'DDE%' AND sde.Data_entry='Complete'\n AND s.Active='Y' AND c.Active='Y'\n AND EXISTS (SELECT 'x' FROM flag dde WHERE\n dde.CommentID=CONCAT('DDE_',sde.CommentID)\n AND Data_entry='Complete')", array('testname' => $test)); foreach ($instruments as $instrument) { // If the instrument requires double data entry, check that DDE is also done if (in_array($instrument['Test_name'], $ddeInstruments)) { print "Recreating conflicts for " . $instrument['Test_name'] . ':' . $instrument['CommentID'] . "\n"; $diff = ConflictDetector::detectConflictsForCommentIds($instrument['Test_name'], $instrument['CommentID'], $instrument['DDECommentID']); ConflictDetector::recordUnresolvedConflicts($diff); } } }