Skip to content

Commit fecdabb

Browse files
committed
chore: adds lesson REAME details
1 parent f35d04c commit fecdabb

File tree

12 files changed

+140
-49
lines changed

12 files changed

+140
-49
lines changed

.github/workflows/check_lesson_03_pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
working-directory: ./lib/typescript/codedifferently-instructional
2626
run: npm ci
2727

28-
- name: Build Lesson 02 with Node.js
28+
- name: Build Lesson 03 with Node.js
2929
working-directory: ./lesson_03/quiz
3030
run: |
3131
npm run lint

lesson_03/README.md

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

1010
## Homework
1111

12-
TODO(anthonydmays): Add this
12+
- [ ] Review [important reminders below](#important-reminders).
13+
- [ ] Create [new quiz questions](#creating-new-quiz-questions).
14+
- [ ] Do pre-work for [lesson 04](/lesson_04/).
15+
16+
### Important reminders
17+
18+
* Make sure to sync your fork before creating a branch in order to pull in the latest changes.
19+
* Sync your branch often to avoid merge conflicts and execute `git pull` to bring the latest changes to your machine.
20+
* If your branch is too far behind or you run into too many issues, feel free to delete and re-create your repository. Make sure to review the article linked at the bottom of the [lesson_00](/lesson_00/README.md) README for instructions on how to create your fork and branch properly.
21+
* Remember, you should not reuse a branch you've used to submit a pull request. If you need to make changes, create a new branch and work from there after you've updated your fork to the latest.
22+
23+
### Creating new quiz questions
24+
25+
Now's your chance to quiz the instructor! In this assignment, you will modify the quiz project to include three quiz questions based on the content you've learned in this course so far. Feel free to choose any topic for your questions.
26+
27+
1. Navigate to the [quiz][quiz-folder] directory and install the required dependencies.
28+
```bash
29+
cd lesson_03/quiz
30+
npm install --prefix ../../lib/typescript/codedifferently-instructional
31+
npm install
32+
npm start
33+
```
34+
2. You will create a quiz file in the [quizzes folder][quizzes-folder]. You should model yours after the example provided in [anthony_mays_quiz.ts][quiz-example]. Note that the name of the file you create should match the name of the class in the file.
35+
3. Make sure to provide a unique provider name for your questions provider. You'll need this name to provide answers in step 4.
36+
```typescript
37+
getProviderName(): string {
38+
return '<your unique name goes here>';
39+
}
40+
```
41+
4. Make at least three questions for your quiz and _leave them unanswered_.
42+
5. To provide answers, you will need to update the [quiz.yaml][test-config-file] file in the test directory. You can copy the example in the file to get started, but you must provide your own answers. To generate an encrypted answer, use [bcrypt.online](https://bcrypt.online).
43+
6. Before attempting to submit your quiz, make sure to run the formatter on the code and run the tests to ensure that you've updated things correctly. These commands must be run from the [quiz][quiz-folder] sub-folder just like the previous assignment:
44+
```bash
45+
npm run lint
46+
npm run test
47+
```
48+
7. Once everything passes, submit a PR.
49+
50+
**Note: If you want to check that you've encoded your answers correctly, you can update you quiz with the real answers and then run the tests using the command below.
51+
```bash
52+
RUN_SKIPPED=true npm run test
53+
```
54+
55+
[quizzes-folder]: ./quiz/src/quizzes/
56+
[quiz-folder]: ./quiz/
57+
[quiz-example]: ./quiz/src/quizzes/anthony_mays_quiz.ts
58+
[test-config-file]: ./quiz/quiz.yaml

lesson_03/quiz/.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ charset = utf-8
88
insert_final_newline = true
99
organize_imports = true
1010
trim_trailing_whitespace = true
11+
quote_type = single

lesson_03/quiz/eslint.config.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
// @ts-check
22

3-
import eslint from "@eslint/js";
4-
import tseslint from "typescript-eslint";
5-
import eslintConfigPrettier from "eslint-config-prettier";
3+
import eslint from '@eslint/js';
4+
import stylistic from '@stylistic/eslint-plugin';
5+
import eslintConfigPrettier from 'eslint-config-prettier';
6+
import tseslint from 'typescript-eslint';
67

78
export default tseslint.config(
89
eslint.configs.recommended,
910
...tseslint.configs.strict,
1011
...tseslint.configs.stylistic,
1112
eslintConfigPrettier,
1213
{
13-
ignores: ["build"],
14+
ignores: ['build'],
15+
plugins: { '@stylistic': stylistic },
1416
rules: {
15-
"@typescript-eslint/interface-name-prefix": "off",
16-
"@typescript-eslint/explicit-function-return-type": "off",
17-
"@typescript-eslint/no-explicit-any": "off",
18-
"@typescript-eslint/no-extraneous-class": "off",
17+
'@typescript-eslint/interface-name-prefix': 'off',
18+
'@typescript-eslint/explicit-function-return-type': 'off',
19+
'@typescript-eslint/no-explicit-any': 'off',
20+
'@typescript-eslint/no-extraneous-class': 'off',
21+
'@stylistic/quotes': [
22+
'error',
23+
'single',
24+
{ avoidEscape: true, allowTemplateLiterals: false },
25+
],
1926
},
2027
},
2128
);

lesson_03/quiz/jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} **/
22
export default {
3-
testEnvironment: "node",
3+
testEnvironment: 'node',
44
transform: {
5-
"^.+.tsx?$": ["ts-jest", { useESM: true }],
5+
'^.+.tsx?$': ['ts-jest', { useESM: true }],
66
},
77
moduleNameMapper: {
8-
"^(\\.\\.?\\/.+)\\.js$": "$1",
8+
'^(\\.\\.?\\/.+)\\.js$': '$1',
99
},
10-
extensionsToTreatAsEsm: [".ts"],
10+
extensionsToTreatAsEsm: ['.ts'],
1111
};

lesson_03/quiz/package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lesson_03/quiz/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@alfonso-presa/soft-assert": "^0.6.0",
2121
"@eslint/js": "^9.11.1",
2222
"@nestjs/testing": "^10.4.4",
23+
"@stylistic/eslint-plugin": "^2.8.0",
2324
"@types/eslint__js": "^8.42.3",
2425
"@types/jest": "^29.5.13",
2526
"@types/node": "20.12.7",
@@ -41,4 +42,4 @@
4142
"reflect-metadata": "^0.2.2",
4243
"rxjs": "^7.8.1"
4344
}
44-
}
45+
}

lesson_03/quiz/src/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Module } from "@nestjs/common";
2-
import { QuizzesModule } from "./quizzes/quizzes.module.js";
1+
import { Module } from '@nestjs/common';
2+
import { QuizzesModule } from './quizzes/quizzes.module.js';
33

44
@Module({
55
imports: [QuizzesModule],

lesson_03/quiz/src/lesson3.test.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { flush, proxy } from "@alfonso-presa/soft-assert";
2-
import { beforeAll, describe, expect, it } from "@jest/globals";
3-
import { Test, TestingModule } from "@nestjs/testing";
1+
import { flush, proxy } from '@alfonso-presa/soft-assert';
2+
import { beforeAll, describe, expect, it } from '@jest/globals';
3+
import { Test, TestingModule } from '@nestjs/testing';
44
import {
55
AnswerChoice,
66
QuizConfig,
77
QuizQuestion,
8-
} from "codedifferently-instructional";
9-
import path from "path";
10-
import { fileURLToPath } from "url";
11-
import { AppModule } from "./app.module.js";
12-
import { Quizzes } from "./quizzes/quizzes.module.js";
8+
} from 'codedifferently-instructional';
9+
import path from 'path';
10+
import { fileURLToPath } from 'url';
11+
import { AppModule } from './app.module.js';
12+
import { Quizzes } from './quizzes/quizzes.module.js';
1313

1414
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
1515
const __dirname = path.dirname(__filename); // get the name of the directory
1616
const softExpect = proxy(expect);
17+
const maybeIt = process.env.RUN_SKIPPED ? it : it.skip;
1718

18-
describe("Lesson3Test", () => {
19+
describe('Lesson3Test', () => {
1920
let moduleFixture: TestingModule;
2021
let quizConfig: QuizConfig;
2122
let quizQuestionsByProvider: Map<string, QuizQuestion[]>;
@@ -25,7 +26,7 @@ describe("Lesson3Test", () => {
2526
imports: [AppModule],
2627
}).compile();
2728

28-
quizConfig = new QuizConfig(path.resolve(__dirname, "../quiz.yaml"));
29+
quizConfig = new QuizConfig(path.resolve(__dirname, '../quiz.yaml'));
2930

3031
makeQuestions();
3132
});
@@ -47,7 +48,7 @@ describe("Lesson3Test", () => {
4748
flush();
4849
});
4950

50-
it("assembles questions correctly", async () => {
51+
it('assembles questions correctly', async () => {
5152
for (const quizQuestions of quizQuestionsByProvider.values()) {
5253
// Expect the right number of questions.
5354
expect(quizQuestions.length).toBe(2);
@@ -59,7 +60,7 @@ describe("Lesson3Test", () => {
5960
}
6061
});
6162

62-
it("checks for unique prompts", async () => {
63+
it('checks for unique prompts', async () => {
6364
for (const quizQuestions of quizQuestionsByProvider.values()) {
6465
const questionPrompts = new Set(
6566
quizQuestions.map((q) => q.getQuestionPrompt()),
@@ -68,13 +69,13 @@ describe("Lesson3Test", () => {
6869
}
6970
});
7071

71-
it("checks correct number of answers are configured", async () => {
72+
it('checks correct number of answers are configured', async () => {
7273
for (const [providerName, questions] of quizQuestionsByProvider) {
7374
expect(quizConfig.size(providerName)).toBe(questions.length);
7475
}
7576
});
7677

77-
it("checks for correct answers", async () => {
78+
maybeIt('checks for correct answers', async () => {
7879
for (const [providerName, questions] of quizQuestionsByProvider) {
7980
for (const question of questions) {
8081
const actualAnswer = question.getAnswer();

lesson_03/quiz/src/lesson3.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { INestApplicationContext } from "@nestjs/common";
2-
import { NestFactory } from "@nestjs/core";
3-
import { QuizPrinter, QuizQuestion } from "codedifferently-instructional";
4-
import { AppModule } from "./app.module.js";
5-
import { Quizzes } from "./quizzes/quizzes.module.js";
1+
import { INestApplicationContext } from '@nestjs/common';
2+
import { NestFactory } from '@nestjs/core';
3+
import { QuizPrinter, QuizQuestion } from 'codedifferently-instructional';
4+
import { AppModule } from './app.module.js';
5+
import { Quizzes } from './quizzes/quizzes.module.js';
66

77
async function bootstrap() {
88
const app = await NestFactory.createApplicationContext(AppModule);
@@ -14,7 +14,7 @@ function run(app: INestApplicationContext) {
1414
const quizzes = app.get(Quizzes);
1515

1616
for (const quiz of quizzes) {
17-
console.log("\nQuestions by " + quiz.getProviderName() + ":");
17+
console.log('\nQuestions by ' + quiz.getProviderName() + ':');
1818
printQuiz(quiz.makeQuizQuestions());
1919
}
2020
}

0 commit comments

Comments
 (0)