Actions

Controllers: Difference between revisions

From LimeSurvey Manual

No edit summary
 
No edit summary
 
Line 32: Line 32:
- Responsible for managing the creation of new entries for surveys.
- Responsible for managing the creation of new entries for surveys.


Example process:
Example process for a 1-question-at-a-time survey:


- EntryController-> create entry for survey 1
/entry/create?sid=12345


- Redirect to SurveyController -> welcome screen (which has a post button that goes to entrycontroller)
- Initialize session.


- Redirect to GroupController -> welcome screen
- Store survey ID in session.
 
- Redirect to /survey/welcome
 
/survey/welcome
 
- If applicable show welcome screen.
 
- Store group ID in session.
 
- Redirect to /group/welcome
 
/group/welcome
 
- Show welcome screen for group.
 
- Store question ID in session.
 
- Redirect to /question/render
 
/question/render
 
- Show question, form action = /entry/addanswer
 
/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.
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.
This approach allows us to divide large complex controller(s) into smaller and easier to manage pieces.

Latest revision as of 14:01, 14 August 2012

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.

SurveyController

- Actions for creating and editing a survey.

GroupController

- Actions for creating and editing a group.

QuestionController

- Actions for creating and editing a question.

EntryController

- Responsible for managing the creation of new entries for surveys.

Example process for a 1-question-at-a-time survey:

/entry/create?sid=12345

- Initialize session.

- Store survey ID in session.

- Redirect to /survey/welcome

/survey/welcome

- If applicable show welcome screen.

- Store group ID in session.

- Redirect to /group/welcome

/group/welcome

- Show welcome screen for group.

- Store question ID in session.

- Redirect to /question/render

/question/render

- Show question, form action = /entry/addanswer

/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.