Skip to main content

Configuration file

The m2c2kit CLI can create an example static site configuration to get you started.

Creating the static website configuration file

Create and enter a new directory where you want to work on creating your static site. Then:

m2 static-site --init

You will see output like this:

CREATE site-config.mjs (2032 bytes)

The file site-config.mjs was created. It will look similar to this:

export default {
configVersion: "0.1.19",
outDir: "./dist",
assessments: [
{
name: "@m2c2kit/assessment-symbol-search",
versions: ">=0.8.19",
parameters: {
number_of_trials: 4,
show_quit_button: false,
},
},
{
name: "@m2c2kit/assessment-grid-memory",
versions: ">=0.8.19",
parameters: {
number_of_trials: 2,
show_quit_button: false,
},
}
],
configure: (context, session, assessment) => {
session.onActivityData((ev) => {
console.log(" newData: " + JSON.stringify(ev.newData));
fetch("https://<www.your-api-server.com>/<your_endpoint>", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(ev.newData),
});
});
}
};

The site-config.mjs file describes:

  • where to output the static website files
  • what m2c2kit assessments and versions to include in the static site
  • customizations to assessment parameters
  • additional code to save participant data to another server or redirect them to another website when finished

We'll go over each of these.

warning

You can rename the static website configuration file, but it must end in .mjs