Skip to content

Commit

Permalink
Hotfix: Fix social media share issues & rounds localization (#1152)
Browse files Browse the repository at this point in the history
* Fix: Update social message based on locale and current URL

* fix: Fix Round x / x localization in Score action

* fix: Update currentUrl logic in Header component by stripping it from query string (participant_id)

* chore: Remove console.log

* refactor: Use experiment collection name as hashtag

* refactor: Use original toontje hoger share message

* refactor: Update button_link in ToontjeHoger rules to "/collection/toontjehoger"
  • Loading branch information
drikusroor authored Jun 26, 2024
1 parent 66fec8d commit e7a3f37
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 24 deletions.
6 changes: 4 additions & 2 deletions backend/experiment/actions/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def __init__(self, session, title: str = None, score=None, score_message=None, c
- feedback: An additional feedback text
"""
self.session = session
self.title = title or _(
f'Round {session.rounds_passed()} / {self.session.experiment.rounds}')
self.title = title or _('Round {rounds_passed} / {total_rounds}').format(
rounds_passed=session.rounds_passed(),
total_rounds=self.session.experiment.rounds
)
self.score = score or session.last_score()
self.score_message = score_message or self.default_score_message
self.feedback = feedback
Expand Down
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_1_mozart.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def get_final_round(self, session):
body=body,
heading="Het Mozart effect",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [*answer_explainer, *score, final, info]
Expand Down
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_2_preverbal.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def get_final_round(self, session):
body=body,
heading="Het eerste luisteren",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [*score, final, info]
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_3_plink.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def get_final_round(self, session):
body=body,
heading="Muziekherkenning",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [score, final, info]
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_4_absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def get_final_round(self, session):
body=body,
heading="Absoluut gehoor",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [*score, final, info]
Expand Down
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_5_tempo.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get_final_round(self, session):
body=body,
heading="Timing en tempo",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [*score, final, info]
Expand Down
2 changes: 1 addition & 1 deletion backend/experiment/rules/toontjehoger_6_relative.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get_final_round(self, session):
body=body,
heading="Relatief gehoor",
button_label="Terug naar ToontjeHoger",
button_link="/toontjehoger"
button_link="/collection/toontjehoger"
)

return [*score, final, info]
Binary file modified backend/locale/nl/LC_MESSAGES/django.mo
Binary file not shown.
25 changes: 14 additions & 11 deletions backend/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-11 15:02+0200\n"
"POT-Creation-Date: 2024-06-25 21:58+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -130,33 +130,34 @@ msgstr ""
msgid "Select a Playlist"
msgstr ""

#: experiment/actions/score.py:31
msgid "Round {session.rounds_passed()} / {self.session.experiment.rounds}"
msgstr ""
#: experiment/actions/score.py:30
#, python-brace-format
msgid "Round {rounds_passed} / {total_rounds}"
msgstr "Ronde {rounds_passed} van {total_rounds}"

#: experiment/actions/score.py:43
#: experiment/actions/score.py:45
#, fuzzy
#| msgid "Final score"
msgid "Total Score"
msgstr "Eindscore"

#: experiment/actions/score.py:44 experiment/rules/musical_preferences.py:125
#: experiment/actions/score.py:46 experiment/rules/musical_preferences.py:125
msgid "Next"
msgstr "Volgende"

#: experiment/actions/score.py:45
#: experiment/actions/score.py:47
msgid "You listened to:"
msgstr "Je luisterde naar:"

#: experiment/actions/score.py:77
#: experiment/actions/score.py:79
msgid "No points"
msgstr "Geen punten"

#: experiment/actions/score.py:80
#: experiment/actions/score.py:82
msgid "Incorrect"
msgstr "Onjuist"

#: experiment/actions/score.py:83
#: experiment/actions/score.py:85
msgid "Correct"
msgstr "Correct"

Expand Down Expand Up @@ -4025,7 +4026,9 @@ msgstr "punten"
msgid "No points yet!"
msgstr "Nog geen punten!"

#~ msgid "Round {} / {}"
#, fuzzy, python-format
#~| msgid "Round {} / {}"
#~ msgid "Round %s / %s"
#~ msgstr "Ronde {} / {}"

#, python-format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ExperimentCollectionDashboard: React.FC<ExperimentCollectionDashboa
collectionSlug: experimentCollection.slug,
...experimentCollection.theme.header,
totalScore,
experimentCollectionTitle: experimentCollection.name,
experimentCollectionDescription: experimentCollection.description

} : undefined;
Expand Down
18 changes: 13 additions & 5 deletions frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface HeaderProps {
nextExperimentButtonText: string;
collectionSlug: string;
aboutButtonText: string;
totalScore: Number;
totalScore: number;
}

interface Score {
Expand All @@ -22,6 +22,7 @@ interface Score {
}

export const Header: React.FC<HeaderProps> = ({
experimentCollectionTitle,
experimentCollectionDescription,
nextExperimentSlug,
nextExperimentButtonText,
Expand All @@ -31,11 +32,18 @@ export const Header: React.FC<HeaderProps> = ({
score,
}) => {

// TODO: Fix this permanently and localize in and fetch content from the backend
// See also: https://github.com/Amsterdam-Music-Lab/MUSCLE/issues/1151
// Get current URL minus the query string
const currentUrl = window.location.href.split('?')[0];
const message = totalScore > 0 ? `Ha! Ik ben muzikaler dan ik dacht - heb maar liefst ${totalScore} punten! Speel mee met #ToontjeHoger` : "Ha! Speel mee met #ToontjeHoger en laat je verrassen: je bent muzikaler dat je denkt!";
const hashtags = [experimentCollectionTitle ? experimentCollectionTitle.replace(/ /g, '') : 'amsterdammusiclab'];

const social = {
'apps': ['facebook', 'twitter'],
'message': `I scored ${totalScore} points`,
'url': 'wwww.amsterdammusiclab.nl',
'hashtags': ["amsterdammusiclab", "citizenscience"]
apps: ['facebook', 'twitter'],
message,
url: currentUrl,
hashtags,
}

const useAnimatedScore = (targetScore: number) => {
Expand Down

0 comments on commit e7a3f37

Please sign in to comment.