From wiki.ginstr.com
Jump to: navigation, search

GnQuestionnaire

Widget XML tag
<com.ginstr.widgets.GnQuestionnaire>
Description
GnQuestionnaire is used to generate a bespoke questionnaire from a configuration table populated in ginstr web.
Each row in the configuration table represents a separate question in the questionnaire, with an array of options available for customisation.
Responses received from each question are saved to ginstr web in individual rows in a separate results table.

XML Attributes Description

Attribute Description
gn:configurationSetTableName Defines the name of the configuration table from where the questionnaire configurations will be read

Can be

  • hardcoded
gn:configurationSetName Defines the name of the specific questionnaire which will be displayed in GnQuestionnaire

Can be

  • hardcoded
gn:resultsTableName Defines the name of the results table where the questionnaire results will be stored

Can be

  • hardcoded
gn:loadExternalData Used to link defined column in reports table with external widget/variable.

When action gn:act_saveQuestionaire is executed, all linked columns will be filled with values from defined external widgets

Can be

  • hardcoded, i.e. columnName,sourceId pairs separated by ;
gn:pageSize Enables paging mechanism and defines number of elements per page.

Can be

  • hardcoded

Example

<com.ginstr.widgets.GnQuestionnaire
  android:id="@+id/questionnaire"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:fillViewport="true"
  gn:configurationSetTableName="questionnaireConfiguration"
  gn:resultsTableName="questionnaireResults"
  gn:loadExternalData="
    questionnaireResults_employeeNumber,@variable/employee_employeeNumberPointer;
    questionnaireResults_employeeType,@variable/employee_employeeType;
    questionnaireResults_SSOemail,@variable/employee_employeeEmailPointer;
    questionnaireResults_building,@variable/building_namePointer;
    questionnaireResults_timestamp,@variable/currentTime;
    questionnaireResults_floor,@variable/floor_floorPointer;
    questionnaireResults_division,@variable/currentDivisionPointer;
    questionnaireResults_deviceSerialNo,@+id/deviceSerialNo;
    questionnaireResults_gpsPosition,@+id/gpsPosition;
    questionnaireResults_statusValueApproved,@variable/false" />	

Questionnaires table

This table is used to store the unique names of individual questionnaires.
Table Definition:
<table id="questionaires" name="questionaireConfiguration_questionaires">
 <columnText id="questionaireConfiguration_name" name="questionaireConfiguration_name" />
</table>
Note:
Column name suffix is hard coded and must not be changed (i.e. for questionaireConfiguration_name, suffix _name is static)

Configuration table

Table Definition:

<table id="questionaireConfiguration" name="questionaireConfiguration_configuration">
 <columnPointer id="questionaireConfiguration_configurationSetName" name="questionaireConfiguration_configurationSetName">
     <table>questionaires</table>
     <column>questionaireConfiguration_name</column>
 </columnPointer>     
 <columnNumber id="questionaireConfiguration_sequenceNumber" name="questionaireConfiguration_sequenceNumber" />
 <columnText id="questionaireConfiguration_language" name="questionaireConfiguration_language">
    <valuesList>
        <value>en</value>
        <value>de</value>
        <value>es</value>
        <value>fr</value>
        <value>ae</value>
    </valuesList>
 </columnText>
 <columnText id="questionaireConfiguration_labelValue" name="questionaireConfiguration_labelValue"/>
 <columnText id="questionaireConfiguration_hint" name="questionaireConfiguration_hint"/>
 <columnStatus id="questionaireConfiguration_required" name="questionaireConfiguration_required"/>
 <columnText id="questionaireConfiguration_requiredErrorMessage" name="questionaireConfiguration_requiredErrorMessage"/> 
 <columnText id="questionaireConfiguration_widget" name="questionaireConfiguration_widget">
    <valuesList>
        <value>group</value>
        <value>text single line</value>
        <value>text multi line</value>
        <value>number integer</value>
        <value>number decimal</value>
        <value>status</value>
        <value>date</value>
        <value>radio group</value>
        <value>picture</value>
        <value>drop down list text</value>
        <value>drop down list numeric</value>
        <value>signature</value>
    </valuesList>
 </columnText>
 <columnText id="questionaireConfiguration_valueList" name="questionaireConfiguration_valueList">
   <multiline>true</multiline>
 </columnText>
 <columnText id="questionaireConfiguration_comments" name="questionaireConfiguration_comments"/> 
</table>
Note:
Column name suffix is hard coded and must not be changed (i.e. for questionaireConfiguration_sequenceNumber, suffix _sequenceNumber is static)
questionaireConfiguration_valueList
contains values for radio group buttons and drop down lists - items in list must be separated with new line character (Ctrl + Enter)

Results table

Table Definition:

<table id="questionaireResults" name="questionaireResults_resultsTable" replicateFromServer="table">
 <columnPointer id="questionaireResults_questionaireName" name="questionaireResults_questionaireName">
     <table>questionaires</table>
     <column>questionaireConfiguration_name</column>
 </columnPointer>
 <columnPointer id="questionaireResults_labelValue" name="questionaireResults_labelValue">
     <table>questionaireConfiguration</table>
     <column>questionaireConfiguration_labelValue</column>
 </columnPointer> 
 <columnText id="questionaireResults_textValue" name="questionaireResults_textValue"/>
 <columnNumber id="questionaireResults_numberValue" name="questionaireResults_numberValue"/>
 <columnDate id="questionaireResults_dateValue" name="questionaireResults_dateValue"/>
 <columnDateTime id="questionaireResults_dateTimeValue" name="questionaireResults_dateTimeValue"/>
 <columnStatus id="questionaireResults_statusValue" name="questionaireResults_statusValue"/>
 <columnPicture id="questionaireResults_pictureValue" name="questionaireResults_pictureValue"/>
</table>
Note:
Column name suffix is hard coded and must not be changed (i.e. for questionaireResults_textValue, suffix _textValue is static)

Supported internal widgets

Internal Widget Description
group Displays text entered in label value field above subsequent questions, allowing you to group several questions into different sections.

Text which is entered in the hint field is not displayed

text single line Displays single line text input box below text entered in label value field.

Input box does not allow line breaks.

Text which is entered in the hint field will be displayed in the input box until some text is entered by the user.

Stores result in questionaireResults_textValue

text multi line

Displays multiple line text input box below text entered in label value field.

Input box allows line breaks.

Text which is entered in the hint field will be displayed in the input box until some text is entered by the user.

Stores result in questionaireResults_textValue

number integer

Displays single line numerical input box below text entered in label value field.

Input box does not allow text entry and only integer numbers are allowed.

Text which is entered in the hint field will be displayed in the input box until some number is entered by the user.

Stores result in questionaireResults_numberValue

number decimal Displays single line numerical input box below text entered in label value field.

Input box does not allow text entry and integer and decimal numbers are allowed

Text which is entered in the hint field will be displayed in the input box until some number is entered by the user.

Stores result in questionaireResults_numberValue

status Displays a check-box next to text entered in label value field.

required status must be set to false.

Text which is entered in the hint field is not displayed.

Stores result in questionaireResults_statusValue

date Displays DatePicker date selection input below text entered in label value field.

required status must be set to false.

Text which is entered in the hint field is not displayed.

Stores result in questionaireResults_dateValue

radio group Displays a list of RadioButtons below text entered in label value field.

Requires list of values (one for each RadioButton required) defined in value list field - items in list must be separated with new line character (Ctrl + Enter).

Text which is entered in the hint field is not displayed.

Stores result in questionaireResults_textValue

picture Displays a take photo button below text entered in label value field, along with a counter starting at #0.

When the take photo button is pressed, the camera app is opened on the device to capture a photo. Once a photo is captured, the counter value increases to indicate how many photos have been captured.

Text which is entered in the hint field is not displayed.

Stores result in questionaireResults_pictureValue

drop down list text Displays a drop down input box below text entered in label value field.

Requires list of values defined in value list field - items in list must be separated with new line character (Ctrl + Enter).

Text which is entered in the hint field is displayed at the top of the drop down list (visible when drop down is collapsed).

Stores result in questionaireResults_textValue

drop down list numeric Displays a drop down input box below text entered in label value field.

Requires list of numeric values defined in value list field - items in list must be separated with new line character (Ctrl + Enter).

Text which is entered in the hint field is displayed at the top of the drop down list (visible when drop down is collapsed).

Stores result in questionaireResults_numberValue

signature Displays a button below text entered in label value field.

When the signature button is pressed, the signature dialog is opened. Once a signature is drawn and the save button is clicked, the signature dialog will be closed.

Text which is entered in the hint field is not displayed.

Stores result in questionaireResults_pictureValue

timestamp Displays single line text input box below text entered in label value field, with preloaded timestamp value
phone number Displays single line text input box below text entered in label value field.

Input box does not allow line breaks. Only valid input is phone number.

Text which is entered in the hint field will be displayed in the input box until some text is entered by the user.

Stores result in questionaireResults_phoneNumbersValue.

dropdown table Displays a drop down input box below text entered in label value field.

Requires table name and column name values defined in value list field - items in list must be separated with new line character (Ctrl + Enter) where first parameter is table and second is column. Column has to be of datatype text.

Text which is entered in the hint field is displayed at the top of the drop down list (visible when drop down is collapsed or nothing is selected).

Stores selected result at time of save of questionnaire into questionaireResults_textValue column

Customising internal widgets

All GnQuestionnaire internal widgets can be customised by placing one the of XML files below in the controls directory.

Note:
File names are hard coded. This means that only one customisation file exists for each internal widget type (i.e. questionnaireNumber.xml will customise all number widgets in questionnaire)

questionnaireDate.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnDatePicker
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:layout_marginTop="5dp"
	android:layout_marginBottom="5dp"
	gn:dataType="date"/>
</FrameLayout>

questionnaireDropDown.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnDropDown
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:layout_marginTop="5dp"
	android:layout_marginBottom="5dp"
	gn:s_sourceType="local"/>
</FrameLayout>

questionnaireLabel.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnTextView
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:background="#AAAAAA"
	android:textColor="#FFFFFF"
	android:layout_marginTop="5dp" 
	android:layout_marginBottom="5dp" />
</FrameLayout>

questionnaireNumberDecimal.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	gn:s_sourceType="input"
	gn:inputType="TYPE_NUMBER_FLAG_DECIMAL"
	gn:dataType="number"/>

questionnaireNumberInteger.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	gn:s_sourceType="input"
	gn:inputType="NUMBER"
	gn:dataType="number"/>

questionnairePicture.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
	<com.ginstr.widgets.GnMediaAction
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginRight="5dp"
		android:layout_alignParentRight="true"
		gn:maxMediaTaken="5"
		gn:maxFileSize="75"
		gn:hidePhotoText="true"
		gn:hideCounter="true"
		gn:s_actionType="photo" />
		
	<com.ginstr.widgets.GnMediaGallery
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		gn:numberOfColumns="3"
		gn:itemHorizontalSpacing="5"
		gn:itemVerticalSpacing="5"
		gn:itemSameSize="true" />
</FrameLayout>
com.ginstr.widgets.GnMediaGallery element is optional

questionnaireRadioButton.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnRadioButton
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" />
</FrameLayout>

questionnaireRadioGroup.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnRadioGroup 
	android:layout_width="match_parent" 
	android:layout_height="wrap_content" 
	gn:dataType="text"
	android:orientation="horizontal">

questionnaireStatus.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnCheckBox  
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:layout_alignParentRight="true"  
	android:layout_centerVertical="true"
	android:checked="false" />
</FrameLayout>

questionnaireTextMultiLine.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:background="#000000"
	android:textColor="#FFFFFF"
	android:textColorHint="#EEEEEE"
	gn:s_sourceType="input"
	android:layout_marginTop="5dp" 
	android:layout_marginBottom="5dp" />

questionnaireTextSingleLine.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:background="#FFFFFF"
	android:textColor="#0B457C"
	android:textColorHint="#BABABA"
	gn:s_sourceType="input"
	android:layout_marginTop="5dp" 
	android:layout_marginBottom="5dp"
	gn:imeOptions="actionDone" />

questionnaireSignature.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
	<com.ginstr.widgets.GnCaptureSignature
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:background="@drawable/buttonHalf.9"
		gn:setBackgroundPressed="@drawable/buttonHalfPressed.9"
		android:layout_marginLeft="10dp"
		android:layout_marginRight="10dp"
		android:layout_marginTop="15dp"
		android:textSize="20sp"
		android:textColor="#FFFFFF"
		android:text="@string/reporting_signatureEmployee" />
		
	<com.ginstr.widgets.GnMediaGallery
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		gn:numberOfColumns="1"
		gn:clearOnNewDataAdd="true"
		gn:itemHorizontalSpacing="5"
		gn:itemVerticalSpacing="5"
		gn:itemSameSize="true" />		
</FrameLayout>

questionnairePhoneNumber.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	gn:style="@style/editableInputStyle"
	gn:s_sourceType="input"
	gn:imeOptions="actionDone" />


questionnaireDropDownTable.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout>
<com.ginstr.widgets.GnDropDown
	android:layout_width="match_parent"
	android:layout_height="wrap_content" 
	gn:style="@style/dropdownStyle"
	gn:s_sourceType="database"/>
</FrameLayout>
com.ginstr.widgets.GnMediaGallery element is optional

questionnaireTimestamp.xml

<?xml version="1.0" encoding="utf-8"?>
<com.ginstr.widgets.GnEditText
	android:layout_width="match_parent" 
	android:layout_height="wrap_content"
	gn:s_sourceType="time" />

Customising pager

The pager layout can be customised by placing the XML file below in the controls directory.

Note:
File name is hard coded.

questionnaire_pager.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:orientation="horizontal"
	android:gravity="center">
	<Button 
		android:id="@+id/btnBack"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:background="#FFFFFF"
		android:text="Back"/>
		
	<TextView 
		android:id="@+id/txtStatus"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:background="#000000"
		android:textColor="#FFFFFF"
		android:text="0/0"
		android:layout_marginLeft="20dp"
		android:layout_marginRight="20dp"/>		
		
	<Button 
		android:id="@+id/btnNext"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:background="#FFFFFF"
		android:text="Next"/>			
</LinearLayout>

GnQuestionnaire Actions

Action Description
gn:act_saveQuestionnaire Action which executes questionnaire saving procedure
gn:act_loadQuestionnaire Action which dynamically generates questionnaire by @variable/questionaireConfigSetName