示例#1
0
function redcap_add_edit_records_page($project_id, $instrument, $event_id)
{
    // Example use of hook_log to track time to execute a hook:
    $hook_start_time = microtime(true);
    $hook_event = __FUNCTION__;
    foreach (get_hook_include_files($hook_event, $project_id) as $script) {
        include $script;
    }
    hook_log(" - {$hook_event} took " . hook_exec_time($hook_start_time), 'DEBUG');
}
if (!isset($hook_functions)) {
    $file = HOOK_PATH_ROOT . 'resources/init_hook_functions.php';
    if (file_exists($file)) {
        include_once $file;
        // Verify it has been loaded
        if (!isset($hook_functions)) {
            hook_log("ERROR: Unable to load required init_hook_functions.");
            return;
        }
    } else {
        hook_log("ERROR: In Hooks - unable to include required file {$file} while in " . __FILE__);
    }
}
// See if the term defined in this hook is used on this page
if (!isset($hook_functions[$term])) {
    hook_log("Skipping {$term} on {$instrument} of {$project_id} - not used.", "DEBUG");
    return;
}
//////////////////////////////
# Step 1 - Create array of fields to inject
$startup_vars = array();
foreach ($hook_functions[$term] as $field => $details) {
    $startup_vars[] = $field;
}
?>

<script type='text/javascript'>
$(document).ready(function() {
	var usernameFields = <?php 
print json_encode($startup_vars);
?>
示例#3
0
            // Copy the default parameters
            $js_params = $imageMapLibrary[$params];
            // Add the field name so we can find it in javascript on the client
            $js_params['field'] = $field;
            // Load the image
            $image_file = dirname(__FILE__) . DS . $js_params['image'];
            $b64 = base64_encode(file_get_contents($image_file));
            //error_log ("b64: $b64");
            $src = "data:image/png;base64,{$b64}";
            $js_params['src'] = $src;
            // Load the area map
            $areas = file_get_contents(dirname(__FILE__) . DS . $js_params['map']);
            $js_params['areas'] = $areas;
            // Add the question type (text or checkbox)
            $js_params['type'] = $elements[$elements_index]['rr_type'];
            $startup_vars[] = $js_params;
        }
    } else {
        hook_log("ERROR: Parameters for {$term} are not configured in the imagemap hook.", "ERROR");
        //return;
    }
}
//error_log("Startup Vars: ". print_r($startup_vars,true));
# Step 3 - inject the custom javascript and start the post-rendering
$script_path = dirname(__FILE__) . DS . "imagemap.js";
$start_function = "imageMapStart()";
echo "<script type='text/javascript'>";
echo "var imageMapLibrary = " . json_encode($startup_vars) . ";";
readfile($script_path);
echo "\$(document).ready(function() {" . $start_function . "});";
echo "</script>";
        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);
            } else {
                $custom_text = "<div class='yellow'><h3><center>This survey form does not apply for this record.</center></h3></div>";
                hook_log("AutoContinue Logic is false but no other options so display 'does not apply' message", "ERROR");
                exitSurvey($custom_text . $full_acknowledgement_text, false);
            }
        }
        //return false;
    } else {
        // administer the instrument
        hook_log("AutoContinue Logic is TRUE for {$record} from {$instrument} - starting survey", "DEBUG");
    }
}
        include $script;
    }
}
// redcap_survey_page (REDCap >= 5.11.0)
function redcap_survey_page($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
    $hook_event = __FUNCTION__;
    foreach (get_hook_include_files($hook_event, $project_id) as $script) {
        include $script;
    }
}
// redcap_survey_page_top (REDCap >= 6.8.0)
function redcap_survey_page_top($project_id, $record, $instrument, $event_id, $group_id, $survey_hash, $response_id)
{
    $hook_event = __FUNCTION__;
    foreach (get_hook_include_files($hook_event, $project_id) as $script) {
        include $script;
    }
}
// redcap_user_rights (REDCap >= 5.11.0)
function redcap_user_rights($project_id)
{
    $hook_event = __FUNCTION__;
    foreach (get_hook_include_files($hook_event, $project_id) as $script) {
        include $script;
    }
}
// INSERT ADDITONAL HOOKS HERE AS THEY ARE DEVELOPED HERE
/////////////////////////////////////
hook_log("------------ redcap_hooks loaded ------------", "DEBUG");
        hook_log("ERROR: In Hooks - unable to include required file {$file} while in " . __FILE__);
    }
}
// See if the term defined in this hook is used on this page
if (!isset($hook_functions[$term])) {
    hook_log("Skipping {$term} on {$instrument} of {$project_id} - not used.", "DEBUG");
    return;
}
//////////////////////////////
$startup_vars = array();
foreach ($hook_functions[$term] as $field => $details) {
    $params = $details['params'];
    try {
        $params = json_decode($params);
    } catch (Exception $e) {
        hook_log('Caught exception decoding params in $term for project $project_id: ' . $e->getMessage(), "ERROR");
    }
    $i = new stdClass();
    $i->fieldName = $field;
    $i->params = json_decode($details['params']);
    $startup_vars[] = $i;
}
// A progress field turned on/off by javascript
print RCView::div(array('id' => 'directory_lookup_progress', 'style' => 'text-align:right;display:none;color:#777;font-size:12px;'), RCView::img(array('src' => 'progress_circle.gif', 'class' => 'imgfix2')) . RCView::span(array('style' => 'color:#800000;font-size:12px;padding-right:5px;font-style:italic'), "Performing Lookup "));
// A sample linked field placed next to all destination fields
print RCView::span(array('id' => 'directory_lookup_link', 'title' => 'This field can be auto-populated by SUNET ID lookup', 'style' => 'display:none;'), RCView::img(array('src' => 'link.png', 'class' => 'imgfix2')));
// A sample linked field placed next to all source fields
print RCView::span(array('id' => 'directory_lookup_source', 'title' => 'This SUNET field queries the Stanford Who database to find additional user information.', 'style' => 'display:none;'), RCView::img(array('src' => 'find.png', 'class' => 'imgfix2')));
// Build some unique keys for additional security...
$key1 = $_SERVER['REMOTE_ADDR'];
$key1 = encrypt(htmlspecialchars($key1));
示例#7
0
\t\ttable.med_summary td {font-weight:normal;}
\t\ttable.med_summart tr:nth-child(2n) { background-color: #eee; }
\t</style>
SCRIPT;
    print $script;
    // INCULDE DIRECTORY LOOKUP
    $file = HOOK_PATH_ROOT . "resources/directory_lookup.php";
    if (file_exists($file)) {
        include_once $file;
    } else {
        hook_log("Unable to include {$file} for project {$project_id} while in " . __FILE__);
    }
    // INCULDE IMAGEMAP
    $file = HOOK_PATH_ROOT . "resources/imagemap/imagemap.php";
    if (file_exists($file)) {
        include_once $file;
    } else {
        hook_log("Unable to include {$file} for project {$project_id} while in " . __FILE__);
    }
}
if ($hook_event == 'redcap_survey_page_top') {
    // INCULDE AUTO-CONTINUE-LOGIC
    // This is an array of forms and logic - add as many as necessary...
    $auto_continue_logic = array('example_of_input_matrix' => "[skip_input_matrix] <> '1'");
    $file = HOOK_PATH_ROOT . "resources/auto_continue_logic.php";
    if (file_exists($file)) {
        include_once $file;
    } else {
        hook_log("Unable to include {$file} for project {$project_id} while in " . __FILE__);
    }
}