How to embed a coding lab from Fermion?
Before starting the embed process, you need two things:- A school on Fermion
- Fermion API key
Getting lab ID
Go toManage features from your instructor dashboard and enable Coding labs if you haven’t done that yet.
Once done, open Coding lab from sidebar and create a new IO lab.
Click on the Embed button to obtain the ID of that lab.
Generating JWT
On any page in which you wish to let the user attempt the lab, you need to embed an iframe as follows:EMBED_URL needs to be securely generated on your backend as follows:
Start with the base embed URL
The embed URL will always contain the following base:
https://acme.fermion.app/embed/io-coding-lab?token=TOKEN_HEREGenerate a JWT with required claims
Generate a JWT (JSON Web Token) containing the following claims. The JWT token must be signed with your Fermion API Key.
labId(String) – This is the unique identifier of the lab as mentioned above.userId(String) – This is a string that you have stored in your database that can uniquely identify a given user. You have to ensure that you store this identifier properly in your database and reuse it every time a user tries to access any lab.isReadOnly(Boolean, optional) – Set totrueto render the embedded coding lab in a read-only mode. Defaults tofalse.
EMBED_URL securely on your backend server:
This example uses the jsonwebtoken package to generate a JWT Token.
