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 e43ca3b..a36caa2 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/CSV.kt @@ -1,5 +1,8 @@ package uk.co.neviyn.observationdatabase +/** + * Header line for a CSV file in the format of the standard observation database + */ fun csvHeaderString(): String { return "Ob ID,Observerfull,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\"," + @@ -9,6 +12,9 @@ fun csvHeaderString(): String { "Develop-Teamwork Leadership,Develop-Teamwork Workload,\"Develop-Knowledge, Skills and Attitudes\"" } +/** + * Given the observations in [data], output a string that aligns the data with the format described in csvHeaderString() + */ fun observationsToCSV(data: List): String { val builder = StringBuilder(csvHeaderString()) data.forEach { diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Email.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Email.kt index f6f53b7..d3954f1 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Email.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Email.kt @@ -17,6 +17,9 @@ class Email { private val logger: Logger = LoggerFactory.getLogger(javaClass)!! + /** + * Send observation data to the configured email address + */ fun sendObservationData(observations: List) { if (observations.isEmpty()) { logger.error("Cannot send observations email containing no observations!") diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/GroupSessionManager.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/GroupSessionManager.kt index 4a9fba8..5c678ef 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/GroupSessionManager.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/GroupSessionManager.kt @@ -17,6 +17,9 @@ object GroupSessionManager { var scenarioTitles: List? = null var observations: MutableMap = mutableMapOf() + /** + * Start a new group session + */ fun startNewSession(site: Site, tutors: Set, trainingType: TrainingType, scenarioTitles: List): Int { logger.info("Starting new Group Session") logger.debug("Previous ID was $sessionId") @@ -34,6 +37,9 @@ object GroupSessionManager { return sessionId } + /** + * Invalidate the current session + */ fun invalidate() { this.site = null this.tutors = null @@ -42,14 +48,23 @@ object GroupSessionManager { this.observations = mutableMapOf() } + /** + * Check if the current session has [sessionId] and is valid + */ fun isValid(sessionId: Int): Boolean { return isValid() && sessionId == this.sessionId } + /** + * Check if the current session is valid + */ fun isValid(): Boolean { return site != null && tutors != null && trainingType != null && scenarioTitles != null } + /** + * Return the data contained in the current session in the scenario format + */ fun asScenarioView(): MutableMap> { val output: MutableMap> = mutableMapOf() scenarioTitles?.forEach { title -> @@ -63,6 +78,9 @@ object GroupSessionManager { return output } + /** + * Check whether the data currently submitted for a session is all valid + */ fun dataComplete(): Boolean { if (observations.isEmpty()) { logger.warn("Observations is currently empty") @@ -77,11 +95,20 @@ object GroupSessionManager { return true } + /** + * Update the stored data for the individual submitting the [input] data + */ fun updateObservationData(input: GroupObservation) { observations[input.person] = input } + /** + * Check whether [name] exists as a participant in this session + */ fun participantExistsInSession(name: String): Boolean = observations.containsKey(name) + /** + * Get the observation data stored in this session for [name] + */ fun getObservationDataForParticipant(name: String): GroupObservation? = observations[name] } \ No newline at end of file