GetQuestionnaire
Description
Get Questionnaire (Routing, PredefinedLists and Quotas). All information about a survey is retrieved. If not all that information is needed, please use a different function that is suited to retrieve a subset of a survey schema.
Signature
SurveySchema GetQuestionnaire(string key,string projectId)
Parameters
Name | Data Type | Description |
---|---|---|
key |
string required |
The authentication key |
projectId |
string required |
ID of the project |
Example
// Create instance of the webservice
var authoring = new AuthoringSoapClient();
SurveySchema def = authoring.GetQuestionnaire(key,projectID,true);
// Get the questionnaire object
Questionnaire questionnaire = (Questionnaire)def.Root.Nodes.GetValue(0);
// Perform some changes
// Set new description of the project
((ProjectInfo)questionnaire.ProjectInfo).Description = "my new description";
// Change name of second quota if exists
if (questionnaire.Quotas.Length >=2)
((Quota)questionnaire.Quotas.GetValue(1)).Name = "new quota name";
// Change the precode of the first answer of the third predefined list if exists
// Check that the third predefined list exists
if (questionnaire.PredefinedLists.Length >=3)
// Check that the third predefined list has at least one answer
if (((PredefinedList)questionnaire.PredefinedLists.GetValue(2)).Answers.Length > 1)
// Check that the first answer is not a reference to a predefined list
if (((PredefinedList)questionnaire.PredefinedLists.GetValue(2)).Answers.GetValue(0).GetType() == typeof(Answer))
// Make the change
((Answer)((PredefinedList)questionnaire.PredefinedLists.GetValue(2)).Answers.GetValue(0)).Precode = "newPrecode";
// Add a new folder to Routing
// Create Folder
Folder folder = AuthoringUtil.NewFolder("new Folder");
// Place folder after 3rd element in the routing
ArrayList routing = new ArrayList((Array)questionnaire.Routing);
routing.Insert(3,folder);
questionnaire.Routing = (QuestionnaireNode[])routing.ToArray(typeof(QuestionnaireNode));
// Update
authoring.Update(key,projectID,def);