Skip to content

Commit

Permalink
Add Course and Module to metainformation of LO's
Browse files Browse the repository at this point in the history
 - Add group filtering to adaptiveContent
 - Add modelAnswer block to adaptiveContent
  • Loading branch information
Tom Reijnders committed Nov 30, 2018
1 parent 5711414 commit c13df8a
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 47 deletions.
36 changes: 18 additions & 18 deletions modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js
Expand Up @@ -368,32 +368,32 @@ x_projectDataLoaded = function(xmlData) {

// sort any parameters in url - these will override those in xml
var tempUrlParams = window.location.search.substr(1, window.location.search.length).split("&");
var urlParams = {};
x_urlParams = {};
for (i = 0; i < tempUrlParams.length; i++) {
urlParams[tempUrlParams[i].split("=")[0]] = tempUrlParams[i].split("=")[1];
x_urlParams[tempUrlParams[i].split("=")[0]] = tempUrlParams[i].split("=")[1];
}

// url embed parameter uses ideal setup for embedding in iframes - can be overridden with other parameters below
if (urlParams.embed == 'true') {
if (x_urlParams.embed == 'true') {
x_params.embed = true;
x_params.displayMode = 'full screen';
x_params.responsive = 'false';
// css button also won't appear
}

// url display parameter will set size of LO (display=fixed|full|fill - or a specified size e.g. display=200,200)
if (urlParams.display != undefined) {
if ($.isNumeric(urlParams.display.split(",")[0]) == true && $.isNumeric(urlParams.display.split(",")[1]) == true) {
x_params.displayMode = urlParams.display.split(",");
if (x_urlParams.display != undefined) {
if ($.isNumeric(x_urlParams.display.split(",")[0]) == true && $.isNumeric(x_urlParams.display.split(",")[1]) == true) {
x_params.displayMode = x_urlParams.display.split(",");
x_fillWindow = false; // overrides fill window for touchscreen devices

} else if (urlParams.display == "fixed" || urlParams.display == "default" || urlParams.display == "full" || urlParams.display == "fill") {
} else if (x_urlParams.display == "fixed" || x_urlParams.display == "default" || x_urlParams.display == "full" || x_urlParams.display == "fill") {
if (x_browserInfo.touchScreen == true) {
x_fillWindow = true;
}
if (urlParams.display == "fixed" || urlParams.display == "default") { // default fixed size using values in css (800,600)
if (x_urlParams.display == "fixed" || x_urlParams.display == "default") { // default fixed size using values in css (800,600)
x_params.displayMode = "default";
} else if (urlParams.display == "full" || urlParams.display == "fill") {
} else if (x_urlParams.display == "full" || x_urlParams.display == "fill") {
x_params.displayMode = "full screen"
}
}
Expand All @@ -410,30 +410,30 @@ x_projectDataLoaded = function(xmlData) {
}

// url hide parameter will remove x_headerBlock &/or x_footerBlock divs
if (urlParams.hide != undefined) {
if (urlParams.hide == "none") {
if (x_urlParams.hide != undefined) {
if (x_urlParams.hide == "none") {
x_params.hideHeader = "false";
x_params.hideFooter = "false";
} else if (urlParams.hide == "both") {
} else if (x_urlParams.hide == "both") {
x_params.hideHeader = "true";
x_params.hideFooter = "true";
} else if (urlParams.hide == "bottom") {
} else if (x_urlParams.hide == "bottom") {
x_params.hideHeader = "false";
x_params.hideFooter = "true";
} else if (urlParams.hide == "top") {
} else if (x_urlParams.hide == "top") {
x_params.hideHeader = "true";
x_params.hideFooter = "false";
}
}

// url parameter to turn responsive on / off
if (urlParams.responsive != undefined && (urlParams.responsive == "true" || urlParams.responsive == "false")) {
x_params.responsive = urlParams.responsive;
if (x_urlParams.responsive != undefined && (x_urlParams.responsive == "true" || x_urlParams.responsive == "false")) {
x_params.responsive = x_urlParams.responsive;
}

if (urlParams.theme != undefined && (x_params.themeurl == undefined || x_params.themeurl != 'true'))
if (x_urlParams.theme != undefined && (x_params.themeurl == undefined || x_params.themeurl != 'true'))
{
x_params.theme = urlParams.theme;
x_params.theme = x_urlParams.theme;
}

x_getLangData(x_params.language);
Expand Down
Expand Up @@ -37,6 +37,7 @@
var numUserSubmits = 0;
var textSize = 12;


// We assume the data contains identical data sets
// TODO: Check this
if (numSubmits == 0) {
Expand Down Expand Up @@ -249,36 +250,37 @@
);
}

function matchActor(statement)
{
switch (studentidmode) {
case 0:
case 2:
if (statement.actor.mbox == 'mailto:' + username) {
return true;
}
break;
case 1:
if (statement.actor.mbox_sha1sum == mboxsha1) {
return true;
}
break;
case 3:
if (statement.actor.account != undefined && statement.actor.account.name == groupname) {
return true;
}
break;
}
return false;
}

function filterOwnStatements(data) {
statements = [];
var statements = [];
for (var i = 0; i < data.length; i++)
{
statement = data[i];
matchactor = false;
switch (studentidmode) {
case 0:
case 2:
if (statement.actor.mbox == 'mailto:' + username) {
matchactor = true;
}
break;
case 1:
if (statement.actor.mbox_sha1sum == mboxsha1) {
matchactor = true;
}
break;
case 3:
if (statement.actor.account != undefined && statement.actor.account.name == groupname) {
matchactor = true;
}
break;
}

if (matchactor) {
if (matchActor(data[i])) {
statements.push(data[i]);
}
}

return statements;
}

Expand Down Expand Up @@ -356,6 +358,7 @@
type,
retrieveAll,
interactionIndex,
group,
handler
) {
url = xerteurl + xertelo + '/' + xertelabel.replace(/ /g, "_");
Expand Down Expand Up @@ -391,6 +394,10 @@
*/
q['activity'] = url;
q['verb'] = 'http://adlnet.gov/expapi/verbs/scored';
if (group != "")
{
q['group'] = group;
}
/*
queryStatements(
lrsEndpoint + '/api/connection/statement',
Expand Down Expand Up @@ -437,6 +444,16 @@
// pageChanged & sizeChanged functions are needed in every model file
// other functions for model should also be in here to avoid conflicts.
var adaptiveContent = new function() {
var xerteurl = "";
var xertelo = "";
var xertelabel = "";
var name = "";
var interactionType = "";
var opinionClass = "";
var url = "";
var divUrl = "";
var group = "";

this.loadJS = function() {
if (numLoaded < 2) {
var fileToLoad;
Expand Down Expand Up @@ -564,6 +581,33 @@
if (opinionClass == undefined) {
opinionClass = '';
}
group = interaction.getAttribute('groupFromUrl');
if (group == undefined) {
group = '';
}
else {
if (group == "true")
{
if (x_urlParams['group'] != undefined)
{
group = x_urlParams['group']
}
else
{
if (interaction.getAttribute('groupName') != undefined)
{
group = interaction.getAttribute('groupName');
}
else {
group = "";
}
}
}
else {
group = "";
}
}


url = xerteurl + xertelo + '/' + xertelabel;
if (opinionClass != '') {
Expand Down Expand Up @@ -608,6 +652,7 @@
interactionType,
hasToRetrieveAll(interaction),
interactionIndex,
group,
function(data, interaction, url, type, interactionIndex) {
statements = filterOwnStatements(data);
if (statements.length > 0) {
Expand Down Expand Up @@ -802,6 +847,7 @@
interactionType,
hasToRetrieveAll(interaction),
interactionIndex,
group,
function(data, interaction, url, type, interactionIndex) {
statements = filterOwnStatements(data);
if (statements.length > 0) {
Expand Down Expand Up @@ -1000,6 +1046,7 @@
interactionType,
hasToRetrieveAll(interaction),
interactionIndex,
group,
function(data, interaction, url, type, interactionIndex) {
jsonData = data.map(function(d) {
var obj = {}
Expand Down Expand Up @@ -1028,6 +1075,69 @@
}
);
}
else if (interactionType == "open")
{
statements = getStatements(
xerteurl,
xertelo,
xertelabel,
opinionClass,
interactionType,
hasToRetrieveAll(interaction),
interactionIndex,
group,
function(data, interaction, url, type, interactionIndex) {
statements = filterOwnStatements(data);
if (statements.length > 0) {
score = statements[0].result.score.raw;
if (interaction.getAttribute("showScore") == "true") {
var txt = scoreLabelText;
txt = txt.replace(/\{0\}/, score);
$('#' + escapeUrl(url, type, interactionIndex) + ' .score').html('<p>' + txt + '%</p>');
}
}
var allAnswers= [];
var myAnswers = [];
for (var i=0; i<data.length; i++) {
var answer = "";
if (data[i].result != undefined && data[i].result.response != undefined && data[i].result.response != "") {
answer = data[i].result.response;
}
if (answer != "") {
if (matchActor(data[i])) {
myAnswers.push(answer);
}
else {
allAnswers.push(answer);

}
}
}
// Perhaps we want to do something with the number of answers
var nrMyAnswers = myAnswers.length;
var nrAnswers = allAnswers.length + nrMyAnswers;
var html = "";
if (nrMyAnswers > 0)
{
html = "<ol>";
for (i=0; i<myAnswers.length; i++)
{
html += "<li>" + myAnswers[i] + "</li>";
}
html += "</ol>";
}
if (allAnswers.length > 0)
{
html += "<ol>";
for (i=0; i<allAnswers.length; i++)
{
html += "<li>" + allAnswers[i] + "</li>";
}
html += "</ol>";
}
$('#' + escapeUrl(url, type, interactionIndex) + ' .message').html(html);
});
}


}
Expand Down
Expand Up @@ -320,14 +320,18 @@
<xerteurl label="URL of Xerte source installation" type="xerteurl" mandatory="true" defaultValue=""/>
<xertelo label="ID of Xerte learning object" type="xertelo" mandatory="true" defaultValue=""/>
<label label="Tracking Label of source" type="TextInput" wysiwyg="false"/>
<interactionType label="Interaction type" type="combobox" data="score,answer,opinion" options="Based on end score,Based on specific answer,Based on 2D opinion"/>
<interactionType label="Interaction type" type="combobox" data="score,answer,opinion,open" options="Based on end score,Based on specific answer,Based on 2D opinion,Open answer" tooltip="Score: use 'Score between' to add one or more interaction blocks; Answer: use 'Result label equals' to add one or more interaction block; Based on 2D opinion: use in combination with class to get a score; Open: Just shows one interaction block with all the given answers, all given interaction blocks will just be ignored."/>
<opinionClass label="Opinion Class" type="TextInput" wysiwyg="false" optional="true" defaultValue="Enter label of class" tooltip="Enter the label of the class of the opinion to use as score in case the interactiontype is based on 2D opinion"/>
<showScore label="Show score/answer" type="CheckBox" optional="true" defaultValue="false" tooltip="Show your score or answer on which the interactionBlocks based"/>
<scoreText label="Score text" type="TextInput" wysiwyg="true" language="true"/>
<answerText label="Answer text" type="TextInput" wysiwyg="true" language="true"/>
<AvgLabel label="Average Graph Label" type="TextInput" wysiwyg="true" language="true"/>
<PersonalLastLabel label="Personal Graph Label" type="TextInput" wysiwyg="true" language="true"/>
<PersonalAvgLabel label="Personal Average Graph Label" type="TextInput" wysiwyg="true" language="true"/>
<group type="group" label="Group filtering" optional="true">
<groupFromUrl label="Filter on group from URL" type="checkbox" defaultValue="false" optional="true" tooltip="Filter on groupname, where the groupname is extracted from the URL (group=groupname)"/>
<groupName label="Filter group name" type="TextInput" defaultValue="" wysiwyg="false" optional="true" tooltip="Filter on groupname, use this groupname, if the group is not specified on the URL (group=groupname)"/>
</group>

<newNodes>
<interactionBlock><![CDATA[<interactionBlock adaptiveContent="Place your adaptive content here" conScoreBetween="0,100" ></interactionBlock>]]></interactionBlock>
Expand Down
19 changes: 17 additions & 2 deletions modules/xerte/xAPI/xttracking_xapi.js
Expand Up @@ -2626,6 +2626,12 @@ function XTGetInteractionScore(page_nr, ia_nr, ia_type, ia_name, full_id,

function XTGetStatements(q, one, callback) {
var search = ADL.XAPIWrapper.searchParams();
var group = "";
if (q['group'] != undefined)
{
group = q['group'];
delete q['group'];
}
$.each(q, function(i, value) {
search[i] = value;
});
Expand All @@ -2643,8 +2649,17 @@ function XTGetStatements(q, one, callback) {
//if (sr.statements[x].actor.mbox == userEMail && lastSubmit == null) {
// lastSubmit = JSON.parse(sr.statements[x].result.extensions["http://xerte.org.uk/xapi/JSONGraph"]);
//}

statements.push(body.statements[x]);
if (group != ""
&& body.statements[x].context.team != undefined
&& body.statements[x].context.team.account != undefined
&& body.statements[x].context.team.account.name != undefined
&& body.statements[x].context.team.account.name != group)
{
continue;
}
{
statements.push(body.statements[x]);
}
}
//stringObjects.push(lastSubmit);
if (err !== null) {
Expand Down
6 changes: 5 additions & 1 deletion src/Nottingham/wizards/en-GB/adaptiveContent.xwd
Expand Up @@ -26,14 +26,18 @@
<xerteurl label="URL of Xerte source installation" type="xerteurl" mandatory="true" defaultValue="" />
<xertelo label="ID of Xerte learning object" type="xertelo" mandatory="true" defaultValue="" />
<label label="Tracking Label of source" type="TextInput" wysiwyg="false" />
<interactionType label="Interaction type" type="combobox" data="score,answer,opinion" options="Based on end score,Based on specific answer,Based on 2D opinion" />
<interactionType label="Interaction type" type="combobox" data="score,answer,opinion,open" options="Based on end score,Based on specific answer,Based on 2D opinion,Open answer" tooltip="Score: use 'Score between' to add one or more interaction blocks; Answer: use 'Result label equals' to add one or more interaction block; Based on 2D opinion: use in combination with class to get a score; Open: Just shows one interaction block with all the given answers, all given interaction blocks will just be ignored."/>
<opinionClass label="Opinion Class" type="TextInput" wysiwyg="false" optional="true" defaultValue="Enter label of class" tooltip="Enter the label of the class of the opinion to use as score in case the interactiontype is based on 2D opinion" />
<showScore label="Show score/answer" type="CheckBox" optional="true" defaultValue="false" tooltip="Show your score or answer on which the interactionBlocks based" />
<scoreText label="Score text" type="TextInput" wysiwyg="true" language="true" />
<answerText label="Answer text" type="TextInput" wysiwyg="true" language="true" />
<AvgLabel label="Average Graph Label" type="TextInput" wysiwyg="true" language="true" />
<PersonalLastLabel label="Personal Graph Label" type="TextInput" wysiwyg="true" language="true" />
<PersonalAvgLabel label="Personal Average Graph Label" type="TextInput" wysiwyg="true" language="true" />
<group type="group" label="Group filtering" optional="true">
<groupFromUrl label="Filter on group from URL" type="checkbox" defaultValue="false" optional="true" tooltip="Filter on groupname, where the groupname is extracted from the URL (group=groupname)"/>
<groupName label="Filter group name" type="TextInput" defaultValue="" wysiwyg="false" optional="true" tooltip="Filter on groupname, use this groupname, if the group is not specified on the URL (group=groupname)"/>
</group>

<newNodes>
<interactionBlock ><![CDATA[<interactionBlock adaptiveContent="Place your adaptive content here" conScoreBetween="0,100" ></interactionBlock>]]></interactionBlock>
Expand Down

0 comments on commit c13df8a

Please sign in to comment.