Recently i notice that someone was searching on “Calculating Points”. In this article we will show you how this could be done. The example we will use is something similar to a panel system where you might get some points for completeing a survey, but the
could be used in any number of ways. We will assume at this stage that you already have the survey and the rules that you want to apply is for each section of the survey that the respondent completes they will get a certain number of points. We will give the respondent 25 points for starting the survey 50 points for completeing any section. At some stage we will need to decide where to store the points , but we will just adress the getting them first. So , what do we do first , well at the top of your survey declare a variable in the routing section that you will use to store the points in. Perhaps something like this,Dim iPointsTotalNext you just need to decide where they will get the rest of the points , so for us we said at the start , so add the following just before the first question is asked.
iPointsTotal = iPointsTotal + 25 Q1.ask()and then at the begining of each section in your survey.
' Section 1 iPointsTotal = iPointsTotal + 50 S1_Q1a.ask()We could , if we wanted to store the value of points in the survey, use a question to hold the value in. so something like this,
' Section 1 S1_Tot.response.value = 50 S1_Q1a.ask() ...... ' Section 2 S2_Tot.response.value = 50 S2_Q1a.ask()Then at the end of the survye we could add all the sections up and store the value in final question or variable perhaps something like this,
PointsTotal = S1_Tot + S2_TotSo Whatever method we have used thus far we might want to store the final results into the sample management table ( if there is one ) or perhaps an external database. Lets look at the first option. To store the result in the sample management table , we of course have to have a column available , lets say we do and it is called FinalTotal then all we need to do is use the IOM.Samplerecord command in our survey. We dont need any unique idenitfier as this has already been taken care of by the sample management process so we just need the following
,iom.SampleRecord["FinalTotal"] = PointsTotalIf however you need want to store the final sum in an external database then you just need to use odbc to connect to the database and update the required tabel. You of course will have to have a unique identifier , perhaps a user id , that will make sure that the points go to the right respondent. In this case lets assume the IOM.Info.RespondentID holds the identifer we need. The
that you would use will look something like this,Dim oConnection Set oConnection = CreateObject("ADODB.Connection") oConnection.ConnectionString = "" oConnection.Open() If ( oConnection.State = 1 ) Then oConnection.Execute("INSERT INTO TABLE SET FinalToTal = " + + " WHERE ID = " + IOM.Info.RespondentID) End If oConnection.Close()And there you have it some
that will help you score your respondets and store the information into the location you require. If this does not meet your exact needs or you have any questions then as allways leave a comment and i will try and help.