Skip to content

Commit

Permalink
Merge pull request #11960 from ethereum/quizzes
Browse files Browse the repository at this point in the history
Add back reverted quizzes: run-a-node, scaling, solo staking
  • Loading branch information
pettinarip authored Jan 29, 2024
2 parents d94a9f6 + 0813e43 commit 35ebc05
Show file tree
Hide file tree
Showing 9 changed files with 666 additions and 18 deletions.
2 changes: 2 additions & 0 deletions public/content/roadmap/scaling/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ This second step is known as [“Danksharding”](/roadmap/danksharding/). It is
## Current progress {#current-progress}

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.

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

<QuizWidget quizKey="solo-staking" />
4 changes: 3 additions & 1 deletion src/components/Quiz/QuizWidget/useQuizWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export const useQuizWidget = ({
if (!showResults) return

updateUserStats((prevStats) => {
const lastScore = prevStats.completed[quizKey][1]
const { completed } = prevStats
const hasResultsSaved = !!completed[quizKey]
const lastScore = hasResultsSaved ? prevStats.completed[quizKey][1] : 0

if (numberOfCorrectAnswers < lastScore) return prevStats

Expand Down
22 changes: 9 additions & 13 deletions src/components/Quiz/useLocalQuizData.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { CompletedQuizzes, UserStats } from "@/lib/types"

import allQuizzesData from "@/data/quizzes"
import { UserStats } from "@/lib/types"

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

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

/**
* Contains each quiz id as key and <boolean, number> to indicate if its completed and the highest score in that quiz
*
* Initialize all quizzes as not completed
*/
const INITIAL_COMPLETED_QUIZZES: CompletedQuizzes = Object.keys(
allQuizzesData
).reduce((object, key) => ({ ...object, [key]: [false, 0] }), {})

export const INITIAL_USER_STATS: UserStats = {
score: 0,
average: [],
completed: INITIAL_COMPLETED_QUIZZES,
completed: {},
}

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

// If the user has an old version of the app, convert the
// `completed` value from a string to an object.
const [current, setCurrent] = data
if (typeof current.completed === "string") {
setCurrent({ ...current, completed: JSON.parse(current.completed) })
}

return data
}
27 changes: 27 additions & 0 deletions src/data/quizzes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ const quizzes: RawQuizzes = {
title: "learn-quizzes:page-assets-merge",
questions: ["h001", "h002", "h003", "h004", "h005"],
},
"solo-staking": {
title: "solo",
questions: ["j001", "j002", "j004", "j005", "j006", "j007", "j008"],
},
scaling: {
title: "scaling",
questions: ["k001", "k002", "k003", "k004"],
},
"run-a-node": {
title: "run-a-node",
questions: ["l001", "l002", "l003", "l004", "l005", "l006"],
},
}

export const ethereumBasicsQuizzes: QuizzesSection[] = [
Expand Down Expand Up @@ -74,11 +86,26 @@ export const usingEthereumQuizzes: QuizzesSection[] = [
{
id: "nfts",
level: "beginner",
next: "scaling",
},
{
id: "scaling",
level: "intermediate",
next: "layer-2",
},
{
id: "layer-2",
level: "intermediate",
next: "run-a-node",
},
{
id: "run-a-node",
level: "intermediate",
next: "solo-staking",
},
{
id: "solo-staking",
level: "advanced",
},
]

Expand Down
Loading

0 comments on commit 35ebc05

Please sign in to comment.