From c1a3ce7fb568b3d226806906b2a49f56c23dbff4 Mon Sep 17 00:00:00 2001 From: Mats Eikeland Mollestad Date: Thu, 13 Feb 2020 15:18:43 +0100 Subject: [PATCH] [fix] Minor improvments --- Public/assets/js/flash-card/edit.js | 2 +- Sources/App/Subject Test/SubjectTestWebController.swift | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Public/assets/js/flash-card/edit.js b/Public/assets/js/flash-card/edit.js index 82bf89d..510714d 100644 --- a/Public/assets/js/flash-card/edit.js +++ b/Public/assets/js/flash-card/edit.js @@ -28,7 +28,7 @@ function editFlashCard() { } }) .then(function (json) { - window.location.href = "/tasks/flash-card/" + json.id; + window.location.href = "/creator/tasks/flash-card/" + json.id + "/edit?wasUpdated=true"; }) .catch(function (error) { presentErrorMessage(error.message); diff --git a/Sources/App/Subject Test/SubjectTestWebController.swift b/Sources/App/Subject Test/SubjectTestWebController.swift index 2c2de54..2708d70 100644 --- a/Sources/App/Subject Test/SubjectTestWebController.swift +++ b/Sources/App/Subject Test/SubjectTestWebController.swift @@ -175,12 +175,18 @@ class SubjectTestWebController: SubjectTestWebCo .map { _ in req.redirect(to: "results") } + .catchMap { error in + switch error { + case SubjectTest.DatabaseRepository.Errors.alreadyEnded: return req.redirect(to: "results") + default: throw error + } + } } static func results(on req: Request) throws -> EventLoopFuture { let user = try req.requireAuthenticated(User.self) - + return try API.results(on: req) .map { results in