File tree Expand file tree Collapse file tree 5 files changed +160
-61
lines changed Expand file tree Collapse file tree 5 files changed +160
-61
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
3
3
import dracula from 'react-syntax-highlighter/dist/cjs/styles/prism/dracula'
4
4
import { CopyToClipboard } from '../CopyToClipboard'
5
5
import SideDrawer from './SideDrawer'
6
- import Form from './Form '
6
+ import Quiz from './Quiz '
7
7
import Callout from './Callout'
8
8
9
9
const Components = {
@@ -42,7 +42,7 @@ const Components = {
42
42
) ,
43
43
SideDrawer,
44
44
Callout,
45
- Form ,
45
+ Quiz ,
46
46
}
47
47
48
48
export default Components
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import {
2
+ Box ,
3
+ VStack ,
4
+ Text ,
5
+ Button ,
6
+ Modal ,
7
+ ModalOverlay ,
8
+ ModalContent ,
9
+ ModalHeader ,
10
+ ModalFooter ,
11
+ ModalBody ,
12
+ ModalCloseButton ,
13
+ } from '@chakra-ui/react'
14
+ import React , { FC , useState } from 'react'
15
+
16
+ interface QuizProps {
17
+ quiz : string
18
+ }
19
+
20
+ interface Quiz {
21
+ title : string
22
+ questions : [
23
+ {
24
+ question : string
25
+ options : [
26
+ {
27
+ answer : string
28
+ correct ?: boolean
29
+ } ,
30
+ ]
31
+ } ,
32
+ ]
33
+ }
34
+
35
+ const Quiz : FC < QuizProps > = ( props : QuizProps ) => {
36
+ const quiz : Quiz = require ( `../../utils/quizzes/${ props . quiz } .json` )
37
+ const [ showQuiz , setShowQuiz ] = useState ( false )
38
+ const [ currenQuestionIndex , setCurrentQuestionIndex ] = useState ( 0 )
39
+
40
+ return (
41
+ < >
42
+ { ! showQuiz && (
43
+ < Button
44
+ colorScheme = "yellow"
45
+ backgroundColor = "yellow.600"
46
+ display = "flex"
47
+ margin = "auto"
48
+ onClick = { ( ) => setShowQuiz ( true ) }
49
+ >
50
+ Take quiz
51
+ </ Button >
52
+ ) }
53
+
54
+ < Modal
55
+ closeOnOverlayClick = { false }
56
+ isOpen = { showQuiz }
57
+ onClose = { ( ) => setShowQuiz ( false ) }
58
+ >
59
+ < ModalOverlay />
60
+ < ModalContent >
61
+ < ModalHeader > { quiz . title } </ ModalHeader >
62
+ < ModalCloseButton />
63
+ < ModalBody pb = { 6 } >
64
+ < VStack
65
+ spacing = { 4 }
66
+ background = "gray.900"
67
+ padding = "6"
68
+ borderRadius = "md"
69
+ >
70
+ < Text fontWeight = "bold" w = "100%" >
71
+ { quiz . questions [ currenQuestionIndex ] . question }
72
+ </ Text >
73
+ < Box
74
+ w = "100%"
75
+ borderRadius = "md"
76
+ background = "gray.600"
77
+ padding = "3"
78
+ cursor = "pointer"
79
+ >
80
+ Transactions
81
+ </ Box >
82
+ < Box
83
+ w = "100%"
84
+ borderRadius = "md"
85
+ background = "yellow.600"
86
+ padding = "3"
87
+ cursor = "pointer"
88
+ >
89
+ Smart Contracts
90
+ </ Box >
91
+ < Box
92
+ w = "100%"
93
+ borderRadius = "md"
94
+ background = "gray.600"
95
+ padding = "3"
96
+ cursor = "pointer"
97
+ >
98
+ Just user wallets have an address
99
+ </ Box >
100
+ < Box
101
+ display = "flex"
102
+ justifyContent = "space-between"
103
+ w = "100%"
104
+ alignItems = "center"
105
+ >
106
+ < Text w = "100%" > { `Question ${ currenQuestionIndex + 1 } /${
107
+ quiz . questions . length
108
+ } `} </ Text >
109
+ < Box w = "100%" display = "flex" >
110
+ < Button mx = "2" > { '< Previous' } </ Button >
111
+ < Button > { 'Next >' } </ Button >
112
+ </ Box >
113
+ </ Box >
114
+ </ VStack >
115
+ </ ModalBody >
116
+
117
+ < ModalFooter >
118
+ < Button
119
+ mx = "1"
120
+ colorScheme = "red"
121
+ backgroundColor = "red.600"
122
+ onClick = { ( ) => setShowQuiz ( false ) }
123
+ >
124
+ Cancel
125
+ </ Button >
126
+ < Button mx = "1" colorScheme = "green" backgroundColor = "green.400" >
127
+ Submit
128
+ </ Button >
129
+ </ ModalFooter >
130
+ </ ModalContent >
131
+ </ Modal >
132
+ </ >
133
+ )
134
+ }
135
+
136
+ export default Quiz
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ icons: ['solidity', 'remix']
6
6
7
7
# Lesson 1: Intro to Smart Contract Development
8
8
9
+ <Quiz quiz = " lesson-1" />
10
+
9
11
## What are we building?
10
12
11
13
### Where are we going with it? Web what? Smart contract?
@@ -725,7 +727,5 @@ Can a view function modify the state of the blockchain?
725
727
726
728
What can we use a smart contract for?
727
729
728
- <Form />
729
-
730
730
** Now, go to the community in Discord to share your new Open Sourcerer
731
731
powers** ......and find the answers too!!!
Original file line number Diff line number Diff line change
1
+ {
2
+ "title" : " Quiz: Lesson 1" ,
3
+ "questions" : [
4
+ {
5
+ "question" : " ❓ Apart from a user wallet, what else uses a blockchain (Ethereum) address?" ,
6
+ "options" : [
7
+ {
8
+ "answer" : " Transactions"
9
+ },
10
+ {
11
+ "answer" : " Smart contracts" ,
12
+ "correct" : true
13
+ },
14
+ {
15
+ "answer" : " Just user wallets have an address"
16
+ }
17
+ ]
18
+ }
19
+ ]
20
+ }
You can’t perform that action at this time.
0 commit comments