Educational Products 2019.2 Help

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:

Choose a language
Choose a language
Choose a language
Choose a language

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 File Menu | New | Framework Lesson. Alternatively, right-click on the course project in the Project View and select New | Framework Lesson:

edu add new framework lesson java
edu add new framework lesson kotlin
edu add new framework lesson python
edu add new framework lesson scala

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 File Menu | New | Task:

edu framework lesson add new task

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

  1. Let's learn to add a description to the task. Click the Edit icon edu framework lesson edit at the top of the Task Description panel or just open the task.html file:

    edu framework lesson task html

  2. Preview all the changes on the Task Description panel while editing:

    edu framework lesson task description preview

  3. You can also build the task description file using Markdown:

    edu framework lesson task description preview markdown

  4. To change the default task description format, navigate to Preferences | Tools | Education Markdown | Course creator.

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.

<div class="hint"> Hints can be added anywhere in task text: type "hint" and press Tab. </div>
edu framework lesson hint

It’s time to write some code. Let’s switch to the next task.

Working with tasks

  1. 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()) }
    edu framework lesson task code java
    edu framework lesson task code kotlin
    edu framework lesson task code python
    edu framework lesson task code scala
  2. Click the Run icon edu framework lesson run in the left gutter to run your code and check if it works as expected:

    edu framework lesson run task java
    edu framework lesson run task kotlin
    edu framework lesson run task python
    edu framework lesson run task scala

Writing tests

  1. 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:

    edu framework lesson test file java
    edu framework lesson test file kotlin
    edu framework lesson test file python
    edu framework lesson test file scala

    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 Course Creator | Make Visible to Learner.

  2. 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!") } }
  3. 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:

    edu framework lesson run test java
    edu framework lesson test code java
    edu framework lesson run test kotlin
    edu framework lesson test code kotlin
    edu framework lesson run test python
    edu framework lesson test code python
    edu framework lesson run test scala
    edu framework lesson test code scala

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:

edu framework lesson add placeholder java
edu framework lesson add placeholder kotlin
edu framework lesson add placeholder python
edu framework lesson add placeholder scala

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 New | Task:

    edu framework lesson task with dependency java
    edu framework lesson task with dependency kotlin
    edu framework lesson task with dependency python
    edu framework lesson task with dependency scala

  • Add dependencies to existing tasks manually. Right-click the answer placeholder and choose Add dependency:

    edu framework lesson 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>:
    edu framework lesson add dependency java
    edu framework lesson add dependency kotlin
    edu framework lesson add dependency python
    edu framework lesson add dependency scala

The Visible parameter lets you hide or highlight the placeholder. If the Visible parameter is enabled, the placeholder is outlined in grey:

edu framework lesson placeholder visible java
edu framework lesson placeholder visible kotlin
edu framework lesson placeholder visible python
edu framework lesson placeholder visible scala

Once it’s been disabled, the placeholder is not outlined:

edu framework lesson placeholder invisible java
edu framework lesson placeholder invisible kotlin
edu framework lesson placeholder invisible python
edu framework lesson placeholder invisible scala

Last modified: 29 November 2019