public function testLogic($logic) { logIt('testLogic: ' . $logic); if (LogicTester::isValid($logic)) { // Append current event details if (REDCap::isLongitudinal() && $this->redcap_event_name) { $logic = LogicTester::logicPrependEventName($logic, $this->redcap_event_name); } // Test logic logIt('Logic:' . $logic, 'DEBUG'); if (LogicTester::evaluateLogicSingleRecord($logic, $this->record)) { $result = RCView::img(array('class' => 'imgfix', 'src' => 'accept.png')) . " True"; } else { $result = RCView::img(array('class' => 'imgfix', 'src' => 'cross.png')) . " False"; } } else { $result = RCView::img(array('class' => 'imgfix', 'src' => 'error.png')) . " Invalid Syntax"; } return $result; }
Stanford University **/ global $end_survey_redirect_next_survey, $end_survey_redirect_url; //hook_log($auto_continue_logic, "DEBUG", "Starting AutoContinueLogic!"); // Check if custom logic is applied to this instrument if (isset($auto_continue_logic[$instrument])) { //hook_log("Applying auto-continue-logic to $instrument","DEBUG"); // Get the logic and evaluate it $raw_logic = $auto_continue_logic[$instrument]; $isValid = LogicTester::isValid($raw_logic); if (!$isValid) { print "<div class='red'><h3><center>Supplied survey auto-continue logic is invalid:<br>{$raw_logic}</center></h3></div>"; hook_log("AutoContinue Logic is INVALID for {$project_id} / {$instrument}: {$raw_logic}", "ERROR"); } $logic_result = LogicTester::evaluateLogicSingleRecord($raw_logic, $record); if ($logic_result == false) { // This instrument should not be taken! hook_log("AutoContinue Logic is FALSE - skipping {$instrument}", "DEBUG"); // If autocontinue is enabled - then redirect to next instrument if ($end_survey_redirect_next_survey) { // Try to get the next survey url $next_survey_url = Survey::getAutoContinueSurveyUrl($record, $instrument, $event_id); //print "Redirecting you to $next_survey_url"; hook_log("Redirecting {$record} from {$instrument} to {$next_survey_url}", "DEBUG"); redirect($next_survey_url); } else { hook_log("AutoContinue Logic is FALSE for {$record} on {$instrument} but auto-continue is not enabled for this survey", "DEBUG"); // If there is a normal end-of-survey url - go there if ($end_survey_redirect_url != "") { redirect($end_survey_redirect_url);