Re: Computing variables for routing
Joel Palmius <[email protected]> Wed, 10 Oct 2007 18:44:01 +0200 (CEST)
| Newsgroups | gmane.comp.apache.mod-survey.general |
|---|---|
| Message-ID | <[email protected]> |
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="hello">
<MATRIX ... >
<CONSTANT NAME="dummy" VALUE="0" />
<SUBMIT>
{|
$val = $session->getValue("SUBMITTED_var1");
$val += $session->getValue("SUBMITTED_var2");
$session->setValue("SUBMITTED_dummy",$val);
|}
</SUBMIT>
<IFROUTE DEFAULT="page1.survey">
<IF THEN="page2.survey">
<MORETHAN VARIABLE="dummy" VALUE="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 <=10 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)=$session->getValue("SUBMITTED_var1") +
> $session->getVAlue("SUBMITTED_var2") ....
>
> if($sum<=10) $document->SetOption("CONTINUE","page1.survey")
> doesnt work
>
>
>
>
>
Skickat av Joel Palmius <[email protected]>
till survey-discussion