Skip to content

Commit 4391f82

Browse files
authored
Merge branch 'main' into Chutt_lesson03
2 parents 4caf300 + 5d1a93c commit 4391f82

File tree

9 files changed

+332
-39
lines changed

9 files changed

+332
-39
lines changed

lesson_03/quiz/quiz.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ quiz:
66
anotherone:
77
- $2y$10$8eHSzy3aCu4Ry3LzO9nWCeGpofSxsNVbnF.wCfn3ZADwQ6MEtN/KK
88
- $2y$10$dGB0CGv7.XQC5OqfyY6iXOiJsdVyxU3ve5YE0gt4m2I8P8H13lNXa
9+
ezraquiz:
10+
- $2y$10$fisFjMsmMwzlj3.PELyBNeupdruYROU00dwq296pg0VfHo05SSkta
11+
- $2y$10$.Z44VoTaxQSdPEx7RatO6OVCw1ff6ohS0kZnCrHEcFnElIgkfjP0u
12+
- $2y$10$nCm/E52FKO7DRo4XbpR2vu.HTyAzsDNNZr2dDfYJyblY1oLuGpnPO
913
meikostephens:
1014
- $2y$10$AD1YHmrZZivus7DoM91UMuErNnpi63ueluFs7DcSQSrZbXwDycAOi
1115
- $2y$10$KvnxAYKh3A151RyOOFtOv.wfImRzZMgbBgKy3gyLd1uUSSjHaN.4u
@@ -33,4 +37,14 @@ quiz:
3337
chanelhutt:
3438
- $2y$10$7/GS4n5j/5TXQc5zjDzlc.2xBKwRqrsksWzcl7VKRwa.fDxzdficS
3539
- $2y$10$9mfdal67CXoVG2phPKe1s.BpAT6HQeyQIiDtStfFazkPMW2AaW6Zu
36-
- $2y$10$LiCnvad23bwZWZbxXLhs3.r/YdwIX9eAFtjofaW1AH3Htnc9sEU1G
40+
- $2y$10$LiCnvad23bwZWZbxXLhs3.r/YdwIX9eAFtjofaW1AH3Htnc9sEU1G
41+
jeremiahwing:
42+
- $2y$10$YLN9gvb8/fBf3ByHNIdb9.UZ8ilcuCdPgZN9QIYd2rwD23vzt2lvy
43+
- $2y$10$AEUmg5pH8c2VLZ871//G4eKjwx5cnKH5c2HGTNXdnAPF.3/ZmNap2
44+
- $2y$10$bcTYSI0R/3x0pPHcGPAjautopYx2MD8mJPqf2nXKMJeteoIwJQrQm
45+
- $2y$10$V8pMtwgtZe725nPssrr8kejs4Evh/Vi3ia8RulylOQ8x2YV4tJ4LO
46+
jasonwatson:
47+
- $2y$10$AZtPKyQ.6Bzb.jreO/u.2O3C7XfvYAVpjHzLkuhLVdsX74wc4vXwS
48+
- $2y$10$QbKtEXqpeItigRLAHsn8Qe/06ZpXhKEP1bGPJSFXymsoFw9.04NHy
49+
- $2y$10$tJLScW1OZpOLpVllM65EI.W1QjkSIIBtz.KG8z/s.07RNb7ZWC0um
50+

lesson_03/quiz/src/lesson3.test.ts

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,52 +80,57 @@ describe('Lesson3Test', () => {
8080
maybeIt(
8181
'checks multiple choice answers are configured correctly',
8282
async () => {
83-
for (const [providerName, questions] of quizQuestionsByProvider) {
84-
for (const question of questions) {
85-
if (!(question instanceof MultipleChoiceQuizQuestion)) {
86-
continue;
87-
}
88-
89-
// Assert that multiple choice questions have at least one correct answer.
90-
const choices = question.getAnswerChoices();
91-
const areAnswersValid = await Promise.all(
92-
[...choices].map(async (choice) => {
93-
return quizConfig.checkAnswer(
94-
providerName,
95-
question.getQuestionNumber(),
96-
choice,
97-
);
98-
}),
99-
);
100-
101-
expect(areAnswersValid.some((isCorrect) => isCorrect)).toBe(true);
83+
const { providerName, questions } = getQuestionsFromCurrentProvider();
84+
for (const question of questions) {
85+
if (!(question instanceof MultipleChoiceQuizQuestion)) {
86+
continue;
10287
}
88+
89+
// Assert that multiple choice questions have at least one correct answer.
90+
const choices = question.getAnswerChoices();
91+
const areAnswersValid = await Promise.all(
92+
[...choices].map(async (choice) => {
93+
return quizConfig.checkAnswer(
94+
providerName,
95+
question.getQuestionNumber(),
96+
choice,
97+
);
98+
}),
99+
);
100+
101+
expect(areAnswersValid.some((isCorrect) => isCorrect)).toBe(true);
103102
}
104103
},
105104
);
106105

107106
maybeIt('checks for correct answers', async () => {
107+
const { providerName, questions } = getQuestionsFromCurrentProvider();
108+
for (const question of questions) {
109+
const actualAnswer = question.getAnswer();
110+
softExpect(actualAnswer).not.toBe(AnswerChoice.UNANSWERED);
111+
softExpect(
112+
await quizConfig.checkAnswer(
113+
providerName,
114+
question.getQuestionNumber(),
115+
actualAnswer,
116+
),
117+
).toBe(true);
118+
}
119+
});
120+
121+
function getQuestionsFromCurrentProvider(): {
122+
providerName: string;
123+
questions: QuizQuestion[];
124+
} {
108125
const targetProviderName = process.env.PROVIDER_NAME?.trim() || '';
109126

110127
if (!quizQuestionsByProvider.has(targetProviderName)) {
111128
throw new Error(`Unknown provider name: ${targetProviderName}`);
112129
}
113130

114-
for (const [providerName, questions] of quizQuestionsByProvider) {
115-
if (providerName !== process.env.PROVIDER_NAME?.trim()) {
116-
continue;
117-
}
118-
for (const question of questions) {
119-
const actualAnswer = question.getAnswer();
120-
softExpect(actualAnswer).not.toBe(AnswerChoice.UNANSWERED);
121-
softExpect(
122-
await quizConfig.checkAnswer(
123-
providerName,
124-
question.getQuestionNumber(),
125-
actualAnswer,
126-
),
127-
).toBe(true);
128-
}
129-
}
130-
});
131+
return {
132+
providerName: targetProviderName,
133+
questions: quizQuestionsByProvider.get(targetProviderName) || [],
134+
};
135+
}
131136
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {
2+
AnswerChoice,
3+
MultipleChoiceQuizQuestion,
4+
} from 'codedifferently-instructional';
5+
6+
export class EzraQuiz {
7+
getProviderName() {
8+
return 'ezraquiz';
9+
}
10+
11+
makeQuizQuestions() {
12+
return [
13+
EzraQuiz.makeQuestion0(),
14+
EzraQuiz.makeQuestion1(),
15+
EzraQuiz.makeQuestion2(),
16+
];
17+
}
18+
19+
static makeQuestion0() {
20+
return new MultipleChoiceQuizQuestion(
21+
0,
22+
'What is the most played video game in the world?',
23+
new Map([
24+
[AnswerChoice.A, 'GTA V'],
25+
[AnswerChoice.B, 'Call of Duty'],
26+
[AnswerChoice.C, 'World of Warcraft'],
27+
[AnswerChoice.D, 'MineCraft'],
28+
]),
29+
AnswerChoice.UNANSWERED,
30+
); // Replace `UNANSWERED` with the correct answer.
31+
}
32+
33+
static makeQuestion1() {
34+
return new MultipleChoiceQuizQuestion(
35+
1,
36+
'What is the top tourist destination in the world?',
37+
new Map([
38+
[AnswerChoice.A, 'China'],
39+
[AnswerChoice.B, 'France'],
40+
[AnswerChoice.C, 'Italy'],
41+
[AnswerChoice.D, 'Brazil'],
42+
]),
43+
AnswerChoice.UNANSWERED,
44+
); // Replace `UNANSWERED` with the correct answer.
45+
}
46+
47+
static makeQuestion2() {
48+
return new MultipleChoiceQuizQuestion(
49+
2,
50+
'What country has the largest number of ocean borders?',
51+
new Map([
52+
[AnswerChoice.A, 'Canada'],
53+
[AnswerChoice.B, 'India'],
54+
[AnswerChoice.C, 'Australia'],
55+
[AnswerChoice.D, 'United Kingdom'],
56+
]),
57+
AnswerChoice.UNANSWERED,
58+
); // Replace `UNANSWERED` with the correct answer.
59+
}
60+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import {
2+
AnswerChoice,
3+
MultipleChoiceQuizQuestion,
4+
QuizQuestion,
5+
QuizQuestionProvider,
6+
} from 'codedifferently-instructional';
7+
8+
export class JasonWatsonQuiz implements QuizQuestionProvider {
9+
getProviderName(): string {
10+
return 'jasonwatson';
11+
}
12+
13+
makeQuizQuestions(): QuizQuestion[] {
14+
return [
15+
JasonWatsonQuiz.makeQuestion0(),
16+
JasonWatsonQuiz.makeQuestion1(),
17+
JasonWatsonQuiz.makeQuestion2(),
18+
];
19+
}
20+
21+
private static makeQuestion0(): QuizQuestion {
22+
return new MultipleChoiceQuizQuestion(
23+
0,
24+
'How much MB of memory is equal to 1GB of RAM',
25+
new Map<AnswerChoice, string>([
26+
[AnswerChoice.A, '500MB'],
27+
[AnswerChoice.B, '1024MB'],
28+
[AnswerChoice.C, '2048MB'],
29+
[AnswerChoice.D, '1000MB'],
30+
]),
31+
AnswerChoice.UNANSWERED,
32+
); // Replace `UNANSWERED` with the correct answer.
33+
}
34+
35+
private static makeQuestion1(): QuizQuestion {
36+
return new MultipleChoiceQuizQuestion(
37+
1,
38+
'What is Visual Studio Code primarily used for',
39+
new Map<AnswerChoice, string>([
40+
[AnswerChoice.A, 'Graphic Design'],
41+
[AnswerChoice.B, 'Word Processing'],
42+
[AnswerChoice.C, 'Code Editing'],
43+
[AnswerChoice.D, 'Video Prodection'],
44+
]),
45+
AnswerChoice.UNANSWERED,
46+
); // Replace `UNANSWERED` with the correct answer.
47+
}
48+
49+
private static makeQuestion2(): QuizQuestion {
50+
return new MultipleChoiceQuizQuestion(
51+
2,
52+
'What file is commonly used to provide instructions or documenttation in a GitHub repository',
53+
new Map<AnswerChoice, string>([
54+
[AnswerChoice.A, 'README.md'],
55+
[AnswerChoice.B, 'INSTRUCTIONS.txt'],
56+
[AnswerChoice.C, 'GUIDE.pdf'],
57+
[AnswerChoice.D, 'DOCS.docx'],
58+
]),
59+
AnswerChoice.UNANSWERED,
60+
); // Replace `UNANSWERED` with the correct answer.
61+
}
62+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import {
2+
AnswerChoice,
3+
MultipleChoiceQuizQuestion,
4+
QuizQuestion,
5+
QuizQuestionProvider,
6+
} from 'codedifferently-instructional';
7+
8+
export class JeremiahWingQuiz implements QuizQuestionProvider {
9+
getProviderName(): string {
10+
return 'jeremiahwing';
11+
}
12+
13+
makeQuizQuestions(): QuizQuestion[] {
14+
return [
15+
JeremiahWingQuiz.makeQuestion0(),
16+
JeremiahWingQuiz.makeQuestion1(),
17+
JeremiahWingQuiz.makeQuestion2(),
18+
JeremiahWingQuiz.makeQuestion3(),
19+
];
20+
}
21+
22+
private static makeQuestion0(): QuizQuestion {
23+
return new MultipleChoiceQuizQuestion(
24+
0,
25+
'What does the SRC element stand for?',
26+
new Map<AnswerChoice, string>([
27+
[AnswerChoice.A, 'Source'],
28+
[AnswerChoice.B, 'Script'],
29+
[AnswerChoice.C, 'Style'],
30+
[AnswerChoice.D, 'Section'],
31+
]),
32+
AnswerChoice.UNANSWERED,
33+
);
34+
}
35+
36+
private static makeQuestion1(): QuizQuestion {
37+
return new MultipleChoiceQuizQuestion(
38+
1,
39+
'What does the git fetch command do?',
40+
new Map<AnswerChoice, string>([
41+
[AnswerChoice.A, 'Downloads objects and refs from another repository'],
42+
[AnswerChoice.B, 'Merges changes from another branch'],
43+
[AnswerChoice.C, 'Commits changes to the local repository'],
44+
[AnswerChoice.D, 'Deletes a branch from the repository'],
45+
]),
46+
AnswerChoice.UNANSWERED,
47+
);
48+
}
49+
50+
private static makeQuestion2(): QuizQuestion {
51+
return new MultipleChoiceQuizQuestion(
52+
2,
53+
'What does the git pull command do?',
54+
new Map<AnswerChoice, string>([
55+
[
56+
AnswerChoice.A,
57+
'Fetches from and integrates with another repository or a local branch',
58+
],
59+
[AnswerChoice.B, 'Merges changes from another branch'],
60+
[AnswerChoice.C, 'Commits changes to the local repository'],
61+
[AnswerChoice.D, 'Deletes a branch from the repository'],
62+
]),
63+
AnswerChoice.UNANSWERED,
64+
);
65+
}
66+
67+
private static makeQuestion3(): QuizQuestion {
68+
return new MultipleChoiceQuizQuestion(
69+
3,
70+
'What does the git push command do?',
71+
new Map<AnswerChoice, string>([
72+
[
73+
AnswerChoice.A,
74+
'Uploads local repository content to a remote repository',
75+
],
76+
[AnswerChoice.B, 'Merges changes from another branch'],
77+
[AnswerChoice.C, 'Commits changes to the local repository'],
78+
[AnswerChoice.D, 'Downloads objects and refs from another repository'],
79+
]),
80+
AnswerChoice.UNANSWERED,
81+
);
82+
}
83+
}

lesson_03/quiz/src/quizzes/quizzes.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
import { Module } from '@nestjs/common';
22
import { AnotherQuiz } from './another_quiz.js';
33
import { AnthonyMaysQuiz } from './anthony_mays_quiz.js';
4+
45
import { ChanelHuttQuiz } from './Chanel_Huttquiz.js';
56
import { DavidAdenaikeQuiz } from './david_adenaike_quiz.js';
67
import { Jbeyquiz } from './jbeyquiz.js';
8+
import { JasonWatsonQuiz } from './jason_watson_quiz.js';
9+
import { MeikoStephensQuiz } from './meiko_stephens_quiz.js';
710
import { DavidAdenaikeQuiz } from './david_adenaike_quiz.js';
11+
import { EzraQuiz } from './ezra_quiz.js';
812
import { Jbeyquiz } from './jbeyquiz.js';
913
import { KhaylaSaundersQuiz } from './khayla_quiz.js';
10-
import { MeikoStephensQuiz } from './meiko_stephens_quiz.js';
1114
import { MercedesMathewsQuiz } from './mercedes_mathews_quiz.js';
1215
import { RasheedMillerQuiz } from './rasheed_miller_quiz.js';
16+
import { JeremiahWingQuiz } from './jeremiah_wing_quiz.js';
1317

1418
export const Quizzes = Symbol.for('Quizzes');
1519

1620
// Add your quiz provider here.
21+
1722
const QUIZ_PROVIDERS = [
1823
AnthonyMaysQuiz,
1924
AnotherQuiz,
2025
MeikoStephensQuiz,
2126
MercedesMathewsQuiz,
2227
Jbeyquiz,
28+
EzraQuiz,
2329
DavidAdenaikeQuiz,
2430
KhaylaSaundersQuiz,
2531
RasheedMillerQuiz,
2632
ChanelHuttQuiz,
33+
JeremiahWingQuiz,
34+
JasonWatsonQuiz,
2735
];
2836

2937
@Module({

lesson_04/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ Please review the following resources before lecture:
99

1010
## Homework
1111

12-
- TODO(anthonydmays): Provide details
12+
- [ ] Do [coding exercise](#writing-some-code).
13+
- [ ] Do pre-work for [lesson 05](/lesson_05/).
14+
15+
### Writing some code
16+
17+
For this assignment, you will need to write code that determines whether a number is a prime number. You will produce code in two different languages, then provide a 100+ word write up about the similarities and differences between the two implementations you made. An example is provided in the [anthonydmays/](./anthonydmays/) folder.

0 commit comments

Comments
 (0)