Rest - Evidence - Questionnaires - Questions: Difference between revisions

From Views API Documentation
Jump to navigation Jump to search
(Created page with "==Purpose== This API is used for creating, editing and deleting questionnaires from the Views system. It is '''not''' a way to submit questionnaire answer data. That is done ...")
 
Line 109: Line 109:




==Creating / Updating a Multiple Questn==
==Creating / Updating Multiple Question==
  curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X [POST|PUT] -d '<xml>'
  curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X [POST|PUT] -d '<xml>'
* id - The id of a Questionnaire
* id - The id of a Questionnaire

Revision as of 13:10, 20 July 2012

Purpose

This API is used for creating, editing and deleting questionnaires from the Views system. It is not a way to submit questionnaire answer data. That is done via the other various sections.

Base URL

http://app.views.coop/api/restful/evidence/questionnaires/<id>/questions

  • id - The is the id of the questionnaire.

Schema

http://app.views.coop/api/restful/evidence/questionnaires/questions/schema(.xml|.json|.xsd)


Listing available Questions

curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml 
  • query - This is a text string to use to search for in the venues records

Questions are not searchable, and by default only the enabled questions are returned. If you want to get a complete list of questions, then you should use the following:

curl --url <Base URL>?allquestions=1 -u<username>:<password> -H Content-Type:text/xml 
<questions count="21">
    <question id="12">
        <QuestionID>12</QuestionID>
        <QuestionnaireID>3</QuestionnaireID>
        <Question>What?</Question>
        <valueListID>83</valueListID>
        <inputType>radio</inputType>
        <validation></validation>
        <category>What</category>
        <enabled>1</enabled>
        <order>0</order>
        <Created>2011-03-04 01:09:55</Created>
        <CreatedBy>ant</CreatedBy>
        <Updated>2011-03-04 01:09:55</Updated>
        <UpdatedBy>ant</UpdatedBy>
    </question>
...
    <question id="13">
        <QuestionID>13</QuestionID>
        <QuestionnaireID>3</QuestionnaireID>
        <Question>Date</Question>
        <valueListID>0</valueListID>
        <inputType>date</inputType>
        <validation>valid_date</validation>
        <category>What</category>
        <enabled>1</enabled>
        <order>0</order>
        <Created>2011-03-04 01:10:09</Created>
        <CreatedBy>ant</CreatedBy>
        <Updated>2011-03-04 01:10:09</Updated>
        <UpdatedBy>ant</UpdatedBy>
    </question>
</questions>


Fetching a Question's details

curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml
  • id - The id of the Question

This will return a single question in the format of:

<question id="12">
    <QuestionID>12</QuestionID>
    <QuestionnaireID>3</QuestionnaireID>
    <Question>What is the question</Question>
    <valueListID>83</valueListID>
    <inputType>radio</inputType>
    <validation></validation>
    <category>What</category>
    <enabled>1</enabled>
    <Created>2011-03-04 01:09:55</Created>
    <CreatedBy>ant</CreatedBy>
    <Updated>2011-03-04 01:09:55</Updated>
    <UpdatedBy>ant</UpdatedBy>
</question>


Creating a Single Question

curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X POST -d '<xml>'

<xml> should be in the following format:

<question>
    <Question>The question test...</Question>
    <inputType>text</inputType>
    <valueListID>0</valueListID>
    <validation/>
    <category>General</category>
</question>
  • Question - This should contain the wording for the question
  • inputTypes - This can be ne of the following:
    1. text
    2. textare
    3. date
    4. time
    5. number
    6. select
    7. selectother
    8. checkselect
    9. radio
  • valueListID - refers to a value list. This is only used with multiple choice inputTypes
  • validation - Documentation to follow, in the mean time contact us for delays on this
  • category - This is the section title that the question should be grouped in


Updating a Single Question

curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X PUT -d '<xml>'
  • id - The id of the questions

The xml for updating a single question is exactly the same as the create xml.


Creating / Updating Multiple Question

curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X [POST|PUT] -d '<xml>'
  • id - The id of a Questionnaire

This allows you to upload a complete questionnaire in one go

<questions>

    <question id="12">
        <Question>Update question 12</Question>
        <valueListID>83</valueListID>
        <inputType>radio</inputType>
        <validation></validation>
        <category>What</category>
    </question>
...
   <question>
        <Question>Add a new question</Question>
        <inputType>text</inputType>
        <valueListID>0</valueListID>
        <validation/>
        <category>General</category>
    </question>
</questions>

By specifying the id attribute for the question, it will update the question rather than create a new one.

It is recommended that you stip to using the PUT method for this, as in the future we make make POST and method to replace all the questions on a questionnaire