Socket
Book a DemoInstallSign in
Socket

gitbook-plugin-exercises

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-exercises

Interactive exercices in a gitbook

latest
Source
npmnpm
Version
3.0.0
Version published
Weekly downloads
25
-19.35%
Maintainers
5
Weekly downloads
 
Created
Source

Interactive exercises in a gitbook

With this plugin, a book can contain interactive exercises (currently only in Javascript). An exercise is a code challenge provided to the reader, who is given a code editor to write a solution which is checked against the book author's validation code.

How to use it?

To use the exercises plugin in your Gitbook project, add the exercises plugin to the book.json file, then install plugins using gitbook install.

{
    "plugins": ["exercises"]
}

Exercises format

An exercise is defined by 4 simple parts:

  • Exercise Message/Goals (in markdown/text)
  • Initial code to show to the user, providing a starting point
  • Solution code, being a correct solution to the exercise
  • Validation code that tests the correctness of the user's input
  • Context (optional) code evaluated before executing the user's solution
{% exercise %}
Define a variable `x` equal to 10.

{% initial %}
var x =

{% solution %}
var x = 10;

{% validation %}
assert(x == 10);

{% context %}
// This is context code available everywhere
// The user will be able to evaluate `exposedVar`
var exposedVar = 3;
// ... or call `exposedFunction`
function exposedFunction {
    return 3;
}
{% endexercise %}

The old format (gitbook < 2.0.0) is no longer supported.

FAQs

Package last updated on 03 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts