R: Computing variables for routing

"Luca Notari" <[email protected]> Wed, 10 Oct 2007 21:07:18 +0200
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <003501c80b70$c71a2040$0400a8c0@asus01>
Hi all,

Again, it doesn't works;

The print instruction I've set at top of the  page reached:
print $session->getValue("SUBMITTED_sum") (sum is the new name of the
CONSTANT tag)
According the code below, always print 1 instead of the sum of
values.... :(
It seems that the instructions $session-setValue doesn't works into the
<submit> tag;
Again, the strange is that I've set value of 0 and not 1 in <CONSTANT>.

-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Joel
Palmius
Inviato: mercoled=EC 10 ottobre 2007 18.44
A: [email protected]
Oggetto: Re: survey-discussion-list: Computing variables for routing


Ok, this is just me speculating a bit. I'll test in a more=20
structured manner tomorrow if this doesn't solve your problem.

How about a) making a CONSTANT variable in the page with the matrix, b)=20
use the submit-time perl to modify the value of the CONSTANT, and c) use

an IFROUTE to determine where to go based on the value of the constant?

(completely untested code: )

<SURVEY TITLE=3D"hello">

   <MATRIX ... >

   <CONSTANT NAME=3D"dummy" VALUE=3D"0" />

   <SUBMIT>
     {|
       $val =3D $session->getValue("SUBMITTED_var1");
       $val +=3D $session->getValue("SUBMITTED_var2");
       $session->setValue("SUBMITTED_dummy",$val);
     |}
   </SUBMIT>

   <IFROUTE DEFAULT=3D"page1.survey">
     <IF THEN=3D"page2.survey">
       <MORETHAN VARIABLE=3D"dummy" VALUE=3D"10" />
     </IF>
   </IFROUTE>

</SURVEY>

I'm not sure in which order the session is updated and the submit perl
is=20
run. This might fail because the session hasn't been updated, but if I=20
remember right it might work.

   // Joel



On Wed, 10 Oct 2007, Luca Notari wrote:

> Hi all,
>
> Unfortunately I'm not able to resolve a problem when computing=20
> variables...
>
> This is the case:
>
> suppose a page with a Matrix tag; the respondent has to reach a score=20
> in order to decide where to go
>
> If the score <=3D10 go to page1.survey
> if > 10 go to page2
>
> I've uset the <SUBMIT> tag , and I need the SUM of variables
>
> Do I need another separate page for computing variables? Because this
> code:
> <SUBMIT>
> {|
> my($sum)=3D$session->getValue("SUBMITTED_var1") +
> $session->getVAlue("SUBMITTED_var2") ....
>
> if($sum<=3D10) $document->SetOption("CONTINUE","page1.survey")
> doesnt work
>
>
>
>
>
Skickat av Joel Palmius <[email protected]>
till survey-discussion


Skickat av "Luca Notari" <[email protected]>
till survey-discussion