Skip to content

Commit 007d779

Browse files
authored
Merge branch 'main' into Work03
2 parents 29666c4 + 5d1a93c commit 007d779

File tree

7 files changed

+193
-37
lines changed

7 files changed

+193
-37
lines changed

lesson_03/quiz/quiz.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ quiz:
3838
- $2y$10$s9Dh1bJak9WjT3sziuq1KeloNnDCuhgjsT6HA.m/fxjJSrJMK0lOu
3939
- $2y$10$Q58g8gsWhL1Zhje9WoLHKuqF44I3NK16i..EQ2SYVAa.PEkowhgOK
4040
- $2y$10$U3eJ/7JtxbPlofL.3K08AeKmVTKWLvyhNCcS.cgF6gNn/cmm5Psia
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
4146
jasonwatson:
4247
- $2y$10$AZtPKyQ.6Bzb.jreO/u.2O3C7XfvYAVpjHzLkuhLVdsX74wc4vXwS
4348
- $2y$10$QbKtEXqpeItigRLAHsn8Qe/06ZpXhKEP1bGPJSFXymsoFw9.04NHy

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: 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Jbeyquiz } from './jbeyquiz.js';
1010
import { KhaylaSaundersQuiz } from './khayla_quiz.js';
1111
import { MercedesMathewsQuiz } from './mercedes_mathews_quiz.js';
1212
import { RasheedMillerQuiz } from './rasheed_miller_quiz.js';
13+
import { JeremiahWingQuiz } from './jeremiah_wing_quiz.js';
1314

1415
export const Quizzes = Symbol.for('Quizzes');
1516

@@ -26,6 +27,7 @@ const QUIZ_PROVIDERS = [
2627
KhaylaSaundersQuiz,
2728
RasheedMillerQuiz,
2829
DavisDQuiz,
30+
JeremiahWingQuiz,
2931
JasonWatsonQuiz,
3032
];
3133

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.

lesson_04/anthonydmays/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Python implementation
2+
3+
```python
4+
def is_even(number):
5+
return number % 2 == 0
6+
7+
# Example usage:
8+
print(is_even(4)) # Output: True
9+
print(is_even(7)) # Output: False
10+
```
11+
12+
## JavaScript implementation
13+
14+
```javascript
15+
function isEven(number) {
16+
return number % 2 === 0;
17+
}
18+
19+
// Example usage:
20+
console.log(isEven(4)); // Output: true
21+
console.log(isEven(7)); // Output: false
22+
```
23+
24+
## Explanation
25+
26+
The Python implementation uses a function named `is_even` that takes a single argument `number`. It returns `True` if the number is even (i.e., when the remainder of the division of the number by 2 is zero), otherwise, it returns `False`.
27+
28+
The JavaScript implementation uses a function named `isEven` that also takes a single argument `number`. It returns `true` if the number is even (using the same logic as the Python function) and `false` otherwise.
29+
30+
### Differences
31+
32+
1. **Syntax**:
33+
- In Python, functions are defined using the `def` keyword, whereas in JavaScript, the `function` keyword is used.
34+
- Python uses `True` and `False` for boolean values, while JavaScript uses `true` and `false`.
35+
36+
2. **Type Coercion**:
37+
- JavaScript has type coercion, which can sometimes lead to unexpected results if the input is not properly handled. In contrast, Python is more strict with types.
38+
39+
3. **Function Calls**:
40+
- The syntax for calling functions and printing to the console/output is slightly different. Python uses `print()`, while JavaScript uses `console.log()`.

lesson_05/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Lesson 05: Software Development Life Cycle ([Slides](https://code-differently.github.io/code-differently-24-q4/slides/#/lesson_05))
2+
3+
## Pre-work
4+
5+
Please review the following resources before lecture:
6+
7+
### Required
8+
* [Software Development Life Cycle: Explained (Video)](https://www.youtube.com/watch?v=SaCYkPD4_K0)
9+
* [What is the "best way" to develop software applications? (Video)](https://www.youtube.com/watch?v=oNmcX6Gozg0)
10+
11+
### Recommended
12+
* [User stories with examples and a template](https://www.atlassian.com/agile/project-management/user-stories)
13+
14+
## Homework
15+
16+
- TODO(anthonydmays): Write details here.

0 commit comments

Comments
 (0)