From d25ec78fd94b0ed7f345526d9f63a828dd45176f Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Tue, 30 Oct 2018 16:47:26 +0000 Subject: [PATCH] Added csv dump button to observations view. --- .../neviyn/observationdatabase/Controller.kt | 2 +- .../co/neviyn/observationdatabase/Entity.kt | 11 +++---- frontend/src/views/ViewObservations.vue | 32 +++++++++++++++++-- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt index e7ef81e..8ab7f3d 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -201,7 +201,7 @@ class Controller { "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\"" } val data = getObservations(observationsRequest) - if(data.isEmpty()) return null + if (data.isEmpty()) return null val builder = StringBuilder(csvHeaderString()) data.forEach { builder.append('\n') diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt index 6580134..12b009b 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt @@ -98,7 +98,7 @@ data class Observation( val persons: Set ) { fun toCsvFormat(): String { - return ",,${tutors.elementAt(0).name},$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," + + return ",,\"${tutors.elementAt(0).name}\",$date,\"$observed\",\"Training\",\"Performance Improvement - Training\",\"${site.name}\",\"N/A\"," + "${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," + "${roundScore(conservatism)},${roundScore(teamworkCommunications)},${roundScore(teamworkLeadership)}," + "${roundScore(teamworkWorkload)},${roundScore(knowledge)},\"${getStrengths(RatingCategory.MONITORING)}\"," + @@ -111,12 +111,12 @@ data class Observation( "\"${getImprovements(RatingCategory.TEAMWORK_WORKLOAD)}\",\"${getImprovements(RatingCategory.KNOWLEDGE)}\"" } - private fun getStrengths(category: RatingCategory): String{ - return entries.asSequence().filter { it.type == category }.map{ it.strengths }.joinToString() + private fun getStrengths(category: RatingCategory): String { + return entries.asSequence().filter { it.type == category }.map { it.strengths }.joinToString() } - private fun getImprovements(category: RatingCategory): String{ - return entries.asSequence().filter { it.type == category }.map{ it.improvements }.joinToString() + private fun getImprovements(category: RatingCategory): String { + return entries.asSequence().filter { it.type == category }.map { it.improvements }.joinToString() } private fun roundScore(input: Double?): String { @@ -127,7 +127,6 @@ data class Observation( } } - /** * Entry giving specific details on observation performance for a tutor defined constraint. */ diff --git a/frontend/src/views/ViewObservations.vue b/frontend/src/views/ViewObservations.vue index a87e7ed..fa819a4 100644 --- a/frontend/src/views/ViewObservations.vue +++ b/frontend/src/views/ViewObservations.vue @@ -119,14 +119,15 @@ + CSV Dump