problem with perl snippets
"Luca Notari" <[email protected]> Tue, 27 Jun 2006 19:01:04 +0200
| Newsgroups | gmane.comp.apache.mod-survey.general |
|---|---|
| Organization | The Marketing Lab |
| Message-ID | <[email protected]> |
Hi all,
some time ago Joel wrote an e-mail with subject: survey-discussion-list:
Interesting use of snippets
in which one can choose some options, and have questions only regarding this
options.
In my opinion this is a very smart perl-based solution, that avoids use of a
complicated sequence of ifroute in a multipaging survey.
I've implemented this in a survey, but experienced this problem:
the first time i run the survey, all is ok; the second time, it seems that
code that populates the array of the pages to be viewed doesn't work;
this code:
{&
$thispage = "per";
if(!$session->getValue($thispage))
{
@tosee = ();
for($i = 1; $i <= 40; $i++)
{
$n = "" . $i;
if($i < 10) { $n = "0$n"; }
$subm = $session->getValue("SUBMITTED_kont$n");
if($subm eq "1")
{
push(@tosee,"pageFunk$n.survey");
}
}
push(@tosee,"pageBak.survey");
$lst = join(';',@tosee);
$session->setValue("tosee",$lst);
}
&}
Creates the array and puts in a session variable;
And this code:
<ROUTE CONTINUE="{&
$thispage = "per";
if(!$session->getValue($thispage))
{
$tosee = $session->getValue("tosee");
@pags = split(";",$tosee);
$next = splice(@pags,0,1);
if(!$next) { $next = "pageBak.survey"; }
print $next;
$lst = join(';',@pags);
$session->setValue($thispage,$next);
$session->setValue("tosee",$lst);
}
else
{
print $session->getValue($thispage);
}
&}" />
Routes in the first page available in the array.
I placed this 2 pieces of code in the same page, the page which contains the
list of choices.
The second time i run the survey (as i was another respondent, but from the
same machine) it seems that $next contains only "pageBak.survey";
Is the code "$next = splice(@pags,0,1);
if(!$next) { $next = "pageBak.survey";" right?
What I have to write into $thispage? I write the name of the document in
which this code is "mypage.survey", but doesn't work;
I've tried many times, but result is that only works for 1 time. So, I've
returned in using ifroute in each page.
What's my fault?
Many thanks
Luca Notari
Skickat av "Luca Notari" <[email protected]>
till survey-discussion