LimeSurvey API - Master branch

CopyQuestion

Class CopyQuestion

This class is responsible for the copy question process.

Table of Contents

Properties

$copyOptions  : array<string|int, mixed>
$copyQuestionValues  : CopyQuestionValues
$mappedSubquestionIds  : array<string|int, mixed>
$newQuestion  : Question

Methods

__construct()  : mixed
CopyQuestion constructor.
copyQuestion()  : bool
Copies the question and all necessary values/parameters (languages, subquestions, answeroptions, defaultanswers, settings)
createNewCopiedQuestion()  : bool
Creates a new question copying the values from questionToCopy
getMappedSubquestionIds()  : array<string|int, mixed>
Returns the mapping of subquestions
getNewCopiedQuestion()  : Question|null
Returns the new created question or null if question was not copied.
copyQuestionLanguages()  : bool
Copies the languages of a question.
copyQuestionsAnswerOptions()  : mixed
Copies the answer options of a question
copyQuestionsDefaultAnswers()  : mixed
Copies the default answers of the question
copyQuestionsSettings()  : bool
Copies the question settings (general_settings (on the left in questioneditor) and advanced settings (bottom)
copyQuestionsSubQuestions()  : bool
Copy subquestions of a question

Properties

$copyOptions

private array<string|int, mixed> $copyOptions = []

options when copying the question ['copySubquestions'] --> true if subquestions should be copied ['copyAnswerOptions'] --> true if answer options should be copied ['copyDefaultAnswers'] --> true if default answers should be copied ['copySettings'] --> generalSettings and advancedSettings ['adjustLinks'] --> true if links should be adjusted to a new survey id (e.g. /upload/348592/images)

$mappedSubquestionIds

private array<string|int, mixed> $mappedSubquestionIds = []

mapping between original subquestion id and new subquestion id

Methods

copyQuestion()

Copies the question and all necessary values/parameters (languages, subquestions, answeroptions, defaultanswers, settings)

public copyQuestion([int|null $surveyId = null ]) : bool
Parameters
$surveyId : int|null = null

The id of the survey to which the new question should be added. If null, it will be added to the current survey.

Return values
bool

True if new copied question could be saved, false otherwise

createNewCopiedQuestion()

Creates a new question copying the values from questionToCopy

public createNewCopiedQuestion(string $questionCode, int $groupId, Question $questionToCopy[, int $surveyId = null ]) : bool
Parameters
$questionCode : string
$groupId : int
$questionToCopy : Question

the question that should be copied

$surveyId : int = null

null if copied to same survey

Return values
bool

true if question could be saved, false otherwise

getMappedSubquestionIds()

Returns the mapping of subquestions

public getMappedSubquestionIds() : array<string|int, mixed>
Return values
array<string|int, mixed>

the mapping of subquestion ids from the original question to the copied question

getNewCopiedQuestion()

Returns the new created question or null if question was not copied.

public getNewCopiedQuestion() : Question|null
Return values
Question|null

copyQuestionLanguages()

Copies the languages of a question.

private copyQuestionLanguages(Question $oQuestion[, array<string, CopyQuestionTextValues$newQuestionL10nData = [] ][, mixed $surveyId = null ]) : bool
Parameters
$oQuestion : Question

old question from where to copy the languages (see table questions_l10ns)

$newQuestionL10nData : array<string, CopyQuestionTextValues> = []

the text values to override

$surveyId : mixed = null
Tags
before

$this->newQuestion must exist and should not be null

Return values
bool

true if all languages could be copied, false if no language was copied or save failed for one language

copyQuestionsAnswerOptions()

Copies the answer options of a question

private copyQuestionsAnswerOptions(int $questionIdToCopy) : mixed
  • @before $this->newQuestion must exist and should not be null
Parameters
$questionIdToCopy : int

copyQuestionsDefaultAnswers()

Copies the default answers of the question

private copyQuestionsDefaultAnswers(int $questionIdToCopy) : mixed
  • @before $this->newQuestion must exist and should not be null
Parameters
$questionIdToCopy : int

copyQuestionsSettings()

Copies the question settings (general_settings (on the left in questioneditor) and advanced settings (bottom)

private copyQuestionsSettings( $questionIdToCopy[,  $surveyId = null ]) : bool
Parameters
$questionIdToCopy :
$surveyId : = null

int The id of the survey to which the question should be copied.

  • @before $this->newQuestion must exist and should not be null
Return values
bool

True if settings are copied, false otherwise

copyQuestionsSubQuestions()

Copy subquestions of a question

private copyQuestionsSubQuestions(int $parentId[, int|null $surveyId = null ]) : bool
Parameters
$parentId : int

id of question to be copied

$surveyId : int|null = null

The id of the survey to which the new subquestion should be added. If null, it will be added to the survey the original question belongs to.

  • @before $this->newQuestion must exist and should not be null
Return values
bool

true if all subquestions could be copied&saved, false if a subquestion could not be saved


        
On this page

Search results