Improved message presented to user
parent
b4615e01b1
commit
4d010ef38f
|
@ -3132,7 +3132,30 @@ class H5PContentValidator {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!in_array($value->library, $semantics->options)) {
|
if (!in_array($value->library, $semantics->options)) {
|
||||||
$this->h5pF->setErrorMessage($this->h5pF->t('Library used in content is not a valid library according to semantics'));
|
$message = NULL;
|
||||||
|
// Create an understandable error message:
|
||||||
|
$machineName = explode(' ', $value->library)[0];
|
||||||
|
foreach ($semantics->options as $semanticsLibrary) {
|
||||||
|
$semanticsMachineName = explode(' ', $semanticsLibrary)[0];
|
||||||
|
if ($machineName === $semanticsMachineName) {
|
||||||
|
// Using the wrong version of the library in the content
|
||||||
|
$message = $this->h5pF->t('The version of the H5P library %machineName used in this content is not valid. Content contains %contentLibrary, but it should be %semanticsLibrary.', array(
|
||||||
|
'%machineName' => $machineName,
|
||||||
|
'%contentLibrary' => $value->library,
|
||||||
|
'%semanticsLibrary' => $semanticsLibrary
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using a library in content that is not present at all in semantics
|
||||||
|
if ($message === NULL) {
|
||||||
|
$message = $this->h5pF->t('The H5P library %library used in the content is not valid', array(
|
||||||
|
'%library' => $value->library
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->h5pF->setErrorMessage($message);
|
||||||
$value = NULL;
|
$value = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue