Skip to content

Commit

Permalink
korjailua
Browse files Browse the repository at this point in the history
  • Loading branch information
PootisHunter committed Aug 7, 2024
2 parents d9b3821 + 8adf090 commit bff94b1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
29 changes: 25 additions & 4 deletions src/build_process.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
//File for initializing the build process
use crate::config::CourseConfiguration;
<<<<<<< HEAD
use crate::flag_gen;
use std::error::Error;
=======
use crate::flag_generator;
>>>>>>> 8adf09037a0c502713d8069b84007c541e15c2fb

pub fn identify_flag_types_for_task(
course_config: CourseConfiguration,
Expand All @@ -12,8 +16,8 @@ pub fn identify_flag_types_for_task(
if week.number == week_number {
for task in week.tasks.iter() {
if task.id == task_id {
if task.subtasks.is_some() {
for subtask in task.subtasks.iter() {
if let Some(subtasks) = &task.subtasks {
for subtask in subtasks.iter() {
for flag_type in task.flag_types.iter() {
if flag_type.id == subtask.id {
subtask.flag_type = flag_type;
Expand All @@ -32,8 +36,8 @@ pub fn identify_flag_types_for_week(course_config: CourseConfiguration, week_num
for week in course_config.weeks.iter() {
if week.number == week_number {
for task in week.tasks.iter() {
if task.subtasks.is_some() {
for subtask in task.subtasks.iter() {
if let Some(subtasks) = &task.subtasks {
for subtask in subtasks.iter() {
for flag_type in task.flag_types.iter() {
if flag_type.id == subtask.id {
subtask.flag_type = flag_type;
Expand All @@ -48,16 +52,33 @@ pub fn identify_flag_types_for_week(course_config: CourseConfiguration, week_num
}

pub fn identify_all_flag_types(course_config: CourseConfiguration) {
<<<<<<< HEAD
for (i, week) in course_config.weeks.iter().enumerate() {
if week.tasks[i].subtasks.is_some() {
for (j, subtask) in week.tasks[i].subtasks.iter().enumerate() {
for flag_type in week.tasks[i].flag_types.iter() {
if flag_type.id == subtask[j].id {
subtask[j].flag_type = flag_type;
break;
=======
for week in course_config.weeks.iter() {
for task in week.tasks.iter() {
if let Some(subtasks) = &task.subtasks {
for subtask in subtasks.iter() {
for flag_type in task.flag_types.iter() {
if flag_type.id == subtask.id {
subtask.flag_type = flag_type;
break;
}
>>>>>>> 8adf09037a0c502713d8069b84007c541e15c2fb
}
}
}
}
<<<<<<< HEAD
}
}
=======
}
}
>>>>>>> 8adf09037a0c502713d8069b84007c541e15c2fb
10 changes: 6 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct Tasks {
pub name: String,
pub description: String,
pub points: f32,
pub flags: Vec<FlagConfig>,
pub flag_types: Vec<FlagConfig>,
pub subtasks: Option<Vec<SubTask>>,
pub build: WeeksTasksBuild,
}
Expand All @@ -98,7 +98,7 @@ impl Tasks {
name: String,
description: String,
points: f32,
flags: Vec<FlagConfig>,
flag_types: Vec<FlagConfig>,
subtasks: Option<Vec<SubTask>>,
build: WeeksTasksBuild,
) -> Tasks {
Expand All @@ -107,7 +107,7 @@ impl Tasks {
name,
description,
points,
flags,
flag_types,
subtasks,
build,
}
Expand All @@ -131,15 +131,17 @@ pub struct SubTask {
pub name: String,
pub description: String,
pub subpoints: f32,
pub flag_type: FlagConfig,
}

impl SubTask {
pub fn new(id: String, name: String, description: String, subpoints: f32) -> SubTask {
pub fn new(id: String, name: String, description: String, subpoints: f32, flag_type: FlagConfig) -> SubTask {
SubTask {
id,
name,
description,
subpoints,
flag_type,
}
}
}
Expand Down

0 comments on commit bff94b1

Please sign in to comment.