CopyQuestion
in package
Class CopyQuestion
This class is responsible for the copy question process.
Table of Contents
Properties
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
- 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
$copyQuestionValues
private
CopyQuestionValues
$copyQuestionValues
values needed to copy a question (e.g. questioncode, questionGroupId ...)
$newQuestion
private
Question
$newQuestion
the new question
Methods
__construct()
CopyQuestion constructor.
public
__construct(CopyQuestionValues $copyQuestionValues) : mixed
Parameters
- $copyQuestionValues : CopyQuestionValues
copyQuestion()
Copies the question and all necessary values/parameters (languages, subquestions, answeroptions, defaultanswers, settings)
public
copyQuestion(array<string|int, mixed> $copyOptions) : bool
Parameters
- $copyOptions : array<string|int, mixed>
-
has the following boolean elements ['copySubquestions'] ['copyAnswerOptions'] ['copyDefaultAnswers'] ['copySettings'] --> generalSettings and advancedSettings
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) : bool
Parameters
- $questionCode : string
- $groupId : int
- $questionToCopy : Question
-
the question that should be copied
Return values
bool —true if question could be saved, false otherwise
getNewCopiedQuestion()
Returns the new created question or null if question was not copied.
public
getNewCopiedQuestion() : Question|null
Return values
Question|nullcopyQuestionLanguages()
Copies the languages of a question.
private
copyQuestionLanguages(Question $oQuestion[, array<string, CopyQuestionTextValues> $newQuestionL10nData = [] ]) : 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
Tags
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) : bool
Parameters
Return values
bool —True if settings are copied, false otherwise
copyQuestionsSubQuestions()
Copy subquestions of a question
private
copyQuestionsSubQuestions(int $parentId) : bool
Parameters
- $parentId : int
-
id of question to be copied
- @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