QuestionAdministrationController
extends LSBaseController
in package
Class QuestionAdministrationController
Table of Contents
Properties
- $aData : array<string|int, mixed>
- $navData : array<string|int, mixed>
- This array contains the survey / group / question id used by the menu widget.
- $sTemplate : null
- $userId : int
Methods
- __construct() : mixed
- Basic initialiser to the base controller class
- accessRules() : array<string|int, mixed>
- It's import to have the accessRules set (security issue).
- actionAjaxLoadExtraOptions() : mixed
- actionAjaxLoadPositionWidget() : CWidget|mixed|void
- Loads the possible Positions where a Question could be inserted to
- actionChangeMultipleQuestionAttributes() : mixed
- Change attributes for multiple questions ajax request (this is a massive action for questionlists view)
- actionChangeMultipleQuestionMandatoryState() : mixed
- Change the Questions mandatory state
- actionChangeMultipleQuestionOtherState() : mixed
- Change the "other" option for applicable question types
- actionCheckAnswerCodeIsUnique() : bool
- Checks given answer code is unique.
- actionCheckLabel() : void
- Check if label set can be replaced without problems
- actionCheckQuestionCodeUniqueness() : mixed
- actionCheckQuestionValidateTitle() : void
- Checks if given Question Code is unique.
- actionCheckSubQuestionCodeIsUnique() : string
- Checks if given Sub Question Code is unique.
- actionCopyQuestion() : void
- Copies a question
- actionCreate() : void
- Show form to create new question.
- actionDelete() : mixed
- Function responsible for deleting a question.
- actionDeleteMultiple() : void
- Delete multiple questions.
- actionEdit() : void
- Show question edit form.
- actionEditdefaultvalues() : void
- Load edit default values of a question screen
- actionGetAdvancedSettingsHTML() : void
- Get HTML for advanced settings.
- actionGetAnswerOptionRowForAllLanguages() : void
- actionGetAnswerOptionRowQuickAdd() : void
- actionGetExtraOptionsHTML() : void
- Get HTML for extra options (subquestions/answers).
- actionGetGeneralOptions() : void|array<string|int, mixed>
- actionGetGeneralSettingsHTML() : void
- Get HTML for general settings.
- actionGetLabelsetDetails() : void
- This function prepares the data for label set details
- actionGetLabelsetPicker() : void
- This function prepares the data for labelset
- actionGetPossibleLanguages() : void
- Returns all languages in a specific survey as a JSON document
- actionGetQuestionData() : void
- Collect initial question data This either creates a temporary question object, or calls a question object from the database
- actionGetQuestionPermissions() : void
- Collect the permissions available for a specific question
- actionGetQuestionTopbar() : false|null|string|array<string|int, string>
- Renders the top bar definition for questions as JSON document
- actionGetQuestionTypeInformation() : void
- actionGetQuestionTypeList() : void
- Returns a json document containing the question types
- actionGetSubquestionRowForAllLanguages() : void
- Called via Ajax.
- actionGetSubquestionRowQuickAdd() : void
- AJAX Method to QuickAdd multiple Rows AJAX-based
- actionGetSummaryHTML() : void
- Get HTML for question summary.
- actionImport() : mixed
- Import the Question
- actionImportView() : mixed
- Display import view for Question
- actionListQuestions() : string
- Load list questions view for a specified survey by $surveyid
- actionRenderItemsSelected() : mixed
- render selected items for massive action widget
- actionSaveQuestionData() : void
- Action called by the FE editor when a save is triggered.
- actionSetMultipleQuestionGroup() : mixed
- Change the question group/order position of multiple questions
- actionView() : void
- Renders the main view for question editor.
- changeMultipleQuestionPositionAndGroup() : mixed
- Change the question group/order position of multiple questions
- createAbsoluteUrl() : string
- Returns an absolute URL based on the given controller and action information.
- getDefaultValues() : array<string|int, mixed>
- Gets default value(s) for a question or subquestion from table defaultvalue_l10ns
- getReorderData() : mixed
- loadHelper() : void
- Loads a helper
- loadLibrary() : void
- Loads a library
- run() : void
- Checks for action specific authorization and then executes an action
- setMultipleQuestionMandatoryState() : mixed
- Set the mandatory state for selected Questions
- setMultipleQuestionOtherState() : mixed
- Set the other state for selected Questions
- _checkInstallation() : void
- Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.
- beforeRender() : bool
- This part comes from renderWrappedTemplate
- customInit() : mixed
- isValidCSSClass() : bool
- Returns true if $class is a valid CSS class (alphanumeric + '-' and '_')
- loadPageStates() : array<string|int, mixed>
- Loads page states from a hidden input.
- renderJSON() : void
- Method to render an array as a json document (this one called by a lot of actions in different controllers)
- sessionControl() : void
- Load and set session vars
- calculateNextCode() : array<string|int, mixed>
- Calculate the next subquestion code based on previous codes.
- copyDefaultAnswers() : bool
- Copies the default value(s) set for a question
- getAdvancedOptions() : array<string|int, mixed>
- It returns a preformatted array of advanced settings.
- getAnswerOptionRow() : string
- getCompiledQuestionData() : array<string|int, mixed>
- getCompiledSurveyInfo() : array<string|int, mixed>
- todo: this should be moved to model, not a controller function .
- getGeneralOptions() : void|array<string|int, mixed>
- getQuestionObject() : Question
- Creates a question object This is either an instance of the placeholder model QuestionCreate for new questions, or of Question for already existing ones
- getQuestionTypeGroups() : array<string|int, mixed>
- getSelectorModeClass() : string
- Returns the selector mode class as string
- getSubquestionRow() : string
- It returns a empty subquestion row.
- renderFormAux() : void
- Helper function to render form.
Properties
$aData
public
array<string|int, mixed>
$aData
= []
import for all new controllers/actions (REFACTORING) to pass data before rendering the content
$navData
This array contains the survey / group / question id used by the menu widget.
public
array<string|int, mixed>
$navData
= array()
$sTemplate
public
null
$sTemplate
= \null
this is needed for the preview rendering inside the questioneditor
$userId
protected
int
$userId
= 0
userId of the logged in user
Methods
__construct()
Basic initialiser to the base controller class
public
__construct(string $id[, CWebModule $module = null ]) : mixed
Parameters
- $id : string
- $module : CWebModule = null
Tags
accessRules()
It's import to have the accessRules set (security issue).
public
accessRules() : array<string|int, mixed>
Only logged in users should have access to actions. All other permissions should be checked in the action itself.
Return values
array<string|int, mixed>actionAjaxLoadExtraOptions()
public
actionAjaxLoadExtraOptions(mixed $questionId) : mixed
Parameters
- $questionId : mixed
actionAjaxLoadPositionWidget()
Loads the possible Positions where a Question could be inserted to
public
actionAjaxLoadPositionWidget(int $gid[, string $classes = '' ]) : CWidget|mixed|void
Parameters
- $gid : int
- $classes : string = ''
Tags
Return values
CWidget|mixed|voidactionChangeMultipleQuestionAttributes()
Change attributes for multiple questions ajax request (this is a massive action for questionlists view)
public
actionChangeMultipleQuestionAttributes() : mixed
actionChangeMultipleQuestionMandatoryState()
Change the Questions mandatory state
public
actionChangeMultipleQuestionMandatoryState() : mixed
actionChangeMultipleQuestionOtherState()
Change the "other" option for applicable question types
public
actionChangeMultipleQuestionOtherState() : mixed
actionCheckAnswerCodeIsUnique()
Checks given answer code is unique.
public
actionCheckAnswerCodeIsUnique(string $code) : bool
Parameters
- $code : string
Return values
boolactionCheckLabel()
Check if label set can be replaced without problems
public
actionCheckLabel(int $lid, array<string|int, mixed> $languages, bool $checkAssessments) : void
Parameters
- $lid : int
- $languages : array<string|int, mixed>
- $checkAssessments : bool
actionCheckQuestionCodeUniqueness()
public
actionCheckQuestionCodeUniqueness(mixed $sid, int $qid, string $code) : mixed
Parameters
- $sid : mixed
- $qid : int
- $code : string
Tags
actionCheckQuestionValidateTitle()
Checks if given Question Code is unique.
public
actionCheckQuestionValidateTitle(int $sid, int $qid, string $code) : void
Echo 'true' if code is unique, otherwise 'false'.
Parameters
- $sid : int
-
Survey id
- $qid : int
-
Question id
- $code : string
-
Question code (title in db)
actionCheckSubQuestionCodeIsUnique()
Checks if given Sub Question Code is unique.
public
actionCheckSubQuestionCodeIsUnique(string $code) : string
Parameters
- $code : string
Return values
stringactionCopyQuestion()
Copies a question
public
actionCopyQuestion() : void
actionCreate()
Show form to create new question.
public
actionCreate(int $surveyid) : void
Parameters
- $surveyid : int
actionDelete()
Function responsible for deleting a question.
public
actionDelete([int $qid = null ][, bool $massAction = false ][, string $redirectTo = null ]) : mixed
Parameters
- $qid : int = null
- $massAction : bool = false
- $redirectTo : string = null
-
'questionlist' or 'groupoverview' or empty
Tags
actionDeleteMultiple()
Delete multiple questions.
public
actionDeleteMultiple() : void
Called by ajax from question list. Permission check is done by questions::delete()
Tags
actionEdit()
Show question edit form.
public
actionEdit(int $questionId[, string $tabOverviewEditor = null ]) : void
Parameters
- $questionId : int
-
Question ID
- $tabOverviewEditor : string = null
-
which tab should be used this can be 'overview' or 'editor'
Tags
actionEditdefaultvalues()
Load edit default values of a question screen
public
actionEditdefaultvalues(int $surveyid, int $gid, int $qid) : void
Parameters
- $surveyid : int
- $gid : int
- $qid : int
Tags
actionGetAdvancedSettingsHTML()
Get HTML for advanced settings.
public
actionGetAdvancedSettingsHTML(int $surveyId, string $questionType[, string $questionTheme = null ][, int $questionId = null ]) : void
Called with Ajax after question type is selected.
Parameters
- $surveyId : int
- $questionType : string
-
One-char string
- $questionTheme : string = null
- $questionId : int = null
-
Null or 0 if new question is being created.
actionGetAnswerOptionRowForAllLanguages()
public
actionGetAnswerOptionRowForAllLanguages(mixed $surveyid, mixed $gid, mixed $codes, mixed $scale_id[, mixed $position = 0 ][, mixed $assessmentvisible = '' ]) : void
Parameters
- $surveyid : mixed
- $gid : mixed
- $codes : mixed
- $scale_id : mixed
- $position : mixed = 0
- $assessmentvisible : mixed = ''
actionGetAnswerOptionRowQuickAdd()
public
actionGetAnswerOptionRowQuickAdd(mixed $surveyid, mixed $gid) : void
Parameters
- $surveyid : mixed
- $gid : mixed
Tags
actionGetExtraOptionsHTML()
Get HTML for extra options (subquestions/answers).
public
actionGetExtraOptionsHTML(int $surveyId, string $questionType[, int $questionId = null ]) : void
Called with Ajax after question type is selected.
Parameters
- $surveyId : int
- $questionType : string
-
One-char string
- $questionId : int = null
-
Null or 0 if new question is being created.
actionGetGeneralOptions()
public
actionGetGeneralOptions([int $iQuestionId = null ][, string $sQuestionType = null ][, int $gid = null ][, bool $returnArray = false ][, string $questionThemeName = null ]) : void|array<string|int, mixed>
Parameters
- $iQuestionId : int = null
- $sQuestionType : string = null
- $gid : int = null
- $returnArray : bool = false
- $questionThemeName : string = null
Tags
Return values
void|array<string|int, mixed>actionGetGeneralSettingsHTML()
Get HTML for general settings.
public
actionGetGeneralSettingsHTML(int $surveyId, string $questionType[, string $questionTheme = null ][, int $questionId = null ]) : void
Called with Ajax after question type is selected.
Parameters
- $surveyId : int
- $questionType : string
-
One-char string
- $questionTheme : string = null
-
the question theme
- $questionId : int = null
-
Null or 0 if new question is being created.
actionGetLabelsetDetails()
This function prepares the data for label set details
public
actionGetLabelsetDetails(int $lid) : void
Parameters
- $lid : int
actionGetLabelsetPicker()
This function prepares the data for labelset
public
actionGetLabelsetPicker(int $sid[, int $match = 0 ][, mixed $language = null ]) : void
Parameters
- $sid : int
- $match : int = 0
- $language : mixed = null
actionGetPossibleLanguages()
Returns all languages in a specific survey as a JSON document
public
actionGetPossibleLanguages(int $iSurveyId) : void
Parameters
- $iSurveyId : int
Tags
actionGetQuestionData()
Collect initial question data This either creates a temporary question object, or calls a question object from the database
public
actionGetQuestionData([int $iQuestionId = null ][, int $gid = null ][, string $type = null ]) : void
Parameters
- $iQuestionId : int = null
- $gid : int = null
- $type : string = null
Tags
actionGetQuestionPermissions()
Collect the permissions available for a specific question
public
actionGetQuestionPermissions([ $iQuestionId = null ]) : void
Parameters
Tags
actionGetQuestionTopbar()
Renders the top bar definition for questions as JSON document
public
actionGetQuestionTopbar([int $qid = null ]) : false|null|string|array<string|int, string>
Parameters
- $qid : int = null
Tags
Return values
false|null|string|array<string|int, string>actionGetQuestionTypeInformation()
public
actionGetQuestionTypeInformation(string $sQuestionType) : void
Parameters
- $sQuestionType : string
Tags
actionGetQuestionTypeList()
Returns a json document containing the question types
public
actionGetQuestionTypeList() : void
actionGetSubquestionRowForAllLanguages()
Called via Ajax.
public
actionGetSubquestionRowForAllLanguages(int $surveyid, int $gid, string $codes, int $scale_id[, int $position = 0 ][, string $assessmentvisible = '' ]) : void
Parameters
- $surveyid : int
- $gid : int
- $codes : string
- $scale_id : int
- $position : int = 0
- $assessmentvisible : string = ''
Tags
actionGetSubquestionRowQuickAdd()
AJAX Method to QuickAdd multiple Rows AJAX-based
public
actionGetSubquestionRowQuickAdd(mixed $surveyid, mixed $gid) : void
Parameters
- $surveyid : mixed
- $gid : mixed
Tags
actionGetSummaryHTML()
Get HTML for question summary.
public
actionGetSummaryHTML(int $questionId) : void
Called with Ajax after question is saved.
Parameters
- $questionId : int
actionImport()
Import the Question
public
actionImport() : mixed
actionImportView()
Display import view for Question
public
actionImportView(int $surveyid[, int|null $groupid = null ]) : mixed
Parameters
- $surveyid : int
- $groupid : int|null = null
actionListQuestions()
Load list questions view for a specified survey by $surveyid
public
actionListQuestions(int $surveyid[, string $landOnSideMenuTab = 'settings' ]) : string
Parameters
- $surveyid : int
-
Goven Survey ID
- $landOnSideMenuTab : string = 'settings'
-
Name of the side menu tab (settings or structure). Default behavior is to land on settings tab.
Tags
Return values
stringactionRenderItemsSelected()
render selected items for massive action widget
public
actionRenderItemsSelected() : mixed
Tags
actionSaveQuestionData()
Action called by the FE editor when a save is triggered.
public
actionSaveQuestionData() : void
This is called for both new question and update.
Tags
actionSetMultipleQuestionGroup()
Change the question group/order position of multiple questions
public
actionSetMultipleQuestionGroup() : mixed
Tags
actionView()
Renders the main view for question editor.
public
actionView(int $surveyid[, int $gid = null ][, int $qid = null ][, string $landOnSideMenuTab = 'structure' ]) : void
Main view function prepares the necessary global js parts and renders the HTML for the question editor
Parameters
- $surveyid : int
-
Survey ID
- $gid : int = null
-
Group ID
- $qid : int = null
-
Question ID
- $landOnSideMenuTab : string = 'structure'
-
Name of the side menu tab. Default behavior is to land on structure tab.
Tags
changeMultipleQuestionPositionAndGroup()
Change the question group/order position of multiple questions
public
static changeMultipleQuestionPositionAndGroup(array<string|int, mixed> $aQids, int $iQuestionOrder, QuestionGroup $oQuestionGroup) : mixed
Parameters
- $aQids : array<string|int, mixed>
-
all question id's affected
- $iQuestionOrder : int
-
the desired position
- $oQuestionGroup : QuestionGroup
-
the desired QuestionGroup
Tags
createAbsoluteUrl()
Returns an absolute URL based on the given controller and action information.
public
createAbsoluteUrl(string $route[, array<string|int, mixed> $params = array() ][, string $schema = '' ][, string $ampersand = '&' ]) : string
The functionalty was moved to \LSYii_Application::createPublicUrl, to be safe the function remains here.
Parameters
- $route : string
-
the URL route. This should be in the format of 'ControllerID/ActionID'.
- $params : array<string|int, mixed> = array()
-
additional GET parameters (name=>value). Both the name and value will be URL-encoded.
- $schema : string = ''
-
schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
- $ampersand : string = '&'
-
the token separating name-value pairs in the URL.
Return values
string —the constructed URL
getDefaultValues()
Gets default value(s) for a question or subquestion from table defaultvalue_l10ns
public
static getDefaultValues(int $iSurveyID, int $gid, int $qid) : array<string|int, mixed>
Parameters
- $iSurveyID : int
- $gid : int
- $qid : int
Return values
array<string|int, mixed> —Array with defaultValues
getReorderData()
public
getReorderData(mixed $oSurvey) : mixed
Parameters
- $oSurvey : mixed
loadHelper()
Loads a helper
public
loadHelper(string $helper) : void
Parameters
- $helper : string
Tags
loadLibrary()
Loads a library
public
loadLibrary(string $library) : void
Parameters
- $library : string
Tags
run()
Checks for action specific authorization and then executes an action
public
run(string $action) : void
TODO: check the dbupdate mechanism, do we really want to check db update before every action??
Parameters
- $action : string
Tags
setMultipleQuestionMandatoryState()
Set the mandatory state for selected Questions
public
static setMultipleQuestionMandatoryState(array<string|int, mixed> $aQids, string $sMandatory, int $iSid) : mixed
Parameters
- $aQids : array<string|int, mixed>
-
All question id's affected
- $sMandatory : string
-
The mandatory va
- $iSid : int
-
survey ID
setMultipleQuestionOtherState()
Set the other state for selected Questions
public
static setMultipleQuestionOtherState(array<string|int, mixed> $aQids, string $sOther, int $iSid) : mixed
Parameters
- $aQids : array<string|int, mixed>
-
All question id's affected
- $sOther : string
-
the "other" value 'Y' or 'N'
- $iSid : int
-
survey ID
_checkInstallation()
Check that installation was already done by looking for config.php Will redirect to the installer script if not exists.
protected
_checkInstallation() : void
Tags
beforeRender()
This part comes from renderWrappedTemplate
protected
beforeRender(string $view) : bool
Parameters
- $view : string
-
View
Return values
boolcustomInit()
protected
customInit() : mixed
isValidCSSClass()
Returns true if $class is a valid CSS class (alphanumeric + '-' and '_')
protected
isValidCSSClass(string $class) : bool
Parameters
- $class : string
Return values
boolloadPageStates()
Loads page states from a hidden input.
protected
loadPageStates() : array<string|int, mixed>
Return values
array<string|int, mixed> —the loaded page states
renderJSON()
Method to render an array as a json document (this one called by a lot of actions in different controllers)
protected
renderJSON(array<string|int, mixed> $aData[, mixed $success = true ]) : void
Parameters
- $aData : array<string|int, mixed>
- $success : mixed = true
sessionControl()
Load and set session vars
protected
sessionControl() : void
todo REFACTORING see comments in mehtod
Tags
calculateNextCode()
Calculate the next subquestion code based on previous codes.
private
calculateNextCode(array<string|int, mixed> $stringCodes) : array<string|int, mixed>
Parameters
- $stringCodes : array<string|int, mixed>
Return values
array<string|int, mixed>copyDefaultAnswers()
Copies the default value(s) set for a question
private
copyDefaultAnswers(Question $oQuestion, int $oldQid) : bool
Parameters
- $oQuestion : Question
- $oldQid : int
Tags
Return values
boolgetAdvancedOptions()
It returns a preformatted array of advanced settings.
private
getAdvancedOptions([int $iQuestionId = null ][, string $sQuestionType = null ][, string $sQuestionTheme = null ]) : array<string|int, mixed>
Parameters
- $iQuestionId : int = null
- $sQuestionType : string = null
- $sQuestionTheme : string = null
Tags
Return values
array<string|int, mixed>getAnswerOptionRow()
private
getAnswerOptionRow(mixed $surveyid, mixed $gid, mixed $qid, mixed $codes, mixed $language, mixed $first, mixed $scale_id, mixed $position[, mixed $assessmentvisible = '' ]) : string
Parameters
- $surveyid : mixed
- $gid : mixed
- $qid : mixed
- $codes : mixed
- $language : mixed
- $first : mixed
- $scale_id : mixed
- $position : mixed
- $assessmentvisible : mixed = ''
Tags
Return values
stringgetCompiledQuestionData()
private
getCompiledQuestionData(Question &$oQuestion) : array<string|int, mixed>
Parameters
- $oQuestion : Question
Tags
Return values
array<string|int, mixed>getCompiledSurveyInfo()
todo: this should be moved to model, not a controller function .
private
getCompiledSurveyInfo( $oQuestion) : array<string|int, mixed>
..
Parameters
Return values
array<string|int, mixed>getGeneralOptions()
private
getGeneralOptions([int $iQuestionId = null ][, string $sQuestionType = null ][, int $gid = null ][, string $questionThemeName = null ]) : void|array<string|int, mixed>
Parameters
- $iQuestionId : int = null
- $sQuestionType : string = null
- $gid : int = null
- $questionThemeName : string = null
Tags
Return values
void|array<string|int, mixed>getQuestionObject()
Creates a question object This is either an instance of the placeholder model QuestionCreate for new questions, or of Question for already existing ones
private
getQuestionObject([int $iQuestionId = null ][, string $sQuestionType = null ][, int $gid = null ][, mixed $questionThemeName = null ]) : Question
todo: this should be moved to model ...
Parameters
- $iQuestionId : int = null
- $sQuestionType : string = null
- $gid : int = null
- $questionThemeName : mixed = null
Tags
Return values
QuestiongetQuestionTypeGroups()
private
getQuestionTypeGroups(array<string|int, QuestionTheme> $questionThemes) : array<string|int, mixed>
Parameters
- $questionThemes : array<string|int, QuestionTheme>
-
Question theme List
Tags
Return values
array<string|int, mixed>getSelectorModeClass()
Returns the selector mode class as string
private
getSelectorModeClass() : string
Return values
stringgetSubquestionRow()
It returns a empty subquestion row.
private
getSubquestionRow(mixed $surveyid, mixed $gid, mixed $qid, string $codes, mixed $language, mixed $first, mixed $scale_id, mixed $position[, mixed $assessmentvisible = '' ]) : string
Used when user clicks "Add new row" in question editor.
Parameters
- $surveyid : mixed
- $gid : mixed
- $qid : mixed
- $codes : string
-
All previous codes (used to calculate the next code)
- $language : mixed
- $first : mixed
- $scale_id : mixed
- $position : mixed
- $assessmentvisible : mixed = ''
Tags
Return values
stringrenderFormAux()
Helper function to render form.
private
renderFormAux(Question $question) : void
Used by create and edit actions.
Parameters
- $question : Question
-
Question