Skip to content

Commit 60005e5

Browse files
authored
feat: adds lesson 03 content and lesson 04 pre-work (#87)
* feat: adds quiz app Signed-off-by: Anthony D. Mays <[email protected]> * feat: actually adds quiz app files * chore: adds dev mode * chore: configure test script in watch mode. * chore: configures auto-fixing imports Signed-off-by: Anthony D. Mays <[email protected]> * chore: add lesson 03 checks. * chore: adds lesson REAME details * chore: adds lesson_04 pre-work * chore: explictly blocks 'any' * chore: adjusts instructions and adds another example. * chore: adds check script and updates pr checks. * fix: correct install command for lesson 03 --------- Signed-off-by: Anthony D. Mays <[email protected]>
1 parent bd5cfa6 commit 60005e5

22 files changed

+6583
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Lesson 03 Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_03/quiz/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Shared Lib with Node.js
25+
working-directory: ./lib/typescript/codedifferently-instructional
26+
run: npm ci
27+
28+
- name: Build Lesson 03 with Node.js
29+
working-directory: ./lesson_03/quiz
30+
run: |
31+
npm ci
32+
npm run check

.github/workflows/check_push.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
paths:
77
- "lib/**"
88
- "lesson_02/quiz/**"
9+
- "lesson_03/quiz/**"
910

1011
jobs:
1112
build:
@@ -42,4 +43,17 @@ jobs:
4243
npm ci
4344
npm run test
4445
46+
- name: Build Lesson 02 with Node.js
47+
working-directory: ./lesson_02/quiz
48+
run: |
49+
npm ci
50+
node run compile
51+
52+
- name: Build Lesson 03 with Node.js
53+
working-directory: ./lesson_03/quiz
54+
run: |
55+
npm ci
56+
npm run compile
57+
npm run lint
58+
4559

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"editor.formatOnPaste": true,
66
"editor.formatOnSave": true,
77
"prettier.requireConfig": true,
8+
"editor.codeActionsOnSave": {
9+
"source.fixAll.eslint": "explicit",
10+
"source.organizeImports": "explicit"
11+
},
812
"[typescriptreact]": {
913
"editor.defaultFormatter": "esbenp.prettier-vscode"
1014
},

lesson_03/README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,51 @@ 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 5.
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. Lastly, you'll need to modify the [quizzes.module.ts][quizzes-module] file to include your quiz.
44+
7. Before attempting to submit your quiz, make sure to run the linter on the code and run the tests to ensure that you've updated things correctly. The commands must be run from the [quiz][quiz-folder] sub-folder just like the previous assignment:
45+
```bash
46+
npm run check
47+
```
48+
8. 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+
PROVIDER_NAME=<Your provider name here> 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
59+
[quizzes-module]: ./quiz/src/quizzes/quizzes.module.ts

lesson_03/quiz/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true
9+
organize_imports = true
10+
trim_trailing_whitespace = true
11+
quote_type = single

lesson_03/quiz/.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

lesson_03/quiz/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

lesson_03/quiz/eslint.config.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @ts-check
2+
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';
7+
8+
export default tseslint.config(
9+
eslint.configs.recommended,
10+
...tseslint.configs.strict,
11+
...tseslint.configs.stylistic,
12+
eslintConfigPrettier,
13+
{
14+
ignores: ['build'],
15+
plugins: { '@stylistic': stylistic },
16+
rules: {
17+
'@typescript-eslint/interface-name-prefix': 'off',
18+
'@typescript-eslint/explicit-function-return-type': 'off',
19+
'@typescript-eslint/no-explicit-any': 'error',
20+
'@typescript-eslint/no-extraneous-class': 'off',
21+
'@stylistic/quotes': [
22+
'error',
23+
'single',
24+
{ avoidEscape: true, allowTemplateLiterals: false },
25+
],
26+
},
27+
},
28+
);

lesson_03/quiz/jest.config.js

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

0 commit comments

Comments
 (0)