Rest - Work - Session Groups - Session Questionnaires

From Views API Documentation
Revision as of 08:12, 6 August 2012 by Wikiadmin (talk | contribs) (Created page with "==Purpose== Used for submitting answer sets to questionnaires against sessions and for retrieving the details of answered questionnaires that have been submitted against a pa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Purpose

Used for submitting answer sets to questionnaires against sessions and for retrieving the details of answered questionnaires that have been submitted against a participant. This is only really a filtered version of the Questionnaires - Answers API

Base URL

http://dev.views.coop/api/restful/work/sessiongroups/sessions/<id>/questionnaires

  • id - This is the session id

Schema

For details of the schemas, please refer to Rest - Evidence - Questionnaires - Answers


Fetching a list of answer sets

The default call will return a list of questionnaires (answer sets) that have been recorded against the participant

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

This will return data similar to the following:

<answersets count="3">
    <answerset id="13" questionnaireid="3">
        <EntityType>Person</EntityType>
        <EntityID>1</EntityID>
        <TargetType>Session</TargetType>
        <TargetID>68</TargetID>
        <Date>2012-07-31T10:00:00</Date>
        <QuestionnaireID>14</QuestionnaireID>
        <AnswerSetID>1</AnswerSetID>
        <Questionnaire>Session Attendance Questionnaire</Questionnaire>
    </answerset>
    <answerset id="14" questionnaireid="4">
        <EntityType>Session</EntityType>
        <EntityID>68</EntityID>
        <TargetType>Session</TargetType>
        <TargetID>68</TargetID>
        <Date>2012-05-04T10:11:00</Date>
        <QuestionnaireID>14</QuestionnaireID>
        <AnswerSetID>4</AnswerSetID>
        <Questionnaire>Questionnaire about the session</Questionnaire>
    </answerset>
    ...
</answersets>

If you are only interested in a particular questionnaire, you should us the following:

curl --url <Base URL>/<questionnairId> -u<username>:<password> -H Content-Type:text/xml

This will return data similar to the following:

<answersets count="1">
    <answerset id="13" questionnaireid="3">
        <EntityType>Person</EntityType>
        <EntityID>1</EntityID>
        <TargetType>Session</TargetType>
        <TargetID>68</TargetID>
        <Date>2012-07-31T10:00:00</Date>
        <QuestionnaireID>14</QuestionnaireID>
        <AnswerSetID>1</AnswerSetID>
        <Questionnaire>Session Attendance Questionnaire</Questionnaire>
    </answerset>
</answersets>

The results are order by the most recent first. This means to get the latest version of a questionnaire, you would only need to fetch the first result.


Fetching the answers of a given questionnaire

curl --url <Base URL>/<questionnairId>/<setId> -u<username>:<password> -H Content-Type:text/xml
  • questionnaireId - This is the id of the questionnaire
  • setId - This is the id of the Answers Set you want to retrieve

It's will return something along the lines of

<answerset questionaireid="3" id="13">
    <EntityType>Person</EntityType>
    <EntityID>1</EntityID>
    <TargetType>Session</TargetType>
    <TargetID>68</TargetID>
    <Date>2012-07-31T10:00:00</Date>
    <answers count="5">
        <answer id="23">
            <QuestionID>25</QuestionID>
            <Answer>On time</Answer>
        </answer>
        <answer id="24">
            <QuestionID>25</QuestionID>
            <Answer>Tidy</Answer>
        </answer>
        <answer id="25">
            <QuestionID>25</QuestionID>
            <Answer>Yes</Answer>
        </answer>
        ...
    </answers>
</answerset>


Fetching a single answer from a questionnaire

curl --url <Base URL>/<questionnairId>/<setId>/<questionId> -u<username>:<password> -H Content-Type:text/xml
  • questionnaireId - This is the id of the questionnaire
  • setId - This is the id of the Answers Set you want to retrieve
  • questionId - This is the id of the question you want the answer for
<answer id="78">
    <QuestionnaireID>3</QuestionnaireID>
    <AnswerSetID>13</AnswerSetID>
    <QuestionID>25</QuestionID>
    <Answer>Yes</Answer>
</answer>


Creating a new Answer Set

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

Note This is still currently under development

Updating an existing Answer Set

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

When updating the answers in an answer set, you should use the same structure as when creating a new answer set. However, if you specify the entities EntityType>, EntityID>, TargetType>, TargetID> they will be ignored.