Framework Lessons Guide for Educators
Choose your programming language
This tutorial will walk you through creating a framework lesson on JavaKotlinPythonScala with a set of programming tasks and integrated tests. You can switch to a different programming language using the Section drop-down menu at the top of the page:
Prerequisites
You can create a Java course in IntelliJ IDEA with EduTools plugin installed.
Download IntelliJ IDEA Edu , or Install EduTools Plugin if you have already installed IntelliJ IDEA Community or Ultimate.Prerequisites
You can create a Kotlin course in IntelliJ IDEA or Android Studio with EduTools plugin installed.
Prerequisites
You can create a Python course in PyCharm.
Download PyCharm Edu , or Install EduTools Plugin if you have already installed PyCharm Community or Professional.Prerequisites
You can create a Scala course in IntelliJ IDEA with EduTools plugin installed.
Download IntelliJ IDEA Edu , or Install EduTools Plugin if you have already installed IntelliJ IDEA Community or Ultimate.Framework Lessons Creation
What Framework Lesson is?
The main intention of the framework lessons is to work continuously with the common code through multiple tasks and lessons. It allows learners to build their own projects while learning to program.
From a learner’s perspective, a Framework Lesson is a set of code files, a project with a list of tasks they need to go through. Every task opens one or more project files in the Editor, so learners can work with answer placeholders in those files. We will learn to use placeholders in the next task.
To add a new framework lesson, highlight your project and select
. Alternatively, right-click on the course project in the Project View and select :Tasks
Every course created with your IDE is structured as a list of lessons. Each lesson contains tasks.
Our newly created framework lesson has no tasks yet, so let’s create them. To add a new task, right-click your framework lesson and select
:By default, each task has the following components:
the task.html description file,
the Task.java Task.kt task.py Task.scala file with exercise code,
the Tests.java Tests.kt tests.py Test.scala file with the task check.
Task Description
-
Let's learn to add a description to the task. Click the Edit icon at the top of the Task Description panel or just open the task.html file:
-
Preview all the changes on the Task Description panel while editing:
You can also build the task description file using Markdown:
To change the default task description format, navigate to
.
Hints
You can add hints anywhere in task description text to help the learner find the right solution. Just copy all the hint div block and modify its content, or type "hint" and press Tab.
It’s time to write some code. Let’s switch to the next task.
Working with tasks
-
Open Task.java Task.kt task.py Task.scala file to write the code you want for the exercise, for example:
class HelloJava { public static void main(String[] args) { System.out.println(sayHello()); } private static String sayHello(){ return "Hello, Java!"; } }fun hello(): String = "Hello, Kotlin!" fun main(args: Array<String>) { println(hello()) }def hello() -> str: return "Hello, Python!" print(hello())object Task extends App { def hello() = { "Hello, Scala!" } println(hello()) } -
Click the Run icon in the left gutter to run your code and check if it works as expected:
Writing tests
-
You can write your custom tests to automatically verify the learner's solution. Every task has a Test.java Tests.kt tests.py Test.scala file that you will need to modify:
Test.java Tests.kt tests.py Test.scala is hidden from the learner by default. You can make it visible by right-clicking on the file with tests and selecting .
-
Let's replace the test file content with the following:
import org.junit.Test; import static org.junit.Assert.*; public class HelloJavaTest { @Test public void testSolution() { assertEquals("You should say hello to Java", "Hello, Java!", HelloJava.sayHello()); } }import org.junit.Assert import org.junit.Test class Test { @Test fun testSolution() { Assert.assertEquals("You should say hello to Kotlin", "Hello, Kotlin!", hello()) } }from test_helper import run_common_tests, failed, passed, get_answer_placeholders def test_answer_placeholders(): placeholders = get_answer_placeholders() placeholder = placeholders[0] if placeholder == '"Hello, Python!"': passed() else: failed("You should say hello to Python") if __name__ == '__main__': run_common_tests() test_answer_placeholders()import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import org.scalatest.FunSuite @RunWith(classOf[JUnitRunner]) class TaskTest extends FunSuite { test("Task.hello") { assert(Task.hello === "Hello, Scala!") } } -
To check that your code passes your own tests go back to Task.java Task.kt task.py Task.scala and click the Check button at the bottom of the Task Description panel. If your code and test are correct, you will see the Correct message:
Placeholders
The most significant and important feature of framework lessons is their interactivity: learners get a unique education experience via the course elements which they can interact with.
To achieve this, we offer Answer Placeholders. You can highlight a code string and hide it behind a placeholder. Learners of this course will see the text of this placeholder only so they will be able to enter the code themselves.
To add a placeholder, invoke the Add Answer Placeholder command from the context menu and add the text displayed to the learner:
If you right-click the same selection again, you will be able to edit the placeholder text or add a dependency. We will talk about dependencies during the next task.
Dependencies
To let the learner use the same code, a dependency between tasks should exist. If you add dependent task B to task A and they both have placeholders, the placeholder in dependent task B will be prefilled with the code entered in the placeholder of task A. We have two ways of achieving this:
During new task creation: right-click the existing task and choose
:Add dependencies to existing tasks manually. Right-click the answer placeholder and choose Add dependency: While adding the dependency, we should specify the exact path to another placeholder in the following format: <lesson name>#<task name>#<path/to/file>#<filename>#<placeholder number>:
The Visible parameter lets you hide or highlight the placeholder. If the Visible parameter is enabled, the placeholder is outlined in grey:
Once it’s been disabled, the placeholder is not outlined: