diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt index 5981203..6d81901 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt @@ -5,11 +5,11 @@ package uk.co.neviyn.observationdatabase */ fun csvHeaderString(): String { return "Observer,obDate,Title,Type,Department,Station,Station Focus,Scores-Monitoring,Scores-Control Procedural," + - "Scores-Control,Scores-Conservatism,Scores-Teamwork Comms,Scores-Teamwork Leadership,Scores-Teamwork Workload,Scores-Knowledge, Skills and Attitudes," + + "Scores-Control,Scores-Conservatism,Scores-Teamwork Comms,Scores-Teamwork Leadership,Scores-Teamwork Workload,\"Scores-Knowledge, Skills and Attitudes\"," + "Strengths-Monitoring,Strengths-Control Procedural,Strengths-Control,Strengths-Conservatism,Strengths-Teamwork Comms," + - "Strengths-Teamwork Leadership,Strengths-Teamwork Workload,Strengths-Knowledge, Skills and Attitudes," + + "Strengths-Teamwork Leadership,Strengths-Teamwork Workload,\"Strengths-Knowledge, Skills and Attitudes\"," + "Develop-Monitoring,Develop-Control Procedural,Develop-Control,Develop-Conservatism,Develop-Teamwork Comms," + - "Develop-Teamwork Leadership,Develop-Teamwork Workload,Develop-Knowledge, Skills and Attitudes,ErrorPrecursors,ActionTaken" + "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\",ErrorPrecursors,ActionTaken" } /** 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 a17453f..b7fbf1a 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt @@ -93,17 +93,29 @@ data class Observation( val person: Person ) { fun toCsvFormat(): String { - return "\"${tutors.joinToString { it.name }}\",$date,\"${scenarios.joinToString { it.title }}\",\"Training\",\"Operations - Shift Operations\",\"${site.name}\",\"N/A\"," + + val dataPortion = "${date.toString("dd/MM/yyyy")},\"${scenarios.joinToString { it.title }}\"," + + "\"Training\",\"Operations - Shift Operations\",\"${site.name}\",\"N/A\"," + "${roundScore(monitoring)},${roundScore(controlProcedural)},${roundScore(control)}," + "${roundScore(conservatism)},${roundScore(teamworkCommunications)},${roundScore(teamworkLeadership)}," + - "${roundScore(teamworkWorkload)},${roundScore(knowledge)},\"${scenarios.joinToString { it.monitoring.strengths }}\"," + - "\"${scenarios.joinToString { it.controlProcedural.strengths }}\",\"${scenarios.joinToString { it.control.strengths }}\",\"${scenarios.joinToString { it.conservatism.strengths }}\"," + - "\"${scenarios.joinToString { it.teamworkCommunications.strengths }}\",\"${scenarios.joinToString { it.teamworkLeadership.strengths }}\"," + - "\"${scenarios.joinToString { it.teamworkWorkload.strengths }}\",\"${scenarios.joinToString { it.knowledge.strengths }}\"," + - "\"${scenarios.joinToString { it.monitoring.improvements }}\",\"${scenarios.joinToString { it.controlProcedural.improvements }}\"," + - "\"${scenarios.joinToString { it.control.improvements }}\",\"${scenarios.joinToString { it.conservatism.improvements }}\"," + - "\"${scenarios.joinToString { it.teamworkCommunications.improvements }}\",\"${scenarios.joinToString { it.teamworkLeadership.improvements }}\"," + - "\"${scenarios.joinToString { it.teamworkWorkload.improvements }}\",\"${scenarios.joinToString { it.knowledge.improvements }}\",;#None;#," + "${roundScore(teamworkWorkload)},${roundScore(knowledge)}," + + "\"${scenarios.map { it.monitoring.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.controlProcedural.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.control.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.conservatism.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkCommunications.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkLeadership.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkWorkload.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.knowledge.strengths }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.monitoring.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.controlProcedural.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.control.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.conservatism.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkCommunications.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkLeadership.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.teamworkWorkload.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + "\"${scenarios.map { it.knowledge.improvements }.filter { it.isNotEmpty() }.joinToString(separator = "; ")}\"," + + ";#None;#," + return tutors.joinToString("\n") { it.name + "," + dataPortion } } private fun roundScore(input: Double?): String {