Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timestamp for start of turn #1350

Merged
merged 7 commits into from
Nov 7, 2024

Conversation

Evert-R
Copy link
Contributor

@Evert-R Evert-R commented Nov 5, 2024

This PR sets a timestamp start_of_turn in the result of the first card.
First when the board has been loaded, then on every third click of a turn.

Closes: #1298

Copy link
Collaborator

@BeritJanssen BeritJanssen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of analyzing data: I think it would be better to not set the start_of_turn variable on each card, but instead, send a start_of_turn variable within the result object. This will be saved to the results' json data. The response_interval_ms can probably be removed (check with @Lia-JX-Li ), as it can be derived from the timestamps.

@@ -62,6 +62,8 @@ const MatchingPairs = ({
yPosition.current = posY;
}

let startOfTurn = performance.now();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work like this in React? 🤔 If written like this, I expect startOfTurn to be overwritten in every re-render... I would expect a state variable that gets set on initialization and to be set again using setStartOfTurn in the finishTurn function (same place as you now do the reassignment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did work but using a state variable would indeed be better.

@@ -141,7 +142,8 @@ const MatchingPairs = ({
currentCard.turned = true;
currentCard.noevents = true;
currentCard.boardposition = index + 1;
currentCard.timestamp = performance.now();
setStartOfTurn(performance.now());
currentCard.start_of_turn = startOfTurn;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
currentCard.start_of_turn = startOfTurn;

@@ -152,6 +154,7 @@ const MatchingPairs = ({
};

const finishTurn = () => {
setStartOfTurn(performance.now());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set this here and at line 145? Wouldn't it be enough to do it in one of those two places?

@Evert-R
Copy link
Contributor Author

Evert-R commented Nov 5, 2024 via email

@Evert-R
Copy link
Contributor Author

Evert-R commented Nov 7, 2024

In terms of analyzing data: I think it would be better to not set the start_of_turn variable on each card, but instead, send a start_of_turn variable within the result object. This will be saved to the results' json data. The response_interval_ms can probably be removed (check with @Lia-JX-Li ), as it can be derived from the timestamps.

start_of_turn is indeed more clear, so I changed it back. I removed the response_interval_ms after consulting with Lia.

@Evert-R Evert-R merged commit 56ac741 into develop Nov 7, 2024
11 checks passed
@Evert-R Evert-R deleted the feature-er/add-timestamps-matching-pairs branch November 7, 2024 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a timestamp for every action in matching pairs
3 participants