SurveyToGo support two main methods of working with images:
- Adding images to the script during design and displaying those during an interview
- Capturing images on field
But what if you want to combine both? This article will show you how you can capture images during the interview and use them later by displaying it in the interview's questions/answers.
Using Attachment source
Attachment source is a mechanism that allows you to handle attachments dynamically during an interview. An attachment source generates a list of the attachments you want to use then later that list can be associated with a specific question. To create an attachment source go to the survey's Advanced tab -> Edit Attachments Sources:
Using the GetAttachedFiles function
This function returns an array of strings where each string indicates the detailed path of an attachment that was captured during the interview. This way you can access and use an attachment during runtime.
In the sample survey we created, you'll see this function is used in the attachment sources codes.
Displaying captured image in a question's body
You can display a captured attachment inside a question's body, by using an attachment source and associate it to the question, following these steps:
- Create the needed attachment source: In the attached sample survey below, you'll see 3 attachment sources:
"dynamicPicture": This attachment source get all the paths of the attachments that were already captured, and add those to the list. In this case, when associating this list to the needed question, all attachments that were added to the list will be displayed in the question.
"dynamicIndex" : This attachment source adds a single attachment to the list, according to a specific index. In our example, attachment that is placed in index 2 of the strings array is being added to the list.
"dynamicName": This attachment source adds a single attachment to the list, according to its name, assuming such name was generated for a captured attachment (you can determine file names for captured attachments through script – click here to learn more about it).
Each attachment source above is used for different purposes, all depends on what you need.
- Associate the attachment source to the question: In order to use the attachment source in the question, go to the question's Advanced tab, and choose the wanted attachment source for the "AttachmentSource" property:
Displaying captured images as question's answers
To display images as answers is very similar to the way to display images in a question's body as explained above. The only difference is that you choose the wanted attachment source for the "AnswerAttachmentSource" property:
In this case, all attachments that were added to the list in the attachment source will be displayed, one attachment for each answer, according to the order of the attachments in the list (the first attachment for the first answer and so on…).
The sample survey demonstrates all different systems to use attachment sources and display captured images as described above.
Click here to learn how you can import an external survey into your studio.
Please sign in to leave a comment.