Skip to content

How to Code an Instrument

Stella Lee edited this page Aug 25, 2016 · 26 revisions

As an example: follow along with NDB_BVL_Instrument_TEMPLATE.class.inc or NDB_BVL_Instrument_mri_parameter_form.class.inc from docs/instruments/ directory.

// Basic Instrument structure
class NDB_BVL_Instrument_$TABLE_NAME$ extends NDB_BVL_Instrument
{
    // Content goes here

    function setup($commentID, $page)
    {
        // Update the testName and tableName
    }		
} 

Copy and rename the file into your project/instruments/ directory, and ensure it is apache-readable. Edit the contents of the file to replace all template placeholders such "TEST_NAME", "", "" and "". Note that TEST_NAME within the file must match the TEST_NAME in the file name.

An example of an uploader instrument (.linst file) can also be found in the docs/instruments directory. For a single-page instrument, include all questions in main() and delete functions _page[1-9]{}. If the instrument has multiple pages, add QuickForm elements inside functions _page[1-9]. Wrappers are included in NDB_BVL_Instrument.class.inc e.g. addTextElement(),addYesNoElement(), addTextAreaElement(). See http://pear.php.net/ for Quickform documentation. Many wrappers also use XinRegisterRule. Element names must be lowercase and fewer than 64 characters (e.g. q07_mother_maiden_name). Never use hyphens - confused with MySQL minus sign. Element names "_status" are reserved for select boxes accompanying text fields and “*_group” are reserved for element groups. Use addDateElement wrapper for dates. Modify dateTimeFields array to include all date elements for proper conversion to database date/timestamp format. For multiple-select elements, use _selectMultipleElements array To ensure instrument completeness for all pages, modify _requiredElements() array to include 'Examiner' field and first question of each page, e.g. $this->_requiredElements=array('Examiner', 'q1', 'q19', 'q37', 'q55')). These array items must be entered to mark instrument as 'Complete' It may be desirable to exclude certain instrument columns from the Conflict Resolver module, such as Comment fields or fields not accessible by the front-end. These fields should be added to the instrument class array _doubleDataEntryDiffIgnoreColumns within the instrument php file. By default, the base class already excludes the following fields: CommentID, UserID, Testdate, Window_Difference, Candidate_Age, Data_entry_completion_status Any date elements used should be added to the dateTimeFields arrayso that they will be converted between HTML_Quickform and MySQL formats. Any multiple select elements should be added to the _selectMultipleElements array so they are transferred between the database and the QuickForm smoothly.

Clone this wiki locally