diff --git a/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-touchToSelect-one_right_answer-colors-shuffle_exercises.yml b/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-touchToSelect-one_right_answer-colors-shuffle_exercises.yml new file mode 100644 index 0000000000..192ebbc3fa --- /dev/null +++ b/Apps/LekaActivityUIExplorer/Resources/GEKNewSystem/activities/activity-touchToSelect-one_right_answer-colors-shuffle_exercises.yml @@ -0,0 +1,37 @@ +# Leka - iOS Monorepo +# Copyright 2023 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +id: 6869327315c945dea0966c7ac4673c05 +name: Touch To Select - One Right Answer - Colors - Shuffle exercises +description: L'objectif est de trouver la bonne couleur ou des les rassembler par famille +image: activity_color_recognition_1 +shuffle_exercises: true +sequence: + - exercises: + - instructions: Touche le rouge + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: red + type: color + isRightAnswer: true + + - instructions: Touche le vert + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: green + type: color + isRightAnswer: true + + - instructions: Touche le bleu + interface: touchToSelect + gameplay: findTheRightAnswers + payload: + choices: + - value: blue + type: color + isRightAnswer: true diff --git a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift index ba0c3ca75d..76fc35a3c6 100644 --- a/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift +++ b/Apps/LekaActivityUIExplorer/Sources/GEKNewSystem/GEKNewSystemView.swift @@ -13,6 +13,7 @@ let kActivities: [Activity] = [ ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-colors"), ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-colors-shuffle_choices"), + ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-colors-shuffle_exercises"), ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-colors-shuffle_sequences"), ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-image"), ContentKit.decodeActivity("activity-touchToSelect-one_right_answer-mixed"), diff --git a/Modules/ContentKit/Sources/Activity/Activity.swift b/Modules/ContentKit/Sources/Activity/Activity.swift index ef4c497569..2604e22586 100644 --- a/Modules/ContentKit/Sources/Activity/Activity.swift +++ b/Modules/ContentKit/Sources/Activity/Activity.swift @@ -10,11 +10,13 @@ public struct Activity: Codable, Identifiable { public let name: String public let description: String public let image: String + public let shuffleExercises: Bool public let shuffleSequences: Bool public var sequence: [Exercise.Sequence] private enum CodingKeys: String, CodingKey { case id, name, description, image, sequence + case shuffleExercises = "shuffle_exercises" case shuffleSequences = "shuffle_sequences" } @@ -27,6 +29,7 @@ public struct Activity: Codable, Identifiable { self.image = try container.decode(String.self, forKey: .image) self.sequence = try container.decode([Exercise.Sequence].self, forKey: .sequence) + self.shuffleExercises = try container.decodeIfPresent(Bool.self, forKey: .shuffleExercises) ?? false self.shuffleSequences = try container.decodeIfPresent(Bool.self, forKey: .shuffleSequences) ?? false } } diff --git a/Modules/ContentKit/Sources/Activity/ActivitySequenceManager.swift b/Modules/ContentKit/Sources/Activity/ActivitySequenceManager.swift index 35f0c7b887..ef136a3dea 100644 --- a/Modules/ContentKit/Sources/Activity/ActivitySequenceManager.swift +++ b/Modules/ContentKit/Sources/Activity/ActivitySequenceManager.swift @@ -11,9 +11,17 @@ public class ActivitySequenceManager { public init(activity: Activity) { var localActivity = activity + + if localActivity.shuffleExercises { + localActivity.sequence = localActivity.sequence.map { sequence in + Exercise.Sequence(exercises: sequence.exercises.shuffled()) + } + } + if localActivity.shuffleSequences { localActivity.sequence.shuffle() } + self.activity = localActivity }