Module, Widget Or Seperate Controllers?


I’m currently working on a site which allows students to make tests. These tests have a ‘ready’, ‘start’ and ‘finish’ page and there are 3 types of tests (‘intake’, ‘normal’, and ‘final’). A lot of the functionality of these different kind of tests overlap. Each type of test has its own table, its own questions (intakequestions, normal questions and end questions) and results.

Currently I have implemented them as seperate controllers, but this is getting unhandy scalability-wise. What would be the best approach from a high level point of view?

I’m thinking about this:

TestModule with ready, start and finish actions (+ functions)

ResultModule with different views (results/group, results/user, results/test)

QuestionWidget to generate the questions of the Tests?

Not exactly sure what you are trying to do but here are some thoughts. As a standard 1.1.x, single enter website I might look at the following:


TestController -> extends components/controller: This contains the common functionality

intake/normal/finalController -> That which is different :)

ResultController -> I don’t think you need a WHOLE module for this, but I could be wrong.

QuestionWidget works for taking the test.

Now all of that depends on the database/table structures, how the system is to be used, how many users, how many tests, etc, etc, etc.

Let me know if this doesn’t make sense.

Thank you for your reply. The idea for using a general TestController makes sense. Could you describe when it would be better to make a TestModule over a general TestController with intake/normal/finalController?

And what would be included in the CreateTestModule?

Edit: The different Tests do also use common views (which have an overlap of about 90%). I feel like module is more logical then, or am I totally wrong about that?

I an fairly new to all of this too, but here are my thoughts.

I think a module comes in when you may need to use the same functionality in another app. Modules, from what I’ve read, are basically a web app in and of themselves. I have also seen a tutorial (somewhere) that talks about making a standard WebApp into a module, so if later you need this testing app on another site then…

You ‘common views’ comment leads me to think a controller would be a better idea also. In the views folder you could have numerous sub views that all relate to testing. You could make an entry view that then calls renerPartial() all the other parts (see update/create in the skeleton app). I am working on a site that has users login info in 1 table and profile info in another.

To view thier info, the controller sets up the $models, and calls render(‘view’, array(…)). The view.php file:

<h1>Viewing Profile</h1>

<h2>Login Information</h2>

<?php $this->renderPartial('_viewUser', array('userModel'=>$userModel)); ?>

<h2>Profile Information</h2>

<?php $this->renderPartial('_viewProfile', array('profileModel'=>$profileModel)); ?>

Then is _viewUser.php I have the information to display user login information. In _profileView.php I have the profile information displayed. This is kind of like how Yii handles the layouts.

Hope this helps :)

Alright, that is very clear.

I don’t intend to use it in another site, so then Controller it is.

Thank you both for your explanation, you have been a great help :)