From 6985f60ee3ba038c8357384aad860d3deca0d210 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Wed, 14 Feb 2024 02:05:25 +0100 Subject: [PATCH 01/14] WIP --- app/Http/Controllers/NameGameController.php | 37 ++++++++ lang/de/t.php | 12 +++ package-lock.json | 48 +++++++++++ package.json | 1 + resources/js/components/form/ButtonSubmit.vue | 3 +- .../js/components/nameGame/AnswerInput.vue | 52 ++++++++++++ .../js/components/nameGame/GuessPrompt.vue | 28 +++++++ resources/js/components/nameGame/NameGame.vue | 75 +++++++++++++++++ .../js/components/nameGame/NameGameGuess.vue | 68 +++++++++++++++ .../js/components/nameGame/NameGameRound.vue | 84 +++++++++++++++++++ resources/sass/app.scss | 4 + resources/views/nameGame/index.blade.php | 17 ++++ routes/web.php | 3 + 13 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 app/Http/Controllers/NameGameController.php create mode 100644 resources/js/components/nameGame/AnswerInput.vue create mode 100644 resources/js/components/nameGame/GuessPrompt.vue create mode 100644 resources/js/components/nameGame/NameGame.vue create mode 100644 resources/js/components/nameGame/NameGameGuess.vue create mode 100644 resources/js/components/nameGame/NameGameRound.vue create mode 100644 resources/views/nameGame/index.blade.php diff --git a/app/Http/Controllers/NameGameController.php b/app/Http/Controllers/NameGameController.php new file mode 100644 index 00000000..db010b6b --- /dev/null +++ b/app/Http/Controllers/NameGameController.php @@ -0,0 +1,37 @@ + "Via PBS MiData einloggen", ), + "name_game" => array( + "correct" => "Richtig!", + "name_game" => "Name Game", + "next" => "Weiter", + "page_title" => "Name Game", + "participants" => "TN", + "select_all" => "Alle auswählen", + "start" => "Los geht's", + "this_is" => "Das ist:", + "who_is_this" => "Wer ist das?", + "you_guessed" => "Deine Antwort:", + ), "observations" => array( "add_success" => "Beobachtung erfasst. Mässi!", "go_to_participant" => "Zu :name", diff --git a/package-lock.json b/package-lock.json index bf11a534..12878156 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1650,6 +1650,54 @@ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", "dev": true }, + "@formatjs/ecma402-abstract": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-1.18.2.tgz", + "integrity": "sha512-+QoPW4csYALsQIl8GbN14igZzDbuwzcpWrku9nyMXlaqAlwRBgl5V+p0vWMGFqHOw37czNXaP/lEk4wbLgcmtA==", + "requires": { + "@formatjs/intl-localematcher": "0.5.4", + "tslib": "^2.4.0" + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, + "@formatjs/intl-durationformat": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@formatjs/intl-durationformat/-/intl-durationformat-0.2.2.tgz", + "integrity": "sha512-8cBgB9ejg9a2pmGVmcVoF0OlK4XifRtm7Se5F9kMj+Ex+5x8QVBLEuqnTHEyV584VMNR2ngUP1dNR36MeTWG3A==", + "requires": { + "@formatjs/ecma402-abstract": "1.18.2", + "@formatjs/intl-localematcher": "0.5.4", + "tslib": "^2.4.0" + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, + "@formatjs/intl-localematcher": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.4.tgz", + "integrity": "sha512-zTwEpWOzZ2CiKcB93BLngUX59hQkuZjT2+SAQEscSm52peDW/getsawMcWF1rGRpMCX6D7nSJA3CzJ8gn13N/g==", + "requires": { + "tslib": "^2.4.0" + }, + "dependencies": { + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, "@fortawesome/fontawesome-free": { "version": "6.1.2", "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-6.1.2.tgz", diff --git a/package.json b/package.json index 5cf4215f..27c79669 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "yjs": "^13.5.12" }, "dependencies": { + "@formatjs/intl-durationformat": "^0.2.2", "jszip": "^3.10.1" } } diff --git a/resources/js/components/form/ButtonSubmit.vue b/resources/js/components/form/ButtonSubmit.vue index 52a0b0af..64ed0296 100644 --- a/resources/js/components/form/ButtonSubmit.vue +++ b/resources/js/components/form/ButtonSubmit.vue @@ -1,7 +1,7 @@ diff --git a/resources/js/components/nameGame/NameGameRound.vue b/resources/js/components/nameGame/NameGameRound.vue index 97098cc4..bd840a9a 100644 --- a/resources/js/components/nameGame/NameGameRound.vue +++ b/resources/js/components/nameGame/NameGameRound.vue @@ -30,18 +30,20 @@ @incorrect="incorrect" @advance="step += 1" > - + + + From a31d88490b0e715431f99eb937746c4d8e0a875d Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sat, 17 Feb 2024 19:31:55 +0100 Subject: [PATCH 03/14] Add link to game and changelog entry --- CHANGELOG.md | 3 +++ app/Http/Controllers/ParticipantController.php | 2 -- lang/de/t.php | 1 + resources/js/components/nameGame/NameGame.vue | 15 +++++++++++++-- resources/views/participants.blade.php | 7 ++++++- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb3cb45b..28799224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +##### Februar 2024 +- Qualix enthält neu ein Namenslernspiel! Auf der TN-Liste hat es einen Link zum Spiel. + ##### Januar 2024 - Aus technischen und praktischen Gründen wurde die Anzahl relevante Anforderungen in einer Rückmeldung auf maximal 40 limitiert. Auslöser war, dass die Übersichtstabelle sonst technisch wie auch visuell nicht mehr sinnvoll angezeigt werden konnte. Auch fachlich gesehen ist das Konzept der Rückmeldungen in Qualix nicht darauf ausgelegt, sehr viele eingebettete Anforderungen zu enthalten, da Übersichtlichkeit, Fördergedanke, Überprüfbarkeit, zweite Chancen, Zweitausbildung etc. alle darunter leiden. Dies sehen wir in folgenden Textstellen der RQF-Broschüre bestätigt, welche klar machen dass mit jeder einzelnen Mindestanforderung der Zeitaufwand für das Kursteam wie auch für die TN markant ansteigt: > [Es] muss beachtet werden, dass zu jeder Mindestanforderung auch ein Beobachtungsmoment gehört, bei dem die TN zeigen können, was sie gelernt haben und das Kursteam ebendies wahrnehmen kann.[^1] diff --git a/app/Http/Controllers/ParticipantController.php b/app/Http/Controllers/ParticipantController.php index 8c41f0b3..b0f121da 100644 --- a/app/Http/Controllers/ParticipantController.php +++ b/app/Http/Controllers/ParticipantController.php @@ -64,7 +64,6 @@ public function upload(Request $request, Course $course) { $request->session()->now('alert-warning', trans('t.views.admin.participant_import.warning_existing_participants')); } - $MiDataParticipantListLink = (new HtmlString) ->s('') ->__('t.views.admin.participant_import.MiData.name') @@ -81,7 +80,6 @@ public function upload(Request $request, Course $course) { * @throws ValidationException if parsing the uploaded file fails */ public function import(ParticipantImportRequest $request, Course $course) { - $request->validated(); try { $imported = $request->getImporter()->import($request->file('file')->getRealPath(), $course); diff --git a/lang/de/t.php b/lang/de/t.php index 933f4b5f..266566af 100644 --- a/lang/de/t.php +++ b/lang/de/t.php @@ -555,6 +555,7 @@ "correct" => "Richtig!", "name_game" => "Name Game", "next" => "Weiter", + "no_image" => "kein Bild", "page_title" => "Name Game", "participants" => "TN", "play_again" => "Nochmals", diff --git a/resources/js/components/nameGame/NameGame.vue b/resources/js/components/nameGame/NameGame.vue index 7544f450..4d52e3b9 100644 --- a/resources/js/components/nameGame/NameGame.vue +++ b/resources/js/components/nameGame/NameGame.vue @@ -9,7 +9,7 @@ name="selectedParticipants" v-model="selectedParticipantIds" multiple - :options="participants" + :options="participantsWithImage" :display-field="anyDuplicateMembershipGroups ? 'name_and_group' : 'scout_name'" required :groups="{[$t('t.views.name_game.select_all')]: participants.map(p => p.id).join()}" @@ -44,12 +44,23 @@ export default { }, data() { return { - selectedParticipants: this.participants, + selectedParticipants: this.participants.filter(participant => participant.image_url), playing: false, gameMode: 'multipleChoice', } }, computed: { + participantsWithImage() { + return this.participants.map(participant => { + if (participant.image_url) { + return participant + } + return { + ...participant, + scout_name: participant.scout_name + ' (' + this.$tc('t.views.name_game.no_image') + ')' + } + }) + }, selectedParticipantIds: { get () { return this.selectedParticipants.map(participant => participant.id).join(',') diff --git a/resources/views/participants.blade.php b/resources/views/participants.blade.php index be4dd981..62d7f132 100644 --- a/resources/views/participants.blade.php +++ b/resources/views/participants.blade.php @@ -5,7 +5,12 @@ @section('content') - + @if (count($course->participants)) From e8c73c949c2741126e57294e345524905f70e712 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sat, 17 Feb 2024 20:14:01 +0100 Subject: [PATCH 04/14] Add harder game mode --- lang/de/t.php | 5 ++++ resources/js/components/form/InputText.vue | 8 ++++- .../js/components/nameGame/AnswerInput.vue | 19 ++++++++++-- resources/js/components/nameGame/NameGame.vue | 8 +++++ .../js/components/nameGame/NameGameGuess.vue | 29 +++++++++++++++---- 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/lang/de/t.php b/lang/de/t.php index 266566af..47d35317 100644 --- a/lang/de/t.php +++ b/lang/de/t.php @@ -553,14 +553,19 @@ ), "name_game" => array( "correct" => "Richtig!", + "game_mode" => "Schwierigkeit", + "manual_name_input" => "Schwierig (Namen eintippen)", + "multiple_choice" => "Einfach (multiple choice)", "name_game" => "Name Game", "next" => "Weiter", "no_image" => "kein Bild", "page_title" => "Name Game", "participants" => "TN", "play_again" => "Nochmals", + "scout_name" => "Name", "select_all" => "Alle auswählen", "start" => "Los geht's", + "submit" => "Abschicken", "this_is" => "Das ist:", "well_done" => "Super gemacht!", "who_is_this" => "Wer ist das?", diff --git a/resources/js/components/form/InputText.vue b/resources/js/components/form/InputText.vue index cfc99017..a8b4ca0e 100644 --- a/resources/js/components/form/InputText.vue +++ b/resources/js/components/form/InputText.vue @@ -30,7 +30,8 @@ v-model="currentValue" :required="required" :autofocus="autofocus" - :v-focus="autofocus"> + :v-focus="autofocus" + ref="input"> {{ errorMessage }} @@ -50,6 +51,11 @@ export default { label: { type: String, required: true }, type: { type: String, default: 'text' }, autofocus: { type: Boolean, default: false }, + }, + methods: { + focus() { + this.$refs.input.focus() + } } } diff --git a/resources/js/components/nameGame/AnswerInput.vue b/resources/js/components/nameGame/AnswerInput.vue index 34647eb4..8df45622 100644 --- a/resources/js/components/nameGame/AnswerInput.vue +++ b/resources/js/components/nameGame/AnswerInput.vue @@ -9,13 +9,23 @@ {{ option.scout_name }} -
{{ participant.scout_name }}
+
+ + +
diff --git a/resources/js/components/nameGame/NameGame.vue b/resources/js/components/nameGame/NameGame.vue index 4d52e3b9..a31e20c8 100644 --- a/resources/js/components/nameGame/NameGame.vue +++ b/resources/js/components/nameGame/NameGame.vue @@ -15,6 +15,14 @@ :groups="{[$t('t.views.name_game.select_all')]: participants.map(p => p.id).join()}" > + + diff --git a/resources/js/components/nameGame/NameGameGuess.vue b/resources/js/components/nameGame/NameGameGuess.vue index 228710b2..1062e236 100644 --- a/resources/js/components/nameGame/NameGameGuess.vue +++ b/resources/js/components/nameGame/NameGameGuess.vue @@ -23,12 +23,13 @@
  - {{ submittedGuess.scout_name }} + {{ submittedScoutName }}
@@ -52,13 +53,15 @@ export default { guessing: true, correct: false, submittedGuess: null, + submittedScoutName: '', } }, methods: { guess(event) { - const selectedId = event.submitter.getAttribute('value') - this.submittedGuess = this.participants.find(p => selectedId === `${p.id}`) - if (this.submittedGuess.id === this.participant.id) { + this.gameMode === 'multipleChoice' ? + this.getSelectedParticipant(event) : + this.getGuessedParticipant(event) + if (this.submittedGuess?.id === this.participant.id) { this.correct = true this.$emit('correct') } else { @@ -66,10 +69,26 @@ export default { this.$emit('incorrect') } this.guessing = false + this.$nextTick(() => this.$refs.nextButton.focus()) }, next() { this.$emit('advance') this.guessing = true + }, + getSelectedParticipant(event) { + const selectedId = event.submitter.getAttribute('value') + this.submittedGuess = this.participants.find(p => selectedId === `${p.id}`) + this.submittedScoutName = this.submittedGuess?.scout_name + }, + getGuessedParticipant(event) { + const input = (new FormData(event.target)).get('scout_name') + this.submittedGuess = this.participants.find(participant => { + return this.normalize(participant.scout_name) === this.normalize(input) + }) + this.submittedScoutName = this.submittedGuess ? this.submittedGuess.scout_name : input + }, + normalize(name) { + return name.toLocaleLowerCase().replaceAll(/[^a-zA-Z]/g, '') } } } From f3671b7046245375f5206b5e7b6df2ea0d579793 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sat, 17 Feb 2024 20:24:05 +0100 Subject: [PATCH 05/14] Complete changelog --- CHANGELOG.md | 2 +- resources/js/components/nameGame/NameGame.vue | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28799224..86152692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ##### Februar 2024 -- Qualix enthält neu ein Namenslernspiel! Auf der TN-Liste hat es einen Link zum Spiel. +- Qualix enthält neu ein Namenslernspiel! Auf der TN-Liste hat es einen Link zum Spiel [#332](https://github.com/gloggi/qualix/pull/332) ##### Januar 2024 - Aus technischen und praktischen Gründen wurde die Anzahl relevante Anforderungen in einer Rückmeldung auf maximal 40 limitiert. Auslöser war, dass die Übersichtstabelle sonst technisch wie auch visuell nicht mehr sinnvoll angezeigt werden konnte. Auch fachlich gesehen ist das Konzept der Rückmeldungen in Qualix nicht darauf ausgelegt, sehr viele eingebettete Anforderungen zu enthalten, da Übersichtlichkeit, Fördergedanke, Überprüfbarkeit, zweite Chancen, Zweitausbildung etc. alle darunter leiden. Dies sehen wir in folgenden Textstellen der RQF-Broschüre bestätigt, welche klar machen dass mit jeder einzelnen Mindestanforderung der Zeitaufwand für das Kursteam wie auch für die TN markant ansteigt: diff --git a/resources/js/components/nameGame/NameGame.vue b/resources/js/components/nameGame/NameGame.vue index a31e20c8..23fffba8 100644 --- a/resources/js/components/nameGame/NameGame.vue +++ b/resources/js/components/nameGame/NameGame.vue @@ -21,6 +21,7 @@ v-model="gameMode" :options="[ { id: 'multipleChoice', label: $t('t.views.name_game.multiple_choice')}, { id: 'manualNameInput', label: $t('t.views.name_game.manual_name_input') } ]" required + :allow-empty="false" > From 62b5eb11457db742460b96c05465312fab17e3bb Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sun, 18 Feb 2024 13:24:27 +0100 Subject: [PATCH 06/14] Visualize correct and wrong in progress bar --- .../js/components/nameGame/NameGameRound.vue | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/resources/js/components/nameGame/NameGameRound.vue b/resources/js/components/nameGame/NameGameRound.vue index bd840a9a..e6781e9e 100644 --- a/resources/js/components/nameGame/NameGameRound.vue +++ b/resources/js/components/nameGame/NameGameRound.vue @@ -18,8 +18,10 @@ - - {{ step }} / {{ participants.length }} + + {{ step }} / {{ participants.length }} + + From 64d9512b28f0d1adddc214c1d25647886d33748e Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Mon, 19 Feb 2024 11:36:24 +0100 Subject: [PATCH 07/14] Add skip button label --- lang/de/t.php | 1 + resources/js/components/nameGame/AnswerInput.vue | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lang/de/t.php b/lang/de/t.php index 47d35317..03c28f1c 100644 --- a/lang/de/t.php +++ b/lang/de/t.php @@ -564,6 +564,7 @@ "play_again" => "Nochmals", "scout_name" => "Name", "select_all" => "Alle auswählen", + "skip" => "Weiss nicht", "start" => "Los geht's", "submit" => "Abschicken", "this_is" => "Das ist:", diff --git a/resources/js/components/nameGame/AnswerInput.vue b/resources/js/components/nameGame/AnswerInput.vue index 8df45622..17592c8e 100644 --- a/resources/js/components/nameGame/AnswerInput.vue +++ b/resources/js/components/nameGame/AnswerInput.vue @@ -10,11 +10,11 @@
- +
@@ -31,6 +31,9 @@ export default { participants: { type: Array, required: true }, gameMode: { type: String, required: true }, }, + data: () => ({ + manualInput: '', + }), computed: { wrongGuess1() { let result = this.participant @@ -53,9 +56,16 @@ export default { options.sort((a, b) => a.scout_name.localeCompare(b.scout_name)) return options }, + buttonLabel() { + if (this.manualInput.length) { + return this.$t('t.views.name_game.submit') + } + return this.$t('t.views.name_game.skip') + }, }, mounted() { if (this.gameMode === 'manualNameInput' && this.$refs.scoutName) { + this.manualInput = '' this.$refs.scoutName.focus() } }, From 443e5922ff69cf7d7e7d03a8893a3872952dbe43 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Mon, 19 Feb 2024 11:43:25 +0100 Subject: [PATCH 08/14] Require a minimum number of names --- lang/de/t.php | 1 + resources/js/components/nameGame/NameGame.vue | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lang/de/t.php b/lang/de/t.php index 03c28f1c..fae33b91 100644 --- a/lang/de/t.php +++ b/lang/de/t.php @@ -568,6 +568,7 @@ "start" => "Los geht's", "submit" => "Abschicken", "this_is" => "Das ist:", + "too_few_participants" => "Wähle mindestens 3 TN aus", "well_done" => "Super gemacht!", "who_is_this" => "Wer ist das?", "you_guessed" => "Deine Antwort:", diff --git a/resources/js/components/nameGame/NameGame.vue b/resources/js/components/nameGame/NameGame.vue index 23fffba8..34efe446 100644 --- a/resources/js/components/nameGame/NameGame.vue +++ b/resources/js/components/nameGame/NameGame.vue @@ -24,7 +24,7 @@ :allow-empty="false" > - + @@ -86,6 +86,9 @@ export default { ) ) }, + tooFewParticipantsSelected() { + return this.selectedParticipants.length < 3 + } } } From ddf6007041784124293079437473d80dc1d37307 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sun, 25 Feb 2024 17:45:36 +0100 Subject: [PATCH 09/14] Clarify message on progress bar --- lang/de/t.php | 1 + resources/js/components/nameGame/NameGameRound.vue | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lang/de/t.php b/lang/de/t.php index fae33b91..c2c784b5 100644 --- a/lang/de/t.php +++ b/lang/de/t.php @@ -559,6 +559,7 @@ "name_game" => "Name Game", "next" => "Weiter", "no_image" => "kein Bild", + "num_correct_and_incorrect" => ":correct richtig, :incorrect falsch von :total", "page_title" => "Name Game", "participants" => "TN", "play_again" => "Nochmals", diff --git a/resources/js/components/nameGame/NameGameRound.vue b/resources/js/components/nameGame/NameGameRound.vue index e6781e9e..0fb151af 100644 --- a/resources/js/components/nameGame/NameGameRound.vue +++ b/resources/js/components/nameGame/NameGameRound.vue @@ -19,9 +19,9 @@ - {{ step }} / {{ participants.length }} - - + {{ $t('t.views.name_game.num_correct_and_incorrect', { correct: numCorrect, incorrect: numIncorrect, total: participants.length }) }} + + Date: Sun, 25 Feb 2024 19:40:55 +0100 Subject: [PATCH 10/14] Fix mobile view --- resources/js/components/nameGame/GuessPrompt.vue | 2 +- resources/js/components/nameGame/NameGameRound.vue | 2 +- resources/sass/app.scss | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/js/components/nameGame/GuessPrompt.vue b/resources/js/components/nameGame/GuessPrompt.vue index 59aea510..0c77b727 100644 --- a/resources/js/components/nameGame/GuessPrompt.vue +++ b/resources/js/components/nameGame/GuessPrompt.vue @@ -1,5 +1,5 @@ diff --git a/resources/js/components/nameGame/ScoreScreen.vue b/resources/js/components/nameGame/ScoreScreen.vue index 7455c768..2cf670c4 100644 --- a/resources/js/components/nameGame/ScoreScreen.vue +++ b/resources/js/components/nameGame/ScoreScreen.vue @@ -1,7 +1,22 @@ From 9711bd82a6b9cd7df43de864c4c91f9c5cf5f825 Mon Sep 17 00:00:00 2001 From: carlobeltrame Date: Sun, 25 Feb 2024 21:18:40 +0100 Subject: [PATCH 14/14] Add simple e2e test for name game --- cypress/e2e/name-game.cy.js | 78 +++++++++++++++++++ resources/js/components/nameGame/NameGame.vue | 2 + 2 files changed, 80 insertions(+) create mode 100644 cypress/e2e/name-game.cy.js diff --git a/cypress/e2e/name-game.cy.js b/cypress/e2e/name-game.cy.js new file mode 100644 index 00000000..14227e70 --- /dev/null +++ b/cypress/e2e/name-game.cy.js @@ -0,0 +1,78 @@ +import { useDatabaseResets } from "../support/databaseTransactions" + +describe('name game', () => { + useDatabaseResets() + + beforeEach(() => { + cy.then(() => { + cy.login().then(user => { + cy.artisan('e2e:scenario', { '--user-id': user.id }) + }) + }) + cy.courseId() + }) + + it('plays through the easy version of the name game', function () { + cy.visit(`/course/${this.courseId}/participants`) + + cy.contains('Namen lernen').click() + + cy.contains('Name Game') + + cy.get('#participants').click() + cy.get('#participants .multiselect__option').first().click() + cy.get('#participants .multiselect__option').eq(2).click() + cy.get('#participants .multiselect__option').eq(3).click() + + // Click outside the multiselect to close the dropdown menu + cy.get('.card-body').click('right') + + cy.contains('Los geht\'s').click() + + cy.contains('Zeit:') + + for (let i = 0; i < 3; i++) { + // 3 participants with 2 clicks each + cy.get('.name-game button[type=submit]').first().click() + cy.get('.name-game button[type=submit]').first().click() + } + + cy.contains('Nochmals').click() + + cy.contains('Los geht\'s') + }) + + it('plays through the hard version of the name game', function () { + cy.visit(`/course/${this.courseId}/participants`) + + cy.contains('Namen lernen').click() + + cy.contains('Name Game') + + cy.get('#participants').click() + cy.get('#participants .multiselect__option').first().click() + cy.get('#participants .multiselect__option').eq(2).click() + cy.get('#participants .multiselect__option').eq(3).click() + + // Click outside the multiselect to close the dropdown menu + cy.get('.card-body').click('right') + + cy.get('#gameMode').click() + cy.contains('Schwierig (Namen eintippen)').click() + + cy.contains('Los geht\'s').click() + + cy.contains('Zeit:') + + for (let i = 0; i < 3; i++) { + // 3 participants with 2 clicks each + cy.get('.name-game button[type=submit]').first().click() + cy.get('.name-game button[type=submit]').first().click() + } + + cy.contains('Nochmals').click() + + cy.contains('Los geht\'s') + cy.contains('Einfach (multiple choice)').should('not.be.visible') + }) +}) diff --git a/resources/js/components/nameGame/NameGame.vue b/resources/js/components/nameGame/NameGame.vue index 55f444d7..5a797cc6 100644 --- a/resources/js/components/nameGame/NameGame.vue +++ b/resources/js/components/nameGame/NameGame.vue @@ -7,6 +7,7 @@