testlib/dto/
question_request.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
45
46
47
use serde::{Deserialize, Serialize};
use uuid::Uuid;

use crate::enums::question_type::QuestionType;
use crate::jsonb::question_option::QuestionOption;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct QuestionRequest {
    pub id: Option<Uuid>,
    #[serde(rename = "question")]
    pub question_body: String,
    pub value: f32,
    pub ver: Option<i32>,
    pub correct_answer: Option<String>,
    pub q_order: Option<i32>,
    pub marking_comment: Option<String>,
    pub test: Option<Uuid>,
    pub picture_path: Option<String>,
    pub video_path: Option<String>,
    pub file_path: Option<String>,
    #[serde(rename = "type")]
    pub question_type: QuestionType,
    pub options: Option<Vec<QuestionOption>>,
    pub description: Option<String>,
}

impl QuestionRequest {
    pub fn equal(&self, other: &QuestionRequest) -> bool {
        let mut eq = true;
        eq &= self.id == other.id;
        eq &= self.question_body == other.question_body;
        eq &= self.value == other.value;
        eq &= self.ver == other.ver;
        eq &= self.correct_answer == other.correct_answer;
        eq &= self.q_order == other.q_order;
        eq &= self.marking_comment == other.marking_comment;
        eq &= self.test == other.test;
        eq &= self.picture_path == other.picture_path;
        eq &= self.video_path == other.video_path;
        eq &= self.file_path == other.file_path;
        eq &= self.question_type == other.question_type;
        eq &= self.options == other.options;
        eq &= self.description == other.description;
        eq
    }
}