diff --git a/frontend/src/components/MatchingPairs/MatchingPairs.tsx b/frontend/src/components/MatchingPairs/MatchingPairs.tsx index 7e37ade79..53e99e8a9 100644 --- a/frontend/src/components/MatchingPairs/MatchingPairs.tsx +++ b/frontend/src/components/MatchingPairs/MatchingPairs.tsx @@ -50,6 +50,7 @@ const MatchingPairs = ({ const [inBetweenTurns, setInBetweenTurns] = useState(false); const [score, setScore] = useState(null); const [total, setTotal] = useState(bonusPoints); + const [startOfTurn, setStartOfTurn] = useState(performance.now()); const columnCount = sections.length > 6 ? 4 : 3; @@ -117,14 +118,11 @@ const MatchingPairs = ({ currentCard.boardposition = index + 1; currentCard.timestamp = performance.now(); - const firstCardTimestamp = firstCard?.timestamp ?? 0; - currentCard.response_interval_ms = Math.round(currentCard.timestamp - firstCardTimestamp); - // check for match const first_card = firstCard; const second_card = currentCard; try { - const scoreResponse = await scoreIntermediateResult({ session, participant, result: { first_card, second_card } }); + const scoreResponse = await scoreIntermediateResult({ session, participant, result: { "start_of_turn": startOfTurn, first_card, second_card } }); if (!scoreResponse) { throw new Error('We cannot currently proceed with the game. Try again later'); } @@ -142,8 +140,6 @@ const MatchingPairs = ({ currentCard.noevents = true; currentCard.boardposition = index + 1; currentCard.timestamp = performance.now(); - // reset response interval in case this card has a value from a previous turn - currentCard.response_interval_ms = ''; // clear feedback text setFeedbackText(''); } @@ -152,6 +148,7 @@ const MatchingPairs = ({ }; const finishTurn = () => { + setStartOfTurn(performance.now()); finishedPlaying(); // remove matched cards from the board if (score === 10 || score === 20) {