Re: R: problem with perl snippets

Joel Palmius <[email protected]> Fri, 30 Jun 2006 13:14:24 +0200 (CEST)
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <[email protected]>
I don't see what's wrong right now. We have run a survey with this 
approach (although not exactly the same snippet code I think) at my univ 
without having problems. I'll mail the survey files to you separately in 
the hope that you can see how they can be used.

   // Joel

On Wed, 28 Jun 2006, luca wrote:

> I don't know if there's something that i do wrong...
> I put explicit reset of session values at top of the page but... For me
> Works only if I do a force refresh in my browser (shift + f5);
> otherwise, route goes exactly to the last page (pageBak of the example,
> p7.survey of my code).
> Maybe instructions of saving data are not good?
> This is code of my last page:
> <SURVEY TITLE="title" CHECKKEY="yes" SUBMITTEXT="Avanti"
> CLEARTEXT="Cancella" THEME="external" STYLESHEET="style.css"
> REDIRECT="yes" CONTINUE="okpost.html">
> <TEXT CAPTION="p7 survey" NAME="q17"/>
> <SEQUENCE>
> <FILE FILENAME="p1.survey"/>
> <FILE FILENAME="pval01.survey"/>
> <FILE FILENAME="pval05.survey"/>
> <FILE FILENAME="pval06.survey"/>
> <FILE FILENAME="pval07.survey"/>
> <FILE FILENAME="pval08.survey"/>
> <FILE FILENAME="p7.survey"/>
> </SEQUENCE>
> </SURVEY>
>
> I ever use this code and I have all data right.
>
>
> -----Messaggio originale-----
> Da: [email protected]
> [mailto:[email protected]] Per conto di Joel
> Palmius
> Inviato: martedì 27 giugno 2006 19.18
> A: [email protected]
> Oggetto: Re: survey-discussion-list: problem with perl snippets
>
>
> 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
>
>
> Skickat av "luca" <[email protected]>
> till survey-discussion
>