Added extra category subdivisions.

This commit is contained in:
neviyn 2018-10-16 14:48:36 +01:00
parent 73f1640515
commit 9c63c307ea
6 changed files with 143 additions and 72 deletions

View File

@ -92,8 +92,11 @@ class Controller {
whom = newObservation.whom, whom = newObservation.whom,
monitoring = overallScores[RatingCategory.MONITORING], monitoring = overallScores[RatingCategory.MONITORING],
conservatism = overallScores[RatingCategory.CONSERVATISM], conservatism = overallScores[RatingCategory.CONSERVATISM],
controlProcedural = overallScores[RatingCategory.CONTROL_PROCEDURAL],
control = overallScores[RatingCategory.CONTROL], control = overallScores[RatingCategory.CONTROL],
teamwork = overallScores[RatingCategory.TEAMWORK], teamworkCommunications = overallScores[RatingCategory.TEAMWORK_COMMUNICATIONS],
teamworkLeadership = overallScores[RatingCategory.TEAMWORK_LEADERSHIP],
teamworkWorkload = overallScores[RatingCategory.TEAMWORK_WORKLOAD],
knowledge = overallScores[RatingCategory.KNOWLEDGE], knowledge = overallScores[RatingCategory.KNOWLEDGE],
entries = newObservation.entries, entries = newObservation.entries,
tutors = tutors tutors = tutors
@ -152,12 +155,15 @@ class Controller {
if (data.isEmpty()) return ChartData(listOf(), listOf()) if (data.isEmpty()) return ChartData(listOf(), listOf())
val groupedData = data.asSequence().groupBy { it.date }.map { entry -> val groupedData = data.asSequence().groupBy { it.date }.map { entry ->
AverageData( AverageData(
entry.value.asSequence().mapNotNull { it.monitoring }.average(), monitoring = entry.value.asSequence().mapNotNull { it.monitoring }.average(),
entry.value.asSequence().mapNotNull { it.control }.average(), controlProcedural = entry.value.asSequence().mapNotNull { it.controlProcedural }.average(),
entry.value.asSequence().mapNotNull { it.conservatism }.average(), control = entry.value.asSequence().mapNotNull { it.control }.average(),
entry.value.asSequence().mapNotNull { it.teamwork }.average(), conservatism = entry.value.asSequence().mapNotNull { it.conservatism }.average(),
entry.value.asSequence().mapNotNull { it.knowledge }.average(), teamworkCommunications = entry.value.asSequence().mapNotNull { it.teamworkCommunications }.average(),
entry.key teamworkLeadership = entry.value.asSequence().mapNotNull { it.teamworkLeadership }.average(),
teamworkWorkload = entry.value.asSequence().mapNotNull { it.teamworkWorkload }.average(),
knowledge = entry.value.asSequence().mapNotNull { it.knowledge }.average(),
date = entry.key
) )
}.toList() }.toList()
val dates = groupedData.map { it.date.toString("yyyy-MM-dd") } val dates = groupedData.map { it.date.toString("yyyy-MM-dd") }
@ -165,9 +171,12 @@ class Controller {
labels = dates, labels = dates,
datasets = listOf( datasets = listOf(
ChartDataset("Monitoring", "#F90", groupedData.map { it.monitoring }), ChartDataset("Monitoring", "#F90", groupedData.map { it.monitoring }),
ChartDataset("Control Procedural", "#3F0", groupedData.map { it.controlProcedural }),
ChartDataset("Control", "#3F0", groupedData.map { it.control }), ChartDataset("Control", "#3F0", groupedData.map { it.control }),
ChartDataset("Conservatism", "#33F", groupedData.map { it.conservatism }), ChartDataset("Conservatism", "#33F", groupedData.map { it.conservatism }),
ChartDataset("Teamwork", "#FF0", groupedData.map { it.teamwork }), ChartDataset("Teamwork Communication", "#FF0", groupedData.map { it.teamworkCommunications }),
ChartDataset("Teamwork Leadership", "#FF0", groupedData.map { it.teamworkLeadership }),
ChartDataset("Teamwork Workload", "#FF0", groupedData.map { it.teamworkWorkload }),
ChartDataset("Knowledge", "#000", groupedData.map { it.knowledge }) ChartDataset("Knowledge", "#000", groupedData.map { it.knowledge })
) )
) )
@ -176,9 +185,12 @@ class Controller {
data class AverageData( data class AverageData(
val monitoring: Double, val monitoring: Double,
val controlProcedural: Double,
val control: Double, val control: Double,
val conservatism: Double, val conservatism: Double,
val teamwork: Double, val teamworkCommunications: Double,
val teamworkLeadership: Double,
val teamworkWorkload: Double,
val knowledge: Double, val knowledge: Double,
val date: LocalDate val date: LocalDate
) )

View File

@ -57,7 +57,7 @@ enum class TrainingType {
} }
enum class RatingCategory { enum class RatingCategory {
MONITORING, CONTROL, CONSERVATISM, TEAMWORK, KNOWLEDGE MONITORING, CONTROL_PROCEDURAL, CONTROL, CONSERVATISM, TEAMWORK_COMMUNICATIONS, TEAMWORK_LEADERSHIP, TEAMWORK_WORKLOAD, KNOWLEDGE
} }
/** /**
@ -81,9 +81,12 @@ data class Observation(
@Column(nullable = false) @Column(nullable = false)
val whom: String, val whom: String,
val monitoring: Double?, val monitoring: Double?,
val controlProcedural: Double?,
val control: Double?, val control: Double?,
val conservatism: Double?, val conservatism: Double?,
val teamwork: Double?, val teamworkCommunications: Double?,
val teamworkLeadership: Double?,
val teamworkWorkload: Double?,
val knowledge: Double?, val knowledge: Double?,
@ElementCollection @ElementCollection
val entries: List<Entry>, val entries: List<Entry>,

View File

@ -94,7 +94,7 @@ class ControllerTest {
doReturn(Optional.of(site)).`when`(siteRepository).findById(1) doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
doReturn(listOf(tutor)).`when`(tutorRepository).findAllById(listOf(1)) doReturn(listOf(tutor)).`when`(tutorRepository).findAllById(listOf(1))
val newData = NewObservation(1, TrainingType.INITIAL, "An Observation", "Group A", listOf(Entry(RatingCategory.MONITORING, 5, "", "")), listOf(1)) val newData = NewObservation(1, TrainingType.INITIAL, "An Observation", "Group A", listOf(Entry(RatingCategory.MONITORING, 5, "", "")), listOf(1))
val observation = Observation(1, site, LocalDate.now(), TrainingType.INITIAL, "An Observation", "Group A", 5.0, 5.0, 5.0, .05, 5.0, newData.entries, setOf(tutor)) val observation = Observation(1, site, LocalDate.now(), TrainingType.INITIAL, "An Observation", "Group A", 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, newData.entries, setOf(tutor))
doReturn(observation).`when`(observationRepository).save(ArgumentMatchers.any()) doReturn(observation).`when`(observationRepository).save(ArgumentMatchers.any())
val result = controller.addObservation(newData) val result = controller.addObservation(newData)
assertEquals(1L, result) assertEquals(1L, result)
@ -112,8 +112,9 @@ class ControllerTest {
val request = ObservationsRequest(1, null, "", LocalDate.now(), LocalDate.now()) val request = ObservationsRequest(1, null, "", LocalDate.now(), LocalDate.now())
val site = Site(1, "Area 51") val site = Site(1, "Area 51")
val observation = Observation(site = site, date = LocalDate.now(), val observation = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf()) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf())
doReturn(Optional.of(site)).`when`(siteRepository).findById(1) doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
doReturn(listOf(observation)) doReturn(listOf(observation))
.`when`(observationRepository).findBySiteAndDateBetween(site, LocalDate.now(), LocalDate.now()) .`when`(observationRepository).findBySiteAndDateBetween(site, LocalDate.now(), LocalDate.now())
@ -127,8 +128,9 @@ class ControllerTest {
val request = ObservationsRequest(1, null, "Group A", LocalDate.now(), LocalDate.now()) val request = ObservationsRequest(1, null, "Group A", LocalDate.now(), LocalDate.now())
val site = Site(1, "Area 51") val site = Site(1, "Area 51")
val observation = Observation(site = site, date = LocalDate.now(), val observation = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf()) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf())
doReturn(Optional.of(site)).`when`(siteRepository).findById(1) doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
doReturn(listOf(observation)) doReturn(listOf(observation))
.`when`(observationRepository).findBySiteAndWhomAndDateBetween(site, "Group A", LocalDate.now(), LocalDate.now()) .`when`(observationRepository).findBySiteAndWhomAndDateBetween(site, "Group A", LocalDate.now(), LocalDate.now())
@ -143,8 +145,9 @@ class ControllerTest {
val site = Site(1, "Area 51") val site = Site(1, "Area 51")
val tutor = Tutor(1, "Mr Unknown", site) val tutor = Tutor(1, "Mr Unknown", site)
val observation = Observation(site = site, date = LocalDate.now(), val observation = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1) doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1)
doReturn(listOf(observation)) doReturn(listOf(observation))
.`when`(observationRepository).findByTutorsAndDateBetween(tutor, LocalDate.now(), LocalDate.now()) .`when`(observationRepository).findByTutorsAndDateBetween(tutor, LocalDate.now(), LocalDate.now())
@ -159,8 +162,9 @@ class ControllerTest {
val site = Site(1, "Area 51") val site = Site(1, "Area 51")
val tutor = Tutor(1, "Mr Unknown", site) val tutor = Tutor(1, "Mr Unknown", site)
val observation = Observation(site = site, date = LocalDate.now(), val observation = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1) doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1)
doReturn(listOf(observation)) doReturn(listOf(observation))
.`when`(observationRepository).findByTutorsAndWhomAndDateBetween(tutor, "Group A", LocalDate.now(), LocalDate.now()) .`when`(observationRepository).findByTutorsAndWhomAndDateBetween(tutor, "Group A", LocalDate.now(), LocalDate.now())

View File

@ -50,17 +50,21 @@ class RepositoryTest {
val tutor = entityManager.persist(Tutor(name = "X", site = correctSite)) val tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite)) val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5), val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
val tooLate = Observation(site = correctSite, date = LocalDate.now().plusDays(5), val tooLate = Observation(site = correctSite, date = LocalDate.now().plusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
val wrongSite = Observation(site = incorrectSite, date = LocalDate.now(), val wrongSite = Observation(site = incorrectSite, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor2)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor2))
val justRight = Observation(site = correctSite, date = LocalDate.now(), val justRight = Observation(site = correctSite, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
entityManager.persist(tooEarly) entityManager.persist(tooEarly)
entityManager.persist(tooLate) entityManager.persist(tooLate)
entityManager.persist(wrongSite) entityManager.persist(wrongSite)
@ -77,20 +81,25 @@ class RepositoryTest {
val tutor = entityManager.persist(Tutor(name = "X", site = correctSite)) val tutor = entityManager.persist(Tutor(name = "X", site = correctSite))
val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite)) val tutor2 = entityManager.persist(Tutor(name = "N", site = incorrectSite))
val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5), val tooEarly = Observation(site = correctSite, date = LocalDate.now().minusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
val tooLate = Observation(site = correctSite, date = LocalDate.now().plusDays(5), val tooLate = Observation(site = correctSite, date = LocalDate.now().plusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
val wrongSite = Observation(site = incorrectSite, date = LocalDate.now(), val wrongSite = Observation(site = incorrectSite, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor2)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor2))
val justRight = Observation(site = correctSite, date = LocalDate.now(), val justRight = Observation(site = correctSite, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
val wrongWhom = Observation(site = correctSite, date = LocalDate.now(), val wrongWhom = Observation(site = correctSite, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G2", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G2", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor))
entityManager.persist(tooEarly) entityManager.persist(tooEarly)
entityManager.persist(tooLate) entityManager.persist(tooLate)
entityManager.persist(wrongSite) entityManager.persist(wrongSite)
@ -107,20 +116,25 @@ class RepositoryTest {
val correctTutor = entityManager.persist(Tutor(name = "X", site = site)) val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site)) val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
val tooEarly = Observation(site = site, date = LocalDate.now().minusDays(5), val tooEarly = Observation(site = site, date = LocalDate.now().minusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val tooLate = Observation(site = site, date = LocalDate.now().plusDays(5), val tooLate = Observation(site = site, date = LocalDate.now().plusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val wrongTutor = Observation(site = site, date = LocalDate.now(), val wrongTutor = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(incorrectTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(incorrectTutor))
val justRight = Observation(site = site, date = LocalDate.now(), val justRight = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val justRightMultipleTutors = Observation(site = site, date = LocalDate.now(), val justRightMultipleTutors = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor, incorrectTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor, incorrectTutor))
entityManager.persist(tooEarly) entityManager.persist(tooEarly)
entityManager.persist(tooLate) entityManager.persist(tooLate)
entityManager.persist(wrongTutor) entityManager.persist(wrongTutor)
@ -143,23 +157,29 @@ class RepositoryTest {
val correctTutor = entityManager.persist(Tutor(name = "X", site = site)) val correctTutor = entityManager.persist(Tutor(name = "X", site = site))
val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site)) val incorrectTutor = entityManager.persist(Tutor(name = "N", site = site))
val tooEarly = Observation(site = site, date = LocalDate.now().minusDays(5), val tooEarly = Observation(site = site, date = LocalDate.now().minusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val tooLate = Observation(site = site, date = LocalDate.now().plusDays(5), val tooLate = Observation(site = site, date = LocalDate.now().plusDays(5),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val wrongTutor = Observation(site = site, date = LocalDate.now(), val wrongTutor = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(incorrectTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(incorrectTutor))
val justRight = Observation(site = site, date = LocalDate.now(), val justRight = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val wrongGroup = Observation(site = site, date = LocalDate.now(), val wrongGroup = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G2", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G2", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor))
val justRightMultipleTutors = Observation(site = site, date = LocalDate.now(), val justRightMultipleTutors = Observation(site = site, date = LocalDate.now(),
type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, type = TrainingType.INITIAL, observed = "1", whom = "G1", monitoring = 5.0, controlProcedural = 3.0,
control = 4.0, conservatism = 3.0, teamwork = 2.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor, incorrectTutor)) control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(correctTutor, incorrectTutor))
entityManager.persist(tooEarly) entityManager.persist(tooEarly)
entityManager.persist(tooLate) entityManager.persist(tooLate)
entityManager.persist(wrongTutor) entityManager.persist(wrongTutor)

View File

@ -20,20 +20,38 @@
</b-row> </b-row>
<b-row align-v="center" class="sidebar-vert-padding"> <b-row align-v="center" class="sidebar-vert-padding">
<b-col class="centered-image"> <b-col class="centered-image">
<img src="../assets/Conservatism.svg" class="image-opacity"/> <img src="../assets/Control.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[2] }}</div> <div class="image-centered-text">{{ totals[2] }}</div>
</b-col> </b-col>
</b-row> </b-row>
<b-row align-v="center" class="sidebar-vert-padding"> <b-row align-v="center" class="sidebar-vert-padding">
<b-col class="centered-image"> <b-col class="centered-image">
<img src="../assets/Teamwork.svg" class="image-opacity"/> <img src="../assets/Conservatism.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[3] }}</div> <div class="image-centered-text">{{ totals[3] }}</div>
</b-col> </b-col>
</b-row> </b-row>
<b-row align-v="center" class="sidebar-vert-padding">
<b-col class="centered-image">
<img src="../assets/Teamwork.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[4] }}</div>
</b-col>
</b-row>
<b-row align-v="center" class="sidebar-vert-padding">
<b-col class="centered-image">
<img src="../assets/Teamwork.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[5] }}</div>
</b-col>
</b-row>
<b-row align-v="center" class="sidebar-vert-padding">
<b-col class="centered-image">
<img src="../assets/Teamwork.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[6] }}</div>
</b-col>
</b-row>
<b-row align-v="center"> <b-row align-v="center">
<b-col class="centered-image"> <b-col class="centered-image">
<img src="../assets/Knowledge.svg" class="image-opacity"/> <img src="../assets/Knowledge.svg" class="image-opacity"/>
<div class="image-centered-text">{{ totals[4] }}</div> <div class="image-centered-text">{{ totals[7] }}</div>
</b-col> </b-col>
</b-row> </b-row>
</b-container> </b-container>
@ -45,9 +63,12 @@
<b-form-select v-bind:value="item.type" @change="changeType(index, $event)" required> <b-form-select v-bind:value="item.type" @change="changeType(index, $event)" required>
<option :value=null>Please select an option</option> <option :value=null>Please select an option</option>
<option value="MONITORING">Monitoring</option> <option value="MONITORING">Monitoring</option>
<option value="CONTROL_PROCEDURAL">Control Procedural</option>
<option value="CONTROL">Control</option> <option value="CONTROL">Control</option>
<option value="CONSERVATISM">Conservatism</option> <option value="CONSERVATISM">Conservatism</option>
<option value="TEAMWORK">Teamwork</option> <option value="TEAMWORK_COMMUNICATIONS">Teamwork Communications</option>
<option value="TEAMWORK_LEADERSHIP">Teamwork Leadership</option>
<option value="TEAMWORK_WORKLOAD">Teamwork Workload</option>
<option value="KNOWLEDGE">Knowledge</option> <option value="KNOWLEDGE">Knowledge</option>
</b-form-select> </b-form-select>
</b-form-group> </b-form-group>
@ -138,7 +159,7 @@ export default {
improvements: null improvements: null
} }
], ],
totals: [0, 0, 0, 0, 0], totals: [0, 0, 0, 0, 0, 0, 0, 0],
submitPassword: null submitPassword: null
}; };
}, },
@ -176,8 +197,8 @@ export default {
this.updateTotals(); this.updateTotals();
}, },
updateTotals: function() { updateTotals: function() {
var iTotals = [0, 0, 0, 0, 0]; var iTotals = [0, 0, 0, 0, 0, 0, 0, 0];
var counts = [0, 0, 0, 0, 0]; var counts = [0, 0, 0, 0, 0, 0, 0, 0];
this.observations.forEach(function(element) { this.observations.forEach(function(element) {
if (element.rating > 0) { if (element.rating > 0) {
switch (element.type) { switch (element.type) {
@ -185,22 +206,34 @@ export default {
iTotals[0] += element.rating; iTotals[0] += element.rating;
counts[0] += 1; counts[0] += 1;
break; break;
case "CONTROL": case "CONTROL_PROCEDURAL":
iTotals[1] += element.rating; iTotals[1] += element.rating;
counts[1] += 1; counts[1] += 1;
break; break;
case "CONSERVATISM": case "CONTROL":
iTotals[2] += element.rating; iTotals[2] += element.rating;
counts[2] += 1; counts[2] += 1;
break; break;
case "TEAMWORK": case "CONSERVATISM":
iTotals[3] += element.rating; iTotals[3] += element.rating;
counts[3] += 1; counts[3] += 1;
break; break;
case "KNOWLEDGE": case "TEAMWORK_COMMUNICATIONS":
iTotals[4] += element.rating; iTotals[4] += element.rating;
counts[4] += 1; counts[4] += 1;
break; break;
case "TEAMWORK_LEADERSHIP":
iTotals[5] += element.rating;
counts[5] += 1;
break;
case "TEAMWORK_WORKLOAD":
iTotals[6] += element.rating;
counts[6] += 1;
break;
case "KNOWLEDGE":
iTotals[7] += element.rating;
counts[7] += 1;
break;
} }
} }
}); });

View File

@ -99,7 +99,6 @@ export default {
}; };
}, },
mounted() { mounted() {
this.resetStore();
Vue.axios Vue.axios
.get("/site") .get("/site")
.then(response => { .then(response => {