Base class for questions with options that may also have a free text option.
More...
#include <mitkQuestionWithOtherOption.h>
|
| void | SetResponse (size_t i) override |
| | Set a regular option as the single response and clear any "Other" response. More...
|
| |
| void | AddOtherResponse (const std::string &response) |
| | Add the free text given as "Other" option to the list of responses. More...
|
| |
| void | RemoveOtherResponse () |
| | Remove the "Other" response from the list of already given responses. More...
|
| |
| void | SetOtherResponse (const std::string &response) |
| | Set the "Other" response as single exclusive response to this question. More...
|
| |
| void | AddResponse (size_t i) |
| | Add one of the possible answer options to the responses. More...
|
| |
| void | RemoveResponse (size_t i) |
| | Remove one of the already given responses. More...
|
| |
Base class for questions with options that may also have a free text option.
This base class is an extension of QuestionWithOptions representing questions that may also have a free text option, typically labeled "Other" in forms/surveys.
Just like with QuestionWithOptions, depending on the exclusivity of the answer options, use using-declarations in derived classes to change the visibility of the respective protected member functions to public, i.e., SetOtherResponse() vs. AddOtherResponse() and RemoveOtherResponse().
Definition at line 31 of file mitkQuestionWithOtherOption.h.
◆ QuestionWithOtherOption()
| mitk::Forms::QuestionWithOtherOption::QuestionWithOtherOption |
( |
| ) |
|
Constructor.
Initializes the question without an "Other" option.
◆ ~QuestionWithOtherOption()
| mitk::Forms::QuestionWithOtherOption::~QuestionWithOtherOption |
( |
| ) |
|
|
override |
◆ AddOtherResponse()
| void mitk::Forms::QuestionWithOtherOption::AddOtherResponse |
( |
const std::string & |
response | ) |
|
|
protected |
Add the free text given as "Other" option to the list of responses.
- Parameters
-
| [in] | response | The free text response. |
- Precondition
- HasOtherOption() must return
true.
- Exceptions
-
- Note
- A question can only have a single "Other" response. Consecutive calls to this method will override the previously set "Other" response.
◆ ClearResponses()
| void mitk::Forms::QuestionWithOtherOption::ClearResponses |
( |
| ) |
|
|
overridevirtual |
◆ EnableOtherOption()
| void mitk::Forms::QuestionWithOtherOption::EnableOtherOption |
( |
| ) |
|
Switch on the "Other" option.
By default, a question does not have an "Other" option.
◆ GetResponsesAsStrings()
| std::vector<std::string> mitk::Forms::QuestionWithOtherOption::GetResponsesAsStrings |
( |
| ) |
const |
|
overridevirtual |
Return all selected responses as strings, including the "Other" response if set.
- Returns
- A vector of response strings. The "Other" response, if present, is appended after the regular option responses.
Reimplemented from mitk::Forms::QuestionWithOptions.
◆ HasOtherOption()
| bool mitk::Forms::QuestionWithOtherOption::HasOtherOption |
( |
| ) |
const |
Query whether this question actually has an "Other" option.
- Returns
true if the "Other" option has been enabled, false otherwise.
◆ IsComplete()
| bool mitk::Forms::QuestionWithOtherOption::IsComplete |
( |
| ) |
const |
|
overridevirtual |
Check whether at least one response (regular or "Other") has been given.
- Returns
true if at least one option is selected or the "Other" response is set.
Reimplemented from mitk::Forms::QuestionWithOptions.
◆ RemoveOtherResponse()
| void mitk::Forms::QuestionWithOtherOption::RemoveOtherResponse |
( |
| ) |
|
|
protected |
Remove the "Other" response from the list of already given responses.
◆ SetOtherResponse()
| void mitk::Forms::QuestionWithOtherOption::SetOtherResponse |
( |
const std::string & |
response | ) |
|
|
protected |
Set the "Other" response as single exclusive response to this question.
This clears any previously selected regular option responses and sets only the "Other" free text as the response.
- Parameters
-
| [in] | response | The free text response. |
- Precondition
- HasOtherOption() must return
true.
- Exceptions
-
◆ SetResponse()
| void mitk::Forms::QuestionWithOtherOption::SetResponse |
( |
size_t |
i | ) |
|
|
overrideprotectedvirtual |
Set a regular option as the single response and clear any "Other" response.
- Parameters
-
| [in] | i | The zero-based index of the option to set. |
Reimplemented from mitk::Forms::QuestionWithOptions.
The documentation for this class was generated from the following file: