SurveyResponse
The user's response to a single SurveyQuestion. Build one with SurveyResponse.newBuilder() and pass it to SurveyClient.record(question, response) (com.microblink.surveys, in the surveys module). It does not implement Parcelable.
Package: com.microblink.core
Declaration
class SurveyResponse(builder: SurveyResponse.Builder)
Quick Reference
Properties
| Property | Description |
|---|---|
answersSelected() | Selected answers of a multiple-choice question |
freeText() | Free-form text entered by the user |
Methods
| Method | Description |
|---|---|
newBuilder() | Creates a SurveyResponse.Builder |
Builder
// Multiple-choice question: positions in question.answers()
val choice = SurveyResponse.newBuilder()
.answersSelected(listOf(0, 2))
.build()
// Open-ended question
val text = SurveyResponse.newBuilder()
.freeText("Great service")
.build()
surveyClient.record(question, choice)
| Builder method | Description |
|---|---|
answersSelected(answersSelected: List<Int>) | Sets the selected answers as zero-based positions in the question's answers() list |
surveyAnswersSelected(answers: List<SurveyAnswer>) | Sets the selected answers from SurveyAnswer objects, storing each answer's serverId() rather than its position |
freeText(freeText: String) | Sets the text for an open-ended question |
build() | Creates the SurveyResponse |
SurveyClient reads answersSelected() as positions in question.answers(), both to route to the next question and to submit the answers. When you record responses with SurveyClient, use answersSelected(List<Int>) with zero-based positions. surveyAnswersSelected() stores server IDs, which SurveyClient would read as positions.
Properties
answersSelected()
fun answersSelected(): List<Int>?
The selected answers of a multiple-choice question, as set on the builder: zero-based positions in the question's answers() list when set with answersSelected(), or answer server IDs when set with surveyAnswersSelected(). null for an open-ended response.
freeText()
fun freeText(): String?
Free-form text entered by the user in response to an open-ended question.
Methods
newBuilder()
// Java static method
fun newBuilder(): SurveyResponse.Builder
Returns a new SurveyResponse.Builder. See Builder.