- Posts: 3
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
Please Log in to join the conversation.
It would be great if you showed us which code you are talking about.recently I use a code that I found in the community of this forum
Please Log in to join the conversation.
' ----------------------------------------------------------------------- ' ESTABLECER CONEXIÓN Y DESCARGAR ENCUESTA ESPECÍFICA ' ----------------------------------------------------------------------- ' Con el siguiente código podemos establecer acceso por JSON-RCP a Lime Survey ' y utilizar códificador en Base64 para poder tratarlo con VBA para EXCEL ' ' SE NECESITA INTRODUCIR ID ENCUESTA DE FORMA MANUAL EN EL CÓDIGO ' ' Se utiliza diferentes módulos: ' VBA JSON tools: https://github.com/VBA-tools/VBA-JSON ' Base64 Deconding: https://www.vbforums.com/showthread.php?379072-VB-Fast-Base64-Encoding-and-Decoding&p=2539878&viewfull=1#post2539878 ' ' Para más documentación: ' https://www.limesurvey.org/community/forums/can-i-do-this-with-limesurvey/114846-export-answers-to-excel-in-semi-realtime ' Sub export_limesurvey() Dim key As String Dim 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 limeurl = "XXXXXX" limeuser = "XXXXXXX" limepass = "XXXXX" SurveyID = Worksheets("Hoja2").Range("A6").Value DocumentType = "csv" 'Limpiar página excel Cells.Clear 'Inicialización Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") URL = limeurl + "/admin/remotecontrol" objHTTP.Open "POST", URL, False objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" objHTTP.setRequestHeader "Content-type", "application/json" 'Establecer acceso (get_session_key) sendtext = "{""method"":""get_session_key"",""params"": [""" + limeuser + """,""" + limepass + """],""id"": 1}" objHTTP.Send (sendtext) jsonText = objHTTP.responseText Set jsonObject = JsonConverter.ParseJson(jsonText) key = jsonObject("result") 'Exportar respuestas (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") 'Codificar respuestas exportadas export64Decoded = Decode64(export64) 'Cerrar sesión sendtext = "{""method"":""release_session_key"",""params"": [""" + key + """],""id"": 1}" objHTTP.Send (sendtext) 'Divide las respuesta en varias líneas, de lo contrario, todo está en una celda s = export64Decoded i = 0 While Split(s, Chr(13) + Chr(10))(i) <> "" Cells(i + 1, 1) = Split(s, Chr(13) + Chr(10))(i) i = i + 1 Wend 'Conversión a CSV Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _ Semicolon:=True, Comma:=False, Space:=False, Other:=False, TrailingMinusNumbers:=True Cells.WrapText = False End Sub 'SI OCURRE ALGUN CAMBIO LLAMA LA FUNCIÓN... 'Private Sub Worksheet_Change(ByVal Target As Range) 'If Not Intersect(Target, Range("A1:Z10000")) Is Nothing Then 'Call copiar_celda 'End If 'End Sub
Please Log in to join the conversation.
export_responses(string $sSessionKey,integer $iSurveyID,string $sDocumentType,string $sLanguageCode = null,string $sCompletionStatus = 'all',string $sHeadingType = 'code',string $sResponseType = 'short',integer $iFromResponseID = null,integer $iToResponseID = null,array $aFields = null): array|string
$response = $myJSONRPCClient->export_responses( $sessionKey, $survey_id, 'json', // Document type : pdf,csv,xls,doc,json null, // Language code : null : default from survey 'all', // Stautus complete|incomplete|all null, // Heading : code|full|abbreviated : question text, default code null // answer : short|long , default : long );
$surveyResponses = $myJSONRPCClient->export_responses( $sessionKey, $survey_id, 'json', // Document type : pdf,csv,xls,doc,json null, // Language code : null : default from survey 'complete', // Stautus complete|incomplete|all NULL, // Heading : code|full|abbreviated : question text, default code NULL, // answer : short|long , default : long 1, // From Response ID 3000, // To Response ID ['id','token','submitdate','lastpage','interviewtime','email','159677X490time','159677X487time','159677X490X9219SQ001','159677X490X9221SQ001'] );
Please Log in to join the conversation.
'Exportar respuestas (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")
Please Log in to join the conversation.