Plugin Quickstart Guide
Plugins
Plugin Structure Description
Plugins are independent modules that can be connected to a course. There are three types of plugins:
View Plugins - display information in the course, such as text, images, videos, etc.
Trainer Plugins - allow students to complete exercises like quizzes, tasks, exercises, etc.
Assignment Plugins - allow students to complete tasks that need to be reviewed by the teacher.
A plugin is a directory containing the necessary files and folders for its operation. In the root of the plugin, there must be a manifest.json
file that describes the plugin's structure.
Example of the manifest.json
file for the Single Choose plugin:
manifest.json
file for the Single Choose plugin:status - status of the plugin (active, inactive, deprecated)
is_public - whether the plugin is public or private
version - plugin version
name - name of the plugin
description - detailed description of the plugin
short_description - brief description of the plugin
icon - path to the plugin icon
settings - plugin settings
settings.answerRequired (boolean) - whether an answer is required
settings.assignmentApproveRequired (boolean) - whether teacher approval is required for the student's answer
entry - plugin files
entry.state - state file for the plugin
entry.handler - plugin handler file
entry.settings - plugin settings file
entry.edit - HTML file for editing the plugin
entry.view - HTML file for displaying the plugin
Plugins can contain additional files and folders necessary for their operation and the compilation of key HTML files (edit and view).
Technical Requirements for Plugins:
Plugins can be written in any language that can transpile to JavaScript (TypeScript, CoffeeScript, Babel, etc.).
Plugins should be compiled into a single file (e.g., using Webpack) — one
edit.html
and oneview.html
.
Plugin State File (state.json
)
state.json
)Each plugin must have a state file where the current state of the plugin is stored. The state file should contain a JSON object that describes the state variables of the plugin. The plugin's interface is generated based on the state file.
Example of the Single Choose plugin state file:
Plugin Settings File (settings.json
)
settings.json
)Each plugin can have a settings file where its settings are stored. This file is separate from the state file because settings may be used to configure the plugin but do not affect its state.
Example of the Single Choose plugin settings file:
The settings file is a JSON Schema object that describes the structure of the dynamic form in react-jsonschema-form
(https://rjsf-team.github.io/react-jsonschema-form/).
Plugin Handler File (handler.lua
)
handler.lua
)Each "trainer" plugin must have a handler file that describes the logic of the plugin. Based on the plugin state and the input data (student’s response), the output data (result of the answer check) is generated. The Lua programming language is used.
Example of the Single Choose plugin handler file:
bx_state - global variable containing the plugin state and input data (student's answer)
bx_state.request - input data (student's answer)
bx_state.component - plugin state
bx_state.component._settings - plugin settings
JS API for Plugins ($_bx
)
$_bx
)Plugins can use the JS API to interact with the platform.
Example of using $_bx
API:
$_bx
API:This API offers several methods for interacting with the platform. The full list includes checking the current component state, saving states, submitting answers, showing messages, and more.
$_bx.onReady(callback: Function)
Executes the callback function after the platform has fully loaded. This is useful for initializing logic once all interface elements are loaded.
$_bx.isCorrect(): boolean
Checks if the user provided a correct answer.
$_bx.getComponentID(): string
Returns the ID of the current component.
$_bx.setSaveButtonEnabled(value: boolean): void
Enables or disables the save button based on the passed value.
$_bx.isSaveButtonEnabled(): boolean
Checks if the save button is enabled. By default, the button is enabled if not specified.
$_bx.event(): Object
Returns an object for working with events.
$_bx.mode(): string
Gets the current display mode of the platform ("light" or "dark").
$_bx.language(): string
Returns the current interface language. The default is "en" if no language is specified.
$_bx.isSyllabus(): boolean
Checks if the component is part of the course syllabus.
$_bx.parseMessage(): {type: string, content: string}
Parses a message and returns an object containing the message type and its content. Supported types include: success
, feedback
, wrong
, info
.
$_bx.isPendingApproval(): boolean
Checks if an answer is pending approval.
$_bx.isDark(): boolean
Checks if the platform is in dark mode.
$_bx.isLight(): boolean
Checks if the platform is in light mode.
$_bx.isAnswerRequired(): boolean
Checks if an answer is required from the user.
$_bx.isAssignmentRequired(): boolean
Checks if completing an assignment is required by the user.
$_bx.hasAnswer(): boolean
Checks if the user has provided an answer.
$_bx.answerMessage(): string
Returns the message containing the user's answer.
$_bx.getResponseId(): string
Returns the ID of the response.
$_bx.getUser(): Object
Returns an object with the user's data.
$_bx.getState(): Object
Returns the current state of the component.
$_bx.getSettings(key: string | null): Object | undefined
Returns the component's settings. If a key is provided, it returns the settings associated with that key.
$_bx.get(key: string): any
Returns the state value associated with the provided key.
$_bx.push(key: string, value: any): void
Updates the state for the specified key and triggers corresponding events.
$_bx.clean(key: string): void
Clears the state value for the specified key.
$_bx.saveState(): Promise
Saves the current state of the component.
$_bx.fixView(): void
Deprecated method for fixing the view. Use refreshHeight
instead.
$_bx.contentLoaded(): void
Notifies that the content has been loaded.
$_bx.showMessageBox(variant: string, message: string): void
Displays a message to the user with the specified style variant.
$_bx.showModal(title: string, message: string): void
Displays a modal window with a title and message.
$_bx.dangerouslyShowModal(title: string, html: string): void
Displays a modal window with HTML content (no JavaScript).
$_bx.showSuccessMessage(message: string): void
Displays a success message to the user.
$_bx.showErrorMessage(message: string): void
Displays an error message to the user.
$_bx.showWarningMessage(message: string): void
Displays a warning message to the user.
$_bx.showInfoMessage(message: string): void
Displays an informational message to the user.
$_bx.showAbout(): void
Displays a dialog with information about the component.
$_bx.isShowSettings(): boolean
Checks if the settings dialog should be displayed.
$_bx.showSettings(): void
Displays the settings dialog for the component.
$_bx.sendMessage(message: string): void
Sends a message to the parent frame.
$_bx.reset(): void
Resets the component's state and closes the dialog.
$_bx.uploadFile(blob: Blob, onProgress: Function, originalFileName: string): Promise<Object>
Uploads a file and tracks the upload progress.
Example of a Hook for Saving Plugin State in edit.html
(Plugin Editing)
edit.html
(Plugin Editing)Example of a Hook for Saving Plugin State in view.html
(Student's Answer)
view.html
(Student's Answer)Deploying the Plugin
coobcli is a command-line tool that allows you to manage plugins and their versions, as well as publish them to the plugin repository.
Installing coobcli:
Using coobcli:
Last updated