From LimeSurvey Manual
This is a proposal for (re)organizing the controller structure for LS2.1
Currently we have very few but fat controllers. It is desirable to have skinny controllers for easier maintenance.
Several main tasks can be identified within LS.
- Survey taking
- Survey creation
- Token management
Since survey taking is what LS is all about we should try to decrease the complexity of this process.
A survey hasMany groups and a group hasMany questions. For taking a survey (which is creating a survey entry) four controllers should be used.
- Actions for creating and editing a survey.
- Actions for creating and editing a group.
- Actions for creating and editing a question.
- Responsible for managing the creation of new entries for surveys.
Example process for a 1-question-at-a-time survey:
- Initialize session.
- Store survey ID in session.
- Redirect to /survey/welcome
- If applicable show welcome screen.
- Store group ID in session.
- Redirect to /group/welcome
- Show welcome screen for group.
- Store question ID in session.
- Redirect to /question/render
- Show question, form action = /entry/addanswer
- Store the result for the current answered question.
- Use answer to find next question / group & store ID.
- Redirect appropriately.
And so on... This does not cause a lot of extra redirects since redirecting after a HTTP POST is standard procedure, we just change the POST ACTION.
This approach allows us to divide large complex controller(s) into smaller and easier to manage pieces.