Click or drag to resize
Askia

ISurvey Interface

Represents a survey

Namespace:  AskiaCore
Assembly:  AskiaCore (in AskiaCore.dll) Version: 6.0.0-build000000000000000000000000000000000000000001
Syntax
public interface ISurvey : ISurveyInformation, 
	IRecordEntity

The ISurvey type exposes the following members.

Properties
  NameDescription
Public propertyCategories
Collection of categories for this survey
Public propertyControls
Collection of controls for this survey
Public propertyCreatedAt
DateTime the record was created at
(Inherited from IRecordEntity.)
Public propertyCreatedBy
Id of the user which created the record
(Inherited from IRecordEntity.)
Public propertyDefaultControls
Collection of default controls for this survey
Public propertyDefaultLanguageId
Id of the survey default Language
(Inherited from ISurveyInformation.)
Public propertyDefaultPageTemplateId
Returns the id of the survey default page template
(Inherited from ISurveyInformation.)
Public propertyDefaultPageTemplateProperties
Collection of default page template properties for this survey
Public propertyDeletedAt
DateTime at which the record was last deleted
(Inherited from IRecordEntity.)
Public propertyDeletedBy
Id of the user which last deleted the record
(Inherited from IRecordEntity.)
Public propertyDescription
Description of the survey
(Inherited from ISurveyInformation.)
Public propertyElements
Collection of elements for this survey
Public propertyId
Id of the record
(Inherited from IRecordEntity.)
Public propertyLanguages
Collection of languages for this survey
Public propertyLastError
Last error that occurred
(Inherited from IRecordEntity.)
Public propertyName
Name of the survey
(Inherited from ISurveyInformation.)
Public propertyPageTemplates
Collection of page templates for this survey
Public propertyPortalId
Id of the survey in AskiaPortal database
(Inherited from ISurveyInformation.)
Public propertyQuestions
Collection of questions for this survey
Public propertyResources
Collection of resources for this survey
Public propertyRoutings
Collection of routings for this survey
Public propertyScenarios
Collection of scenarios for this survey
Public propertyThemeProperties
Collection of theme properties for this survey
Public propertyUpdatedAt
DateTime at which the record was last updated
(Inherited from IRecordEntity.)
Public propertyUpdatedBy
Id of the user which last updated the record
(Inherited from IRecordEntity.)
Public propertyVersion
Gets the version of the engine that created the survey
Top
Methods
  NameDescription
Public methodApplyTheme
Applies the given theme
Public methodCheckAll
Checks all the survey
Public methodCheckElementsStructure
Checks the integrity of the elements structure
Public methodCheckQuestionsStructure
Checks the integrity of the questions structure
Public methodCheckResourceFileLocationAlreadyExist
Checks if the given resource file location already exist
Public methodCheckRoutings
Checks the routings
Public methodCompileScript(RoutingActionType, String)
Compiles an Askia script.
Public methodCompileScript(RoutingConditionType, String)
Compiles an Askia script.
Public methodCopyAsQuestionsTemplate
Copies the current survey as a questions Template
Public methodCopyAsSurveyTemplate
Copies the current survey as a survey Template
Public methodCreateConditionFromScript
Creates an assisted condition given a script.
Public methodCreateInterview
Creates an interview from this survey
Public methodCreateInterview(Int32)
Creates an interview from this survey
Public methodCreateScriptFromCondition
Creates a script given an assisted condition.
Public methodCreateSubSurveyForScreen
Creates a sub-survey for the variables in the page element.
Public methodDelete
Deletes the record in the database
(Inherited from IRecordEntity.)
Public methodExtractResources
Extract resources to their appropriate location ResourcesPath
Public methodFindResponse
Retrieve a response from within the questions of the survey given its id
Public methodFindResponses
Retrieve responses from within the questions of the survey given their ids
Public methodGetMessages
Returns a collection of the messages for the current language
Public methodIndentQuestions
Indent questions
Public methodInsertFromQuestionsTemplate
Insert questions from a given template to a specific destination
Public methodIsDeleted
Indicates if the record is flagged as deleted
(Inherited from IRecordEntity.)
Public methodIsLoaded
Checks if the record is successfully loaded from the database
(Inherited from IRecordEntity.)
Public methodLoadFromXML
Reads from memory in XML format
Public methodLoadFromXMLFile
Reads from file in XML format
Public methodLoadInterview
Loads a specific interview
Public methodMergeQuestionPages
Merge questions from the given id's range into the same page
Public methodMoveElement
Move element to a given destination
Public methodMoveQuestions
Move questions to a given destination
Public methodMoveRoutings
Move routings to a given destination
Public methodReadFromExchangeFormat(Byte)
Reads from file in exchange format (.qex)
Public methodReadFromExchangeFormat(String)
Reads from file in exchange format (.qex)
Public methodReadFromExchangeFormat(String, String)
Reads from file in exchange format (.qex)
Public methodReload
Reloads the record
(Inherited from IRecordEntity.)
Public methodResetResourcePath
Empties the Live and test path so it works in a published survey
Public methodRestore
Restores the deleted record in the database
(Inherited from IRecordEntity.)
Public methodRunScript
Runs an Askia script
Public methodSave
Saves the record in the database
(Inherited from IRecordEntity.)
Public methodSaveAll
Saves all the survey recursively
Public methodSaveRoutings
Saves a batch of routings in one go, all or nothing.
Public methodSaveToExchangeFormat(Byte)
Saves to memory in exchange format
Public methodSaveToExchangeFormat(String)
Saves to file in exchange format (.qex)
Public methodSaveToExchangeFormat(String, String)
Saves to file in exchange format (.qex)
Public methodSaveToXML
Saves to memory in XML format
Public methodSaveToXMLFile
Saves to file in XML format
Public methodSetDefaultLanguage
Set the default language ID for the whole survey
Public methodSetDefaultPageTemplate
Set the default pages template id for the whole survey
Public methodSetName
Sets the name of the survey
(Inherited from ISurveyInformation.)
Public methodSplitQuestionPages
Split merged questions from the given id's range
Public methodTestCode
Internal debug function
Public methodTransformIntoQuestionsTemplate
Promotes the current survey to a questions Template
Public methodTransformIntoSurveyTemplate
Promotes the current survey to a survey Template
Public methodUnindentQuestions
Unindent questions
Public methodUpgrade
Upgrades survey to latest version
Top
Remarks

The survey instance is created for a given context.
You can have multiple instances representing the same survey with different contexts,
they all will internally interact with the same reference of the survey data.

The concurrent management of survey with context is mostly done to allows edition by multiple users at the same time on the same survey.

Examples

Use two different survey instances to manipulate the same survey data

using AskiaCore;

namespace MyApp
{
    public class MyProgram
    {
        static void Main()
        {
            // Initialize the database connection string (Where the survey will be stored)
            Persistent.InitDatabaseConnection("connectionstring", DatabaseTypes.PORTAL);

            // Create a context with the user 1
            IContext contextA = ContextFactory.Create();
            contextA.UserId = 1;
            contextA.SessionId = "xxxxx-xxxxx-xxxxx-xxxxxx";
            contextA.LanguageId = 2057; // Edit the survey with this language (English)

            // Get the survey with the AskiaPortal id 1
            // and with the contextA
            ISurvey surveyWithContextA = SurveyFactory.Get(contextA, 1);
            IQuestion ageContextA = surveyWithContextA.Questions["age"];
            Console.WriteLine(ageContextA.Responses.Count);
            // -> Output: 4

            // Create a context with the user 2
            IContext contextB = ContextFactory.Create();
            contextB.UserId = 2;
            contextB.SessionId = "yyyyy-yyyyy-yyyyy-yyyyy";
            contextB.LanguageId = 1036; // Edit the survey with this language (French)

            // Get the survey with the AskiaPortal id 1
            // and with the contextB
            ISurvey surveyWithContextB = SurveyFactory.Get(contextB, 1);
            IQuestion ageContextB = surveyWithContextB.Questions["age"];
            IResponse response ageContextB.Responses.Create();
            response.MainCaption = "50+";

            // Save all changes using the context B
            surveyWithContextB.SaveAll();

            // The survey with the context A and the survey with the context B
            // are both up-to-date with the additional response

            Console.WriteLine(ageContextA.Responses.Count);
            // -> Output: 5
            Console.WriteLine(ageContextB.Responses.Count);
            // -> Output: 5

            // Release the database connection
            Persistent.EndDatabaseConnection();
        }
    }
}
See Also