shared/domain/module/body/find_answer/
play_settings.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use serde::{Deserialize, Serialize};

/// Default limit for attempts a student can make on an answer before a trace
/// is highlighted.
pub const DEFAULT_ATTEMPTS_LIMIT: u32 = 3;

/// Play settings
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct PlaySettings {
    /// Question ordering
    pub ordering: Ordering,

    /// number of attempts
    pub n_attempts: Option<u32>,

    /// time limit in minutes
    pub time_limit: Option<u32>,
}

impl Default for PlaySettings {
    fn default() -> Self {
        Self {
            n_attempts: Some(DEFAULT_ATTEMPTS_LIMIT),
            ordering: Default::default(),
            time_limit: Default::default(),
        }
    }
}

/// Ordering of questions
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub enum Ordering {
    /// Questions should be randomized
    Randomize,

    /// Questions should be shown in order
    InOrder,
}

impl Default for Ordering {
    fn default() -> Self {
        Self::InOrder
    }
}