Table of Contents

Class QuestionnaireController

Namespace
UI

The QuestionaireController provides the functionality to control the input field questions, reqular question and question lists. The input field question opens the keyboard and recives any given string input from the user. The regular question opens a question with up to four possible pre-defined awnsers. The question list opens a list with n possible items and continues when all right items were selected.

public class QuestionnaireController : MonoBehaviour
Inheritance
object
QuestionnaireController

Fields

ButtonBlueprint

Reference to the AnswerButtonPrefab.

public Button ButtonBlueprint

Field Value

Button

Set in inspector.

buttons

References to the Buttons

public List<Button> buttons

Field Value

List<Button>

Set in inspector.

correctAnswerColor

Color for correct answers.

public Color correctAnswerColor

Field Value

Color

Default set in inspector.

correctAnswerSound

Audioclip that is played when correct answer is pressed.

public AudioClip correctAnswerSound

Field Value

AudioClip

Default is set in inspector.

defaultUIColor

Color for unpressed buttons.

public Color defaultUIColor

Field Value

Color

Default set in inspector.

duration

How long it takes to fade in the UI.

public float duration

Field Value

float

Default is 1.0f seconds.

feedbackDuration

How long the feedback of a chosen answer stays open before the questionnaire continues on its own. Tapping the feedback or the question closes it earlier.

public float feedbackDuration

Field Value

float

Default is 5 seconds.

feedbackTimerBackgroundColor

Color of the not yet filled part of the feedback timer bar.

public Color feedbackTimerBackgroundColor

Field Value

Color

Default is a dark shade of the UI blue.

feedbackTimerColor

Color of the bar on top of the question that fills up while the feedback is open.

public Color feedbackTimerColor

Field Value

Color

Default is the light teal of the TrainAR logo.

feedbackTimerHeight

Height of the feedback timer bar in canvas units.

public float feedbackTimerHeight

Field Value

float

Default is 24.

inputFieldAnswerText

Reference to the inputFieldAnswerText.

public TextMeshProUGUI inputFieldAnswerText

Field Value

TextMeshProUGUI

Set in inspector.

inputFieldQuestionText

Reference to the inputFieldQuestionText.

public TextMeshProUGUI inputFieldQuestionText

Field Value

TextMeshProUGUI

Set in inspector.

inputFieldQuestionUI

Reference to the root gameObject of the inputFieldUI.

public GameObject inputFieldQuestionUI

Field Value

GameObject

Set in inspector.

questionList

Reference to the root of the question list UI.

public GameObject questionList

Field Value

GameObject

Set in inspector.

questionListQuestionText

Reference to the QuestionListText.

public TextMeshProUGUI questionListQuestionText

Field Value

TextMeshProUGUI

Set in inspector.

questionText

Reference to the questionText.

public TextMeshProUGUI questionText

Field Value

TextMeshProUGUI

Set in inspector.

questionTextUI

Reference to the questionText.

public GameObject questionTextUI

Field Value

GameObject

Set in inspector.

questionnaireUIRectTransform

Reference to the UIRectTransform.

public RectTransform questionnaireUIRectTransform

Field Value

RectTransform

Set in inspector.

regularQuestionUI

Reference to the root gameObject of the regularQuestionUI.

public GameObject regularQuestionUI

Field Value

GameObject

Set in inspector.

responseText

Reference to the ResponseText.

public GameObject responseText

Field Value

GameObject

Set in inspector.

rightAnswer

Stores right answers for endscreen UI.

public List<string> rightAnswer

Field Value

List<string>

Set on runtime.

wrongAnswerColor

Color for wrong answers.

public Color wrongAnswerColor

Field Value

Color

Default set in inspector.

wrongAnswerSound

Audioclip that is played when wrong answer is pressed.

public AudioClip wrongAnswerSound

Field Value

AudioClip

Default is set in inspector.

wrongAnsweredQuestions

Stores wrong answered questions for endscreen UI.

public List<string> wrongAnsweredQuestions

Field Value

List<string>

Set on runtime.

wrongAnswers

Stores wrong answers for endscreen UI.

public List<string> wrongAnswers

Field Value

List<string>

Set on runtime.

Methods

ContinueButtonOnClick()

Get's called when the continue button is pressed. When the chosen answer was correct, the statemachine gets notified. When the chosen answer was wrong, the question gets displayed again.

public void ContinueButtonOnClick()

InitInputfield(string)

Open the inputField question UI.

public void InitInputfield(string question)

Parameters

question string

Text of the question.

InitQuestion(string, List<Answer>)

Open the regular question UI.

public void InitQuestion(string question, List<QuestionnaireController.Answer> answers)

Parameters

question string

Text of the question.

answers List<QuestionnaireController.Answer>

List of all possible answers.

InitQuestionList(string, List<Answer>)

Open the questionList UI.

public void InitQuestionList(string question, List<QuestionnaireController.Answer> answers)

Parameters

question string

Text of the question.

answers List<QuestionnaireController.Answer>

List of all possbile answers.

NotifyStatemachine(string, QuestionUITypes)

Notify the statemachine with the result of the question UI.

public void NotifyStatemachine(string value, QuestionnaireController.QuestionUITypes type = QuestionUITypes.Question)

Parameters

value string

Result in text form.

type QuestionnaireController.QuestionUITypes

Type of question.

OnInputFieldSubmitted(string)

Receives TMP's Submit event (Return or the mobile keyboard's Done action). The raw model preserves exact answers, including an explicitly configured empty answer.

public void OnInputFieldSubmitted(string answer)

Parameters

answer string

QuestionInputValidate()

Submit the current input model from an explicit submit button or other caller. Do not connect this to End Edit, which also fires for cancellation and focus loss.

public void QuestionInputValidate()