From 255a39626374f946f95f0bddf2a81ee1a18b2810 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 9 Aug 2025 17:23:35 +0200 Subject: [PATCH] fix: delete Topic.swift --- QuizApp/Topic.swift | 51 --------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 QuizApp/Topic.swift diff --git a/QuizApp/Topic.swift b/QuizApp/Topic.swift deleted file mode 100644 index 3cd3c95..0000000 --- a/QuizApp/Topic.swift +++ /dev/null @@ -1,51 +0,0 @@ -// -// Topic.swift -// QuizApp -// -// Created by Paul on 03.08.25. -// - -import Foundation - -struct QuizQuestion: Decodable, Hashable, Identifiable { - let id: UUID - let question: String - let answers: [String] - let correctAnswer: Int - - let type: String? - let minValue: Double? - let maxValue: Double? - let correctValue: Double? - let unit: String? - - // Manuelles Decoding, id wird generiert - init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - - question = try container.decode(String.self, forKey: .question) - - // Falls im JSON nicht vorhanden, Standard setzen - answers = (try? container.decode([String].self, forKey: .answers)) ?? [] - correctAnswer = (try? container.decode(Int.self, forKey: .correctAnswer)) ?? 0 - - // Optional - type = try container.decodeIfPresent(String.self, forKey: .type) - minValue = try container.decodeIfPresent(Double.self, forKey: .minValue) - maxValue = try container.decodeIfPresent(Double.self, forKey: .maxValue) - correctValue = try container.decodeIfPresent(Double.self, forKey: .correctValue) - unit = try container.decodeIfPresent(String.self, forKey: .unit) - - id = UUID() - } - - private enum CodingKeys: String, CodingKey { - case question, answers, correctAnswer - case type, minValue, maxValue, correctValue, unit - } - - var isEstimation: Bool { - if let t = type?.lowercased() { return t == "estimation" } - return !answers.isEmpty ? false : (minValue != nil || maxValue != nil || correctValue != nil) - } -}