# Assignment boards from a learning platform

> Teachers connect MockFlow, and each assignment becomes a board shared with the class.

Source: https://mockflow.com/developers/examples/oauth/lms-assignments

A learning platform wants project assignments to happen on a visual board instead of a document upload. With this plugin, each teacher connects their own MockFlow account once. Creating an assignment then makes a board in the teacher's class space, with the brief, the rubric as a checklist and an area for the students' work, and shares the space with the class roster.

[**Download the code**](/developers/assets/examples/mockflow-lms-assignments.zip) (Node.js 18 or later, no packages)

## What it creates

- A space for the class in the teacher's account, found by name or made the first time.
- Every student on the roster added to the space as an editor, with an invitation email the first time.
- An assignment board with the brief as [markdown](/developers/reference/item-types/markdown), the rubric as a [checklist](/developers/reference/item-types/checklist), and a "Your work" section.

## How it works

1. The teacher connects through the [OAuth flow](/developers/concepts/oauth-apps) with the scopes `user:read boards:write members:write`.
2. [List the teacher's spaces](/developers/reference/spaces/list-spaces) to find the class space, or [create it](/developers/reference/spaces/create-space).
3. [Share the space](/developers/reference/spaces/add-space-member) with each student. Adding someone who is already a member keeps them there with the role you send.
4. [Create the board](/developers/reference/boards/create-board) in the space and draw the brief, rubric and work area in one [batch](/developers/reference/items/batch-items).

## Run the example

Register an app in the **OAuth apps** tab of the [developer console](/developers/console/?tab=oauth) with the redirect URI `http://localhost:3000/oauth/callback` and the scopes `user:read`, `boards:write` and `members:write`. Put test emails in `class.json`, then:

```bash
cp .env.example .env        # paste the client ID and secret into .env
node server.js              # open http://localhost:3000
```

## The key code

```javascript
let space = null;
for await (const sp of mf.paginate('/spaces')) if (sp.name === cls.className) space = sp;
if (!space) space = await mf.post('/spaces', { name: cls.className });

for (const email of cls.students) {
  await mf.post(`/spaces/${space.id}/members`, { email, role: 'editor' });
}

const board = await mf.post('/boards', { title: f.title, spaceId: space.id });
```

## Plan limits for teachers

The space, the board and the sharing happen in the teacher's account, under the teacher's plan. Adding students as editors needs Plus or Max. On Basic, a space can be shared as reviewer only, with up to five people, and there is one space; the example shows the API's message and an upgrade link when it answers `402`.

## What you need

An OAuth app with the scopes `user:read`, `boards:write` and `members:write`.
