Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitk::Forms::CheckboxesQuestion Class Reference

A Question whose possible responses are represented by checkboxes. More...

#include <mitkCheckboxesQuestion.h>

Inheritance diagram for mitk::Forms::CheckboxesQuestion:
Collaboration diagram for mitk::Forms::CheckboxesQuestion:

Public Member Functions

 ~CheckboxesQuestion () override
 
std::string GetType () const override
 Return the type of a question as string, e.g. "Multiple choice" or "Drop-down". More...
 
QuestionCreateAnother () const override
 Create a new instance of the derived question class type. More...
 
void FromJSON (const nlohmann::ordered_json &j) override
 Deserialize from JSON. More...
 
void ToJSON (nlohmann::ordered_json &j) const override
 Serialize to JSON. 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...
 
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...
 
- Public Member Functions inherited from mitk::Forms::QuestionWithOtherOption
 QuestionWithOtherOption ()
 
 ~QuestionWithOtherOption () override
 
std::vector< std::string > GetResponsesAsStrings () const override
 Return the question's response(s) as strings. More...
 
void ClearResponses () override
 Clear the/all response(s). More...
 
bool IsComplete () const override
 Check if a question is considered to be answered completely. More...
 
bool HasOtherOption () const
 Query whether this question actually has an "Other" option. More...
 
void EnableOtherOption ()
 Switch on the "Other" option. More...
 
- Public Member Functions inherited from mitk::Forms::QuestionWithOptions
 ~QuestionWithOptions () override
 
size_t AddOption (const std::string &option)
 Add a non-exclusive option as possible answer to the question. More...
 
std::vector< std::string > GetOptions () const
 
- Public Member Functions inherited from mitk::Forms::Question
 Question ()
 
virtual ~Question ()
 
std::string GetQuestionText () const
 Get the literal question. More...
 
void SetQuestionText (const std::string &question)
 Set the literal question. 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 resonse 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...
 

Additional Inherited Members

- Protected Member Functions inherited from mitk::Forms::QuestionWithOtherOption
void SetResponse (size_t i) override
 Set one of the possible answer options as the single 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...
 
- Protected Member Functions inherited from mitk::Forms::QuestionWithOptions
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...
 

Detailed Description

A Question whose possible responses are represented by checkboxes.

The question can have multiple responses at once, including an optional free text response.

See also
MultipleChoiceQuestion, DropdownQuestion

Definition at line 27 of file mitkCheckboxesQuestion.h.

Constructor & Destructor Documentation

◆ ~CheckboxesQuestion()

mitk::Forms::CheckboxesQuestion::~CheckboxesQuestion ( )
override

Member Function Documentation

◆ AddOtherResponse()

void mitk::Forms::QuestionWithOtherOption::AddOtherResponse

Add the free text given as "Other" option to the list of responses.

Note
A question can only have a single "Other" response. Consequtive calls to this method will override the previously set "Other" response.

◆ AddResponse()

void mitk::Forms::QuestionWithOptions::AddResponse

Add one of the possible answer options to the responses.

Indexes to responses are inserted in ascending order.

See also
AddOption()

◆ CreateAnother()

Question* mitk::Forms::CheckboxesQuestion::CreateAnother ( ) const
overridevirtual

Create a new instance of the derived question class type.

This method is mainly used by IQuestionFactory to create new instances from registered prototype instances based on a type string.

Question* RhetoricalQuestion::CreateAnother() const
{
return new RhetoricalQuestion;
}
See also
GetType()

Implements mitk::Forms::Question.

◆ FromJSON()

void mitk::Forms::CheckboxesQuestion::FromJSON ( const nlohmann::ordered_json &  j)
overridevirtual

Deserialize from JSON.

Polymorphism and the use of base class pointers make it necessary to implement serialization through member functions. Using the pure native approach of the "JSON for Modern C++" library via free functions would lead to partially serialized instances of derived classes.

The actual implementation can and should still be located in a corresponding from_json() free function but we also need the indirection through this member function.

void RhetoricalQuestion::FromJSON(const nlohmann::ordered_json& j)
{
from_json(j, *this);
}
See also
from_json(const nlohmann::ordered_json& j, Question& q)

Implements mitk::Forms::Question.

◆ GetType()

std::string mitk::Forms::CheckboxesQuestion::GetType ( ) const
overridevirtual

Return the type of a question as string, e.g. "Multiple choice" or "Drop-down".

This method is essential for the deserialization of questions into their correct type, resp. derived class. The type string is used by IQuestionFactory to look up a registered prototype instance of a certain type to create another instance of it.

The type string does not have to match the class name or follow any other convention except for it must be unique amongst all question types. Prefer natural language like in the examples above in case it is used in a user interface to display a question's type.

std::string RhetoricalQuestion::GetType() const
{
return "Rhetorical";
}
See also
CreateAnother()

Implements mitk::Forms::Question.

◆ RemoveOtherResponse()

void mitk::Forms::QuestionWithOtherOption::RemoveOtherResponse

Remove the "Other" response from the list of already given responses.

◆ RemoveResponse()

void mitk::Forms::QuestionWithOptions::RemoveResponse

Remove one of the already given responses.

See also
AddOption(), AddResponse()

◆ ToJSON()

void mitk::Forms::CheckboxesQuestion::ToJSON ( nlohmann::ordered_json &  j) const
overridevirtual

Serialize to JSON.

Polymorphism and the use of base class pointers make it necessary to implement serialization through member functions. Using the pure native approach of the "JSON for Modern C++" library via free functions would lead to partially serialized instances of derived classes.

The actual implementation can and should still be located in a corresponding to_json() free function but we also need the indirection through this member function.

void RhetoricalQuestion::ToJSON(nlohmann::ordered_json& j) const
{
to_json(j, *this);
}
See also
to_json(nlohmann::ordered_json& j, const Question& q)

Implements mitk::Forms::Question.


The documentation for this class was generated from the following file:
mitk::FromJSON
MITKCORE_EXPORT void FromJSON(const nlohmann::json &j, AffineTransform3D::Pointer transform)
Read transform from JSON array (16 elements, resp. 4x4 matrix).
mitk::Forms::to_json
MITKFORMS_EXPORT void to_json(nlohmann::ordered_json &j, const CheckboxesQuestion &q)
mitk::Forms::from_json
MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json &j, CheckboxesQuestion &q)
mitk::ToJSON
MITKCORE_EXPORT void ToJSON(nlohmann::json &j, AffineTransform3D::ConstPointer transform)
Write transform (4x4 matrix) as JSON array with 16 elements.
mitk::Forms::Question::Question
Question()