Re: Can CakePHP do what I need...

2008-11-12 Thread [EMAIL PROTECTED]

Sorry for the late reply. I've been running between meetings for a few
days.

Say that a Question has a field called "type".
In your model you could use that "key" to help in stats calculation
and even storage.
In your views you could select the correct element based on that key:

echo $this->element('form_'.$data['Question']['type'])

If you have a big if-else clause you can almost always do without it.
If you have some other data related to each type. Store it in an array
and call it like this:

$some_data = $this->type_data[$data['Question']['type']]

If you need to Store the answers in a different table for each type of
question:

$model_name = $data['Question']['type'];
$this->$model_name->findBySomething(...);


/Martin

On Nov 8, 1:00 am, pgraju <[EMAIL PROTECTED]> wrote:
> Thanks for the reply!
>
> "To choose the correct gui element, I would, in the view (not the
> controller), use the same logic that sets which type of question it is
> for the model side of things."
>
> I'm not sure what you mean by this, would I put in conditional steps
> in the view i.e
>
> if model_says textbox then
>       do textbox
> else if model_says scale_1_5 then
>       do scale_1_5
> else if
>       
>
> Would you set something like that up in the view?
>
> I might put together a tutorial on this as well if I can finally get
> it going :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can CakePHP do what I need...

2008-11-07 Thread pgraju

Thanks for the reply!

"To choose the correct gui element, I would, in the view (not the
controller), use the same logic that sets which type of question it is
for the model side of things."

I'm not sure what you mean by this, would I put in conditional steps
in the view i.e

if model_says textbox then
  do textbox
else if model_says scale_1_5 then
  do scale_1_5
else if
  

Would you set something like that up in the view?

I might put together a tutorial on this as well if I can finally get
it going :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can CakePHP do what I need...

2008-11-07 Thread teknoid

You could make a separate element for each question.
Each element would be rendered depending on where you are in the
steps.

You could do it with ajax, as well as what martin suggested and even
the way you had it planned.

In short, cakephp can certainly do what you need... the implementation
is up to you really.
"The best" way really depends on the specifics of your situation.

On Nov 7, 8:25 am, pgraju <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> To start off here is my idea:
>
> I want to build a survey application, users log in and answer (for
> example) 10 questions all on separate pages, if a user enters below
> their average an email is sent out. The 10 questions have all
> different responses i.e. Drop downs, 1-10 or 1-5 scales, Yes/No
> answers etc.
>
> I have been able to build my database model and have got the admin
> area scaffolding fine however I'm stuck on how I can now build this
> model into my views for the user to enter data.
>
> Would I set up my application to follow URLs i.e.:
>
> /questions/view/1/ - Question 1 - Yes/No question
> /questions/view/2/ - Question 2 - 1 - 5 radio button question
> etc.
>
> The question controllers works out what the type of response the
> question has and renders using elements appropriately... I think?
>
> This is the only way I can think of building this app's views and just
> wanted to see what other opinions/criticisms are on my method? Or if
> you have a better idea I would like to hear about it!
>
> Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Can CakePHP do what I need...

2008-11-07 Thread [EMAIL PROTECTED]

Hi pgraju,
I have a few quick suggestions and comments for you.

You probably have each question set to a certain type (free text, 1-5,
1-10, A B C...)?
To choose the correct gui element, I would, in the view (not the
controller), use the same logic that sets which type of question it is
for the model side of things. Or, you might want to look at something
like the Wizard component in the bakery. It is ideal for surveys as
well.

/Martin



On Nov 7, 2:25 pm, pgraju <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> To start off here is my idea:
>
> I want to build a survey application, users log in and answer (for
> example) 10 questions all on separate pages, if a user enters below
> their average an email is sent out. The 10 questions have all
> different responses i.e. Drop downs, 1-10 or 1-5 scales, Yes/No
> answers etc.
>
> I have been able to build my database model and have got the admin
> area scaffolding fine however I'm stuck on how I can now build this
> model into my views for the user to enter data.
>
> Would I set up my application to follow URLs i.e.:
>
> /questions/view/1/ - Question 1 - Yes/No question
> /questions/view/2/ - Question 2 - 1 - 5 radio button question
> etc.
>
> The question controllers works out what the type of response the
> question has and renders using elements appropriately... I think?
>
> This is the only way I can think of building this app's views and just
> wanted to see what other opinions/criticisms are on my method? Or if
> you have a better idea I would like to hear about it!
>
> Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Can CakePHP do what I need...

2008-11-07 Thread pgraju

Hi all,

To start off here is my idea:

I want to build a survey application, users log in and answer (for
example) 10 questions all on separate pages, if a user enters below
their average an email is sent out. The 10 questions have all
different responses i.e. Drop downs, 1-10 or 1-5 scales, Yes/No
answers etc.

I have been able to build my database model and have got the admin
area scaffolding fine however I'm stuck on how I can now build this
model into my views for the user to enter data.

Would I set up my application to follow URLs i.e.:

/questions/view/1/ - Question 1 - Yes/No question
/questions/view/2/ - Question 2 - 1 - 5 radio button question
etc.

The question controllers works out what the type of response the
question has and renders using elements appropriately... I think?

This is the only way I can think of building this app's views and just
wanted to see what other opinions/criticisms are on my method? Or if
you have a better idea I would like to hear about it!

Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---