Support Forums

We encourage an open exchange of information. Ask your questions or make suggestions. We are here to help, but we also encourage all of you to help one another.
Click on the Subscribe Flag to be notified by email of replies to your post.
Current User: Guest Login Register
Please consider registering

Help with Scripting

Add a New Topic Reply to Post
UserPost

8:13
July 28, 2008


Experimentus

Member

London, UK

posts 47

I know you SG guys are busy with a new version, but perhaps some of the lovely community people could help me with my first ever bit of scripting??!

I’m not even sure if this is possible, but:

I have a very basic survey; 4 pages containing 3 or 4 radio button questions each.

All questions score the same; 0,2,4,6 or NA

Here’s what I want to try and do:

1. Count number of Questions on page and set as a variable (QP)

2. Set Maximum page value (MV) varialble (QP*6)

3. Count scores from questions - ignoring NA answers

4. Divide the total score for the page by the number of answers that weren’t NA

5. Calculate the score as a percentage of the total possible

Firstly, can this even be done? Secondly, please can someone help me get started??

6:08
July 30, 2008


Mario

Moderator

Boulder, CO

posts 610

1) You would have to set this manually at this time such as:
%%page1 == 7;
2) %%mpv == %%page1 * 6;
3) You would be doing an if statement such as:
if (sgapiGetValue(%%ident) != ‘NA’){
%%count = sgapiGetValue(%%ident) + %%count;
%%notnacount == %%notnacount+1;
}
This is adding the totals together if the value is not NA and also adding 1 to the variable that counts the number of not NA questions
4) %%score = %%count / %%notnacount;
5) %%percent = %%score / %%mpv * 100;

Fair warning, I’m not the custom scripting expert at SG, so all mistakes are completely intentionally and my fault. ;) In some cases, it’s best to just start playing with it after creating a ‘test’ survey of 1 or 2 pages.

3:45
July 31, 2008


Experimentus

Member

London, UK

posts 47

That’s fantastic, Thanks Mario.

I’ll give it a go today….

Add a New Topic Reply to Post


Reply to Topic: Help with Scripting

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 1 + 2        (Required)

Topic Reply:


 
© Simple:Press Forum - Version 3.1.4 (Build 357)