Cleaned up the courses list and added some more metrics.

This commit is contained in:
Andrew Lalis 2019-05-10 13:13:41 +02:00 committed by andrewlalis
parent ae2886fe63
commit 035a7f9c44
3 changed files with 36 additions and 16 deletions

View File

@ -15,6 +15,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
/**
* Controller for the action to merge all single teams in a course.
* TODO: Implement this functionality automatically.
*/
@Controller @Controller
public class MergeSingleTeams { public class MergeSingleTeams {

View File

@ -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.TeachingAssistant;
import nl.andrewlalis.teaching_assistant_assistant.model.people.teams.StudentTeam; 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.TeachingAssistantTeam;
import nl.andrewlalis.teaching_assistant_assistant.model.people.teams.Team;
import javax.persistence.*; import javax.persistence.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -205,4 +206,18 @@ public class Course extends BasicEntity {
} }
return sb.toString(); 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;
}
} }

View File

@ -6,22 +6,23 @@
<body> <body>
<div id="content"> <div id="content">
<table> <h1>Courses</h1>
<tr> <hr>
<th>Name</th>
<th>Code</th> <ul>
<th>Created at</th> <li th:each="course: ${courses}">
<th>Students</th> <h2><a th:href="@{/courses/{code}(code=${course.getCode()})}" th:text="${course.getName()}"></a></h2>
</tr> <ul>
<tr th:each="course: ${courses}"> <li>Code: <span th:text="${course.getCode()}"></span></li>
<td> <li>Created on: <span th:text="${course.getCreatedOn()}"></span></li>
<a th:href="@{/courses/{code}(code=${course.getCode()})}" th:text="${course.getName()}"></a> <li>Students: <span th:text="${course.getStudents().size()}"></span></li>
</td> <li>Teaching Assistants: <span th:text="${course.getTeachingAssistants().size()}"></span></li>
<td th:text="${course.getCode()}"></td> <li>Student Teams: <span th:text="${course.getStudentTeams().size()}"></span></li>
<td th:text="${course.getCreatedOn()}"></td> <li>Teaching Assistant Teams: <span th:text="${course.getTeachingAssistantTeams().size()}"></span></li>
<td th:text="${course.getStudents().size()}"></td> <li>Number of Active Students (in a team): <span th:text="${course.getNumberOfStudentsInTeams()}"></span></li>
</tr> </ul>
</table> </li>
</ul>
</div> </div>
<div id="sidebar"> <div id="sidebar">