Skip to content

Danielson Adjocy Feature/lesson 02 + stretch #99

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

Closed
wants to merge 26 commits into from
Closed
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
2 changes: 1 addition & 1 deletion lesson_02/quiz/src/lesson2.test.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't have made any changes to this file.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
QuizConfig,
QuizQuestion,
AnswerChoice,
} from "codedifferently-instructional";
} from "codedifferently-instructional";
import { Lesson2 } from "./lesson2.js";
import { beforeEach, describe, it, expect } from "@jest/globals";
import { proxy, flush } from "@alfonso-presa/soft-assert";
Expand Down
22 changes: 11 additions & 11 deletions lesson_02/quiz/src/lesson2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

Expand All @@ -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,
);
}

Expand All @@ -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,
);
}

Expand All @@ -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,
);
}

Expand All @@ -98,7 +98,7 @@ export class Lesson2 {
[AnswerChoice.C, "NetBeans"],
[AnswerChoice.D, "VS Code"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.D,
);
}

Expand All @@ -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,
);
}

Expand All @@ -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,
);
}

Expand All @@ -140,7 +140,7 @@ export class Lesson2 {
[AnswerChoice.C, "cd"],
[AnswerChoice.D, "mkdir"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.B,
);
}

Expand All @@ -154,7 +154,7 @@ export class Lesson2 {
[AnswerChoice.C, "cd"],
[AnswerChoice.D, "mkdir"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.C,
);
}

Expand All @@ -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,
);
}

Expand All @@ -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,
);
}
}
Expand Down
12 changes: 12 additions & 0 deletions lesson_02/quiz_java/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf

# Binary files should be left untouched
*.jar binary

5 changes: 5 additions & 0 deletions lesson_02/quiz_java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore Gradle project-specific cache directory
.gradle

# Ignore Gradle build output directory
build
55 changes: 55 additions & 0 deletions lesson_02/quiz_java/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/9.0.0/userguide/building_java_projects.html in the Gradle documentation.
*/

plugins {
java
id("org.springframework.boot") version "3.1.0"
id("io.spring.dependency-management") version "1.1.0"
application
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
flatDir {
dirs("../../../lib/java/codedifferently-instructional")
}
}


// Instead of this (which doesn't work):
// implementation("com.codedifferently.instructional:instructional-lib")

// Use direct file reference:
dependencies {
implementation("org.apache.commons:commons-text:1.10.0")
implementation(project(":instructional-lib"))
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")


}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(22)
}
}

application {
// Define the main class for the application.
mainClass.set("org.example.Lesson2")
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
204 changes: 204 additions & 0 deletions lesson_02/quiz_java/app/src/main/java/org/example/Lesson2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
package org.example;

import java.util.* ;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.codedifferently.instructional.quiz.AnswerChoice;
import com.codedifferently.instructional.quiz.MultipleChoiceQuizQuestion;
import com.codedifferently.instructional.quiz.QuizPrinter;
import com.codedifferently.instructional.quiz.QuizQuestion;

@SpringBootApplication
public class Lesson2 {

public static ArrayList<QuizQuestion> makeQuizQuestions() {
ArrayList<QuizQuestion> quizQuestions = new ArrayList<>();
quizQuestions.add(Lesson2.makeQuestion0());
quizQuestions.add(Lesson2.makeQuestion1());
quizQuestions.add(Lesson2.makeQuestion2());
quizQuestions.add(Lesson2.makeQuestion3());
quizQuestions.add(Lesson2.makeQuestion4());
quizQuestions.add(Lesson2.makeQuestion5());
quizQuestions.add(Lesson2.makeQuestion6());
quizQuestions.add(Lesson2.makeQuestion7());
quizQuestions.add(Lesson2.makeQuestion8());
quizQuestions.add(Lesson2.makeQuestion9());
quizQuestions.add(Lesson2.makeQuestion10());
return quizQuestions;
}

public static void main(String[] args) {
ArrayList<QuizQuestion> quizQuestions = Lesson2.makeQuizQuestions();
if (quizQuestions == null || quizQuestions.isEmpty()) {
throw new Error("Quiz questions cannot be null or empty");
}
final QuizPrinter printer = new QuizPrinter();
printer.printQuiz(quizQuestions);
}

private static QuizQuestion makeQuestion0(){
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "To make backups of files");
answers.put(AnswerChoice.B, "To keep a record of changes over time");
answers.put(AnswerChoice.C, "To delete unnecessary files");
answers.put(AnswerChoice.D, "To run code more efficiently");

return new MultipleChoiceQuizQuestion(
0,
"What is the main purpose of version control?",
answers,
AnswerChoice.B);
}

private static QuizQuestion makeQuestion1() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "A duplicate copy of a repository that you own and modify");
answers.put(AnswerChoice.B, "A temporary backup of the code");
answers.put(AnswerChoice.C, "A tool for merging branches");
answers.put(AnswerChoice.D, "A way to delete a repository");

return new MultipleChoiceQuizQuestion(
1,
"What is a fork in Git?",
answers,
AnswerChoice.A
);
}

private static QuizQuestion makeQuestion2() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "Pull the latest changes");
answers.put(AnswerChoice.B, "Commit changes locally");
answers.put(AnswerChoice.C, "Push changes to the server");
answers.put(AnswerChoice.D, "Write code directly in GitHub");

return new MultipleChoiceQuizQuestion(
2,
"Which of the following is NOT part of the basic Git workflow?",
answers,
AnswerChoice.D
);
}

private static QuizQuestion makeQuestion3() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "git commit");
answers.put(AnswerChoice.B, "git merge");
answers.put(AnswerChoice.C, "git branch");
answers.put(AnswerChoice.D, "git pull");

return new MultipleChoiceQuizQuestion(
3,
"What command is used to combine changes from different branches?",
answers,
AnswerChoice.B
);
}

private static QuizQuestion makeQuestion4() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "Eclipse");
answers.put(AnswerChoice.B, "IntelliJ IDEA");
answers.put(AnswerChoice.C, "NetBeans");
answers.put(AnswerChoice.D, "VS Code");

return new MultipleChoiceQuizQuestion(
4,
"Which IDE is being used in the class?",
answers,
AnswerChoice.D
);
}

private static QuizQuestion makeQuestion5() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "Extensions");
answers.put(AnswerChoice.B, "Debugger");
answers.put(AnswerChoice.C, "Dev Containers");
answers.put(AnswerChoice.D, "Source Control");

return new MultipleChoiceQuizQuestion(
5,
"What feature allows developers to work from the same pre-configured environment in VS Code?",
answers,
AnswerChoice.C
);
}

private static QuizQuestion makeQuestion6() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "Editing and refactoring code");
answers.put(AnswerChoice.B, "Browsing code");
answers.put(AnswerChoice.C, "Playing music");
answers.put(AnswerChoice.D, "Managing source control");

return new MultipleChoiceQuizQuestion(
6,
"What is NOT a reason for using an IDE?",
answers,
AnswerChoice.C
);
}

private static QuizQuestion makeQuestion7() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "pwd");
answers.put(AnswerChoice.B, "ls");
answers.put(AnswerChoice.C, "cd");
answers.put(AnswerChoice.D, "mkdir");

return new MultipleChoiceQuizQuestion(
7,
"What is the command to list files in the current directory?",
answers,
AnswerChoice.B
);
}

private static QuizQuestion makeQuestion8() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "pwd");
answers.put(AnswerChoice.B, "ls");
answers.put(AnswerChoice.C, "cd");
answers.put(AnswerChoice.D, "mkdir");

return new MultipleChoiceQuizQuestion(
8,
"Which command is used to change directories in the terminal?",
answers,
AnswerChoice.C
);
}

private static QuizQuestion makeQuestion9() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "Change file or directory permissions");
answers.put(AnswerChoice.B, "List files in a directory");
answers.put(AnswerChoice.C, "Remove a file or directory");
answers.put(AnswerChoice.D, "Copy a file or directory");

return new MultipleChoiceQuizQuestion(
9,
"What does the command `chmod` do?",
answers,
AnswerChoice.A
);
}

private static QuizQuestion makeQuestion10() {
Map<AnswerChoice, String> answers = new HashMap<>();
answers.put(AnswerChoice.A, "⌘ + Shift + T");
answers.put(AnswerChoice.B, "⌘ + Spacebar, then type \"terminal\"");
answers.put(AnswerChoice.C, "⌘ + Q");
answers.put(AnswerChoice.D, "⌘ + S, then type \"terminal\"");

return new MultipleChoiceQuizQuestion(
10,
"What is the shortcut for getting to the Mac terminal?",
answers,
AnswerChoice.B
);
}

}
Loading