questionedit

Extends \Survey_Common_Action

Controller questionedit Contains methods to control and view the vuejs based question editor

This controller contains common functions for survey related views.

package

LimeSurvey

author

LimeSurvey Team support@limesurvey.org

copyright

2019 LimeSurvey GmbH

access

public

Methods

__construct

__construct( $controller = null,  $id = null) 
inherited

Arguments

$controller

$id

Some functions have different parameters, which are just an alias of the usual parameters we're getting in the url. This function just populates those variables so that we don't end up in an error.

_addPseudoParams(array $params) : array
inherited

This is also used while rendering wrapped template Survey_Common_Action::_renderWrappedTemplate()

Throws
\CHttpException

Arguments

$params

array

Parameters to parse and populate

Response

array

Populated parameters

Browse Menu Bar

_browsemenubar(array $aData) 
inherited

Arguments

$aData

array

_filterImportedResources

_filterImportedResources(string $extractdir, string $destdir) : array
inherited

Arguments

$extractdir

string

$destdir

string

Response

array

_fullpagebar

_fullpagebar( $aData) 
inherited

Arguments

$aData

_generaltopbar

_generaltopbar( $aData) 
inherited

Arguments

$aData

_generaltopbarAdditions

_generaltopbarAdditions( $aData) 
inherited

Arguments

$aData

listquestion groups

_listquestiongroups(array $aData) 
inherited

Arguments

$aData

array

_listquestions

_listquestions( $aData) 
inherited
Throws
\CException

Arguments

$aData

Display notifications

_notifications() 
inherited

Show admin menu for question group view

_nquestiongroupbar(array $aData) 
inherited

Arguments

$aData

array

?

Survey summary

_nsurveysummary(array $aData) 
inherited

Arguments

$aData

array

Render the save/cancel bar for Organize question groups/questions

_organizequestionbar(array $aData) 
inherited
since 2014-09-30
author

Olle Haerstedt

Arguments

$aData

array

Shows admin menu for question

_questionbar(array $aData) 
inherited

Arguments

$aData

array

Renders template(s) wrapped in header and footer

_renderWrappedTemplate(string $sAction = '', array|string $aViewUrls = array(), array $aData = array(), string|boolean $sRenderFile = false) 
inherited

Addition of parameters should be avoided if they can be added to $aData

NOTE FROM LOUIS : We want to remove this function, wich doesn't respect MVC pattern. The work it's doing should be handle by layout files, and subviews inside views. Eg : for route "admin/survey/sa/listquestiongroups/surveyid/282267" the Group controller should use a main layout (with admin menu bar as a widget), then render the list view, in wich the question group bar is called as a subview.

So for now, we try to evacuate all the renderWrappedTemplate logic (if statements, etc.) to subfunctions, then it will be easier to remove. Comments starting with //// indicate how it should work in the future

Throws
\CHttpException

Arguments

$sAction

string

Current action, the folder to fetch views from

$aViewUrls

array|string

View url(s)

$aData

array

Data to be passed on. Optional.

$sRenderFile

string|boolean

File to be rendered as a layout. Optional.

_showadminmenu() function returns html text for the administration button bar

_showadminmenu( $aData) : string
inherited
access

public

global

string $homedir

string $scriptname

string $surveyid

string $setfont

string $imageurl

int $surveyid

Arguments

$aData

Response

string

Header

_showHeaders(array $aData,  $sendHTTPHeader = true) 
inherited

Arguments

$aData

array

$sendHTTPHeader

Shows admin menu for surveys

_surveybar(array $aData) 
inherited
deprecated

Arguments

$aData

array

Show side menu for survey view

_surveysidemenu(array $aData) 
inherited

Arguments

$aData

array

all the needed data

Show survey summary

_surveysummary(array $aData) 
inherited

Arguments

$aData

array

_titlebar

_titlebar( $aData) 
inherited

Arguments

$aData

Display the update notification

_updatenotification() 
inherited

Load menu bar of user group controller.

_userGroupBar(array $aData) : void
inherited

Arguments

$aData

array

applyAnswerI10N

applyAnswerI10N(\Answer $oAnswer, \Question $oQuestion, array $dataSet) : boolean
todo

document me

Throws
\CHttpException

Arguments

$oAnswer

\Answer

$oQuestion

\Question

$dataSet

array

Response

boolean

applyI10N

applyI10N(\Question &$oQuestion, array $dataSet) : boolean
todo

document me

Throws
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

Response

boolean

applyI10NSubquestion

applyI10NSubquestion(\Question $oQuestion, array $dataSet) : boolean
todo

document me

Throws
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

Response

boolean

Returns content from event beforeSideMenuRender

beforeSideMenuRender(array $aData) : string
inherited

Arguments

$aData

array

Response

string

cleanAnsweroptions

cleanAnsweroptions(\Question &$oQuestion, array &$dataSet) : void
todo

document me

Arguments

$oQuestion

\Question

$dataSet

array

cleanSubquestions

cleanSubquestions(\Question &$oQuestion, array &$dataSet) : void
todo

document me.

PHPDoc description

Arguments

$oQuestion

\Question

$dataSet

array

Copies the default value(s) set for a question

copyDefaultAnswers(\Question $oQuestion, integer $oldQid) : boolean
Throws
\CHttpException

Arguments

$oQuestion

\Question

$oldQid

integer

Response

boolean

Get extra menus from plugins that are using event beforeAdminMenuRender

fetchExtraMenus(array $aData) : \array<ExtraMenu>
inherited

Arguments

$aData

array

Response

\array

getAdvancedOptions

getAdvancedOptions(integer $iQuestionId = null, string $sQuestionType = null, boolean $returnArray = false, string $question_template = 'core') : void|array
todo

document me

Throws
\CException

Arguments

$iQuestionId

integer

$sQuestionType

string

$returnArray

boolean

$question_template

string

Response

void|array

getCompiledQuestionData

getCompiledQuestionData(\Question &$oQuestion) : array
todo

document me.

Arguments

$oQuestion

\Question

Response

array

getCompiledSurveyInfo

getCompiledSurveyInfo( &$oQuestion) 

Arguments

$oQuestion

getGeneralOptions

getGeneralOptions(integer $iQuestionId = null, string $sQuestionType = null, integer $gid = null, boolean $returnArray = false, string $question_template = 'core') : void|array
todo

document me

Throws
\CException

Arguments

$iQuestionId

integer

$sQuestionType

string

$gid

integer

$returnArray

boolean

$question_template

string

Response

void|array

Returns all languages in a specific survey as a JSON document

getPossibleLanguages(integer $iSurveyId) : void

Arguments

$iSurveyId

integer

Either renders a JSON document of the question attribute array, or returns it

getQuestionAttributeData(integer $iQuestionId = null, boolean $returnArray = false) : void|array
Throws
\CException

Arguments

$iQuestionId

integer

$returnArray

boolean

| If true returns array

Response

void|array

Collect initial question data This either creates a temporary question object, or calls a question object from the database

getQuestionData(integer $iQuestionId = null, integer $gid = null, string $type = null) : void
Throws
\CException

Arguments

$iQuestionId

integer

$gid

integer

$type

string

Creates a question object This is either an instance of the placeholder model QuestionCreate for new questions, or of Question for already existing ones

getQuestionObject(integer $iQuestionId = null, string $sQuestionType = null, integer $gid = null) : \Question
Throws
\CException

Arguments

$iQuestionId

integer

$sQuestionType

string

$gid

integer

Response

\Question

Collect the permissions available for a specific question

getQuestionPermissions( $iQuestionId = null) : void
Throws
\CException

Arguments

$iQuestionId

Renders the top bar definition for questions as JSON document

getQuestionTopbar(integer $qid = null) : void
Throws
\CException

Arguments

$qid

integer

getQuestionTypeInformation

getQuestionTypeInformation(string $sQuestionType) : void
todo

document me.

Arguments

$sQuestionType

string

Returns a json document containing the question types

getQuestionTypeList() : void

Live preview rendering

getRenderedPreview(integer $iQuestionId, string $sLanguage, boolean $root = false) : void
Throws
\CException
\Throwable
\Twig_Error_Loader
\Twig_Error_Syntax
\WrongTemplateVersionException

Arguments

$iQuestionId

integer

$sLanguage

string

$root

boolean

index

index() : void
inherited

Update the data set in the FE

reloadQuestionData(integer $iQuestionId = null, string $type = null, integer $gid = null, string $question_template = 'core') : void
Throws
\CException

Arguments

$iQuestionId

integer

$type

string

$gid

integer

Group id

$question_template

string

Rendering the subviews and views of _renderWrappedTemplate

renderCentralContents(string $sAction, array|string $aViewUrls, array $aData = array()) : string
inherited

Arguments

$sAction

string

$aViewUrls

array|string

$aData

array

Response

string

renderInternal

renderInternal(string $_viewFile_,  $_data_ = null,  $_return_ = false) 
inherited
inheritdoc

Arguments

$_viewFile_

string

$_data_

$_return_

Method to render an array as a json document

renderJSON(array $aData,  $success = true) : void
inherited

Arguments

$aData

array

$success

Render the quick-menu that is shown when side-menu is hidden.

renderQuickmenu(array $aData) : string
inherited

Only show home-icon for now.

Add support for plugin to attach icon elements using event afterQuickMenuLoad

todo

Make quick-menu user configurable

Arguments

$aData

array

Response

string

Routes the action into correct subaction

route(string $sa, array<mixed,string> $get_vars) : mixed
inherited
access

protected

Arguments

$sa

string

$get_vars

array<mixed,string>

Response

mixed

Action classes require them to have a run method. We reroute it to index if called.

run() 
inherited

Override runWithParams() implementation in CAction to help us parse requests with subactions.

runWithParams(array $params) : boolean
inherited

Arguments

$params

array

URL Parameters

Response

boolean

Action called by the FE editor when a save is triggered.

saveQuestionData(integer $sid) : void
Throws
\CException

Arguments

$sid

integer

Survey id

storeAnswerOptions

storeAnswerOptions(\Question &$oQuestion, array $dataSet,  $isCopyProcess = false) : boolean
todo

document me

Throws
\CException
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

$isCopyProcess

Response

boolean

Method to store and filter questionData for a new question

storeNewQuestionData(array $aQuestionData = null, boolean $subquestion = false) : \Question
Throws
\CHttpException

Arguments

$aQuestionData

array

$subquestion

boolean

Response

\Question

storeSubquestions

storeSubquestions(\Question &$oQuestion, array $dataSet,  $isCopyProcess = false) : boolean
todo

document me.

Throws
\CException
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

$isCopyProcess

Response

boolean

unparseAndSetAdvancedOptions

unparseAndSetAdvancedOptions(\Question &$oQuestion, array $dataSet) : boolean
todo

document me

Throws
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

Response

boolean

unparseAndSetGeneralOptions

unparseAndSetGeneralOptions(\Question &$oQuestion, array $dataSet) : boolean
todo

document me

Throws
\CHttpException

Arguments

$oQuestion

\Question

$dataSet

array

Response

boolean

Method to store and filter questionData for editing a question

updateQuestionData(\Question &$oQuestion, array $aQuestionData) : \Question
Throws
\CHttpException

Arguments

$oQuestion

\Question

$aQuestionData

array

Response

\Question

Main view function prepares the necessary global js parts and renders the HTML

view(integer $surveyid, integer $gid = null, integer $qid = null, string $landOnSideMenuTab = 'structure') 
Throws
\CException
\CHttpException

Arguments

$surveyid

integer

$gid

integer

$qid

integer

$landOnSideMenuTab

string

Name of the side menu tab. Default behavior is to land on structure tab.