From 035a7f9c443f4a1a29c4e1ecfcb09bc7fd8bd5b4 Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Fri, 10 May 2019 13:13:41 +0200 Subject: [PATCH] Cleaned up the courses list and added some more metrics. --- .../student_teams/MergeSingleTeams.java | 4 +++ .../model/Course.java | 15 +++++++++ src/main/resources/templates/courses.html | 33 ++++++++++--------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/main/java/nl/andrewlalis/teaching_assistant_assistant/controllers/courses/entity/student_teams/MergeSingleTeams.java b/src/main/java/nl/andrewlalis/teaching_assistant_assistant/controllers/courses/entity/student_teams/MergeSingleTeams.java index e7980e4..1d5ac35 100644 --- a/src/main/java/nl/andrewlalis/teaching_assistant_assistant/controllers/courses/entity/student_teams/MergeSingleTeams.java +++ b/src/main/java/nl/andrewlalis/teaching_assistant_assistant/controllers/courses/entity/student_teams/MergeSingleTeams.java @@ -15,6 +15,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +/** + * Controller for the action to merge all single teams in a course. + * TODO: Implement this functionality automatically. + */ @Controller public class MergeSingleTeams { diff --git a/src/main/java/nl/andrewlalis/teaching_assistant_assistant/model/Course.java b/src/main/java/nl/andrewlalis/teaching_assistant_assistant/model/Course.java index e22cf53..d1dfe0b 100644 --- a/src/main/java/nl/andrewlalis/teaching_assistant_assistant/model/Course.java +++ b/src/main/java/nl/andrewlalis/teaching_assistant_assistant/model/Course.java @@ -6,6 +6,7 @@ import nl.andrewlalis.teaching_assistant_assistant.model.people.Student; import nl.andrewlalis.teaching_assistant_assistant.model.people.TeachingAssistant; import nl.andrewlalis.teaching_assistant_assistant.model.people.teams.StudentTeam; import nl.andrewlalis.teaching_assistant_assistant.model.people.teams.TeachingAssistantTeam; +import nl.andrewlalis.teaching_assistant_assistant.model.people.teams.Team; import javax.persistence.*; import java.util.ArrayList; @@ -205,4 +206,18 @@ public class Course extends BasicEntity { } return sb.toString(); } + + public int getNumberOfStudentsInTeams() { + int sum = 0; + for (Student s : this.getStudents()) { + for (Team team : s.getTeams()) { + if (team.getCourse().equals(this)) { + sum++; + break; + } + } + } + + return sum; + } } diff --git a/src/main/resources/templates/courses.html b/src/main/resources/templates/courses.html index 42b41e7..a225f7a 100644 --- a/src/main/resources/templates/courses.html +++ b/src/main/resources/templates/courses.html @@ -6,22 +6,23 @@
- - - - - - - - - - - - - -
NameCodeCreated atStudents
- -
+

Courses

+
+ +