Merge branch 'MDL-67173-master' of git://github.com/cescobedo/moodle
This commit is contained in:
@@ -99,9 +99,18 @@ class external extends external_api {
|
||||
$messages = $h5pplayer->get_messages();
|
||||
} catch (\moodle_exception $e) {
|
||||
$messages = (object) [
|
||||
'exception' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
];
|
||||
// To mantain the coherence between web coding error and Mobile coding errors.
|
||||
// We need to return the same message error to Mobile.
|
||||
// The 'out_al_local_url called on a non-local URL' error is provided by the \moodle_exception.
|
||||
// We have to translate to h5pinvalidurl which is the same coding error showed in web.
|
||||
if ($e->errorcode === 'codingerror' &&
|
||||
$e->a === 'out_as_local_url called on a non-local URL') {
|
||||
$messages->exception = get_string('h5pinvalidurl', 'core_h5p');
|
||||
} else {
|
||||
$messages->exception = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($messages->error) && empty($messages->exception)) {
|
||||
|
||||
@@ -124,6 +124,17 @@ class core_h5p_external_testcase extends externallib_advanced_testcase {
|
||||
// Check the warnings to be sure that h5pinvalidurl is the message by moodle_exception.
|
||||
$this->assertEquals($urlempty, $result['warnings'][0]['item']);
|
||||
$this->assertEquals(get_string('h5pinvalidurl', 'core_h5p'), $result['warnings'][0]['message']);
|
||||
|
||||
// Create a non-local URL.
|
||||
$urlnonlocal = 'http://www.google.com/pluginfile.php/644/block_html/content/arithmetic-quiz-1-1.h5p';
|
||||
$result = external::get_trusted_h5p_file($urlnonlocal, 0, 0, 0, 0);
|
||||
$result = external_api::clean_returnvalue(external::get_trusted_h5p_file_returns(), $result);
|
||||
// Expected result: Just 1 record on warnings and none on files.
|
||||
$this->assertCount(0, $result['files']);
|
||||
$this->assertCount(1, $result['warnings']);
|
||||
// Check the warnings to be sure that h5pinvalidurl is the message by moodle_exception.
|
||||
$this->assertEquals($urlnonlocal, $result['warnings'][0]['item']);
|
||||
$this->assertEquals(get_string('h5pinvalidurl', 'core_h5p'), $result['warnings'][0]['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user