Linking your surveys to your protal.

Lots of users have the need to link their surveys to other systems or portals. In this article we discuss some of the things that you can do to get all this to work. We will look at linking surveys to particular people, how we can get their existing database information into the survey data and how we can have one link that can decide what surveys they should be running, reducing the need to continually change the link they click on. To answer the first question , how do we link the survey to a specific users portal , well that is easy , let’s assume they we know how to add the link to the portal and we just need to know the actual link to add. Let’s say that our survey is called Navigator and our basic link would be something like,

http://www.MySurvey.com/mrIWeb/mrIWeb.dll?I.Project=Navigator

so to get a specific user to answer a specific survey we need to provide the survey with an ID that represent this user. In your portal you would have assigned a number to the user so perhaps you could use this. All you need to do is to activate you survey with samplemangement and make sure that the ID of the sample table is the ID that comes from your system. When you have done this , and your users click on the link they will be presented with a default screen like this that you can customize to look however you like.

Login to survey

You might not want them to enter the ID or perhaps they don’t know the ID so you can pass it in via the url like this,

http://www.MySurvey.com/mrIWeb/mrIWeb.dll?I.Project=Navigator&i.ID=123ABC

by doing this they will get sent to the survey directly and you will have their id in the respondent data. If you wanted to store the users name into the survey data also , then you could upload the name with the ID in the sample file and then use the following script in your survey.

qName.response.value = IOM.SampleRecord["Name"].Value

So how do we take all this to the next level of having one link that perhaps takes people to different surveys perhaps dependent on the month or some sample field setting. Let’s take a look at the month option. Let’s say that every month we want our portal members to run a different survey. This is what the Navigator survey would look like this time,

Routing(Web)

Dim sProject,sLink

	Select Case month(now())

		Case is = 1 ' January
			sProject = "JanuaryProject"
		Case is = 2 ' February
			sProject = "FebruaryProject"
		Case is = 3 ' March
			sProject = "MarchProject"
		Case is = 4 ' April
			sProject = "AprilProject"

	End Select

	sLink = "http://www.MySurvey.com/mrIWeb/mrIWeb.dll?I.Project=" + sProject+ "&i.ID=" & IOM.Info.RespondentID
	IOM.Texts.EndOfInterview = ""
End Routing

Hopefully you can see that this Navigator survey is now , not really a survey , but a redirect that you can manage via IOM script. If we wanted to do the same sort of thing but get the next survey info from the sample , then all we have to do is have something like,

Routing(Web)

Dim sProject,sLink

	sProject = IOM.SampleRecord["NextSurveyID"].Value

	sLink = "http://www.MySurvey.com/mrIWeb/mrIWeb.dll?I.Project=" + sProject+ "&i.ID=" & IOM.Info.RespondentID
	IOM.Texts.EndOfInterview = ""
End Routing

Some of you might be thinking that this is all well and good having the navigator survey , but surely that means that you will end up with a survey that has lots of useless records in it. And yes you would be right, but we can get the Navigator survey to delete them. What you could do is say , at the beginning of your survey , delete all the records that are two days old. To do this you would have some code like this,

Routing(Web)

If ( IOM.Info.IsDebug = False ) Then
	    DeleteRecord("Navigator","192.168.145.128","\192.168.145.128SPSSMR_FMROOT")
	End If

 Dim sProject,sLink

	Select Case month(now())

		Case is = 1 ' January
			sProject = ""
		Case is = 2 ' February
			sProject = ""
		Case is = 3 ' March
			sProject = ""
		Case is = 4 ' April
			sProject = ""

	End Select

	sLink = "http://www.MySurvey.com/mrIWeb/mrIWeb.dll?I.Project=" + sProject+ "&i.ID=" & IOM.Info.RespondentID
	IOM.Texts.EndOfInterview = ""
Sub DeleteRecord(sSurvey,sSQLServer,sFMROOT)
    Dim oConnection, oRecordset

	' DELETE VDATA RECORD
	Set oConnection = CreateObject("ADODB.Connection")

	oConnection.ConnectionString = "Provider=mrOleDB.Provider.2;Data Source=mrRdbDsc2;Location=""Provider=SQLOLEDB.1;Data
Source=" + _
			sSQLServer + ";User ID=;Password=;Initial Catalog=" + sSurvey + _
			";Integrated Security=SSPI;Persist Security Info=False"";Initial Catalog=" + _
			sFMRoot + "Master" + sSurvey + "" + sSurvey + _
			".mdd;MR Init MDM Version={..};MR Init MDM DataSource Use=2;MR Init Category Names=1;MR Init Project=" +
sSurvey

	oConnection.Open()

	If ( oConnection.State = 1 ) Then

		Set oRecordset = CreateObject("ADODB.Recordset")

			oRecordset.Open("DELETE FROM VDATA WHERE DataCollection.StartTime < now()-2" ,oConnection,3,1)

		Set oRecordset = Null

	End If

	oConnection.Close()

	Set oConnection = Null

End Sub

End Routing

And there you have it a survey , that deletes old data and redirects you users to the next correct survey dependent on Sample or the day of the month.

Leave a Comment

%d bloggers like this: