Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Suggestions for a web survey framework

by Anonymous Monk
on Oct 16, 2009 at 16:08 UTC ( #801583=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm tasked with building a web survey with some dynamic elements and I want to build it in Perl, or at least a prototype. I have no experience in web development in Perl so I'm in a fresh position to learn a toolkit. However I'm not asking the usual question of which one is the "best," I simply need one that can best help me do my task with minimal "rolling my own."

The web survey elements are what you'd expect - unique, persistent sessions and standard form-based question types. The content and type of some questions will be dictated by previous answers.

Thanks, I appreciate any advice.

Comment on Suggestions for a web survey framework
Re: Suggestions for a web survey framework
by stonecolddevin (Vicar) on Oct 16, 2009 at 18:29 UTC

    Personally, I'd recommend a simple app in Catalyst.  I actually have some code lying around I put together a small voting app with.

     

    It's pretty easy.  You could get most of the CRUD out of the way with Catalyst and an ORM of your choice, and focus on the business logic, ie. survey tallies, statistics, etc.

    mtfnpy

      Is Catalyst really worth learning just to make a simple web survey? I'm probably looking for a more shallow learning curve, unless there's a compelling argument that it's both easy to learn and easy to code.

        If this is the only Web application you'll ever write, then it's a good question. However, if you plan to write others in the future, then it's definitely worthwhile to find and learn a good tool to do the job rather than attempt to roll your own.

        ...roboticus

        Yup.

        Catalyst is dead easy. I mean, if you really want simple, go use one of those sites that create a survey for you and use that.

        But Catalyst will help you create code that's maintainable and scalable so you can reuse it over and over and add on as you please.

        mtfnpy

      Catalyst is the way to go.
Re: Suggestions for a web survey framework
by hangon (Deacon) on Oct 16, 2009 at 18:34 UTC

    Probably the best place to start is the CGI module, it should have everything your need for handling forms. The documentation is a bit long, but the learning curve is not bad. You also might want to check out the Tutorials on this site, particularly CGI Programming under the Web Programing category.

      I'm currently looking at CGI::Session to handle the sessions and simply doing the rest manually. Maybe this is in fact the best way to go.
Re: Suggestions for a web survey framework
by leocharre (Priest) on Oct 16, 2009 at 18:51 UTC

    Use CGI::Application with CGI::Application::Plugin::Session

    pseudocode...

    package MyApp; use base 'CGI::Application'; use CGI::Application::Plugin::Session; use CGI::Application::Plugin::AutoRunmode; sub setup { my $self = shift; $self->start_mode('home'); } # this method is a "runmode" a "screen view" if you will sub home : Runmode { my $self = shift; $self->have_basic_info or return $self->forward('basic_info'); ... } sub basic_info : Runmode { my $self = shift; return q{<form> name: <input name="name" value=""> <input type="hidden" name="rm" value="_basic_info_save"> ... }; } sub _basic_info_save : Runmode { my $self = shift; $self->query->param('name') or die('missing name'); $self->session->param('name' => $self->query->param('name') ); ... } # this method is not a runmode : sub have_basic_info { my $self = shift; # LOOK: you don't worry about instancing the session object, about +making # sure who it's for, etc etc-- you just freaking call self->session +() # and your object is there- cookies set.. the works- all for you! $self->session->param('name') ? 1 : 0; }

    And in your cgi-bin/myapp.cgi ...

    #!/usr/bin/perl use MyApp; my $app = MyApp->new; $app->run; # DONE

    There's a learning curve. But this is hands down the fastest way to do it, while doing it "right". CGI::Application and plugins do so much work for you that it's just hard to believe such few lines of code do so damn much.. as mentioned, you don't see there instancing of the session object, setting the cookie, retrieving it.. It's done *for* you. It's really very nice.

    And the code you're using has been tested retested debugged and redebugged by a legion of extremely talented people much wiser than you or I! :-)

    You can use the session object as is with defaults, or you can tweak it to all heck- timeout, expiry.. etc. Just like you would a CGI::Session object- which is what you get. The plugin manages that object.

    If you want to learn it as fast as possible, look up the docs to the mentioned modules, read it all top to bottom- and give it a try.

      This works too, minus the gruesome HTML in code bit :-)

      mtfnpy

      Excellent- thank you so much, this looks right and I like what I see from the plugins.
Re: Suggestions for a web survey framework
by Anonymous Monk on Oct 18, 2009 at 06:42 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://801583]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2014-08-27 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (247 votes), past polls