Please help us help you and fill where relevant:
LimeSurvey version: [6.13]
Own server or LimeSurvey Cloud:Cloud
Survey theme/template:Twenty Three
==================
Here is the script for data export through API from Lime survey but when we run that for Single choice it shows only coded format data but i need it label format along with header of Question with question number along with its labeling
Function Decode64(base64String As String) As String
Dim xml As Object
Dim bytes() As Byte
Dim result As String
Set xml = CreateObject("MSXML2.DOMDocument")
Dim element As Object
Set element = xml.createElement("base64")
element.DataType = "bin.base64"
element.Text = base64String
bytes = element.nodeTypedValue
result = StrConv(bytes, vbUnicode)
Decode64 = result
End Function
Sub Export_LimeSurvey()
Dim key As String, limeuser As String, limepass As String, limeurl As String, URL As String
Dim jsonText As String, jsonObject As Object
Dim SurveyID As String, DocumentType As String
Dim export64 As String, export64Decoded As String
Dim objHTTP As Object, sendtext As String
limeurl = "
livesurvey.limesurvey.net/
"
limeuser = "xxxx"
limepass = "xxxxx"
SurveyID = "855297"
DocumentType = "csv"
Cells.Clear
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = limeurl + "/admin/remotecontrol"
' Step 1: Get session key
sendtext = "{""method"":""get_session_key"", ""params"": [""" & limeuser & """, """ & limepass & """],""id"": 1}"
With objHTTP
.Open "POST", URL, False
.setRequestHeader "User-Agent", "Mozilla/4.0"
.setRequestHeader "Content-type", "application/json"
.Send sendtext
jsonText = .responseText
End With
Set jsonObject = JsonConverter.ParseJson(jsonText)
key = jsonObject("result")
' Step 2: Export responses
sendtext = "{""method"":""export_responses"", ""params"": [""" & key & """, """ & SurveyID & """, """ & DocumentType & """],""id"": 1}"
objHTTP.Send sendtext
jsonText = objHTTP.responseText
Set jsonObject = JsonConverter.ParseJson(jsonText)
export64 = jsonObject("result")
' Step 3: Decode base64
export64Decoded = Decode64(export64)
' Step 4: Release session key
sendtext = "{""method"":""release_session_key"", ""params"": [""" & key & """],""id"": 1}"
objHTTP.Send sendtext
' Step 5: Write to Excel
Dim lines() As String
lines = Split(export64Decoded, vbCrLf)
Dim i As Integer
For i = LBound(lines) To UBound(lines)
Cells(i + 1, 1).Value = lines(i)
Next i
' Step 6: Convert to CSV columns
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, Comma:=True
Cells.WrapText = False
End Sub
Please make necessary change in the script as per my need