Trait Question

Source
pub trait Question {
    // Required methods
    fn get_name(&self) -> &str;
    fn get_description(&self) -> &str;
    fn set_text_format(&mut self, format: TextFormat);
    fn add_answers(&mut self, answers: Vec<Answer>) -> Result<(), QuizError>;
    fn to_xml(&self, writer: &mut EventWriter<&File>) -> Result<(), QuizError>;
}
Expand description

Common trait for all question types

Required Methods§

Source

fn get_name(&self) -> &str

Returns the name of the question>

Source

fn get_description(&self) -> &str

Returns the description of the question.

Source

fn set_text_format(&mut self, format: TextFormat)

Set the text rendering format TextFormat for the question.

Source

fn add_answers(&mut self, answers: Vec<Answer>) -> Result<(), QuizError>

Adds all answers from type Vec<Answer> to the Question variant type. May return an error if there is a problem with the fractions or count of answers.

Source

fn to_xml(&self, writer: &mut EventWriter<&File>) -> Result<(), QuizError>

Writes the question in XML format to the provided file descriptor.

Implementors§