Re: R: Computing variables for routing
Joel Palmius <[email protected]> Thu, 11 Oct 2007 14:58:56 +0200 (CEST)
| Newsgroups | gmane.comp.apache.mod-survey.general |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
---481066056-1811998207-1192107536=:12368
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE
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 $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
> structured manner tomorrow if this doesn't solve your problem.
>
> How about a) making a CONSTANT variable in the page with the matrix, b)
> 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
> run. This might fail because the session hasn't been updated, but 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
>> 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
>
---481066056-1811998207-1192107536=:12368--
Skickat av Joel Palmius <[email protected]>
till survey-discussion