Skip to content

Commit

Permalink
[DONE] Fanfounet/bugfix xAPI (EsupPortail#1161)
Browse files Browse the repository at this point in the history
Co-authored-by: Charneau Franck <[email protected]>
  • Loading branch information
fanfounet and Charneau Franck authored Jun 12, 2024
1 parent 60e4e4e commit cf17347
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions pod/video/templates/videos/video_more_script.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
{% endif %}
{% endif %}

{% get_setting "USE_XAPI" False as USE_XAPI %}
{% get_setting "USE_XAPI_VIDEO" False as USE_XAPI_VIDEO %}
{% if USE_XAPI and USE_XAPI_VIDEO %}
{% include 'xapi/xapi_video.html' %}
Expand Down
26 changes: 13 additions & 13 deletions pod/xapi/static/xapi/script-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ player.on("play", function () {
"https://w3id.org/xapi/video/extensions/time": time_played,
},
};
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
context = {
contextActivities: {
category: [
Expand All @@ -99,7 +99,7 @@ player.on("play", function () {
.duration()
.toFixed(3),
},
registration: registration,
registration: registration_xapi,
};
active_statement();
});
Expand All @@ -122,7 +122,7 @@ player.on("pause", function () {
},
};
played_segments.push(time_played + "[.]" + time_paused);
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
context = {
contextActivities: {
category: [
Expand All @@ -137,7 +137,7 @@ player.on("pause", function () {
.duration()
.toFixed(3),
},
registration: registration,
registration: registration_xapi,
};
active_statement();
});
Expand All @@ -156,7 +156,7 @@ player.on("seeked", function () {
last_time[last_time.indexOf(time_seek) - 1],
},
};
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
context = {
contextActivities: {
category: [
Expand All @@ -168,7 +168,7 @@ player.on("seeked", function () {
extensions: {
"https://w3id.org/xapi/video/extensions/session-id": session_id,
},
registration: registration,
registration: registration_xapi,
};
active_statement();
});
Expand All @@ -192,7 +192,7 @@ player.on("ended", function () {
.toFixed(3),
},
};
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
context = {
contextActivities: {
category: [
Expand All @@ -210,7 +210,7 @@ player.on("ended", function () {
parseInt(player.duration(), 10) / player.duration()
).toFixed(3),
},
registration: registration,
registration: registration_xapi,
};
active_statement();
});
Expand Down Expand Up @@ -243,7 +243,7 @@ player.on("loadedmetadata", function () {
display: { "en-US": action },
};
result = {};
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
cc_lang = get_current_subtitle_lang();
current_quality = get_current_quality();
context = {
Expand Down Expand Up @@ -279,7 +279,7 @@ player.on("loadedmetadata", function () {
"https://w3id.org/xapi/video/extensions/full-screen":
player.isFullscreen(),
},
registration: registration,
registration: registration_xapi,
};
result = {};
active_statement();
Expand Down Expand Up @@ -321,7 +321,7 @@ function set_completed_statement() {
.duration()
.toFixed(3),
},
registration: registration,
registration: registration_xapi,
};
}

Expand All @@ -338,7 +338,7 @@ function set_interacted_statement() {
.toFixed(3),
},
};
if (registration == "") registration = create_UUID();
if (registration_xapi == "") registration_xapi = create_UUID();
cc_lang = get_current_subtitle_lang();
current_quality = get_current_quality();
quality = "";
Expand Down Expand Up @@ -378,7 +378,7 @@ function set_interacted_statement() {
"https://w3id.org/xapi/video/extensions/full-screen":
player.isFullscreen(),
},
registration: registration,
registration: registration_xapi,
};
}

Expand Down
4 changes: 2 additions & 2 deletions pod/xapi/templates/xapi/xapi_video.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const endpoint = "{% url "xapi:statement" app="video" %}";
const csrftoken = document.querySelector('[name=csrfmiddlewaretoken]').value;
const session_id = create_UUID();
let registration, action = "";
let registration_xapi, action = "";
const progress = [];
object = {
"definition": {
Expand All @@ -14,7 +14,7 @@
},
{% if video.description|addslashes != "" %}
"description": {
"{{video.main_lang}}": "{{video.description|addslashes}}"
"{{video.main_lang}}": "{{video.description|addslashes|escapejs}}"
}
{% endif %}
},
Expand Down

0 comments on commit cf17347

Please sign in to comment.