Questionnaire

Questionnaire

class octopus_sensing.questionnaire.questionnaire.Questionnaire(name: str, experiment_id: str, stimulus_id: str, title: str, width: int = 400, height: int = 200, output_path='output/self_report')[source]

Bases: gi.overrides.Gtk.Window

Creating a questionnaire using Gtk It has a Done button which by clicking on it, the answers will be saved and window will be destroyed

Parameters
  • name (str) – Questionnaire name

  • experiment_id (str) – The unique ID of the experiment

  • stimulus_id (str) – The unique ID of the stimulus

  • title (str) – Questionnaire title

  • width (int, default: 400) – The width of questionnaire window in pixel

  • height (int, default: 200) – The height of questionnaire window in pixel

  • output_path (str) – The output path for recording answers

Examples

Creating an opinion question, a text question and adding it to the questionnaire

>>> emotions = {"Happiness": 4, "Sadness": 6, "Neutral": 5, "Fear": 3, "Anger": 1}
>>> question_1 = OpinionQuestion("q1",
...                              "1- What emotion did you feel the most?",
...                              options=emotions,
...                              default_answer=5)
>>> question_2 = TextQuestion("q2",
...                           "1- Was your feelings positive or negative?",
...                           default_answer="Positive")
>>> questionnaire = Questionnaire("after_stimuli",
...                               "study01_p10",
...                               "stimuli00",
...                               "After Stimulus Questionnaire")
>>> questionnaire.add_questions([question_1, question_2])
add_question(question: octopus_sensing.questionnaire.question.Question) None[source]

Adds a question to the questionnaire

Parameters

Question (question) –

add_questions(questions: List[octopus_sensing.questionnaire.question.Question]) None[source]

Adds a list of questions to the questionnaire

Parameters

questions (List(Question)) – a list of questions

show() None[source]

Shows the questionnaire

Base question

class octopus_sensing.questionnaire.question.Question(id: str, text: str)[source]

Bases: object

The base class for creating questions using Gtk 3.0

Parameters
  • id (str) – A unique ID for the question

  • text (str) – The text of question

render(grid: gi.repository.Gtk.Grid, grid_row: int)[source]
get_answer()[source]

Text Question

class octopus_sensing.questionnaire.text_question.TextQuestion(id: str, text: str, default_answer: Union[int, str] = 0)[source]

Bases: octopus_sensing.questionnaire.question.Question

The class for creating text questions using Gtk 3.0

Parameters
  • id (str) – A unique ID for the question

  • text (str) – The text of question

  • default_answer (Union[int, str], default: 0) – The default answer

render(grid: gi.repository.Gtk.Grid, grid_row: int) int[source]

renders a question for adding to a questionnaire

Parameters
  • grid (Gtk.Grid) – a Gtk grid object that this question will be added to it

  • grid_row (int) – The row number of grid that the question will be added to it

Returns

row_counter – The grid’s row for adding the next object after adding this question

Return type

int

Examples

Creating a text question and adding it to the questionnaire

>>> question_1 = TextQuestion("q1",
...                           "1- What emotion did you feel the most?",
...                           default_answer="Happiness")
>>> questionnaire = Questionnaire("after_stimuli",
...                               "study01_p10",
...                               "stimuli00",
...                               "After Stimulus Questionnaire")
>>> questionnaire.add_question(question_1)
get_answer() Union[int, str][source]

Gets the answer

Returns

answer – answer

Return type

str or int

Opinion question

class octopus_sensing.questionnaire.opinion_question.Option(id: int, label: str = None, value: Any = None)[source]

Bases: object

The class for creating opinions

Parameters
  • id (int) – A unique ID for the opinion

  • label (str) – The text of opinion

  • value (Any) – The value of opinion

class octopus_sensing.questionnaire.opinion_question.OpinionQuestion(id: str, text: str, options: Union[dict, int], image_path: str = None, default_answer: int = 0)[source]

Bases: octopus_sensing.questionnaire.question.Question

The class for creating opinion questions using Gtk 3.0

Parameters
  • id (str) – A unique ID for the question

  • text (str) – The text of question

  • options (Union[dict, int]) –

  • image_path (str, default: None) – The path to an image which will be showed with the question.

default_answer: Union[int, str], default: 0

The default checked option

render(grid: gi.repository.Gtk.Grid, grid_row: int)[source]

renders a question for adding to a questionnaire

Parameters
  • grid (Gtk.Grid) – a Gtk grid object that this question will be added to it

  • grid_row (int) – The row number of grid that the question will be added to it

Returns

row_counter – The grid’s row for adding the next object after adding this question

Return type

int

Examples

Creating an opinion question and adding it to the questionnaire

>>> emotions = {"Happiness": 4, "Sadness": 6, "Neutral": 5, "Fear": 3, "Anger": 1}
>>> question_1 = OpinionQuestion("q1",
...                              "1- What emotion did you feel the most?",
...                              options=emotions,
...                              default_answer=5)
>>> questionnaire = Questionnaire("after_stimuli",
...                               "study01_p10",
...                               "stimuli00",
...                               "After Stimulus Questionnaire")
>>> questionnaire.add_questions([question_1])
get_answer() int[source]

Gets selected answer

Returns

answer – answer

Return type

int