use crate::Question;
#[derive(Debug, Clone)]
pub struct SurveyDefinition {
pub prelude: Option<String>,
pub questions: Vec<Question>,
pub epilogue: Option<String>,
}
impl SurveyDefinition {
pub fn new(questions: Vec<Question>) -> Self {
Self {
prelude: None,
questions,
epilogue: None,
}
}
pub fn empty() -> Self {
Self {
prelude: None,
questions: Vec::new(),
epilogue: None,
}
}
pub fn with_prelude(mut self, prelude: impl Into<String>) -> Self {
self.prelude = Some(prelude.into());
self
}
pub fn with_epilogue(mut self, epilogue: impl Into<String>) -> Self {
self.epilogue = Some(epilogue.into());
self
}
pub fn questions(&self) -> &[Question] {
&self.questions
}
pub fn questions_mut(&mut self) -> &mut Vec<Question> {
&mut self.questions
}
pub fn is_empty(&self) -> bool {
self.questions.is_empty()
}
pub fn len(&self) -> usize {
self.questions.len()
}
}
impl Default for SurveyDefinition {
fn default() -> Self {
Self::empty()
}
}