Skip to content

feat: adds lesson 03 content and lesson 04 pre-work #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/check_lesson_03_pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Check Lesson 03 Pull Request

on:
pull_request:
branches: [ "main" ]
paths:
- "lesson_03/quiz/**"

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Build Shared Lib with Node.js
working-directory: ./lib/typescript/codedifferently-instructional
run: npm ci

- name: Build Lesson 03 with Node.js
working-directory: ./lesson_03/quiz
run: |
npm ci
npm run check
14 changes: 14 additions & 0 deletions .github/workflows/check_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- "lib/**"
- "lesson_02/quiz/**"
- "lesson_03/quiz/**"

jobs:
build:
Expand Down Expand Up @@ -42,4 +43,17 @@ jobs:
npm ci
npm run test

- name: Build Lesson 02 with Node.js
working-directory: ./lesson_02/quiz
run: |
npm ci
node run compile

- name: Build Lesson 03 with Node.js
working-directory: ./lesson_03/quiz
run: |
npm ci
npm run compile
npm run lint


4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down
49 changes: 48 additions & 1 deletion lesson_03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,51 @@ Please review the following resources before lecture:

## Homework

TODO(anthonydmays): Add this
- [ ] Review [important reminders below](#important-reminders).
- [ ] Create [new quiz questions](#creating-new-quiz-questions).
- [ ] Do pre-work for [lesson 04](/lesson_04/).

### Important reminders

* Make sure to sync your fork before creating a branch in order to pull in the latest changes.
* Sync your branch often to avoid merge conflicts and execute `git pull` to bring the latest changes to your machine.
* 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.
* 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.

### Creating new quiz questions

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.

1. Navigate to the [quiz][quiz-folder] directory and install the required dependencies.
```bash
cd lesson_03/quiz
npm install --prefix ../../lib/typescript/codedifferently-instructional
npm install
npm start
```
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.
3. Make sure to provide a unique provider name for your questions provider. You'll need this name to provide answers in step 5.
```typescript
getProviderName(): string {
return '<your unique name goes here>';
}
```
4. Make at least three questions for your quiz and _leave them unanswered_.
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).
6. Lastly, you'll need to modify the [quizzes.module.ts][quizzes-module] file to include your quiz.
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:
```bash
npm run check
```
8. Once everything passes, submit a PR.

**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.
```bash
PROVIDER_NAME=<Your provider name here> npm run test
```

[quizzes-folder]: ./quiz/src/quizzes/
[quiz-folder]: ./quiz/
[quiz-example]: ./quiz/src/quizzes/anthony_mays_quiz.ts
[test-config-file]: ./quiz/quiz.yaml
[quizzes-module]: ./quiz/src/quizzes/quizzes.module.ts
11 changes: 11 additions & 0 deletions lesson_03/quiz/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
insert_final_newline = true
organize_imports = true
trim_trailing_whitespace = true
quote_type = single
3 changes: 3 additions & 0 deletions lesson_03/quiz/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
1 change: 1 addition & 0 deletions lesson_03/quiz/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
28 changes: 28 additions & 0 deletions lesson_03/quiz/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @ts-check

import eslint from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import eslintConfigPrettier from 'eslint-config-prettier';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
eslintConfigPrettier,
{
ignores: ['build'],
plugins: { '@stylistic': stylistic },
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extraneous-class': 'off',
'@stylistic/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false },
],
},
},
);
11 changes: 11 additions & 0 deletions lesson_03/quiz/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
export default {
testEnvironment: 'node',
transform: {
'^.+.tsx?$': ['ts-jest', { useESM: true }],
},
moduleNameMapper: {
'^(\\.\\.?\\/.+)\\.js$': '$1',
},
extensionsToTreatAsEsm: ['.ts'],
};
Loading