From 18675481df4c4bfce9e6aec05327ad30121ada43 Mon Sep 17 00:00:00 2001 From: cdbluejr Date: Mon, 7 Oct 2024 14:49:38 +0000 Subject: [PATCH 1/2] Add Lesson 2 quiz / Lesson 5 quiz / User Stories --- lesson_02/quiz/cdbluejr/lesson2.ts | 192 +++++++++++++++++++++++++++++ lesson_02/quiz/src/lesson2.ts | 22 ++-- lesson_05/cdbluejr/lesson5.ts | 174 ++++++++++++++++++++++++++ lesson_05/quiz/src/lesson5.ts | 20 +-- 4 files changed, 387 insertions(+), 21 deletions(-) create mode 100644 lesson_02/quiz/cdbluejr/lesson2.ts create mode 100644 lesson_05/cdbluejr/lesson5.ts diff --git a/lesson_02/quiz/cdbluejr/lesson2.ts b/lesson_02/quiz/cdbluejr/lesson2.ts new file mode 100644 index 00000000..922bb966 --- /dev/null +++ b/lesson_02/quiz/cdbluejr/lesson2.ts @@ -0,0 +1,192 @@ +import { + AnswerChoice, + MultipleChoiceQuizQuestion, + QuizPrinter, + QuizQuestion, +} from "codedifferently-instructional"; + +export class Lesson2 { + run(): void { + const quizQuestions = Lesson2.makeQuizQuestions(); + if (!quizQuestions) throw new Error("Quiz questions cannot be null"); + const printer = new QuizPrinter(); + printer.printQuiz(quizQuestions); + } + + static makeQuizQuestions(): QuizQuestion[] { + return [ + Lesson2.makeQuestion0(), + Lesson2.makeQuestion1(), + Lesson2.makeQuestion2(), + Lesson2.makeQuestion3(), + Lesson2.makeQuestion4(), + Lesson2.makeQuestion5(), + Lesson2.makeQuestion6(), + Lesson2.makeQuestion7(), + Lesson2.makeQuestion8(), + Lesson2.makeQuestion9(), + Lesson2.makeQuestion10(), + ]; + } + + private static makeQuestion0(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 0, + "What is the main purpose of version control?", + new Map([ + [AnswerChoice.A, "To make backups of files"], + [AnswerChoice.B, "To keep a record of changes over time"], + [AnswerChoice.C, "To delete unnecessary files"], + [AnswerChoice.D, "To run code more efficiently"], + ]), + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion1(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 1, + "What is a fork in Git?", + new Map([ + [ + AnswerChoice.A, + "A duplicate copy of a repository that you own and modify", + ], + [AnswerChoice.B, "A temporary backup of the code"], + [AnswerChoice.C, "A tool for merging branches"], + [AnswerChoice.D, "A way to delete a repository"], + ]), + AnswerChoice.A, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion2(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 2, + "Which of the following is NOT part of the basic Git workflow?", + new Map([ + [AnswerChoice.A, "Pull the latest changes"], + [AnswerChoice.B, "Commit changes locally"], + [AnswerChoice.C, "Push changes to the server"], + [AnswerChoice.D, "Write code directly in GitHub"], + ]), + AnswerChoice.D, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion3(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 3, + "What command is used to combine changes from different branches?", + new Map([ + [AnswerChoice.A, "git commit"], + [AnswerChoice.B, "git merge"], + [AnswerChoice.C, "git branch"], + [AnswerChoice.D, "git pull"], + ]), + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion4(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 4, + "Which IDE is being used in the class?", + new Map([ + [AnswerChoice.A, "Eclipse"], + [AnswerChoice.B, "IntelliJ IDEA"], + [AnswerChoice.C, "NetBeans"], + [AnswerChoice.D, "VS Code"], + ]), + AnswerChoice.D, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion5(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 5, + "What feature allows developers to work from the same pre-configured environment in VS Code?", + new Map([ + [AnswerChoice.A, "Extensions"], + [AnswerChoice.B, "Debugger"], + [AnswerChoice.C, "Dev Containers"], + [AnswerChoice.D, "Source Control"], + ]), + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion6(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 6, + "What is NOT a reason for using an IDE?", + new Map([ + [AnswerChoice.A, "Editing and refactoring code"], + [AnswerChoice.B, "Browsing code"], + [AnswerChoice.C, "Playing music"], + [AnswerChoice.D, "Managing source control"], + ]), + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion7(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 7, + "What is the command to list files in the current directory?", + new Map([ + [AnswerChoice.A, "pwd"], + [AnswerChoice.B, "ls"], + [AnswerChoice.C, "cd"], + [AnswerChoice.D, "mkdir"], + ]), + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion8(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 8, + "Which command is used to change directories in the terminal?", + new Map([ + [AnswerChoice.A, "pwd"], + [AnswerChoice.B, "ls"], + [AnswerChoice.C, "cd"], + [AnswerChoice.D, "mkdir"], + ]), + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion9(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 9, + "What does the command `chmod` do?", + new Map([ + [AnswerChoice.A, "Change file or directory permissions"], + [AnswerChoice.B, "List files in a directory"], + [AnswerChoice.C, "Remove a file or directory"], + [AnswerChoice.D, "Copy a file or directory"], + ]), + AnswerChoice.A, // Replace `UNANSWERED` with the correct answer. + ); + } + + private static makeQuestion10(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 10, + "What is the shortcut for getting to the Mac terminal?", + new Map([ + [AnswerChoice.A, "⌘ + Shift + T"], + [AnswerChoice.B, '⌘ + Spacebar, then type "terminal"'], + [AnswerChoice.C, "⌘ + Q"], + [AnswerChoice.D, '⌘ + S, then type "terminal"'], + ]), + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. + ); + } +} + +if (!process.env.JEST_WORKER_ID) { + new Lesson2().run(); +} diff --git a/lesson_02/quiz/src/lesson2.ts b/lesson_02/quiz/src/lesson2.ts index aa22c2e2..922bb966 100644 --- a/lesson_02/quiz/src/lesson2.ts +++ b/lesson_02/quiz/src/lesson2.ts @@ -39,7 +39,7 @@ export class Lesson2 { [AnswerChoice.C, "To delete unnecessary files"], [AnswerChoice.D, "To run code more efficiently"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. ); } @@ -56,7 +56,7 @@ export class Lesson2 { [AnswerChoice.C, "A tool for merging branches"], [AnswerChoice.D, "A way to delete a repository"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.A, // Replace `UNANSWERED` with the correct answer. ); } @@ -70,7 +70,7 @@ export class Lesson2 { [AnswerChoice.C, "Push changes to the server"], [AnswerChoice.D, "Write code directly in GitHub"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.D, // Replace `UNANSWERED` with the correct answer. ); } @@ -84,7 +84,7 @@ export class Lesson2 { [AnswerChoice.C, "git branch"], [AnswerChoice.D, "git pull"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. ); } @@ -98,7 +98,7 @@ export class Lesson2 { [AnswerChoice.C, "NetBeans"], [AnswerChoice.D, "VS Code"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.D, // Replace `UNANSWERED` with the correct answer. ); } @@ -112,7 +112,7 @@ export class Lesson2 { [AnswerChoice.C, "Dev Containers"], [AnswerChoice.D, "Source Control"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. ); } @@ -126,7 +126,7 @@ export class Lesson2 { [AnswerChoice.C, "Playing music"], [AnswerChoice.D, "Managing source control"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. ); } @@ -140,7 +140,7 @@ export class Lesson2 { [AnswerChoice.C, "cd"], [AnswerChoice.D, "mkdir"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. ); } @@ -154,7 +154,7 @@ export class Lesson2 { [AnswerChoice.C, "cd"], [AnswerChoice.D, "mkdir"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.C, // Replace `UNANSWERED` with the correct answer. ); } @@ -168,7 +168,7 @@ export class Lesson2 { [AnswerChoice.C, "Remove a file or directory"], [AnswerChoice.D, "Copy a file or directory"], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.A, // Replace `UNANSWERED` with the correct answer. ); } @@ -182,7 +182,7 @@ export class Lesson2 { [AnswerChoice.C, "⌘ + Q"], [AnswerChoice.D, '⌘ + S, then type "terminal"'], ]), - AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer. + AnswerChoice.B, // Replace `UNANSWERED` with the correct answer. ); } } diff --git a/lesson_05/cdbluejr/lesson5.ts b/lesson_05/cdbluejr/lesson5.ts new file mode 100644 index 00000000..74ec7562 --- /dev/null +++ b/lesson_05/cdbluejr/lesson5.ts @@ -0,0 +1,174 @@ +import { + AnswerChoice, + MultipleChoiceQuizQuestion, + QuizPrinter, + QuizQuestion, +} from "codedifferently-instructional"; + +export class Lesson5 { + run(): void { + const quizQuestions = Lesson5.makeQuizQuestions(); + if (!quizQuestions) throw new Error("Quiz questions cannot be null"); + const printer = new QuizPrinter(); + printer.printQuiz(quizQuestions); + } + + static makeQuizQuestions(): QuizQuestion[] { + return [ + Lesson5.makeQuestion0(), + Lesson5.makeQuestion1(), + Lesson5.makeQuestion2(), + Lesson5.makeQuestion3(), + Lesson5.makeQuestion4(), + Lesson5.makeQuestion5(), + Lesson5.makeQuestion6(), + Lesson5.makeQuestion7(), + Lesson5.makeQuestion8(), + Lesson5.makeQuestion9(), + ]; + } + + private static makeQuestion0(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 0, + "What is the purpose of the

tag in HTML?", + new Map([ + [AnswerChoice.A, "To create a hyperlink"], + [AnswerChoice.B, "To define the most important heading"], + [AnswerChoice.C, "To insert an image"], + [AnswerChoice.D, "To create a paragraph"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion1(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 1, + "Which attribute is used to specify alternative text for an image in HTML?", + new Map([ + [AnswerChoice.A, "title"], + [AnswerChoice.B, "src"], + [AnswerChoice.C, "alt"], + [AnswerChoice.D, "href"], + ]), + AnswerChoice.C, + ); + } + + private static makeQuestion2(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 2, + "Which HTML tag is used to create a hyperlink?", + new Map([ + [AnswerChoice.A, "

"], + [AnswerChoice.B, ""], + [AnswerChoice.C, "

"], + [AnswerChoice.D, ""], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion3(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 3, + "Which of the following is a semantic HTML tag?", + new Map([ + [AnswerChoice.A, "
"], + [AnswerChoice.B, "
"], + [AnswerChoice.C, ""], + [AnswerChoice.D, "
"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion4(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 4, + "What does CSS stand for?", + new Map([ + [AnswerChoice.A, "Creative Style Sheets"], + [AnswerChoice.B, "Cascading Style Sheets"], + [AnswerChoice.C, "Computer Style Sheets"], + [AnswerChoice.D, "Cascading System Sheets"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion5(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 5, + "Which CSS property is used to change the text color?", + new Map([ + [AnswerChoice.A, "font-color"], + [AnswerChoice.B, "color"], + [AnswerChoice.C, "text-color"], + [AnswerChoice.D, "background-color"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion6(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 6, + "How do you add a comment in CSS?", + new Map([ + [AnswerChoice.A, "// this is a comment"], + [AnswerChoice.B, "# this is a comment"], + [AnswerChoice.C, "/* this is a comment */"], + [AnswerChoice.D, ""], + ]), + AnswerChoice.C, + ); + } + + private static makeQuestion7(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 7, + "Which CSS property controls the size of text?", + new Map([ + [AnswerChoice.A, "font-style"], + [AnswerChoice.B, "font-size"], + [AnswerChoice.C, "text-size"], + [AnswerChoice.D, "text-style"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion8(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 8, + "What is the default display value for `
` in CSS?", + new Map([ + [AnswerChoice.A, "inline"], + [AnswerChoice.B, "block"], + [AnswerChoice.C, "inline-block"], + [AnswerChoice.D, "none"], + ]), + AnswerChoice.B, + ); + } + + private static makeQuestion9(): QuizQuestion { + return new MultipleChoiceQuizQuestion( + 9, + "How do you link an external CSS file to an HTML document?", + new Map([ + [AnswerChoice.A, ""], + [AnswerChoice.B, "