Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::Forms::TextQuestion Class Reference

Abstract base class for questions with a single free-text response. More...

#include <mitkTextQuestion.h>

Inheritance diagram for mitk::Forms::TextQuestion:
Collaboration diagram for mitk::Forms::TextQuestion:

Public Member Functions

 ~TextQuestion () override
 Virtual destructor. More...
 
std::vector< std::string > GetResponsesAsStrings () const override
 Return the text response as a single-element vector. More...
 
void ClearResponses () override
 Clear the text response. More...
 
bool IsComplete () const override
 Check whether the response is non-empty. More...
 
std::string GetResponse () const
 Get the current text response. More...
 
void SetResponse (const std::string &response)
 Set the text response. More...
 
- Public Member Functions inherited from mitk::Forms::Question
 Question ()
 Default constructor. More...
 
virtual ~Question ()
 Virtual destructor. More...
 
std::string GetQuestionText () const
 Get the literal question text. More...
 
void SetQuestionText (const std::string &question)
 Set the literal question text. More...
 
bool IsRequired () const
 Check whether a response to this question is required to complete a form. More...
 
void SetRequired (bool required=true)
 Set whether a response to this question is required to complete a form. More...
 
virtual std::string GetRequiredText () const
 Get the text that should be displayed to clearly mark a question as required. More...
 
virtual bool HasFileResponses () const
 Query whether the responses given to this question are file paths. More...
 
virtual std::vector< fs::path > SubmitFileResponses (const fs::path &basePath) const
 Attach response files to submission. More...
 
virtual std::string GetType () const =0
 Return the type of a question as string, e.g. "Multiple choice" or "Drop-down". More...
 
virtual Question * CreateAnother () const =0
 Create a new instance of the derived question class type. More...
 
virtual void FromJSON (const nlohmann::ordered_json &j)=0
 Deserialize from JSON. More...
 
virtual void ToJSON (nlohmann::ordered_json &j) const =0
 Serialize to JSON. More...
 

Detailed Description

Abstract base class for questions with a single free-text response.

This intermediate class provides shared response storage and accessors for question types whose answer is a plain text string.

See also
ParagraphQuestion, ShortAnswerQuestion

Definition at line 27 of file mitkTextQuestion.h.

Constructor & Destructor Documentation

◆ ~TextQuestion()

mitk::Forms::TextQuestion::~TextQuestion ( )
override

Virtual destructor.

Member Function Documentation

◆ ClearResponses()

void mitk::Forms::TextQuestion::ClearResponses ( )
overridevirtual

Clear the text response.

Implements mitk::Forms::Question.

◆ GetResponse()

std::string mitk::Forms::TextQuestion::GetResponse ( ) const

Get the current text response.

Returns
The response string.

◆ GetResponsesAsStrings()

std::vector<std::string> mitk::Forms::TextQuestion::GetResponsesAsStrings ( ) const
overridevirtual

Return the text response as a single-element vector.

Returns
A vector containing exactly one string (which may be empty).

Implements mitk::Forms::Question.

◆ IsComplete()

bool mitk::Forms::TextQuestion::IsComplete ( ) const
overridevirtual

Check whether the response is non-empty.

Returns
true if the response string is not empty, false otherwise.

Implements mitk::Forms::Question.

◆ SetResponse()

void mitk::Forms::TextQuestion::SetResponse ( const std::string &  response)

Set the text response.

Parameters
[in]responseThe response string.

The documentation for this class was generated from the following file: