[dancer-users] Designing a route for a long survey
Richard Reina
gatorreina at gmail.com
Sat Feb 20 16:06:25 EST 2021
Hello Gert,
Thank you very much for the reply. I will try to make use of it.
El mié, 17 feb 2021 a las 2:48, Gert van Oss (<gertvanoss at me.com>) escribió:
> Something like this?
> You can get lost in the ‘IF, AND, OR’ stuff but it could be a start.
> Gert
>
> package App;
> use Dancer2;
> use Data::Dumper;
>
> get '/' => sub {
> return <<'HTML';
> <form action="/q-1" method="GET">
> <p>Did you ever drink coffee?</p>
> <input type="text" name="coffee">
> <p>What is your age?</p>
> <input type="text" name="age">
> <input type="submit">
> </form>
> HTML
> };
>
> get '/q-1' => sub {
> my %FIELD;
> my @field_names = qw(coffee age);
> foreach my $field_name (@field_names) {
> if ( defined param("$field_name") ) {
> $FIELD{$field_name} = param("$field_name");
> }
> }
>
> print Dumper \%FIELD;
> if ( $FIELD{'coffee'} eq "yes" && $FIELD{'age'} >= 16 ) {
>
> # redirect '/more-questions';
> redirect '/bike';
> }
> else {
> redirect '/other-questions';
> }
> if ( $FIELD{'age'} > 16 ) {
> redirect '/bike';
> }
> };
>
> get '/more-questions' => sub {
> return "More questions";
> };
> get '/other-questions' => sub {
> return "Other questions";
> };
> get '/bike' => sub {
> return "In my country you may ride a scooter though it is better to
> bike!";
> };
> App->to_app;
>
>
>
>
>
> On 16 Feb 2021, at 00:26, Richard Reina <gatorreina at gmail.com> wrote:
>
> I have a friend who needs me to develop a page which is a long survey,
> There is some skip logic needed, for example, if users birthday is before x
> date skip to question 5, if answer to question 12 is 'no' skip to question
> 16, but nothing too complicated. I nevertheless am struggling with how to
> design such a route and was wondering if anyone perhaps knew of any similar
> examples.
>
> Rciahrd
> _______________________________________________
> dancer-users mailing list
> dancer-users at lists.preshweb.co.uk
> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at lists.preshweb.co.uk
> https://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20210220/ddf40b7f/attachment.htm>
More information about the dancer-users
mailing list