Skip to content

Commit e9437ac

Browse files
committed
Show rough progress indications and counts
We will tune these, or may remove them, but they're maybe useful indicators.
1 parent 6b06bf3 commit e9437ac

4 files changed

Lines changed: 80 additions & 11 deletions

File tree

src/course.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,26 @@ pub struct TraineeWithSubmissions {
316316
pub modules: IndexMap<String, ModuleWithSubmissions>,
317317
}
318318

319+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize)]
320+
pub enum TraineeStatus {
321+
OnTrack,
322+
Behind,
323+
AtRisk,
324+
}
325+
319326
impl TraineeWithSubmissions {
327+
pub fn status(&self) -> TraineeStatus {
328+
let progress_score = self.progress_score();
329+
// These thresholds are super arbitrary.
330+
if progress_score >= 5000 {
331+
TraineeStatus::OnTrack
332+
} else if progress_score >= 2500 {
333+
TraineeStatus::Behind
334+
} else {
335+
TraineeStatus::AtRisk
336+
}
337+
}
338+
320339
// This whole calculation is super ad-hoc, we should feel free to tweak this whole process and these parameters however we find useful.
321340
pub fn progress_score(&self) -> u64 {
322341
let mut numerator = 0_u64;

src/frontend.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
config::CourseScheduleWithRegisterSheetId,
1717
course::{
1818
fetch_batch_metadata, get_batch, Attendance, Batch, BatchMetadata, Course, Submission,
19+
TraineeStatus,
1920
},
2021
google_groups::{get_groups, groups_client, GoogleGroup},
2122
octocrab::octocrab,
@@ -135,7 +136,7 @@ struct TraineeBatchTemplate {
135136
}
136137

137138
impl TraineeBatchTemplate {
138-
fn css_classes(&self, submission: &Submission) -> String {
139+
fn css_classes_for_submission(&self, submission: &Submission) -> String {
139140
match submission {
140141
Submission::Attendance(Attendance::Absent { .. }) => String::from("attendance-absent"),
141142
Submission::Attendance(Attendance::OnTime { .. }) => String::from("attendance-present"),
@@ -151,6 +152,32 @@ impl TraineeBatchTemplate {
151152
},
152153
}
153154
}
155+
156+
fn css_classes_for_trainee_status(&self, trainee_status: &TraineeStatus) -> String {
157+
match trainee_status {
158+
TraineeStatus::OnTrack => "trainee-on-track",
159+
TraineeStatus::Behind => "trainee-behind",
160+
TraineeStatus::AtRisk => "trainee-at-risk",
161+
}
162+
.to_owned()
163+
}
164+
165+
fn on_track_and_total_for_region(&self, region: Option<&str>) -> (usize, usize) {
166+
let mut on_track = 0;
167+
let mut total = 0;
168+
for trainee in &self.batch.trainees {
169+
if let Some(region) = region {
170+
if trainee.region.as_str() != region {
171+
continue;
172+
}
173+
}
174+
if trainee.status() == TraineeStatus::OnTrack {
175+
on_track += 1;
176+
}
177+
total += 1;
178+
}
179+
(on_track, total)
180+
}
154181
}
155182

156183
#[derive(Deserialize)]

src/newtypes.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ impl Region {
4343
chrono_tz::Europe::London
4444
}
4545
}
46+
47+
pub fn as_str(&self) -> &str {
48+
self.0.as_str()
49+
}
4650
}

templates/trainee-batch.html

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
<html>
33
<head>
44
<style type="text/css">
5+
:root {
6+
--green: #adf7c7;
7+
--orange: #f8bca3;
8+
--red: #ffaaaa;
9+
}
510
th, td {
611
border: 1px black solid;
712
background-color: white;
813
}
914
td.attendance-absent {
10-
background-color: #ff0d0d57;
15+
background-color: var(--red);
1116
}
1217
td.attendance-present {
13-
background-color: rgba(68, 238, 142, 0.5);
18+
background-color: var(--green);
1419
}
1520
td.attendance-late {
1621
background-color: #e6f4ae;
@@ -19,21 +24,33 @@
1924
background-color: grey;
2025
}
2126
td.pr-missing {
22-
background-color: #ff0d0d57;
27+
background-color: var(--red);
2328
}
2429
td.pr-complete {
25-
background-color: rgba(68, 238, 142, 0.5);
30+
background-color: var(--green);
2631
}
2732
td.pr-reviewed {
28-
background-color: #ee784480;
33+
background-color: var(--orange);
2934
}
3035
td.pr-needs-review {
31-
background-color: #ee784480;
36+
background-color: var(--orange);
3237
}
3338
td.pr-unknown {
3439
background-color: grey;
3540
}
3641

42+
.trainee-on-track {
43+
background-color: var(--green);
44+
}
45+
46+
.trainee-behind {
47+
background-color: var(--orange);
48+
}
49+
50+
.trainee-at-risk {
51+
background-color: var(--red);
52+
}
53+
3754
table {
3855
border-spacing: 0px;
3956
}
@@ -57,9 +74,11 @@
5774
</head>
5875
<body>
5976
<h1>{{ course.name }} - {{ batch.name }}</h1>
60-
<button id="regions-filter-all">All Regions</button>
77+
{% set (global_on_track, global_total) = on_track_and_total_for_region(None) %}
78+
<button id="regions-filter-all">All Regions ({{ global_on_track }} / {{ global_total }})</button>
6179
{% for region in batch.all_regions() %}
62-
<input type="checkbox" checked="checked" name="region-checkbox" value="{{ region }}" /> {{ region }}
80+
{% set (on_track, total) = on_track_and_total_for_region(Some(region.as_str())) %}
81+
<input type="checkbox" checked="checked" name="region-checkbox" value="{{ region }}" /> {{ region }} ({{ on_track }} / {{ total }})
6382
{% endfor %}
6483
<button id="regions-filter-none">No Regions</button>
6584
<table>
@@ -95,14 +114,14 @@ <h1>{{ course.name }} - {{ batch.name }}</h1>
95114
<tbody>
96115
{% for trainee in batch.trainees %}
97116
<tr>
98-
<th>{{ trainee.name }} - <a href="https://github.com/{{trainee.github_login}}">@{{ trainee.github_login }}</a> - {{ trainee.email }}</th>
117+
<th class="{{ css_classes_for_trainee_status(&trainee.status()) }}">{{ trainee.name }} - <a href="https://github.com/{{trainee.github_login}}">@{{ trainee.github_login }}</a> - {{ trainee.email }} - {{ trainee.progress_score() / 100 }}%</th>
99118
<td>{{ trainee.region }}</td>
100119
{% for (module_name, module) in trainee.modules %}
101120
{% for sprint in module.sprints %}
102121
{% for submission in sprint.submissions %}
103122
{% match submission %}
104123
{% when crate::course::SubmissionState::Some(submission) %}
105-
<td class="{{ css_classes(submission) }}"><a href="{{ submission.link() }}">{{ submission.display_text() }}</a></td>
124+
<td class="{{ css_classes_for_submission(submission) }}"><a href="{{ submission.link() }}">{{ submission.display_text() }}</a></td>
106125
{% when crate::course::SubmissionState::MissingButExpected(_) %}
107126
<td class="pr-missing"></td>
108127
{% when crate::course::SubmissionState::MissingButNotExpected(_) %}

0 commit comments

Comments
 (0)