Merge branch 'master' into improved-file-handling

moodle-rc3
Frode Petterson 2016-07-14 10:29:30 +02:00
commit 61219a7d84
3 changed files with 20 additions and 15 deletions

View File

@ -78,7 +78,7 @@ class H5PDevelopment {
} }
$library = json_decode($libraryJSON, TRUE); $library = json_decode($libraryJSON, TRUE);
if ($library === FALSE) { if ($library === NULL) {
continue; // Invalid JSON. continue; // Invalid JSON.
} }

View File

@ -2344,7 +2344,7 @@ class H5PCore {
* rebuilt only if non-existing * rebuilt only if non-existing
*/ */
public function validateLibrarySupport($force = false) { public function validateLibrarySupport($force = false) {
if (!($this->h5pF->getUnsupportedLibraries() === NULL || $force)) { if (!$force && $this->h5pF->getUnsupportedLibraries() !== NULL) {
return; return;
} }
@ -2379,9 +2379,8 @@ class H5PCore {
); );
} }
} }
$this->h5pF->setUnsupportedLibraries(empty($unsupportedLibraries) ? NULL : $unsupportedLibraries);
} }
$this->h5pF->setUnsupportedLibraries($unsupportedLibraries);
} }
/** /**
@ -3428,7 +3427,7 @@ class H5PContentValidator {
return '<'; return '<';
} }
if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) { if (!preg_match('%^<\s*(/\s*)?([a-zA-Z0-9\-]+)([^>]*)>?|(<!--.*?-->)$%', $string, $matches)) {
// Seriously malformed. // Seriously malformed.
return ''; return '';
} }

View File

@ -24,7 +24,7 @@ H5P.XAPIEvent.prototype.constructor = H5P.XAPIEvent;
*/ */
H5P.XAPIEvent.prototype.setScoredResult = function (score, maxScore, instance, completion, success) { H5P.XAPIEvent.prototype.setScoredResult = function (score, maxScore, instance, completion, success) {
this.data.statement.result = {}; this.data.statement.result = {};
if (typeof score !== 'undefined') { if (typeof score !== 'undefined') {
if (typeof maxScore === 'undefined') { if (typeof maxScore === 'undefined') {
this.data.statement.result.score = {'raw': score}; this.data.statement.result.score = {'raw': score};
@ -40,22 +40,22 @@ H5P.XAPIEvent.prototype.setScoredResult = function (score, maxScore, instance, c
} }
} }
} }
if (typeof completion === 'undefined') { if (typeof completion === 'undefined') {
this.data.statement.result.completion = (this.getVerb() === 'completed' || this.getVerb() === 'answered'); this.data.statement.result.completion = (this.getVerb() === 'completed' || this.getVerb() === 'answered');
} }
else { else {
this.data.statement.result.completion = completion; this.data.statement.result.completion = completion;
} }
if (typeof success !== 'undefined') { if (typeof success !== 'undefined') {
this.data.statement.result.success = success; this.data.statement.result.success = success;
} }
if (instance && instance.activityStartTime) { if (instance && instance.activityStartTime) {
var duration = Math.round((Date.now() - instance.activityStartTime ) / 10) / 100; var duration = Math.round((Date.now() - instance.activityStartTime ) / 10) / 100;
// xAPI spec allows a precision of 0.01 seconds // xAPI spec allows a precision of 0.01 seconds
this.data.statement.result.duration = 'PT' + duration + 'S'; this.data.statement.result.duration = 'PT' + duration + 'S';
} }
}; };
@ -188,12 +188,18 @@ H5P.XAPIEvent.prototype.setActor = function () {
} }
else { else {
var uuid; var uuid;
if (localStorage.H5PUserUUID) { try {
uuid = localStorage.H5PUserUUID; if (localStorage.H5PUserUUID) {
uuid = localStorage.H5PUserUUID;
}
else {
uuid = H5P.createUUID();
localStorage.H5PUserUUID = uuid;
}
} }
else { catch (err) {
uuid = H5P.createUUID(); // LocalStorage and Cookies are probably disabled. Do not track the user.
localStorage.H5PUserUUID = uuid; uuid = 'not-trackable-' + H5P.createUUID();
} }
this.data.statement.actor = { this.data.statement.actor = {
'account': { 'account': {