Skip to content

Commit

Permalink
Add extra contaext to xAPI interactions
Browse files Browse the repository at this point in the history
 - Opinion add opinionClass extension to xAPI interactions
  • Loading branch information
torinfo committed Oct 13, 2021
1 parent c684323 commit 36a8a7f
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 35 deletions.
Expand Up @@ -1129,7 +1129,7 @@ function XTVideo(page_nr, name, block_name, verb, videostate, grouping) {
return;
}

function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping)
function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping, context)
{
state.enterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback);
}
Expand Down Expand Up @@ -1204,8 +1204,8 @@ function XTTerminate()
var url = window.location.href;
if (url.indexOf("lti_launch.php") >= 0) {
url = url.replace("lti_launch.php", "website_code/php/lti/sendgrade.php");
} else if (url.indexOf("lti2_launch.php") >= 0) {
url = url.replace("lti2_launch.php", "website_code/php/lti/sendgrade.php");
} else if (url.indexOf("lti13_launch.php") >= 0) {
url = url.replace("lti13_launch.php", "website_code/php/lti/sendgrade.php");
} else {
url = "";
}
Expand Down
97 changes: 90 additions & 7 deletions modules/site/xAPI/xttracking_xapi.js
Expand Up @@ -378,11 +378,11 @@ function XApiTrackingState() {
}

function enterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions,
correctanswer, feedback, grouping) {
correctanswer, feedback, grouping, context) {
this.verifyEnterInteractionParameters(ia_type, ia_name, correctoptions,
correctanswer, feedback);
var sit = this.findCreate(page_nr, ia_nr, ia_type, ia_name);
sit.enterInteraction(correctanswer, correctoptions, grouping);
sit.enterInteraction(correctanswer, correctoptions, grouping, context);
this.currentid = sit.id;
}

Expand Down Expand Up @@ -1011,6 +1011,7 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
this.weighting = 0.0;
this.score = 0.0;
this.grouping = "";
this.context = "";
this.correctAnswers = [];
this.learnerAnswers = [];
this.learnerOptions = [];
Expand Down Expand Up @@ -1042,6 +1043,8 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
this.nrinteractions = jsonObj.nrinteractions;
this.weighting = jsonObj.weighting;
this.score = jsonObj.score;
this.grouping = jsonObj.grouping;
this.context = jsonObj.context;
this.correctOptions = jsonObj.correctOptions;
this.correctAnswers = jsonObj.correctAnswers;
this.learnerOptions = jsonObj.learnerOptions;
Expand Down Expand Up @@ -1123,7 +1126,7 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {

}

function enterInteraction(correctAnswers, correctOptions, grouping) {
function enterInteraction(correctAnswers, correctOptions, grouping, context) {
this.correctAnswers = correctAnswers;
this.correctOptions = correctOptions;

Expand All @@ -1134,6 +1137,13 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
this.grouping = "";
}

if (typeof context != "undefined" && context != "" && context !=
null) {
this.context = context;
} else {
this.context = "";
}

var id = this.getxApiId();
var description = this.getxApiDescription();

Expand Down Expand Up @@ -1179,6 +1189,18 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
}]
};
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1].replace(" ", "_");
statement.context.extensions[key] = value;
}
});
}
SaveStatement(statement);

}
Expand Down Expand Up @@ -1552,6 +1574,18 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
}]
};
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1];
statement.context.extensions[key] = value;
}
});
}
SaveStatement(statement);
if (typeof statement.result.score != 'undefined') {
var scoredstatement = {
Expand Down Expand Up @@ -1582,6 +1616,18 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
if (this.grouping != "") {
scoredstatement.context.contextActivities = statement.context.contextActivities;
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1];
statement.context.extensions[key] = value;
}
});
}
SaveStatement(scoredstatement);
}
}
Expand Down Expand Up @@ -1624,6 +1670,18 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
}]
};
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1];
statement.context.extensions[key] = value;
}
});
}
SaveStatement(statement);
// If not a page
if (this.ia_nr >= 0) {
Expand Down Expand Up @@ -1675,6 +1733,18 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
}]
};
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1];
statement.context.extensions[key] = value;
}
});
}
SaveStatement(statement);
}
}
Expand Down Expand Up @@ -1751,10 +1821,23 @@ function XApiInteractionTracking(page_nr, ia_nr, ia_type, ia_name) {
}]
};
}
if (this.context != "")
{
let contextitems = this.context.split(',');
contextitems.forEach(function (contextitem){
let item = contextitem.split('=');
if (item.length == 2) {
let key = "http://xerte.org.uk/" + item[0];
let value = item[1];
statement.context.extensions[key] = value;
}
});
}
SaveStatement(statement);
}
}
this.grouping = "";
this.context = "";
}

function getStatements(q, one, callback)
Expand Down Expand Up @@ -2964,9 +3047,9 @@ function XTSetPageScoreJSON(page_nr, score, JSONGraph) {
}

function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions,
correctanswer, feedback, grouping) {
correctanswer, feedback, grouping, context) {
state.enterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions,
correctanswer, feedback, grouping);
correctanswer, feedback, grouping, context);
}

function XTExitInteraction(page_nr, ia_nr, result, learneroptions,
Expand Down Expand Up @@ -3298,8 +3381,8 @@ function XTTerminate() {
var url = window.location.href;
if (url.indexOf("lti_launch.php") >= 0) {
url = url.replace("lti_launch.php", "website_code/php/lti/sendgrade.php");
} else if (url.indexOf("lti2_launch.php") >= 0) {
url = url.replace("lti2_launch.php", "website_code/php/lti/sendgrade.php");
} else if (url.indexOf("lti13_launch.php") >= 0) {
url = url.replace("lti13_launch.php", "website_code/php/lti/sendgrade.php");
} else {
url = "";
}
Expand Down
Expand Up @@ -1129,7 +1129,7 @@ function XTVideo(page_nr, name, block_name, verb, videostate, grouping) {
return;
}

function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping)
function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping, context)
{
state.enterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback);
}
Expand Down
Expand Up @@ -96,7 +96,7 @@
}
break;
case 3:
if (obj.actor.account.name == groupname) {
if (obj.actor.account != undefined && obj.actor.account.name == groupname) {
matchactor = true;
}
break;
Expand Down Expand Up @@ -880,24 +880,36 @@
{
summaryText = `<h1><p>${summaryText}</p></h1>`;
}
div.html(
`<h2><p>${name}</p></h2>` +
`<div class='introduction'>${introductionText}</div>` +
'<div class="summary-container">' +
if (summaryText != "" || adviceHeader != "" || interactionType == 'grouping') {
div.html(
`<h2><p>${name}</p></h2>` +
`<div class='introduction'>${introductionText}</div>` +
'<div class="summary-container">' +
'<div class="summary">' +
summaryText +
'<div class="score">' +
'<div class="stats-div"><ul class="stats"></ul></div>' +
'</div>' +
specificationDiv +
'<div class="advice">' +
adviceHeader +
'<div class="message"></div>' +
'</div>' +
summaryText +
'<div class="score">' +
'<div class="stats-div"><ul class="stats"></ul></div>' +
'</div>' +
specificationDiv +
'<div class="advice">' +
adviceHeader +
'<div class="message"></div>' +
'</div>' +
'</div>' +
'<div class="graph-container"></div>' +
'</div>'
);
'</div>'
);
}
else
{
div.html(
`<h2><p>${name}</p></h2>` +
`<div class='introduction'>${introductionText}</div>` +
'<div class="summary-container">' +
'<div class="graph-container"></div>' +
'</div>'
);
}

$(location).append(div);

Expand Down
Expand Up @@ -181,6 +181,7 @@

this.loadQuestions = function()
{
debugger;
$("#checkBtn").button("disable");

$pageContents.data('radioButtonQuestions', []);
Expand Down Expand Up @@ -253,6 +254,7 @@
else
{
var $thisQ = $(x_currentPageXML).children().children()[questions[currentQuestion]];
let classQ = $($thisQ).parent();
var infoString = $thisQ.getAttribute("prompt");

if ($thisQ.getAttribute("sound") != undefined && $thisQ.getAttribute("sound") != "") {
Expand Down Expand Up @@ -408,7 +410,7 @@
}
}

XTEnterInteraction(x_currentPage, questions[currentQuestion], 'numeric', name, correctOptions, correctAnswer, null, x_currentPageXML.getAttribute("grouping"));
XTEnterInteraction(x_currentPage, questions[currentQuestion], 'numeric', name, correctOptions, correctAnswer, null, x_currentPageXML.getAttribute("grouping"), "opinionClass=" + classQ.attr("name"));
$pageContents.data('checked', false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/xerte/scorm1.2/xttracking_scorm1.2.js
Expand Up @@ -1613,7 +1613,7 @@ function XTSetPageScoreJSON(page_nr, score, JSONGraph) {
XTSetPageScore(page_nr, score);
}

function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping)
function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping, context)
{
if (state.scormmode == 'normal')
{
Expand Down
2 changes: 1 addition & 1 deletion modules/xerte/scorm2004.3rd/xttracking_scorm2004.3rd.js
Expand Up @@ -1557,7 +1557,7 @@ function XTSetPageScoreJSON(page_nr, score, JSONGraph) {
}


function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping)
function XTEnterInteraction(page_nr, ia_nr, ia_type, ia_name, correctoptions, correctanswer, feedback, grouping, context)
{
if (state.scormmode == 'normal')
{
Expand Down

0 comments on commit 36a8a7f

Please sign in to comment.