Hi
Just wanted to say thank you to everyone who assisted in solving my
problem with using custom templates (forms) with phpESP. After many,
many hours and lots of hair pulling the solution turned out to be far
simplier than we thought.
BACKGROUND
Because phpESP doesn't handle question branching, and also just
because the writers of this survey were super wordy; there were a
number of reasons why the auto-generated survey from phpESP would not
be suitable as the final survey. So, I had naively assumed, I could
extract each section page, reformat it as needed, then submit data
back to phpESP and have it handle all the other processing.
It sounded simple enough, but the reality took four different minds
over 60hrs, and was leading us down the path off practically recoding
the system, for a single survey. Not good.
SOLUTION
After throwing out a number of solutions, happenstance landed me on
this one, which works pretty well, though it does have one glitch.
Basically, the solution involves creating an html include for each
page of the survey. The include code starts after the form headers,
and ends before the submission buttons. This code has everything
formatted as we want it (multiple questions grouped, reorder, field
and textbox size modifications, etcc.)
Use the /survey.php file so that you can format everything besides the
form. Remember to include the handler-prefix.php and handler.php
include calls; as specified by phpESP.
Inside /css a new class called "hidden" was created, set to display:
none; . Inside /public/handler.php line 158
<?php=09survey_render($sid,$HTTP_POST_VARS['sec'],$msg); ?>
was changed to <div
class=3D"hidden"><?php=09survey_render($sid,$HTTP_POST_VARS['sec'],$msg);
?></div>.
Then additional code was added to call the various forms. Either an
if/else or case statement would have worked, we used the if/else. For
each form the code required the field values and the form name, like
below:
[CODE]
else if ($sec=3D=3D"2") {
=09$formhtml =3D file_get_contents('http://nahic.ucsf.edu/phpESP/public/for=
m2.html');
=09echo replace_values($formhtml, get_values(42,55));
=09}
[/CODE]
The key turned out to be, DO NOT BYPASS the rendoring engine. Once we
allowed survey_render to process per normal all the other features
kicked back in.
GLITCH
The one glitch in this hack is that although login, save, resume and
submit all work properly now, when resuming, the duplicate/formatted
form DOES NOT display data. If you view code, you'll see the data
values are there in the hidden form, just not the formatted one. I'm
still working on that issue. But otherwise everything else, that I've
tested works.
So if anyone else runs into this issue on a tough survey, hopefully my
hours upon hours of struggle will be to your benefit. Also, if your
running more than one survey simultaneously, duplicate the survey.php
and handler.php files, then rename them. That way your adjustments
don't effect other surveys.
DEMO
See it in action at http://nahic.ucsf.edu/phpESP/survey.php login
Wisconsin no password.
THANKS!!!
|