Skip to content

Commit 94fde1f

Browse files
committed
Flag attendance on wrong days
This makes it more clear when someone has e.g. submitted the register a week early or late. If people have submitted the same register more than once, we will use one arbitrary submission, rather than looking for the most correct in the list.
1 parent 0f172fd commit 94fde1f

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/course.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,9 @@ impl TraineeWithSubmissions {
334334
Attendance::Late { .. } => {
335335
numerator += 8;
336336
}
337+
Attendance::WrongDay { .. } => {
338+
numerator += 3;
339+
}
337340
Attendance::Absent { .. } => {}
338341
}
339342
}
@@ -382,7 +385,7 @@ impl TraineeWithSubmissions {
382385
Attendance::OnTime { .. } | Attendance::Late { .. } => {
383386
numerator += 1;
384387
}
385-
Attendance::Absent { .. } => {}
388+
Attendance::Absent { .. } | Attendance::WrongDay { .. } => {}
386389
}
387390
}
388391
}
@@ -435,6 +438,7 @@ impl Submission {
435438
Self::Attendance(Attendance::Absent { .. }) => String::from("Absent"),
436439
Self::Attendance(Attendance::OnTime { .. }) => String::from("On time"),
437440
Self::Attendance(Attendance::Late { .. }) => String::from("Late"),
441+
Self::Attendance(Attendance::WrongDay { .. }) => String::from("Wrong day"),
438442
Self::PullRequest { pull_request } => format!("#{}", pull_request.number),
439443
}
440444
}
@@ -452,6 +456,7 @@ pub enum Attendance {
452456
Absent { register_url: String },
453457
OnTime { register_url: String },
454458
Late { register_url: String },
459+
WrongDay { register_url: String },
455460
}
456461

457462
impl Attendance {
@@ -460,6 +465,7 @@ impl Attendance {
460465
Attendance::Absent { register_url } => &register_url,
461466
Attendance::OnTime { register_url } => &register_url,
462467
Attendance::Late { register_url } => &register_url,
468+
Attendance::WrongDay { register_url } => &register_url,
463469
}
464470
}
465471
}
@@ -649,7 +655,6 @@ fn get_trainee_module_attendance(
649655
.collect::<Vec<chrono::NaiveDate>>();
650656
let attendance = match dates.as_slice() {
651657
[date] => {
652-
// TODO: Handle Cape Town
653658
let start_time = DateTime::<Tz>::from_naive_utc_and_offset(
654659
NaiveDateTime::new(
655660
date.clone(),

src/frontend.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ impl TraineeBatchTemplate {
139139
Submission::Attendance(Attendance::Absent { .. }) => String::from("attendance-absent"),
140140
Submission::Attendance(Attendance::OnTime { .. }) => String::from("attendance-present"),
141141
Submission::Attendance(Attendance::Late { .. }) => String::from("attendance-late"),
142+
Submission::Attendance(Attendance::WrongDay { .. }) => String::from("attendance-wrong-day"),
142143
Submission::PullRequest { pull_request } => match pull_request.state {
143144
PrState::NeedsReview => "pr-needs-review".to_owned(),
144145
PrState::Reviewed => "pr-reviewed".to_owned(),

src/register.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub struct Attendance {
3535

3636
impl Attendance {
3737
pub fn to_attendance_enum(&self, start_time: DateTime<Utc>) -> crate::course::Attendance {
38+
if self.timestamp.date_naive() != start_time.date_naive() {
39+
return crate::course::Attendance::WrongDay { register_url: self.register_url.clone() };
40+
}
3841
let late_by = self.timestamp.signed_duration_since(start_time);
3942
if late_by.num_minutes() > 10 {
4043
crate::course::Attendance::Late {

templates/trainee-batch.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
td.attendance-late {
1515
background-color: #e6f4ae;
1616
}
17-
td.attendance-unknown {
17+
td.attendance-wrong-day {
1818
background-color: grey;
1919
}
2020
td.pr-missing {

0 commit comments

Comments
 (0)