[Solved] Custom script to select maximum value of 4 quiz scores


I have a survey with 4 quiz scores. Based on which score is highest, I want to present different content. Does anyone have an idea of how to build a custom script to select the highest quiz score and then display specific content?

I have never used pho before. Am I headed in the right direction? Thanks!


$a = [question(“quiz tally result”), id=”#”] ;
$b = [question(“quiz tally result”), id=”#”] ;
$c = [question(“quiz tally result”), id=”#”] ;
$d = [question(“quiz tally result”), id=”#”] ;

echo $a;
echo “<br>”;
echo $b;
echo “<br>”;
echo $c;
echo “<br>”;
echo $d;

echo(max($a,$b,$c,$d) . “<br>”);



sg asked

    Best answer



    You are heading in the right direction by learning PHP syntax, and I think your best next step will be to become familiar with the list of available functions in the Custom Scripting documentation. Custom Scripting is based upon PHP, but only subset of functions are available. There is also some great information to be had on the homepage of the Custom Scripting help site (such as, variables begin with %% in Custom Scripting, instead of $ as normal in PHP).


    To answer your question, you’ll want to use the “get value” function (sgapiGetValue) to fetch the quiz scores. After determining which score is highest, you might either assign some content directly to the %%output variable (see the intro on the Custom Scripting help site for more about this variable), or store the highest-scoring quiz name in a field somewhere, and then use Logic in the Build tab to trigger some content to show based upon that.

    I hope this information helps!

    Nathan - Survey Astronaut answered


      Question stats

      • Active
      • Views294 times
      • Answers1 answer
      • Followers0 followers