Skip to content

Commit

Permalink
Calculate completion percentage to be able to calculated weighted end…
Browse files Browse the repository at this point in the history
…score

- Do same in noop as in xapi and scorm
  • Loading branch information
torinfo committed Dec 8, 2022
1 parent b828ddd commit 677b674
Showing 1 changed file with 19 additions and 1 deletion.
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -1019,6 +1034,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)
Expand Down Expand Up @@ -1214,7 +1232,7 @@ function XTTerminate()
method: "POST",
url: url,
data: {
grade: state.getdScaledScore()
grade: state.getdScaledScore() * state.getCompletionPercentage() / 100.0,
}
})
.done(function (msg) {
Expand Down

0 comments on commit 677b674

Please sign in to comment.