assignmentlib/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
48
49
50
51
52
53
54
55
56
57
58
use common::enums::status::Status;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::enums::question_simplicity_type::QuestionSimplicityType;
use crate::enums::question_type::QuestionType;
use crate::jsonb::question_option_group::QuestionOptionGroup;

#[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 marking_comment: Option<String>,
    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 options_groups: Option<Vec<QuestionOptionGroup>>,
    pub description: Option<String>,
    pub banks: Option<Vec<Uuid>>,
    pub audio_path: Option<String>,
    pub copyright_license: Option<String>,
    pub copyright_author: Option<String>,
    pub status: Option<Status>,
    pub hint: Option<String>,
    pub tags: Option<Vec<String>>,
    pub name: 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.marking_comment == other.marking_comment;
        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 &= self.audio_path == other.audio_path;
        eq &= self.copyright_license == other.copyright_license;
        eq &= self.copyright_author == other.copyright_author;
        eq &= self.status == other.status;
        eq &= self.hint == other.hint;
        eq &= self.tags == other.tags;
        eq &= self.name == other.name;
        eq
    }
}