-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} | ||
} | ||
} |