|
1 | | -import { |
2 | | - AnswerChoice, |
3 | | - MultipleChoiceQuizQuestion, |
4 | | - QuizPrinter, |
5 | | - QuizQuestion, |
6 | | -} from "codedifferently-instructional"; |
7 | | - |
8 | | -export class Lesson2 { |
9 | | - run(): void { |
10 | | - const quizQuestions = Lesson2.makeQuizQuestions(); |
11 | | - if (!quizQuestions) throw new Error("Quiz questions cannot be null"); |
12 | | - const printer = new QuizPrinter(); |
13 | | - printer.printQuiz(quizQuestions); |
14 | | - } |
15 | | - |
16 | | - static makeQuizQuestions(): QuizQuestion[] { |
17 | | - return [ |
18 | | - Lesson2.makeQuestion0(), |
19 | | - Lesson2.makeQuestion1(), |
20 | | - Lesson2.makeQuestion2(), |
21 | | - Lesson2.makeQuestion3(), |
22 | | - Lesson2.makeQuestion4(), |
23 | | - Lesson2.makeQuestion5(), |
24 | | - Lesson2.makeQuestion6(), |
25 | | - Lesson2.makeQuestion7(), |
26 | | - Lesson2.makeQuestion8(), |
27 | | - Lesson2.makeQuestion9(), |
28 | | - Lesson2.makeQuestion10(), |
29 | | - ]; |
30 | | - } |
31 | | - |
32 | | - private static makeQuestion0(): QuizQuestion { |
33 | | - return new MultipleChoiceQuizQuestion( |
34 | | - 0, |
35 | | - "What is the main purpose of version control?", |
36 | | - new Map([ |
37 | | - [AnswerChoice.A, "To make backups of files"], |
38 | | - [AnswerChoice.B, "To keep a record of changes over time"], |
39 | | - [AnswerChoice.C, "To delete unnecessary files"], |
40 | | - [AnswerChoice.D, "To run code more efficiently"], |
41 | | - ]), |
42 | | - AnswerChoice.B |
43 | | - ); |
44 | | - } |
45 | | - |
46 | | - private static makeQuestion1(): QuizQuestion { |
47 | | - return new MultipleChoiceQuizQuestion( |
48 | | - 1, |
49 | | - "What is a fork in Git?", |
50 | | - new Map([ |
51 | | - [AnswerChoice.A, "A duplicate copy of a repository that you own and modify"], |
52 | | - [AnswerChoice.B, "A temporary backup of the code"], |
53 | | - [AnswerChoice.C, "A tool for merging branches"], |
54 | | - [AnswerChoice.D, "A way to delete a repository"], |
55 | | - ]), |
56 | | - AnswerChoice.A |
57 | | - ); |
58 | | - } |
59 | | - |
60 | | - private static makeQuestion2(): QuizQuestion { |
61 | | - return new MultipleChoiceQuizQuestion( |
62 | | - 2, |
63 | | - "Which of the following is NOT part of the basic Git workflow?", |
64 | | - new Map([ |
65 | | - [AnswerChoice.A, "Pull the latest changes"], |
66 | | - [AnswerChoice.B, "Commit changes locally"], |
67 | | - [AnswerChoice.C, "Push changes to the server"], |
68 | | - [AnswerChoice.D, "Write code directly in GitHub"], |
69 | | - ]), |
70 | | - AnswerChoice.D |
71 | | - ); |
72 | | - } |
73 | | - |
74 | | - private static makeQuestion3(): QuizQuestion { |
75 | | - return new MultipleChoiceQuizQuestion( |
76 | | - 3, |
77 | | - "What command is used to combine changes from different branches?", |
78 | | - new Map([ |
79 | | - [AnswerChoice.A, "git commit"], |
80 | | - [AnswerChoice.B, "git merge"], |
81 | | - [AnswerChoice.C, "git branch"], |
82 | | - [AnswerChoice.D, "git pull"], |
83 | | - ]), |
84 | | - AnswerChoice.B |
85 | | - ); |
86 | | - } |
87 | | - |
88 | | - private static makeQuestion4(): QuizQuestion { |
89 | | - return new MultipleChoiceQuizQuestion( |
90 | | - 4, |
91 | | - "Which IDE is being used in the class?", |
92 | | - new Map([ |
93 | | - [AnswerChoice.A, "Eclipse"], |
94 | | - [AnswerChoice.B, "IntelliJ IDEA"], |
95 | | - [AnswerChoice.C, "NetBeans"], |
96 | | - [AnswerChoice.D, "VS Code"], |
97 | | - ]), |
98 | | - AnswerChoice.D |
99 | | - ); |
100 | | - } |
101 | | - |
102 | | - private static makeQuestion5(): QuizQuestion { |
103 | | - return new MultipleChoiceQuizQuestion( |
104 | | - 5, |
105 | | - "What feature allows developers to work from the same pre-configured environment in VS Code?", |
106 | | - new Map([ |
107 | | - [AnswerChoice.A, "Extensions"], |
108 | | - [AnswerChoice.B, "Debugger"], |
109 | | - [AnswerChoice.C, "Dev Containers"], |
110 | | - [AnswerChoice.D, "Source Control"], |
111 | | - ]), |
112 | | - AnswerChoice.C |
113 | | - ); |
114 | | - } |
115 | | - |
116 | | - private static makeQuestion6(): QuizQuestion { |
117 | | - return new MultipleChoiceQuizQuestion( |
118 | | - 6, |
119 | | - "What is NOT a reason for using an IDE?", |
120 | | - new Map([ |
121 | | - [AnswerChoice.A, "Editing and refactoring code"], |
122 | | - [AnswerChoice.B, "Browsing code"], |
123 | | - [AnswerChoice.C, "Playing music"], |
124 | | - [AnswerChoice.D, "Managing source control"], |
125 | | - ]), |
126 | | - AnswerChoice.C |
127 | | - ); |
128 | | - } |
129 | | - |
130 | | - private static makeQuestion7(): QuizQuestion { |
131 | | - return new MultipleChoiceQuizQuestion( |
132 | | - 7, |
133 | | - "What is the command to list files in the current directory?", |
134 | | - new Map([ |
135 | | - [AnswerChoice.A, "pwd"], |
136 | | - [AnswerChoice.B, "ls"], |
137 | | - [AnswerChoice.C, "cd"], |
138 | | - [AnswerChoice.D, "mkdir"], |
139 | | - ]), |
140 | | - AnswerChoice.B |
141 | | - ); |
142 | | - } |
143 | | - |
144 | | - private static makeQuestion8(): QuizQuestion { |
145 | | - return new MultipleChoiceQuizQuestion( |
146 | | - 8, |
147 | | - "Which command is used to change directories in the terminal?", |
148 | | - new Map([ |
149 | | - [AnswerChoice.A, "pwd"], |
150 | | - [AnswerChoice.B, "ls"], |
151 | | - [AnswerChoice.C, "cd"], |
152 | | - [AnswerChoice.D, "mkdir"], |
153 | | - ]), |
154 | | - AnswerChoice.C |
155 | | - ); |
156 | | - } |
157 | | - |
158 | | - private static makeQuestion9(): QuizQuestion { |
159 | | - return new MultipleChoiceQuizQuestion( |
160 | | - 9, |
161 | | - "What does the command `chmod` do?", |
162 | | - new Map([ |
163 | | - [AnswerChoice.A, "Change file or directory permissions"], |
164 | | - [AnswerChoice.B, "List files in a directory"], |
165 | | - [AnswerChoice.C, "Remove a file or directory"], |
166 | | - [AnswerChoice.D, "Copy a file or directory"], |
167 | | - ]), |
168 | | - AnswerChoice.A |
169 | | - ); |
170 | | - } |
171 | | - |
172 | | - private static makeQuestion10(): QuizQuestion { |
173 | | - return new MultipleChoiceQuizQuestion( |
174 | | - 10, |
175 | | - "What is the shortcut for getting to the Mac terminal?", |
176 | | - new Map([ |
177 | | - [AnswerChoice.A, "⌘ + Shift + T"], |
178 | | - [AnswerChoice.B, '⌘ + Spacebar, then type "terminal"'], |
179 | | - [AnswerChoice.C, "⌘ + Q"], |
180 | | - [AnswerChoice.D, '⌘ + S, then type "terminal"'], |
181 | | - ]), |
182 | | - AnswerChoice.B |
183 | | - ); |
184 | | - } |
185 | | -} |
186 | | - |
187 | | -if (!process.env.JEST_WORKER_ID) { |
188 | | - new Lesson2().run(); |
189 | | -} |
| 1 | + 1 import { |
| 2 | + 2 AnswerChoice, |
| 3 | + 3 MultipleChoiceQuizQuestion, |
| 4 | + 4 QuizPrinter, |
| 5 | + 5 QuizQuestion, |
| 6 | + 6 } from "codedifferently-instructional"; |
| 7 | + 7 |
| 8 | + 8 export class Lesson2 { |
| 9 | + 9 run(): void { |
| 10 | +10 const quizQuestions = Lesson2.makeQuizQuestions(); |
| 11 | +11 if (!quizQuestions) throw new Error("Quiz questions cannot be null"); |
| 12 | +12 const printer = new QuizPrinter(); |
| 13 | +13 printer.printQuiz(quizQuestions); |
| 14 | +14 } |
| 15 | +15 |
| 16 | +16 static makeQuizQuestions(): QuizQuestion[] { |
| 17 | +17 return [ |
| 18 | +18 Lesson2.makeQuestion0(), |
| 19 | +19 Lesson2.makeQuestion1(), |
| 20 | +20 Lesson2.makeQuestion2(), |
| 21 | +21 Lesson2.makeQuestion3(), |
| 22 | +22 Lesson2.makeQuestion4(), |
| 23 | +23 Lesson2.makeQuestion5(), |
| 24 | +24 Lesson2.makeQuestion6(), |
| 25 | +25 Lesson2.makeQuestion7(), |
| 26 | +26 Lesson2.makeQuestion8(), |
| 27 | +27 Lesson2.makeQuestion9(), |
| 28 | +28 Lesson2.makeQuestion10(), |
| 29 | +29 ]; |
| 30 | +30 } |
| 31 | +31 |
| 32 | +32 private static makeQuestion0(): QuizQuestion { |
| 33 | +33 return new MultipleChoiceQuizQuestion( |
| 34 | +34 0, |
| 35 | +35 "What is the main purpose of version control?", |
| 36 | +36 new Map([ |
| 37 | +37 [AnswerChoice.A, "To make backups of files"], |
| 38 | +38 [AnswerChoice.B, "To keep a record of changes over time"], |
| 39 | +39 [AnswerChoice.C, "To delete unnecessary files"], |
| 40 | +40 [AnswerChoice.D, "To run code more efficiently"], |
| 41 | +41 ]), |
| 42 | +42 AnswerChoice.B |
| 43 | +43 ); |
| 44 | +44 } |
| 45 | +45 |
| 46 | +46 private static makeQuestion1(): QuizQuestion { |
| 47 | +47 return new MultipleChoiceQuizQuestion( |
| 48 | +48 1, |
| 49 | +49 "What is a fork in Git?", |
| 50 | +50 new Map([ |
| 51 | +51 [AnswerChoice.A, "A duplicate copy of a repository that you own and modify"], |
| 52 | +52 [AnswerChoice.B, "A temporary backup of the code"], |
| 53 | +53 [AnswerChoice.C, "A tool for merging branches"], |
| 54 | +54 [AnswerChoice.D, "A way to delete a repository"], |
| 55 | +55 ]), |
| 56 | +56 AnswerChoice.A |
| 57 | +57 ); |
| 58 | +58 } |
| 59 | +59 |
| 60 | +60 private static makeQuestion2(): QuizQuestion { |
| 61 | +61 return new MultipleChoiceQuizQuestion( |
| 62 | +62 2, |
| 63 | +63 "Which of the following is NOT part of the basic Git workflow?", |
| 64 | +64 new Map([ |
| 65 | +65 [AnswerChoice.A, "Pull the latest changes"], |
| 66 | +66 [AnswerChoice.B, "Commit changes locally"], |
| 67 | +67 [AnswerChoice.C, "Push changes to the server"], |
| 68 | +68 [AnswerChoice.D, "Write code directly in GitHub"], |
| 69 | +69 ]), |
| 70 | +70 AnswerChoice.D |
| 71 | +71 ); |
| 72 | +72 } |
| 73 | +73 |
| 74 | +74 private static makeQuestion3(): QuizQuestion { |
| 75 | +75 return new MultipleChoiceQuizQuestion( |
| 76 | +76 3, |
| 77 | +77 "What command is used to combine changes from different branches?", |
| 78 | +78 new Map([ |
| 79 | +79 [AnswerChoice.A, "git commit"], |
| 80 | +80 [AnswerChoice.B, "git merge"], |
| 81 | +81 [AnswerChoice.C, "git branch"], |
| 82 | +82 [AnswerChoice.D, "git pull"], |
| 83 | +83 ]), |
| 84 | +84 AnswerChoice.B |
| 85 | +85 ); |
| 86 | +86 } |
| 87 | +87 |
| 88 | +88 private static makeQuestion4(): QuizQuestion { |
| 89 | +89 return new MultipleChoiceQuizQuestion( |
| 90 | +90 4, |
| 91 | +91 "Which IDE is being used in the class?", |
| 92 | +92 new Map([ |
| 93 | +93 [AnswerChoice.A, "Eclipse"], |
| 94 | +94 [AnswerChoice.B, "IntelliJ IDEA"], |
| 95 | +95 [AnswerChoice.C, "NetBeans"], |
| 96 | +96 [AnswerChoice.D, "VS Code"], |
| 97 | +97 ]), |
| 98 | +98 AnswerChoice.D |
| 99 | +99 ); |
| 100 | +100 } |
| 101 | +101 |
| 102 | +102 private static makeQuestion5(): QuizQuestion { |
| 103 | +103 return new MultipleChoiceQuizQuestion( |
| 104 | +104 5, |
| 105 | +105 "What feature allows developers to work from the same pre-configured environment in VS Code?", |
| 106 | +106 new Map([ |
| 107 | +107 [AnswerChoice.A, "Extensions"], |
| 108 | +108 [AnswerChoice.B, "Debugger"], |
| 109 | +109 [AnswerChoice.C, "Dev Containers"], |
| 110 | +110 [AnswerChoice.D, "Source Control"], |
| 111 | +111 ]), |
| 112 | +112 AnswerChoice.C |
| 113 | +113 ); |
| 114 | +114 } |
| 115 | +115 |
| 116 | +116 private static makeQuestion6(): QuizQuestion { |
| 117 | +117 return new MultipleChoiceQuizQuestion( |
| 118 | +118 6, |
| 119 | +119 "What is NOT a reason for using an IDE?", |
| 120 | +120 new Map([ |
| 121 | +121 [AnswerChoice.A, "Editing and refactoring code"], |
| 122 | +122 [AnswerChoice.B, "Browsing code"], |
| 123 | +123 [AnswerChoice.C, "Playing music"], |
| 124 | +124 [AnswerChoice.D, "Managing source control"], |
| 125 | +125 ]), |
| 126 | +126 AnswerChoice.C |
| 127 | +127 ); |
| 128 | +128 } |
| 129 | +129 |
| 130 | +130 private static makeQuestion7(): QuizQuestion { |
| 131 | +131 return new MultipleChoiceQuizQuestion( |
| 132 | +132 7, |
| 133 | +133 "What is the command to list files in the current directory?", |
| 134 | +134 new Map([ |
| 135 | +135 [AnswerChoice.A, "pwd"], |
| 136 | +136 [AnswerChoice.B, "ls"], |
| 137 | +137 [AnswerChoice.C, "cd"], |
| 138 | +138 [AnswerChoice.D, "mkdir"], |
| 139 | +139 ]), |
| 140 | +140 AnswerChoice.B |
| 141 | +141 ); |
| 142 | +142 } |
| 143 | +143 |
| 144 | +144 private static makeQuestion8(): QuizQuestion { |
| 145 | +145 return new MultipleChoiceQuizQuestion( |
| 146 | +146 8, |
| 147 | +147 "Which command is used to change directories in the terminal?", |
| 148 | +148 new Map([ |
| 149 | +149 [AnswerChoice.A, "pwd"], |
| 150 | +150 [AnswerChoice.B, "ls"], |
| 151 | +151 [AnswerChoice.C, "cd"], |
| 152 | +152 [AnswerChoice.D, "mkdir"], |
| 153 | +153 ]), |
| 154 | +154 AnswerChoice.C |
| 155 | +155 ); |
| 156 | +156 } |
| 157 | +157 |
| 158 | +158 private static makeQuestion9(): QuizQuestion { |
| 159 | +159 return new MultipleChoiceQuizQuestion( |
| 160 | +160 9, |
| 161 | +161 "What does the command `chmod` do?", |
| 162 | +162 new Map([ |
| 163 | +163 [AnswerChoice.A, "Change file or directory permissions"], |
| 164 | +164 [AnswerChoice.B, "List files in a directory"], |
| 165 | +165 [AnswerChoice.C, "Remove a file or directory"], |
| 166 | +166 [AnswerChoice.D, "Copy a file or directory"], |
| 167 | +167 ]), |
| 168 | +168 AnswerChoice.A |
| 169 | +169 ); |
| 170 | +170 } |
| 171 | +171 |
| 172 | +172 private static makeQuestion10(): QuizQuestion { |
| 173 | +173 return new MultipleChoiceQuizQuestion( |
| 174 | +174 10, |
| 175 | +175 "What is the shortcut for getting to the Mac terminal?", |
| 176 | +176 new Map([ |
| 177 | +177 [AnswerChoice.A, "⌘ + Shift + T"], |
| 178 | +178 [AnswerChoice.B, '⌘ + Spacebar, then type "terminal"'], |
| 179 | +179 [AnswerChoice.C, "⌘ + Q"], |
| 180 | +180 [AnswerChoice.D, '⌘ + S, then type "terminal"'], |
| 181 | +181 ]), |
| 182 | +182 AnswerChoice.B |
| 183 | +183 ); |
| 184 | +184 } |
| 185 | +185 } |
| 186 | +186 |
| 187 | +187 if (!process.env.JEST_WORKER_ID) { |
| 188 | +188 new Lesson2().run(); |
| 189 | +189 } |
0 commit comments