code-differently-24-q4

Lesson 03: How Computers Work (Slides)

Pre-work

Please review the following resources before lecture:

Homework

Important reminders

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 directory and install the required dependencies.
    cd lesson_03/quiz
    npm install --prefix ../../lib/javascript/codedifferently-instructional
    npm install
    npm start
    
  2. You will create a quiz file in the quizzes folder. You should model yours after the example provided in anthony_mays_quiz.ts. 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.
      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 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.
  6. Lastly, you’ll need to modify the quizzes.module.ts 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 sub-folder just like the previous assignment:
    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.

PROVIDER_NAME=<Your provider name here> npm run test

Dealing with merge conflicts

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:

  1. Sync the main branch of your fork and ensure that it is up-to-date.
  2. Use git checkout main and git pull to get the latest updates pulled down to your computer.
  3. Checkout your feature branch (e.g. git checkout feature/lesson_03).
  4. Run git rebase main on your feature branch to pull in the latest changes and deal with merge conflicts.
  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.
  6. Stage and commit the changed files.
  7. Repeat steps 5-6 until the rebase is complete.

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.

Check out this YouTube video for a quick explaination of what’s going on.