Skip to main content

Enforcing compulsory slides

There are two ways LivePreso can enforce the idea of "compulsory slides". The first option is to mark slides as "requiring prep" - this blocks the user from starting a preso without reviewing the slide, and the second is to prevent the slide from being toggled off in a slide sorter.

Mark as "requiring prep"

In order to mark a slide as "requiring prep", we will be using the application hook, markers. The markers hook runs after each context change and when an appointment is created or saved. If a slide has been marked for review the user will not be able to start the presentation until they have viewed that slide either in Prep mode or in the Slidesorter preview.

Add markers interface to hooks

Let's set it up so that the CDK and LivePreso recognise that you want to deal with markers. First you will want to create a hooks file, use the hooks object in the project.yaml to define where in your deck your hooks.js file is located.

project.yaml

hooks: js/hooks.js

Second you will want to create a markers file. In general, you place this in js/hooks/markers.js. To this file you will add the bare minimum for markers to be loaded.

markers.js

export default {
onUpdate({ sections, data, context, previousContext, feeds, markers }) {
return markers;
},
};

hooks.js

Going back to our hooks.js file, you need to export the hook:

import Markers from "./hooks/markers.js";

export default {
markers: Markers,
};

That's it! The CDK and LivePreso now read markers.

Mark slides for review

In order to mark slides for review you return an array of markers. These markers consist of the slide key and its review completion status.

{
key: "slide_key",
complete: false
}

The completion attribute allows you to check the current status of the markers, ensuring you do not re-add a marker which has already been reviewed.

warning

The Markers feature does not automatically remove previous duplicate entries. Ensure that you update existing entries first, and only add to the Markers list when required. Duplication of marker entries results in the LivePreso app reporting an incorrect total number of slides for review.

For an easy solution, we suggest including a function at the bottom of your markers.js file to handle the merger of new and previous Markers before they are returned.

const newMarkers = [];

// ...
// Code that adds all new markers to the newMarkers list

// Combine newMarkers with original markers
// Update existing entries and avoid duplication
_.each(newMarkers, (marker) => {
const existingMarker = _.find(markers, { key: marker.key });

if (existingMarker) {
existingMarker.complete = false;
} else {
markers.push(marker);
}
});

return markers;

Below is a more complete example, it uses Lodash's _.unionBy in place of the markers merging code above:

import _ from "lodash";

export default {
onUpdate({ sections, data, context, previousContext, feeds, markers }) {
if (data.isNewAppointment) {
const initialMarkers = ["key1", "key2", "key3"];
return _.unionBy(
_.map(initialMarkers, (key) => {
return { key, complete: false };
}),
markers,
"key"
);
}
return markers;
},
};

Prevent slides being toggled off

This guide is currently under construction 🚧

See the following reference and related guide to get you started: