Welcome, Guest
Username: Password: Remember me

TOPIC: Multiple choice quiz component possible to build?

Multiple choice quiz component possible to build? 11 Sep 2012 07:36 #3512

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
I was wondering...

I'm trying to create a sort of quiz component, where I'd like to have multiple choice as an option.
I can't seem to get my head around the DB design for such a task, and I'm wondering if Cook is even capable of creating such kind of a component?

I'm trying to create a component where I can display questions to the user like demo.mavrosxristoforos.com/a-simple-quiz

Thanks
Last Edit: 11 Sep 2012 07:45 by dyvel.
The administrator has disabled public write access.

Re: Multiple choice quiz component possible to build? 12 Sep 2012 20:16 #3548

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
N:N

Not possible yet.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: Multiple choice quiz component possible to build? 12 Sep 2012 20:33 #3549

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Of course you can realize it manually afterwards. Everithing can be prepared for it.
You create first your linking tables with Cook, I mean you create a table with 2 FK only, pointing to the 2 main tables to link.

And then, you must code inside your component, it require a medium level of programming.

I cannot exlain you clearly now, I hope you will receive some help from the users, or may wait a little bit for more explainations.

Here a road map :

- A html control send you ($_POST) and array of selected values. these values are the ids of the others items.

- You must know the id of the concerned current item to link, so it can work only AFTER that the item has been stored (created or updated)

- Once the storing of the main item form succeeds, you can continue the process, wich will consist to 'link' this current item to the other received ids from the other table (N:N)

- Create a function in the current model which recieve the arrays of values to link. for instance : $model->linkProducts($cids)

- This function in the model deals with SQL and does the job you should be able to write. It consist in writting in the linking table the id of the 2 items to link.

This functionality should be able to create, delete, or update every link. A very good exercice.

The whole process is called by the controller, in the save() function :
- First call the save() functionality of the model
- Second if it succeeds : Send the ids[] to your custom function for linking in the model.

A little bit of work, and this is the reason why it take time to integrate in Cook native.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.101 seconds

Get Started