Re: problem with perl snippets

Joel Palmius <[email protected]> Tue, 27 Jun 2006 19:17:31 +0200 (CEST)
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
And do you actually submit data between the attempts? Sounds to me as if 
your old session remains, which is bad, since each new user is supposed to 
get a new session. A session is only deleted if a) 60 minutes has passed 
or b) data is successfully submitted.

If the session remains after having submitted data, then that's a bug.

A work-around would be to explicitly reset the session values in the 
first page:

{&
$session->setValue("tosee","");
$session->setValue("per","");
$session->setValue("pageFunk1.survey",""); # Ie, reset all page names
$session->setValue("pageFunk2.survey",""); # 
&}

I have not tested this, there might be a logical error I haven't thought 
about involved with resetting values.

   // Joel

On Tue, 27 Jun 2006, Luca Notari wrote:

> 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
>
Skickat av Joel Palmius <[email protected]>
till survey-discussion