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 unrated puzzles option #1445

Merged
merged 8 commits into from
Feb 20, 2025
Merged

Conversation

CloudyDino
Copy link
Contributor

@CloudyDino CloudyDino commented Feb 15, 2025

Unrated Puzzles

Close #1120
Close #297

Changes

  • Adds a switch to the puzzle settings screen to let users play unrated puzzles that don't affect their rating.
add.rated.game.switch.mp4
  • Logged out users don't see the rating switch:
logged.out.user.mp4

Testing

Tested using a proxy to spy on what app sends to API.

offline.testing.mp4
  1. First puzzle is correctly win: false, rated: true
{
	"solutions": [{
		"id": "24pDF",
		"win": false,
		"rated": true
	}]
}
  1. Second puzzle is correctly win: true, rated: true
{
	"solutions": [{
		"id": "7nI7d",
		"win": true,
		"rated": true
	}]
}
  1. Third puzzle is correctly win: true, rated: false
{
	"solutions": [{
		"id": "6YIPJ",
		"win": false,
		"rated": false
	}]
}
  1. Rest of the puzzles are played offline and are correctly rated once I turn the internet back on and the batch is submitted.
{
	"solutions": [{
		"id": "8Cm4H",
		"win": true,
		"rated": false
	}, {
		"id": "0haqU",
		"win": true,
		"rated": true
	}, {
		"id": "5T8Mz",
		"win": true,
		"rated": true
	}, {
		"id": "2106v",
		"win": false,
		"rated": true
	}, {
		"id": "2ZCbv",
		"win": false,
		"rated": false
	}, {
		"id": "9h38Q",
		"win": true,
		"rated": false
	}]
}

@CloudyDino CloudyDino force-pushed the unrated-puzzles branch 3 times, most recently from 264a498 to c0203dd Compare February 17, 2025 21:44
@veloce
Copy link
Contributor

veloce commented Feb 18, 2025

Thanks for this!

How does it work with batches? Puzzles work offline too. If you solve puzzle offline, the solution is saved until network is up again. Then batches of puzzle are solved at once.

@CloudyDino
Copy link
Contributor Author

@veloce Good catch! I updated the testing section above with a video that shows me turning on/off my wifi and turning on/off the rating. I then checked that once the internet was back, the batch puzzle submissions were all correctly rated or not rated. I think this should be ready for a final review

Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

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

Code looks good.

This feature should be tested. Puzzles are already well tested so it should be relatively easy to add a widget test.

There is already a widget test that solves a puzzle. I guess we should reuse that and intercept the mock storage to verify that the rated flag is correctly saved in database depending on the preferences.

@veloce
Copy link
Contributor

veloce commented Feb 20, 2025

I've rebased your branch to fix the CI @CloudyDino

@veloce
Copy link
Contributor

veloce commented Feb 20, 2025

I approved the code, but the puzzles tests are not OK. Can you have a look? Thanks.

@CloudyDino
Copy link
Contributor Author

@veloce
Removed the offending line await tester.pumpAndSettle().
Renamed rated to isRatedPreference.
Once this is merged in, I'll base the hints branch off of this for the tests over there

@CloudyDino CloudyDino mentioned this pull request Feb 20, 2025
Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

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

LGTM. Great job, thanks!

@veloce veloce merged commit 9dc51fa into lichess-org:main Feb 20, 2025
1 check passed
@CloudyDino CloudyDino deleted the unrated-puzzles branch February 20, 2025 20:08
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.

Not rated puzzles Add puzzle rating on/off toggle
2 participants