Educational Products 2020.2 Help

Framework Lessons Guide for Educators

Choose your programming language

This tutorial will walk you through creating a framework lesson on Java KotlinPython ScalaJavaScript RustC++ Go 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
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.

Prerequisites

You can create a JavaScript course in WebStorm, IntelliJ IDEA Ultimate and PyCharm Professional with EduTools plugin installed.

Download WebStorm, IntelliJ IDEA Ultimate or PyCharm Professional bundled with evaluation license key for a free 30-day trial , and Install EduTools plugin.

If you are a student or academic staff member, apply to our Educational Licenses Program to get access to all JetBrains desktop products, including WebStorm.

Prerequisites

You can create a Rust course in CLion with EduTools and Rust plugins installed.

Download CLionbundled with evaluation license key for a free 30-day trial , and Install EduTools Plugin. Alternatively, you can downloadIntelliJ IDEA Edu.

To learn how to install the Rust plugin, see this guide.

Prerequisites

You can create a C++ course in CLion with EduTools plugin installed.

Download CLionbundled with evaluation license key for a free 30-day trial , and Install EduTools Plugin.

If you are a student or academic staff member, apply to our Educational Licenses Program to get access to all JetBrains desktop products, including CLion.

Prerequisites

You can create a Go course in GoLand and IntelliJ IDEA Ultimate with EduTools plugin installed.

Download GoLand or IntelliJ IDEA Ultimatebundled with evaluation license key for a free 30-day trial , and Install EduTools Plugin.

If you are a student or academic staff member, apply to our Educational Licenses Program to get access to all JetBrains desktop products, including GoLand.

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

edu add new framework lesson png

    Tasks

    1. Every course created with your IDE is structured as a list of lessons. Each lesson contains tasks. There are 5 types of tasks:

      • Edu - a coding exercise validated by tests.

      • Output - a coding exercise validated by output.

      • Theory - theoretical learning material without validation.

      • Multiple-choice - single or multiple choice quiz.

      • IDE - a task that helps to learn IDE functionality.

      Let’s take a closer look at each type:

      This is the most common type of task in our courses.
      Its design is quite simple: there are task files that need to be modified and test files that validate the written code.

      To create a new Edu task, go to File | New | Task or right-click your lesson, choose New | Task, and select Edu in the list:

      edu task types edu png

      This type of task allows you to avoid writing tests for simple tasks, instead validating the learner's code by providing the expected output.
      We have a task file where the code needs to be written to and an output.txt file where the desired output is predefined.

      To create a new Output task, go to File | New | Task or right-click your lesson, choose New | Task, and select Output in the list:

      edu task types output png

      It’s really important to keep a good balance between practical and theoretical tasks. That’s why we came up with the idea of Theory tasks. In these tasks, an educator gives training material to a learner that can be used to solve practical tasks.

      Also, as there’s no validation, a learner can practice their coding skills in the Editor view. They can even compile and run the program by clicking Run in the bottom left of the Task Description view. Educators also have the opportunity to provide learners with runnable code samples to accompany the theory.

      To create a new Theory task, go to File | New | Task or right-click your lesson, choose New | Task, and select Theory in the list:

      edu task types theory png

      The questions on these quizzes are multiple choice, and they can allow for the selection of either single or multiple answers. Each quiz consists of a question and possible answers. These parameters are defined in the task-info.yaml file. Here’s an example of such file:

      type: choice is_multiple_choice: false options: - text: Correct is_correct: true - text: Incorrect is_correct: false message_correct: Congratulations! message_incorrect: Incorrect solution files: - name: src/Main.java visible: true

      The most important parameters here are is_multiple choice, options, message_correct, and message_incorrect.

      To create a new Multiple-choice task, go to File | New | Task or right-click your lesson, choose New | Task, and select Multiple-choice in the list:

      edu task types multi choice png

      IDE tasks are similar to the theory tasks in terms of their structure.

      These tasks assume that an educator is teaching learners how to interact with an IDE. Note that there’s no validation for such tasks.

      For example, these tasks may contain information regarding descriptions of useful IDE features, the configuration of the IDE, or the most convenient shortcuts.

      To create a new IDE task, go to File | New | Task or right-click your lesson, choose New | Task, and select IDE in the list:

      edu task types ide png
    2. Typically, a task has the following components:

      • a task.html description file,

      • a main.go file with main function declaration,

      • a Task.java Task.kt task.py Task.scala lib.rs task.js task.cpp task.go file with exercise code,

      • Test.java Tests.kt test_task.py Test.scala tests.rs test.js test.cpp task_test.go file with the task check,

      • CMakeLists.txt file that contains a set of directives and instructions describing the project's source files and targets,

      • any other files needed for the learner to complete the task.

    Task Description

    1. Now it's time to add the task description. Click the Edit icon edit svg at the top of the Task Description panel, or just open task.html file.

    2. You can add images to accompany the task description using corresponding markup in HTML/Markdown.

      You can even instruct the plugin to display a separate set of screenshots for the dark IDE theme.

      For local images, it's enough to add _dark suffix to their names.

      For example, we have the screenshot.png image, it will be used with the light theme, if we put the screenshot_dark.png image to the same directory, it will be used with the dark theme automatically.

      For remote images, path for remote image that is used with the dark theme, should be specified in the srcset attribute like this: <img src="https://light.png" srcset="https://dark.png"/>

    3. Preview all the changes on the Task Description panel while editing.

      edu task description java png
      edu task description kotlin png
      edu task description python png
      edu task description scala png
      edu task description rust png
      edu task description js png
      edu task description cpp png
      edu task description go png

    Working with tasks

    1. Open the main.go file to declare the main function, for example:

      package main import ( "fmt" task "task1" ) func main() { fmt.Println("The result of sum is:", task.Sum(2, 3)) }

    2. Open the Task.java Task.kt task.py Task.scala task.js lib.rs task.cpp task.go 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 test_sum(a, b): return a + b print("Sum is", test_sum(1, 2))
      object Task extends App { def hello() = { "Hello, Scala!" } println(hello()) }
      pub fn hello_world() -> String { String::from("Hello, World!") }
      function sum(a, b) { return a + b; }
      #include <iostream> int sum(int a, int b) { return a + b; } int main() { std::cout << sum(1, 2) << std::endl; }
      package task func Sum(a, b int) int { return a + b }
      edu task code java png
      edu task code kotlin png
      edu task code python png
      edu task code scala png
      edu task code rust png
      edu task code js png
      edu task code cpp png
    3. Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Choose the execute svg Run option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      Go to Run | Run 'global...run' or press Shift+F10 to run your code and check if it works as expected:

      Go to Run | Run 'go build.../main' option from the context menu or press Shift+F10 to run your code and check if it works as expected:

      edu run task java png
      edu run task kotlin png
      edu run task python png
      edu run task scala png
      edu run task js png
      edu run task rust png
      edu run task cpp png
      edu run task go png

    Writing tests

    1. You can write your custom tests to automatically verify the learner's solution. Every task has a Test.java Tests.kt test_task.py Test.scala tests.rs test.js test.cpp file in the test/tests directory that you will need to modify:

      edu test file java png
      edu test file kotlin png
      edu test file python png
      edu test file scala png
      edu test file rust png
      edu test file js png
      edu test file cpp png
      edu test file go png
    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()) } }
      import unittest from ..task import test_sum class TestCase(unittest.TestCase): def test(self): self.assertEqual(3, test_sum(1, 2), msg="1 + 2 = 3")
      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!") } }
      use task1::hello_world; #[test] fn test() { assert_eq!("Hello, World!", hello_world()); }
      function import_task_file(f) { const path = require("path"); const fs = require("fs"); eval.apply(global, [fs.readFileSync(path.join(__dirname, "..", f)).toString()]); } test('adds 1 + 2 to equal 3', () => { import_task_file("task.js"); expect(sum(1, 2)).toBe(3); });
      #include <gtest/gtest.h> int sum(int a, int b); TEST(SumTest, Simple) { ASSERT_EQ(sum(1, 2), 3); }
      package test import ( task "task1" "testing" ) func TestSum(t *testing.T) { type args struct { a int b int } tests := []struct { name string args args want int }{ {"1", args{1, 1}, 2}, {"2", args{1, 2}, 3}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := task.Sum(tt.args.a, tt.args.b); got != tt.want { t.Errorf("Sum() = %v, want %v", got, tt.want) } }) } }
    3. To check that your code passes your own tests, 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 run test java png
      edu run test kotlin png
      edu run test python png
      edu run test scala png
      edu test code rust png
      edu run test js png
      edu run test cpp png
      edu run test go png

    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 answer placeholder java png
    edu answer placeholder kotlin png
    edu answer placeholder python png
    edu answer placeholder scala png
    edu answer placeholder rust png
    edu answer placeholder js png
    edu answer placeholder cpp png
    edu answer placeholder go png

    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:

      edu answer placeholder add dependency png

      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 png
      edu framework lesson add dependency kotlin png
      edu framework lesson add dependency python png
      edu framework lesson add dependency scala png
      edu framework lesson add dependency js png
      edu framework lesson add dependency rust png
      edu framework lesson add dependency cpp png
      edu framework lesson add dependency go png

      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 png
      edu framework lesson placeholder visible kotlin png
      edu framework lesson placeholder visible python png
      edu framework lesson placeholder visible scala png
      edu framework lesson placeholder visible js png
      edu framework lesson placeholder visible rust png
      edu framework lesson placeholder visible cpp png
      edu framework lesson placeholder visible go png

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

      edu framework lesson placeholder invisible java png
      edu framework lesson placeholder invisible kotlin png
      edu framework lesson placeholder invisible python png
      edu framework lesson placeholder invisible scala png
      edu framework lesson placeholder invisible js png
      edu framework lesson placeholder invisible rust png
      edu framework lesson placeholder invisible cpp png
      edu framework lesson placeholder invisible go png

        Last modified: 22 October 2020