diff --git a/modules/site/parent_templates/site/common/js/xttracking_noop.js b/modules/site/parent_templates/site/common/js/xttracking_noop.js index 0db394a04..4e52de4c5 100644 --- a/modules/site/parent_templates/site/common/js/xttracking_noop.js +++ b/modules/site/parent_templates/site/common/js/xttracking_noop.js @@ -71,6 +71,7 @@ function NoopTrackingState() this.initialise = initialise; this.pageCompleted = pageCompleted; this.getCompletionStatus = getCompletionStatus; + this.getCompletionPercentage = getCompletionPercentage; this.getSuccessStatus = getSuccessStatus; this.getdScaledScore = getdScaledScore; this.getdRawScore = getdRawScore; @@ -130,6 +131,20 @@ function NoopTrackingState() } } + function getCompletionPercentage() { + var completed = true; + var completedpages = 0; + if (this.completedPages.length == 0) { + return 0; + } + for (var i = 0; i < this.completedPages.length; i++) { + if (this.completedPages[i] == true) { + completedpages++; + } + } + return (completedpages / this.completedPages.length) * 100.0; + } + function getSuccessStatus() { if (this.lo_type != "pages only") @@ -321,7 +336,7 @@ function NoopTrackingState() function setPageScore(page_nr, score) { var sit = state.findPage(page_nr); - if (sit != null && (state.scoremode != 'first' || sit.count < 1)) + if (sit != null && (state.scoremode != 'first' || sit.count <= 1)) { sit.score = score; sit.count++; @@ -1027,6 +1042,9 @@ function XTSetOption(option, value) break; case "toComplete": state.toCompletePages = value; + for (i = 0; i < state.toCompletePages.length; i++) { + state.completedPages[i] = false; + } break; case "tracking-mode": switch(value) @@ -1222,7 +1240,7 @@ function XTTerminate() method: "POST", url: url, data: { - grade: state.getdScaledScore() + grade: state.getdScaledScore() * state.getCompletionPercentage() / 100.0, } }) .done(function (msg) { diff --git a/modules/site/xAPI/xttracking_xapi.js b/modules/site/xAPI/xttracking_xapi.js index 263d328ac..b2e48c82b 100644 --- a/modules/site/xAPI/xttracking_xapi.js +++ b/modules/site/xAPI/xttracking_xapi.js @@ -458,7 +458,7 @@ function XApiTrackingState() { function setPageScore(page_nr, score) { var sit = this.findPage(page_nr); - if (sit != null && (this.scoremode != 'first' || sit.count < 1)) { + if (sit != null && (this.scoremode != 'first' || sit.count <= 1)) { sit.score = score; } } diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/js/xttracking_noop.js b/modules/xerte/parent_templates/Nottingham/common_html5/js/xttracking_noop.js index 54f7e34fe..df0602125 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/js/xttracking_noop.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/js/xttracking_noop.js @@ -336,7 +336,7 @@ function NoopTrackingState() function setPageScore(page_nr, score) { var sit = state.findPage(page_nr); - if (sit != null && (state.scoremode != 'first' || sit.count < 1)) + if (sit != null && (state.scoremode != 'first' || sit.count <= 1)) { sit.score = score; sit.count++;