? = null) = setSystemIn(input?.joinToString(newLineSeparator))
+
+fun String.replaceLineSeparator() = this.lines().joinToString(newLineSeparator)
+
+fun setSystemIn(input: String? = null) = input?.let {
+ System.setIn(it.replaceLineSeparator().byteInputStream())
+}
+
+fun setSystemOut(): ByteArrayOutputStream {
+ val baos = ByteArrayOutputStream()
+ val ps = PrintStream(baos, true, StandardCharsets.UTF_8.name())
+ System.setOut(ps)
+ return baos
+}
+
+fun isSystemInEmpty() = String(System.`in`.readBytes()).isEmpty()
+
+@Suppress("SwallowedException")
+fun runMainFunction(mainFunction: () -> Unit, input: String? = null, toAssertSystemIn: Boolean = true): String {
+ return try {
+ setSystemIn(input)
+ val baos = setSystemOut()
+ mainFunction()
+ if (toAssertSystemIn) {
+ assert(isSystemInEmpty()) { "You are asking the user to enter data fewer times than required in the task!" }
+ }
+ baos.toString("UTF-8").replaceLineSeparator()
+ } catch (e: IllegalStateException) {
+ val userInput = input?.let { "the user input: $it" } ?: "the empty user input"
+ val errorPrefix =
+ "Try to run the main function with $userInput, the function must process the input and exit, but the current version of the function"
+ if ("Your input is incorrect" in (e.message ?: "")) {
+ assert(false) { "$errorPrefix waits more user inputs, it must be fixed." }
+ }
+ assert(false) { "$errorPrefix throws an unexpected error, please, check the function's implementation." }
+ ""
+ } catch (e: NotImplementedError) {
+ assert(false) { "You call not implemented functions (that use TODO()) inside the main function. Please, don't do it until the task asks it" }
+ ""
+ }
+}
diff --git a/common/src/main/resources/images/course-structure-author.png b/common/src/main/resources/images/course-structure-author.png
new file mode 100644
index 0000000..cf8ae5f
Binary files /dev/null and b/common/src/main/resources/images/course-structure-author.png differ
diff --git a/common/src/main/resources/images/course-structure-student.png b/common/src/main/resources/images/course-structure-student.png
new file mode 100644
index 0000000..cb91a54
Binary files /dev/null and b/common/src/main/resources/images/course-structure-student.png differ
diff --git a/common/src/main/resources/images/files-order.gif b/common/src/main/resources/images/files-order.gif
new file mode 100644
index 0000000..b19689e
Binary files /dev/null and b/common/src/main/resources/images/files-order.gif differ
diff --git a/common/src/main/resources/images/get-from-version-control.png b/common/src/main/resources/images/get-from-version-control.png
new file mode 100644
index 0000000..a15cb89
Binary files /dev/null and b/common/src/main/resources/images/get-from-version-control.png differ
diff --git a/common/src/main/resources/images/logo.png b/common/src/main/resources/images/logo.png
new file mode 100644
index 0000000..e31ce07
Binary files /dev/null and b/common/src/main/resources/images/logo.png differ
diff --git a/common/src/main/resources/images/logo_dark.png b/common/src/main/resources/images/logo_dark.png
new file mode 100644
index 0000000..a8a5ca6
Binary files /dev/null and b/common/src/main/resources/images/logo_dark.png differ
diff --git a/common/src/main/resources/images/run-debug-configurations.png b/common/src/main/resources/images/run-debug-configurations.png
new file mode 100644
index 0000000..cd735ce
Binary files /dev/null and b/common/src/main/resources/images/run-debug-configurations.png differ
diff --git a/common/src/main/resources/images/theme_example.gif b/common/src/main/resources/images/theme_example.gif
new file mode 100644
index 0000000..59432dc
Binary files /dev/null and b/common/src/main/resources/images/theme_example.gif differ
diff --git a/common/src/main/resources/images/use_template_blur.jpg b/common/src/main/resources/images/use_template_blur.jpg
new file mode 100644
index 0000000..89f86ed
Binary files /dev/null and b/common/src/main/resources/images/use_template_blur.jpg differ
diff --git a/course-info.yaml b/course-info.yaml
new file mode 100644
index 0000000..8b4e103
--- /dev/null
+++ b/course-info.yaml
@@ -0,0 +1,9 @@
+type: marketplace
+title: JetBrains Academy Kotlin course template
+language: English
+summary: "Here you can put the course description. You can use HTML tags inside the description."
+programming_language: Kotlin
+content:
+ - courseSection
+environment_settings:
+ jvm_language_level: JDK_17
diff --git a/courseSection/courseFrameworkLesson/lesson-info.yaml b/courseSection/courseFrameworkLesson/lesson-info.yaml
new file mode 100644
index 0000000..3bfc725
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/lesson-info.yaml
@@ -0,0 +1,6 @@
+type: framework
+custom_name: Course framework lesson
+content:
+ - theoryTask
+ - programmingTask
+is_template_based: false
diff --git a/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt b/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
new file mode 100644
index 0000000..cd63678
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.academy.kotlin.template
+
+// This file will be hidden in the student mode
+// Since this file is invisible, it can be changed between tasks
+@Suppress("FunctionOnlyReturningConstant")
+fun sayBye() = "Bye"
diff --git a/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/Main.kt b/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/Main.kt
new file mode 100644
index 0000000..1596b0f
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/src/org/jetbrains/academy/kotlin/template/Main.kt
@@ -0,0 +1,13 @@
+package org.jetbrains.academy.kotlin.template
+
+// Since the file from the first lesson will be propagated,
+// you can put the solution here
+fun invokeSayBye(howManyTimes: Int): String {
+ return List(howManyTimes) { sayBye() }.joinToString(System.lineSeparator())
+}
+
+fun main() {
+ println("How many times should I print Bye?")
+ val howManyTimes = readln().toInt()
+ println(invokeSayBye(howManyTimes))
+}
diff --git a/courseSection/courseFrameworkLesson/programmingTask/task-info.yaml b/courseSection/courseFrameworkLesson/programmingTask/task-info.yaml
new file mode 100644
index 0000000..98134f0
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/task-info.yaml
@@ -0,0 +1,12 @@
+type: edu
+files:
+ - name: src/org/jetbrains/academy/kotlin/template/Main.kt
+ visible: true
+ - name: src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
+ visible: false
+ - name: test/InvokeSayByeFunction.kt
+ visible: false
+ - name: test/MainClass.kt
+ visible: false
+ - name: test/Tests.kt
+ visible: false
diff --git a/courseSection/courseFrameworkLesson/programmingTask/task.md b/courseSection/courseFrameworkLesson/programmingTask/task.md
new file mode 100644
index 0000000..109e4fb
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/task.md
@@ -0,0 +1,3 @@
+In this task, the user needs to implement some functions.
+You can check the user mode – the content of the `Main.kt` file will be propagated from the previous step;
+however, `InvisibleFile.kt` will be changed.
diff --git a/courseSection/courseFrameworkLesson/programmingTask/test/InvokeSayByeFunction.kt b/courseSection/courseFrameworkLesson/programmingTask/test/InvokeSayByeFunction.kt
new file mode 100644
index 0000000..483bfea
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/test/InvokeSayByeFunction.kt
@@ -0,0 +1,11 @@
+import org.jetbrains.academy.test.system.core.models.TestKotlinType
+import org.jetbrains.academy.test.system.core.models.method.TestMethod
+import org.jetbrains.academy.test.system.core.models.variable.TestVariable
+
+internal val invokeSayByeFunction = TestMethod(
+ "invokeSayBye",
+ TestKotlinType("String"),
+ arguments = listOf(
+ TestVariable("howManyTimes", "Int"),
+ ),
+)
diff --git a/courseSection/courseFrameworkLesson/programmingTask/test/MainClass.kt b/courseSection/courseFrameworkLesson/programmingTask/test/MainClass.kt
new file mode 100644
index 0000000..ec121fd
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/test/MainClass.kt
@@ -0,0 +1,8 @@
+import org.jetbrains.academy.test.system.core.models.classes.TestClass
+
+internal val mainClass = TestClass(
+ classPackage = "org.jetbrains.academy.kotlin.template",
+ customMethods = listOf(
+ invokeSayByeFunction,
+ ),
+)
diff --git a/courseSection/courseFrameworkLesson/programmingTask/test/Tests.kt b/courseSection/courseFrameworkLesson/programmingTask/test/Tests.kt
new file mode 100644
index 0000000..9344d6d
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/programmingTask/test/Tests.kt
@@ -0,0 +1,58 @@
+import org.jetbrains.academy.kotlin.template.main
+import org.jetbrains.academy.kotlin.template.newLineSeparator
+import org.jetbrains.academy.kotlin.template.runMainFunction
+import org.jetbrains.academy.kotlin.template.throwInternalCourseError
+import org.jetbrains.academy.test.system.core.invokeWithArgs
+import org.jetbrains.academy.test.system.core.models.classes.findClassSafe
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.Arguments
+import org.junit.jupiter.params.provider.MethodSource
+
+class Test {
+ companion object {
+ private lateinit var mainClazz: Class<*>
+
+ @JvmStatic
+ @BeforeAll
+ fun beforeAll() {
+ mainClazz = mainClass.findClassSafe() ?: throwInternalCourseError()
+ }
+
+ private const val BYE = "Bye"
+
+ @JvmStatic
+ fun invokeSayByeArguments() = listOf(
+ Arguments.of(1, List(1) { BYE }.joinToString(System.lineSeparator())),
+ Arguments.of(2, List(2) { BYE }.joinToString(System.lineSeparator())),
+ Arguments.of(3, List(3) { BYE }.joinToString(System.lineSeparator()))
+ )
+ }
+ @Test
+ fun invokeSayByeFunction() {
+ mainClass.checkMethod(mainClazz, invokeSayByeFunction)
+ }
+
+ @ParameterizedTest
+ @MethodSource("invokeSayByeArguments")
+ fun invokeSayByeImplementation(
+ howManyTimes: Int,
+ output: String,
+ ) {
+ val userMethod = mainClass.findMethod(mainClazz, invokeSayByeFunction)
+ Assertions.assertEquals(
+ output,
+ userMethod.invokeWithArgs(howManyTimes, clazz = mainClazz)?.toString()?.trimIndent(),
+ "For howManyTimes = $howManyTimes the function ${invokeSayByeFunction.name} should return $output"
+ )
+ }
+ @Test
+ fun testSolution() {
+ Assertions.assertEquals(
+ "How many times should I print $BYE?${newLineSeparator}$BYE${newLineSeparator}$BYE".trimIndent(),
+ runMainFunction(::main, "2").trimIndent()
+ )
+ }
+}
\ No newline at end of file
diff --git a/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt b/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
new file mode 100644
index 0000000..415bdcf
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.academy.kotlin.template
+
+// This file will be hidden in the student mode
+// Since this file is invisible, it can be changed between tasks
+@Suppress("FunctionOnlyReturningConstant")
+fun sayHello() = "Hello"
diff --git a/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/Main.kt b/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/Main.kt
new file mode 100644
index 0000000..a81bd1c
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/theoryTask/src/org/jetbrains/academy/kotlin/template/Main.kt
@@ -0,0 +1,6 @@
+package org.jetbrains.academy.kotlin.template
+
+// This file will be visible for the student
+fun main() {
+ // Write your solution here
+}
diff --git a/courseSection/courseFrameworkLesson/theoryTask/task-info.yaml b/courseSection/courseFrameworkLesson/theoryTask/task-info.yaml
new file mode 100644
index 0000000..d577bb8
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/theoryTask/task-info.yaml
@@ -0,0 +1,6 @@
+type: theory
+files:
+ - name: src/org/jetbrains/academy/kotlin/template/Main.kt
+ visible: true
+ - name: src/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
+ visible: false
diff --git a/courseSection/courseFrameworkLesson/theoryTask/task.md b/courseSection/courseFrameworkLesson/theoryTask/task.md
new file mode 100644
index 0000000..fb21ec7
--- /dev/null
+++ b/courseSection/courseFrameworkLesson/theoryTask/task.md
@@ -0,0 +1,27 @@
+This is an example of a framework lesson.
+If you create this type of lesson, the user can solve tasks step by step.
+Initially, the user sees all the visible files from the first task in the lesson.
+Next, all changes made by the user in the visible files
+will be propagated to the following tasks.
+
+Beginning from the second lesson, you can modify the visible files to be able to provide
+students with the correct solution from the course author.
+Invisible files can be modified between tasks.
+
+**Note, you need to have the same set of files between all tasks.**
+Thus, it is the same for the resources folder, and to avoid double-storing of images,
+you can put them into the `common` module:
+
+
+
+
+
+
+
+You can put the picture for the dark theme with the suffix "_dark" together with the initial one.
+In such a case, the plugin will use this picture if the user switched the IDE theme to the dark one:
+
+
+
+
+
diff --git a/courseSection/courseLesson/lesson-info.yaml b/courseSection/courseLesson/lesson-info.yaml
new file mode 100644
index 0000000..7a40575
--- /dev/null
+++ b/courseSection/courseLesson/lesson-info.yaml
@@ -0,0 +1,6 @@
+custom_name: Course lesson
+content:
+ - theoryTask
+ - quizTask
+ - programmingTask
+ - multiFileTask
diff --git a/courseSection/courseLesson/multiFileTask/src/Main.kt b/courseSection/courseLesson/multiFileTask/src/Main.kt
new file mode 100644
index 0000000..e5bd56b
--- /dev/null
+++ b/courseSection/courseLesson/multiFileTask/src/Main.kt
@@ -0,0 +1,3 @@
+fun main() {
+ helloWorld()
+}
diff --git a/courseSection/courseLesson/multiFileTask/src/MainTaskFile.kt b/courseSection/courseLesson/multiFileTask/src/MainTaskFile.kt
new file mode 100644
index 0000000..aef3b3b
--- /dev/null
+++ b/courseSection/courseLesson/multiFileTask/src/MainTaskFile.kt
@@ -0,0 +1 @@
+fun helloWorld(): Unit = println("Hello, world!")
\ No newline at end of file
diff --git a/courseSection/courseLesson/multiFileTask/task-info.yaml b/courseSection/courseLesson/multiFileTask/task-info.yaml
new file mode 100644
index 0000000..dc6bc59
--- /dev/null
+++ b/courseSection/courseLesson/multiFileTask/task-info.yaml
@@ -0,0 +1,18 @@
+type: output
+files:
+ - name: src/MainTaskFile.kt
+ visible: true
+ placeholders:
+ - offset: 25
+ length: 24
+ placeholder_text: TODO("Not implemented yet")
+ - name: src/Main.kt
+ visible: true
+ placeholders:
+ - offset: 17
+ length: 12
+ placeholder_text: // invoke the implemented functions here
+ - name: test/output.txt
+ visible: false
+ - name: test/input.txt
+ visible: false
diff --git a/courseSection/courseLesson/multiFileTask/task.md b/courseSection/courseLesson/multiFileTask/task.md
new file mode 100644
index 0000000..f427fbe
--- /dev/null
+++ b/courseSection/courseLesson/multiFileTask/task.md
@@ -0,0 +1,8 @@
+This is an example of an input/output task.
+In this type of task, you can give an expected input and output to the program instead of implementing
+your own tests.
+
+This task also demonstrates how you can set up which file should be opened in the student mode if the task has several files.
+You just need to put this file as the first file in the `task-info.yaml` config, e.g. in this task the `MainTaskFile.kt` will be opened:
+
+![Expected behaviour](../../../common/src/main/resources/images/files-order.gif)
diff --git a/courseSection/courseLesson/multiFileTask/test/input.txt b/courseSection/courseLesson/multiFileTask/test/input.txt
new file mode 100644
index 0000000..e69de29
diff --git a/courseSection/courseLesson/multiFileTask/test/output.txt b/courseSection/courseLesson/multiFileTask/test/output.txt
new file mode 100644
index 0000000..af5626b
--- /dev/null
+++ b/courseSection/courseLesson/multiFileTask/test/output.txt
@@ -0,0 +1 @@
+Hello, world!
diff --git a/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt b/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
new file mode 100644
index 0000000..2795778
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
@@ -0,0 +1,5 @@
+package org.jetbrains.academy.kotlin.template
+
+// This file will be hidden in the student mode
+@Suppress("FunctionOnlyReturningConstant")
+fun sayHello() = "Hello"
diff --git a/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt b/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
new file mode 100644
index 0000000..a8ce7a8
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
@@ -0,0 +1,11 @@
+package org.jetbrains.academy.kotlin.template
+
+fun invokeSayHello(howManyTimes: Int): String {
+ return List(howManyTimes) { sayHello() }.joinToString(System.lineSeparator())
+}
+
+fun main() {
+ println("How many times should I print Hello?")
+ val howManyTimes = readln().toInt()
+ println(invokeSayHello(howManyTimes))
+}
diff --git a/courseSection/courseLesson/programmingTask/task-info.yaml b/courseSection/courseLesson/programmingTask/task-info.yaml
new file mode 100644
index 0000000..120fb8e
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/task-info.yaml
@@ -0,0 +1,20 @@
+type: edu
+custom_name: Course programming task
+files:
+ - name: test/Tests.kt
+ visible: false
+ - name: src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
+ visible: true
+ placeholders:
+ - offset: 95
+ length: 81
+ placeholder_text: TODO("Write your solution here")
+ - offset: 193
+ length: 133
+ placeholder_text: // Write your solution here
+ - name: src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
+ visible: false
+ - name: test/InvokeSayHelloFunction.kt
+ visible: false
+ - name: test/MainClass.kt
+ visible: false
diff --git a/courseSection/courseLesson/programmingTask/task.md b/courseSection/courseLesson/programmingTask/task.md
new file mode 100644
index 0000000..b7f7cb2
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/task.md
@@ -0,0 +1,6 @@
+This task asks the user to implement something and runs tests from the [Tests.kt](./test/Tests.kt) file.
+You need to add _placeholders_ into the places where the user needs to implement something (see [task-info.yaml](./task-info.yaml)).
+
+This task also demonstrates how you can use the [kotlin test framework](https://github.com/jetbrains-academy/kotlin-test-framework)
+to test functions or classes without using the correct implementation in the tests.
+It allows you to avoid using the correct implementation in tests directly.
diff --git a/courseSection/courseLesson/programmingTask/test/InvokeSayHelloFunction.kt b/courseSection/courseLesson/programmingTask/test/InvokeSayHelloFunction.kt
new file mode 100644
index 0000000..df96949
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/test/InvokeSayHelloFunction.kt
@@ -0,0 +1,12 @@
+import org.jetbrains.academy.test.system.core.models.TestKotlinType
+import org.jetbrains.academy.test.system.core.models.Visibility
+import org.jetbrains.academy.test.system.core.models.method.TestMethod
+import org.jetbrains.academy.test.system.core.models.variable.TestVariable
+
+internal val invokeSayHelloFunction = TestMethod(
+ "invokeSayHello",
+ TestKotlinType("String"),
+ arguments = listOf(
+ TestVariable("howManyTimes", "Int"),
+ ),
+)
diff --git a/courseSection/courseLesson/programmingTask/test/MainClass.kt b/courseSection/courseLesson/programmingTask/test/MainClass.kt
new file mode 100644
index 0000000..216684e
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/test/MainClass.kt
@@ -0,0 +1,8 @@
+import org.jetbrains.academy.test.system.core.models.classes.TestClass
+
+internal val mainClass = TestClass(
+ classPackage = "org.jetbrains.academy.kotlin.template",
+ customMethods = listOf(
+ invokeSayHelloFunction,
+ ),
+)
diff --git a/courseSection/courseLesson/programmingTask/test/Tests.kt b/courseSection/courseLesson/programmingTask/test/Tests.kt
new file mode 100644
index 0000000..02855ec
--- /dev/null
+++ b/courseSection/courseLesson/programmingTask/test/Tests.kt
@@ -0,0 +1,58 @@
+import org.jetbrains.academy.kotlin.template.main
+import org.jetbrains.academy.kotlin.template.newLineSeparator
+import org.jetbrains.academy.kotlin.template.runMainFunction
+import org.jetbrains.academy.kotlin.template.throwInternalCourseError
+import org.jetbrains.academy.test.system.core.invokeWithArgs
+import org.jetbrains.academy.test.system.core.models.classes.findClassSafe
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.BeforeAll
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.params.ParameterizedTest
+import org.junit.jupiter.params.provider.Arguments
+import org.junit.jupiter.params.provider.MethodSource
+
+class Test {
+ companion object {
+ private lateinit var mainClazz: Class<*>
+
+ @JvmStatic
+ @BeforeAll
+ fun beforeAll() {
+ mainClazz = mainClass.findClassSafe() ?: throwInternalCourseError()
+ }
+
+ private const val HELLO = "Hello"
+
+ @JvmStatic
+ fun invokeSayHelloArguments() = listOf(
+ Arguments.of(1, List(1) { HELLO }.joinToString(System.lineSeparator())),
+ Arguments.of(2, List(2) { HELLO }.joinToString(System.lineSeparator())),
+ Arguments.of(3, List(3) { HELLO }.joinToString(System.lineSeparator()))
+ )
+ }
+ @Test
+ fun invokeSayHelloFunction() {
+ mainClass.checkMethod(mainClazz, invokeSayHelloFunction)
+ }
+
+ @ParameterizedTest
+ @MethodSource("invokeSayHelloArguments")
+ fun invokeSayHelloImplementation(
+ howManyTimes: Int,
+ output: String,
+ ) {
+ val userMethod = mainClass.findMethod(mainClazz, invokeSayHelloFunction)
+ Assertions.assertEquals(
+ output,
+ userMethod.invokeWithArgs(howManyTimes, clazz = mainClazz)?.toString()?.trimIndent(),
+ "For howManyTimes = $howManyTimes the function ${invokeSayHelloFunction.name} should return $output"
+ )
+ }
+ @Test
+ fun testSolution() {
+ Assertions.assertEquals(
+ "How many times should I print $HELLO?${newLineSeparator}$HELLO${newLineSeparator}$HELLO".trimIndent(),
+ runMainFunction(::main, "2").trimIndent()
+ )
+ }
+}
\ No newline at end of file
diff --git a/courseSection/courseLesson/quizTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt b/courseSection/courseLesson/quizTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
new file mode 100644
index 0000000..ee3a607
--- /dev/null
+++ b/courseSection/courseLesson/quizTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
@@ -0,0 +1,5 @@
+package org.jetbrains.academy.kotlin.template
+
+fun main() {
+ // Write your solution here
+}
diff --git a/courseSection/courseLesson/quizTask/task-info.yaml b/courseSection/courseLesson/quizTask/task-info.yaml
new file mode 100644
index 0000000..fb0a18e
--- /dev/null
+++ b/courseSection/courseLesson/quizTask/task-info.yaml
@@ -0,0 +1,12 @@
+type: choice
+is_multiple_choice: false
+options:
+ - text: Correct
+ is_correct: true
+ - text: Incorrect
+ is_correct: false
+message_incorrect: This text will be shown if the user made a mistake.
+files:
+ - name: src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
+ visible: true
+custom_name: Course quiz task
diff --git a/courseSection/courseLesson/quizTask/task.md b/courseSection/courseLesson/quizTask/task.md
new file mode 100644
index 0000000..a3a4d32
--- /dev/null
+++ b/courseSection/courseLesson/quizTask/task.md
@@ -0,0 +1,2 @@
+You cannot change the question text **Select one option from the list**; you just need to put your question into this file.
+You can set up all quiz options in the [task-info](./task-info.yaml) file.
diff --git a/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt b/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
new file mode 100644
index 0000000..2795778
--- /dev/null
+++ b/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
@@ -0,0 +1,5 @@
+package org.jetbrains.academy.kotlin.template
+
+// This file will be hidden in the student mode
+@Suppress("FunctionOnlyReturningConstant")
+fun sayHello() = "Hello"
diff --git a/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt b/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
new file mode 100644
index 0000000..ee3a607
--- /dev/null
+++ b/courseSection/courseLesson/theoryTask/src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
@@ -0,0 +1,5 @@
+package org.jetbrains.academy.kotlin.template
+
+fun main() {
+ // Write your solution here
+}
diff --git a/courseSection/courseLesson/theoryTask/task-info.yaml b/courseSection/courseLesson/theoryTask/task-info.yaml
new file mode 100644
index 0000000..0fe3de8
--- /dev/null
+++ b/courseSection/courseLesson/theoryTask/task-info.yaml
@@ -0,0 +1,7 @@
+type: theory
+custom_name: Course theory task
+files:
+ - name: src/main/kotlin/org/jetbrains/academy/kotlin/template/Main.kt
+ visible: true
+ - name: src/main/kotlin/org/jetbrains/academy/kotlin/template/InvisibleFile.kt
+ visible: false
diff --git a/courseSection/courseLesson/theoryTask/task.md b/courseSection/courseLesson/theoryTask/task.md
new file mode 100644
index 0000000..13e51fe
--- /dev/null
+++ b/courseSection/courseLesson/theoryTask/task.md
@@ -0,0 +1,14 @@
+This is an example of a theory lesson.
+
+
+
+You can use hints to explain something to the students.
+Please leave an empty line to be able to apply markdown formatting, like **this**.
+
+Invisible files are hidden in the student mode.
+You can use them to define, for example, the helper functions in the course.
+
+To mark a file as invisible, you need to set up the `false` value for the corresponding file in the [task-info](./task-info.yaml) file.
+
+
+Theory tasks do not contain any tests.
diff --git a/courseSection/section-info.yaml b/courseSection/section-info.yaml
new file mode 100644
index 0000000..daa299c
--- /dev/null
+++ b/courseSection/section-info.yaml
@@ -0,0 +1,4 @@
+custom_name: Course section
+content:
+ - courseLesson
+ - courseFrameworkLesson
diff --git a/detekt.yml b/detekt.yml
new file mode 100644
index 0000000..e9034e6
--- /dev/null
+++ b/detekt.yml
@@ -0,0 +1,34 @@
+# buildUponDefaultConfig is active; add only the rules that require explicit configuration here
+potential-bugs:
+ Deprecation:
+ active: true
+
+style:
+ MaxLineLength:
+ active: true
+ maxLineLength: 180
+ # wildcards are used all over the project
+ WildcardImport:
+ active: false
+ ReturnCount:
+ max: 3
+ MagicNumber:
+ active: false
+ UnusedPrivateMember:
+ active: false
+
+complexity:
+ TooManyFunctions:
+ active: true
+ thresholdInFiles: 20
+
+exceptions:
+ active: true
+ InstanceOfCheckForException:
+ active: false
+
+naming:
+ MatchingDeclarationName:
+ active: false
+ PackageNaming:
+ active: false
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..9728aac
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,7 @@
+courseGroup=org.jetbrains.academy.kotlin.template
+courseVersion=1.1.0
+
+gradleVersion=8.3
+jvmVersion=17
+
+kotlin.code.style=official
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..249e583
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..db9a6b8
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000..a69d9cb
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..f127cfd
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,91 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 0000000..77c7bb2
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,37 @@
+rootProject.name = "JetBrains Academy Kotlin course template"
+
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ google()
+ mavenCentral()
+
+ // To be able to use the Kotlin test framework for the tests - https://github.com/jetbrains-academy/kotlin-test-framework
+ maven(url = "https://packages.jetbrains.team/maven/p/kotlin-test-framework/kotlin-test-framework")
+ }
+}
+
+// Mark all task folders as a Gradle module
+rootProject.projectDir.walkTopDown().forEach {
+ if (!isTaskDir(it) || it.path.contains(".idea") || it.path.contains("build") || it.path.contains("node_modules")) {
+ return@forEach
+ }
+ val taskRelativePath = rootDir.toPath().relativize(it.toPath())
+ val parts = mutableListOf()
+ for (name in taskRelativePath) {
+ parts.add(sanitizeName(name.toString()))
+ }
+ val moduleName = parts.joinToString("-")
+ include(moduleName)
+ project(":$moduleName").projectDir = it
+}
+
+fun sanitizeName(name: String) =
+ name.replace("listOf( /\\\\:<>\"?*|())", "_").replace("(^listOf(.)+)|(listOf(.)+\$)", "")
+
+fun isTaskDir(dir: File) = File(dir, "src").exists()
+
+// Include other common resources
+include(
+ "common",
+)
\ No newline at end of file