Interfaces for Limesurvey entities: Survey, Group, Question, Answer
Interfaces for Limesurvey entities: Survey, Group, Question, Answer, (*1)
Abstracting from the Limesurvey questions, subquestions and answer scales is done in the following way., (*2)
--DRAFT, (*3)
public function int getDimensions(); /** * Returns the subquestions for the specified dimension. **/ public function QuestionInterface[] getQuestions(int $i);
If getDimensions()
returns 2 for a question, then all questions returned from getQuestions()
will have 1 dimension.
(Think of it like partial function application), (*4)
if ($question->getDimensions() == 2) { foreach($question->getQuestions(0) as $i => $subQuestion) { assert($subQuestion->getDimensions() == 1); foreach($subQuestion->getQuestions(0) as $j => $subSubQuestion) { assert($subSubQuestion->getDimensions() == 0); assert( $subSubQuestion->getId() == $question->getQuestions(1)[j]->getQuestions(0)[$i]->getId() == $question->getQuestions($i, $j)->getId() ); } } }
Intuitively in most cases you can think of dimension 0 as the Y axis, and dimension 1 as the X axis. How much did you eat?, (*5)
........ | Yesterday | Today |
---|---|---|
Vegetables | [0, 0] | [1, 0] |
Meat | [0, 1] | [1, 1] |
These interfaces require the implementer implements question objects even when LimeSurvey might not have corresponding questions, consider dual scale questions:, (*6)
... | Scale 1 | Scale 2 |
---|---|---|
SQ001 | {1, 2, 3} | {Yes, Maybe, No} |
SQ002 | {1, 2, 3} | {Yes, Maybe, No} |
In this example (in LS) scale 1 has answer options 1, 2 and 3, scale 2 has options Yes, Maybe and No. These interfaces do not have the notion of answer scales. Instead only questions with 0 dimensions may have answer options. Further more our interfaces require this to be exposed as a question with 2 dimensions, with 2 questions each. Note that Scale 1 and Scale 2 in this must be exposed as Questions., (*7)
The goal of these interfaces is to allow developers to program against interfaces without worrying about LimeSurvey internals. An implementer can, for example, create a client that uses the JSON-RPC API available in LS2.x (https://github.com/SAM-IT/ls2-jsonrpc-client). Alternatives, could be creating a LimeSurvey plugin that exposes the required data as JSON (this could be more performant since less round trips are requried)., (*8)
When LimeSurvey internals change there is no need to adapt dependent code and the only thing that needs to be adapted are the implementations of these interfaces., (*9)
Some random notes that will be moved to appropriate interfaces:, (*10)
QuestionInterface::getId()
must be unique within a LimeSurvey installation, this must also hold for "dummy" objects like the Scale questions.