R: R: Computing variables for routing

"Luca Notari" <[email protected]> Thu, 11 Oct 2007 15:33:25 +0200
Newsgroups gmane.comp.apache.mod-survey.general
Message-ID <000801c80c0b$4cf446b0$0400a8c0@asus01>
Now is working;
Many thanks Joel, in the meanwhile I've putted a page between the start
page and the destination page, in which the user has to click a button
to proceed.

In that page, this is my ROUTE TAG code:
<ROUTE CONTINUE=3D"{&
my ($sumS1)=3D$session->getValue("SUBMITTED_S1a01")+
$session->getValue("SUBMITTED_S1ba01")+$session->getValue("SUBMITTED_S1c
01")+$session->getValue("SUBMITTED_S1d01")+$session->getValue("SUBMITTED
_S1e01")+$session->getValue("SUBMITTED_S1f01")+$session->getValue("SUBMI
TTED_S1g01");
if($sumS1 <=3D17){
print "p15.survey";
}
else{
print "p14.survey";
}
&}" />

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


Ok, got it working. You'll have to intercept the argument rather than
the=20
session to make it work. This works for me:

<SURVEY TITLE=3D"Hello">

   <LICKERT NAME=3D"var1" CAPTION=3D"var1" />
   <LICKERT NAME=3D"var2" CAPTION=3D"var2" />
   <LICKERT NAME=3D"var3" CAPTION=3D"var3" />
   <LICKERT NAME=3D"var4" CAPTION=3D"var4" />

   <ROUTE CONTINUE=3D"{&

   $val =3D $argument->ArgByName("var1") || "novalue";

   if($val eq "novalue")
   {
     print "default.survey";
   }
   else
   {
     $val +=3D $argument->ArgByName("var2");
     $val +=3D $argument->ArgByName("var3");
     $val +=3D $argument->ArgByName("var4");

     if($val > 5)
     {
       print "morethan5.survey";
     }
     else
     {
       print "lessthan5.survey";
     }
   }

   &}" />

</SURVEY>

Reason for first part of if() statement is so document parses even when
no=20
data has been submitted.

Hope this helps you.

   // Joel


On Wed, 10 Oct 2007, Luca Notari wrote:

> Hi all,
>
> Again, it doesn't works;
>
> The print instruction I've set at top of the  page reached: print=20
> $session->getValue("SUBMITTED_sum") (sum is the new name of the=20
> CONSTANT tag) According the code below, always print 1 instead of the=20
> 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=20
> 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 structured=20
> manner tomorrow if this doesn't solve your problem.
>
> How about a) making a CONSTANT variable in the page with the matrix,=20
> b) use the submit-time perl to modify the value of the CONSTANT, and=20
> c) use
>
> an IFROUTE to determine where to go based on the value of the=20
> 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 run. This might fail because the session hasn't been updated, but=20
> if I 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

>> 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
>


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