Skip to content

Commit 9209256

Browse files
authored
feat: adds lesson_03 homework and lesson_04 pre-work (#87)
* feat: add lesson_03 homework and lesson_04 pre-work Signed-off-by: Anthony D. Mays <[email protected]> * feat: add lesson_03 homework and lesson_04 pre-work Signed-off-by: Anthony D. Mays <[email protected]> --------- Signed-off-by: Anthony D. Mays <[email protected]>
1 parent 602e049 commit 9209256

18 files changed

+6537
-2
lines changed

lesson_03/README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,66 @@ Please review the following resources before lecture:
1010
## Homework
1111

1212
- [ ] Review [important reminders below](#important-reminders).
13-
- TODO(anthonydmays): Add more details
13+
- [ ] Create [new quiz questions](#creating-new-quiz-questions).
14+
- [ ] Do pre-work for [lesson 04](/lesson_04/).
1415

1516
### Important reminders
1617

1718
* Make sure to sync your fork before creating a branch in order to pull in the latest changes.
1819
* Sync your branch often to avoid merge conflicts and execute `git pull` to bring the latest changes to your machine.
1920
* 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.
20-
* 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.
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/javascript/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+
### Dealing with merge conflicts
56+
57+
Since everyone needs to modify the same files for this assignment, you will most certainly encounter merge conflicts. To resolve this, here are the steps:
58+
59+
1. Sync the main branch of your fork and ensure that it is up-to-date.
60+
2. Use `git checkout main` and `git pull` to get the latest updates pulled down to your computer.
61+
3. Checkout your feature branch (e.g. `git checkout feature/lesson_03`).
62+
4. Run `git rebase main` on your feature branch to pull in the latest changes and deal with merge conflicts.
63+
5. Use the *Source Control* view in VS Code to identify files with conflicts. Click to open them and use the *Merge Editor* to resolve conflicts.
64+
6. Stage and commit the changed files.
65+
7. Repeat steps 5-6 until the rebase is complete.
66+
67+
An alternative approach is to open the PR and manually edit the conflicting files to work out any issues. This may be easier for some of you, but it can also be tricky to do if you don't know what you're doing.
68+
69+
Check out [this YouTube video](https://www.youtube.com/watch?v=OXtdxHTh2oY) for a quick explaination of what's going on.
70+
71+
[quizzes-folder]: ./quiz/src/quizzes/
72+
[quiz-folder]: ./quiz/
73+
[quiz-example]: ./quiz/src/quizzes/anthony_mays_quiz.ts
74+
[test-config-file]: ./quiz/quiz.yaml
75+
[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)