Click or drag to resize
Askia

SurveyFactoryCreate Method

Create a new blank survey

Namespace:  AskiaCore
Assembly:  AskiaCore (in AskiaCore.dll) Version: 6.0.0-build000000000000000000000000000000000000000001
Syntax
public static ISurvey Create(
	IContext context
)

Parameters

context
Type: AskiaCoreIContext
Context used to create the survey

Return Value

Type: ISurvey
Return the newly created survey
Examples

Create a new survey

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 new context
            IContext context = ContextFactory.Create();
            context.UserId = 1;
            context.SessionId = "xxxxx-xxxxx-xxxxx-xxxxxx";
            context.LanguageId = 2057; // Edit the survey with this language (English)

            // Create a new survey
            ISurvey survey = SurveyFactory.Create(context);
            survey.Name = "MySurvey";
            survey.DefaultLanguageId = 2057; // English

            // ... Rest of the code to create questions

            // Save all changes
            survey.SaveAll();

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