Skip to content

Commit 35ebc05

Browse files
authored
Merge pull request #11960 from ethereum/quizzes
Add back reverted quizzes: run-a-node, scaling, solo staking
2 parents d94a9f6 + 0813e43 commit 35ebc05

File tree

9 files changed

+666
-18
lines changed

9 files changed

+666
-18
lines changed

public/content/roadmap/scaling/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ This second step is known as [“Danksharding”](/roadmap/danksharding/). It is
4545
## Current progress {#current-progress}
4646

4747
Proto-Danksharding is likely to be one of the earlier roadmap items to be implemented. The decentralized computation steps required to set it up are already underway and several clients have implemented prototypes for handling blob data. Full Danksharding is likely several years away, as it relies upon several other roadmap items being completed first. Decentralizing rollup infrastructure is likely to be a gradual process - there are many different rollups that are building slightly different systems and will fully decentralize at different rates.
48+
49+
<QuizWidget quizKey="scaling" />

public/content/staking/solo/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,5 @@ To unlock and receive your entire balance back you must also complete the proces
202202
- [How To: Shop For Ethereum Validator Hardware](https://www.youtube.com/watch?v=C2wwu1IlhDc) - _EthStaker 2022_
203203
- [Step by Step: How to join the Ethereum 2.0 Testnet](https://kb.beaconcha.in/guides/tutorial-eth2-multiclient) - _Butta_
204204
- [Eth2 Slashing Prevention Tips](https://medium.com/prysmatic-labs/eth2-slashing-prevention-tips-f6faa5025f50) - _Raul Jordan 2020_
205+
206+
<QuizWidget quizKey="solo-staking" />

src/components/Quiz/QuizWidget/useQuizWidget.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export const useQuizWidget = ({
108108
if (!showResults) return
109109

110110
updateUserStats((prevStats) => {
111-
const lastScore = prevStats.completed[quizKey][1]
111+
const { completed } = prevStats
112+
const hasResultsSaved = !!completed[quizKey]
113+
const lastScore = hasResultsSaved ? prevStats.completed[quizKey][1] : 0
112114

113115
if (numberOfCorrectAnswers < lastScore) return prevStats
114116

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
import { CompletedQuizzes, UserStats } from "@/lib/types"
2-
3-
import allQuizzesData from "@/data/quizzes"
1+
import { UserStats } from "@/lib/types"
42

53
import { USER_STATS_KEY } from "@/lib/constants"
64

75
import { useLocalStorage } from "@/hooks/useLocalStorage"
86

9-
/**
10-
* Contains each quiz id as key and <boolean, number> to indicate if its completed and the highest score in that quiz
11-
*
12-
* Initialize all quizzes as not completed
13-
*/
14-
const INITIAL_COMPLETED_QUIZZES: CompletedQuizzes = Object.keys(
15-
allQuizzesData
16-
).reduce((object, key) => ({ ...object, [key]: [false, 0] }), {})
17-
187
export const INITIAL_USER_STATS: UserStats = {
198
score: 0,
209
average: [],
21-
completed: INITIAL_COMPLETED_QUIZZES,
10+
completed: {},
2211
}
2312

2413
export const useLocalQuizData = () => {
2514
const data = useLocalStorage(USER_STATS_KEY, INITIAL_USER_STATS)
2615

16+
// If the user has an old version of the app, convert the
17+
// `completed` value from a string to an object.
18+
const [current, setCurrent] = data
19+
if (typeof current.completed === "string") {
20+
setCurrent({ ...current, completed: JSON.parse(current.completed) })
21+
}
22+
2723
return data
2824
}

src/data/quizzes/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ const quizzes: RawQuizzes = {
3636
title: "learn-quizzes:page-assets-merge",
3737
questions: ["h001", "h002", "h003", "h004", "h005"],
3838
},
39+
"solo-staking": {
40+
title: "solo",
41+
questions: ["j001", "j002", "j004", "j005", "j006", "j007", "j008"],
42+
},
43+
scaling: {
44+
title: "scaling",
45+
questions: ["k001", "k002", "k003", "k004"],
46+
},
47+
"run-a-node": {
48+
title: "run-a-node",
49+
questions: ["l001", "l002", "l003", "l004", "l005", "l006"],
50+
},
3951
}
4052

4153
export const ethereumBasicsQuizzes: QuizzesSection[] = [
@@ -74,11 +86,26 @@ export const usingEthereumQuizzes: QuizzesSection[] = [
7486
{
7587
id: "nfts",
7688
level: "beginner",
89+
next: "scaling",
90+
},
91+
{
92+
id: "scaling",
93+
level: "intermediate",
7794
next: "layer-2",
7895
},
7996
{
8097
id: "layer-2",
8198
level: "intermediate",
99+
next: "run-a-node",
100+
},
101+
{
102+
id: "run-a-node",
103+
level: "intermediate",
104+
next: "solo-staking",
105+
},
106+
{
107+
id: "solo-staking",
108+
level: "advanced",
82109
},
83110
]
84111

0 commit comments

Comments
 (0)