Skip to content

The @sypnia/learn package

Read and validate lesson files, render a lesson for a level, run checks, and read progress from your code.

Applies to EngineCloud
View as Markdown
On this page
  1. Authors
  2. Apps and scripts
Terminal
npm install @sypnia/learn
ImportFor
@sypnia/learn/formatreading, validating and rendering lesson files: for authors and their tools
@sypnia/learn/checksrunning a lesson’s checks on your machine while you write it
@sypnia/learn/clientthe Learn API: courses, lessons, exercises, progress, explanations

Authors

lint-course.ts
import { lint, parseLesson, render } from '@sypnia/learn/format';

const { problems } = await lint('./learn/use-cases-first');
if (problems.length) console.table(problems);

const lesson = await parseLesson('./learn/use-cases-first/failures-have-names.lesson.md');
const { text } = render(lesson, { level: 'starter', language: 'en', slots: { case: { title: 'Order for today', failures: [{ name: 'OutOfStock' }] } } });

Apps and scripts

next-lesson.ts
import { createLearn } from '@sypnia/learn/client';

const learn = createLearn(); // the session of `npx @sypnia/app login`
const next = await learn.next();
const exercise = await learn.exercises.start(next.id, { project: 'la-espiga' });
const result = await learn.exercises.check(exercise.id);
console.log(result.status, result.checks);

createLearn({ token, baseUrl }) takes a personal access token and your engine’s address instead. A token belongs to a person: Learn has no secret key for apps, because every record belongs to someone.

  1. Authors
  2. Apps and scripts

    Search pages, sections and terms