GetProjectInfo
Description
Get project-info from a project
Signature
SurveySchema GetProjectInfo(string key,string projectId)
Parameters
Name | Data Type | Description |
---|---|---|
key |
string required |
The authentication key |
projectId |
string required |
ID of the project |
Example
//***************************************************
//
// Retrieve, change and update ProjectInfo
//
//***************************************************
// Create instance of the webservice
var SurveyDesign = new SurveyDesignSoapClient();
// Add a normal project (false = not a panel)
// projectID will be set to the new projectnumber
string projectID = SurveyDesign.AddProject(key,false);
// Get the project information (only projectnumber, build and
// default language is set
SurveySchema def = SurveyDesign.GetProjectInfo(key,projectID);
// Get ProjectInfo
ProjectInfo projectInfo = (ProjectInfo)def.Root.Nodes.GetValue(0);
// Check that we got it
if (projectInfo==null)
throwError();
// Change ProjectInfo
projectInfo.Description = "The first project made by use of the API";
// Suppose that default language is English (9), make a title
LanguageString newTitle = SurveyDesignUtil.NewLanguageString("My new Title",9);
// Add the title to projectInfo
ArrayList titles = new ArrayList((Array)projectInfo.Titles);
titles.Add(newTitle);
projectInfo.Titles = (LanguageString[])titles.ToArray(typeof(LanguageString));
// Set name of the project
projectInfo.Name = "API-made project";
// Update
SurveyDesign.Update(key,projectID,def);
//***************************************************
//
// FullDeployment
//
//***************************************************
// Example of how to automatically deploy a project based
// on a survey XML of an old format without WI-deployment
// information. (Note that in XMLs from ConfirmIt8.1 WI-deployment
// information is already part of the XML and the following scheme
// is only necessary if WI-deployment information is to be changed.
// Make a survey import from a file.
SurveyDesign SurveyDesign = new SurveyDesign();
XmlDocument xml = new XmlDocument();
xml.Load(filename);
string newProjectId = SurveyDesign.ImportSurvey(key,xml.InnerXml);
// Retrieve the project information
SurveySchema schema = SurveyDesign.GetProjectInfo(key,newProjectId);
ProjectInfo pi = (ProjectInfo)schema.Root.Nodes.GetValue(0);
// Make the first of the legal languages the default language
// Note that setting the default language is necessary to be able to
// use URLs to the survey without language specified. Setting the
// default language also prevents confirmit from using default WI-properties
// if the survey is compiled through the ConfirmIt userinterface later.
pi.DefaultLanguage = pi.Languages[0];
// Setting a few standard properties
pi.ProgressBar = true;
pi.AllowModify = false;
pi.AllowModifyComplete = false;
// Putting some values into the help and endlink fields
ArrayList urls = new ArrayList();
ArrayList texts = new ArrayList();
foreach (int language in pi.Languages)
{
LanguageString text = new LanguageString();
text.Language = language;
text.Value = "Please click here...";
texts.Add(text);
LanguageString url = new LanguageString();
url.Language = language;
url.Value = "http://www.yahoo.com";
urls.Add(url);
}
pi.EndLinkTexts = (LanguageString[])texts.ToArray(typeof(LanguageString));
pi.HelpLinkTexts = pi.EndLinkTexts;
pi.EndLinkUrls = (LanguageString[])urls.ToArray(typeof(LanguageString));
pi.HelpLinkUrls = pi.EndLinkUrls;
// Update projectInfo
SurveyDesign.Update(key,newProjectId,schema);
// Generate database and generate Web Interview
// Note that a alias for SurveyDeployer namespace was used to prevent ambigous
// names. Normally this would have been prevented by splitting the deployer
// part into a separate class
dep.SurveyDeployer deployer = new dep.SurveyDeployer();
deployer.DeployProject(key,newProjectId,dep.DatabaseType.Production);