Exam Player
Displays either an interface for students to complete an assessment, or an interface that allows instructors to see results of the assessment. If the exam session being launched does not already exist, our service will automatically create an exam session for you.
If one does exist, the SDK will launch into the pre-existing exam session.
Preview
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The exam config to launch. |
user_id | string | The user ID to launch as. |
context_id | string | (Optional) The host-specfied course under which to launch this exam. |
resource_link_id | string | (Optional) The host-specified assignment identifier under which to launch this exam. |
Our SDK provides a way for you to launch the same exam-config to the same
student, but under different contexts (context_id
and resource_link_id
). You
may assign your own meaning to these parameters; providing different values for
these parameters will result in different exam-session
IDs, which is a
convenient way to assign the same user the same exam-config, and track those
assignments separately.
As a reminder, we already support the notion of attempts
in each
exam-session
, so you do not need to create different exam-session IDs in order
to observe results across attempts.
Launch Options
Parameter | Type | Description |
---|---|---|
disableScoreEditor | boolean | Disables score editor in the results screen for an exam. |
tags | Object[] | Attach tags to new exam sessions on launch |
Events
Parameter | Type | Description |
---|---|---|
launched | The exam session has launched. | |
examSessionStarted | The exam session has started. | |
examSessionSubmitted | The exam session has been submitted. |
Deterministic ID
The id
of the launched (or created, then launched) exam session is
deterministically generated based on four parameters provided in the SDK launch
params
.
exam-config
ID (required)user_id
(required)context_id
resource_link_id
The same same parameters are considered when launching a new exam session via
our API; identical input parameters will result in an identical exam session ID.
If you are attempting to generate an exam session via API, and then launch it
via SDK, and are experiencing trouble launching the identical exam-session id
,
please verify that your inputs on both calls are the same.
Tagging a session on launch
Apply one or more tags on launch (new exam sessions only) by adding tags
to
your launch options.
{
"oauth_consumer_key": "...",
"resource_link_id": "...",
"roles": "...",
"tags": "[{\"key\":\"custom:cohort\",\"type\":\"string\",\"value\":\"cohort-2\"}]"
};
Launch using SDK
<!DOCTYPE html>
<html>
<head>
<title>Campfire SDK Samples</title>
<link
rel="stylesheet"
href="https://unpkg.com/modern-normalize@2.0.0/modern-normalize.css"
/>
<script src="https://unpkg.com/@campfirelearning/sdk-lti@0.6.1/dist/browser/index.js"></script>
<script src="https://unpkg.com/@campfirelearning/sdk-lti-oauth@0.0.2/dist/browser/index.js"></script>
<style type="text/css">
body,
html {
height: 100%;
}
iframe {
width: 100%;
height: 90vh;
border: none;
flex: 1;
min-height: 0;
}
div#app {
padding: 0;
height: 100%;
display: flex;
flex-direction: column;
}
div#app > h1 {
padding: 1rem;
margin: 0;
font-size: 1rem;
border-bottom: solid 1px #999;
}
div#pad {
padding: 1rem;
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
}
</style>
</head>
<body>
<div id="app">
<h1>🔥 <a href=".">Campfire SDK Samples</a></h1>
<div id="pad">
<iframe id="tool" name="tool"></iframe>
</div>
</div>
<script>
const consumer = new CampfireSDK.CampfireAssessmentPlayer({
id: "80390a0a-a90d-4471-9c22-bd806268cc82", // the exam-config ID
params: {
oauth_consumer_key: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
user_id: "s-123", // the student ID
resource_link_id: "0",
context_id: "1",
lis_person_name_given: "Johnny",
lis_person_name_family: "Appleseed",
lis_person_name_full: `Johnny Appleseed`,
lis_outcome_service_url: "https://examspark.dev/my-webhook?format=json",
lis_result_sourcedid: "student1-gradebook-cell-123"
roles: [
"Learner",
"urn:lti:instrole:ims/lis/Student",
],
},
signingFunction: (url) => CampfireOAuth.getUnsafeOauthSigningFunction({
launchUrl: url,
secretKey: "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}),
});
consumer.addEventListener("message", (message) => {
console.log("Message received", message.data)
})
consumer.mount("tool").then(() => {
console.log("Mounted!");
});
</script>
</body>
</html>
Webhook Payload Sample
Each time your exam-session is scored on our end, we will send this payload to
the URL specified in the launch parameter lis_outcome_service_url
. The value of
lis_result_sourcedid
should correspond to an gradebook cell identifier (that you
maintain on your servers). Both parameters are required to receive these webhook
subscriptions. Below is a sample payload. Ensure you are sending ?format=json
in
the lis_outcome_service_url
to receive this format, otherwise you will receive
an XML format meant for Learning Management Systems.
{
"examSession": {
"examConfigId": "a2f2a294-fbfe-4f54-90c1-d31c8844c13c",
"examSessionResults": {
"points": {
"actual": 3,
"isScorable": true,
"max": 4,
"min": 0
}
},
"id": "28506449-44ef-5bee-bf5f-0fc5a1504dc9",
"schemaVersion": "2020-01-01",
"scoreActual": 75,
"scoreMax": 100,
"scoreMin": 0,
"sk": "exam-session",
"sourcedId": "student1-gradebook-cell-123"
}
}