Skip to content

Commit

Permalink
Create config.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kemppis3 authored Jul 8, 2024
1 parent 989cdb6 commit c6f010b
Showing 1 changed file with 144 additions and 0 deletions.
144 changes: 144 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
use serde::{Deserialize, Serialize};
use std::fs;
use std::error::Error;
use uuid::Uuid;

#[derive(Deserialize)]
pub struct CourseConfiguration {
pub course_identifier: CourseIdentifier,
pub weeks: Vec<Weeks>,
pub tasks: Vec<WeeksTasks>,
pub taskbuild: Vec<WeeksTasksBuild>,
pub taskoutput: Vec<WeeksTasksOutput>,
}

impl CourseConfiguration {
pub fn new(course_identifier: CourseIdentifier, weeks: Vec<Weeks>, tasks: Vec<WeeksTasks>, taskbuild: Vec<WeeksTasksBuild>, taskoutput: Vec<WeeksTasksOutput>) -> CourseConfiguration {
CourseConfiguration {
course_identifier,
weeks,
tasks,
taskbuild,
taskoutput,
}
}
}

#[derive(Deserialize)]
pub struct CourseIdentifier {
//TODO:Change to UUID
pub identifier: String,
pub name: String,
pub description: String,
pub version: String,
}

impl CourseIdentifier {
pub fn new(identifier: String, name: String, description: String, version: String) -> CourseIdentifier {
CourseIdentifier {
identifier,
name,
description,
version,
}
}
}
#[derive(Deserialize)]
struct Weeks {
number: i32,
theme: String,
}

impl Weeks {
pub fn new(number: i32, theme: String) -> Weeks {
Weeks {
number,
theme,
}
}
}
#[derive(Deserialize)]
struct WeeksTasks {
id: String,
name: String,
description: String,
points: f32,
flags: Vec<Flag>,
subtasks: Vec<SubTask>,
}

impl WeeksTasks {
pub fn new(id: String, name: String, description: String, points: f32, flags: Vec<Flag>, subtasks: Vec<SubTask>) -> WeeksTasks {
WeeksTasks {
id,
name,
description,
points,
flags,
subtasks,
}
}
}
#[derive(Deserialize)]
struct Flag {
flag_type: String,
id: String,
}

impl Flag {
pub fn new(flag_type: String, id: String) -> Flag {
Flag {
flag_type,
id,
}
}
}

#[derive(Deserialize)]
struct SubTask {
id: String,
name: String,
description: String,
subpoints: f32,
}

impl SubTask {
pub fn new(id: String, name: String, description: String, subpoints: f32) -> SubTask {
SubTask {
id,
name,
description,
subpoints,
}
}
}
#[derive(Deserialize)]
struct WeeksTasksBuild {
directory: String,
entrypoint: String,
builder: String,
}

impl WeeksTasksBuild {
pub fn new(directory: String, entrypoint: String, builder: String) -> WeeksTasksBuild {
WeeksTasksBuild {
directory,
entrypoint,
builder,
}
}
}
#[derive(Deserialize)]
struct WeeksTasksOutput {
name: String,
output_type: String,
}

impl WeeksTasksOutput {
pub fn new(name: String, output_type: String) -> WeeksTasksOutput {
WeeksTasksOutput {
name,
output_type,
}
}
}

0 comments on commit c6f010b

Please sign in to comment.