From 92219c8ffdebfac3b6a7588a351f2351ab5965a0 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Wed, 10 Jun 2020 12:27:40 +0200 Subject: [PATCH] MDL-69002 core_badges: move backpack validation to a separate page Instead of running the site backpack validation every time badges/backpacks.php page is loaded, an action button has been added to the backpacks with OB set to 2.0 to let admins running manually this verification when needed. --- badges/backpacks.php | 8 ++++++++ badges/classes/output/external_backpacks_page.php | 2 +- badges/templates/external_backpacks_page.mustache | 11 ++++++----- lang/en/badges.php | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/badges/backpacks.php b/badges/backpacks.php index ae63fd68d2c48..74beaddd85c20 100644 --- a/badges/backpacks.php +++ b/badges/backpacks.php @@ -80,6 +80,14 @@ echo $output->heading(get_string('managebackpacks', 'badges')); $form->display(); +} else if ($action == 'test') { + // If no backpack has been selected, there isn't anything to test. + if (empty($id)) { + redirect($url); + } + + echo $OUTPUT->header(); + echo $output->render_test_backpack_result($id); } else { echo $OUTPUT->header(); echo $output->heading(get_string('managebackpacks', 'badges')); diff --git a/badges/classes/output/external_backpacks_page.php b/badges/classes/output/external_backpacks_page.php index f9258b36f2b0e..28da925df37f6 100644 --- a/badges/classes/output/external_backpacks_page.php +++ b/badges/classes/output/external_backpacks_page.php @@ -72,11 +72,11 @@ public function export_for_template(\renderer_base $output) { } else { $backpack->canedit = false; } + $backpack->cantest = ($backpack->apiversion == OPEN_BADGES_V2); $backpack->iscurrent = ($backpack->id == $CFG->badges_site_backpack); $data->backpacks[] = $backpack; } - $data->warning = badges_verify_site_backpack(); return $data; } diff --git a/badges/templates/external_backpacks_page.mustache b/badges/templates/external_backpacks_page.mustache index aab0f2fc6fbea..0f9df01005192 100644 --- a/badges/templates/external_backpacks_page.mustache +++ b/badges/templates/external_backpacks_page.mustache @@ -25,9 +25,8 @@ Example context (json): { "backpacks": [ - {"backpackweburl": "http://localhost/", "sitebackpack": true, "canedit": false} - ], - "warning": "Could not login" + {"backpackweburl": "http://localhost/", "sitebackpack": true, "canedit": false, "cantest": true} + ] } }} @@ -59,9 +58,11 @@ {{#pix}}t/delete, core,{{#str}}delete{{/str}}{{/pix}} {{/iscurrent}} + {{#cantest}} + {{#pix}}t/check, core,{{#str}}testsettings, core_badges{{/str}}{{/pix}} + {{/cantest}} {{/backpacks}} - -{{{warning}}} + \ No newline at end of file diff --git a/lang/en/badges.php b/lang/en/badges.php index 14f709f895225..85abc8a28b236 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -552,6 +552,7 @@ $string['targetcode'] = 'Code'; $string['targetcode_help'] = 'A unique string identifier for referencing the external skill or standard within its framework.'; $string['testbackpack'] = 'Test backpack \'{$a}\''; +$string['testsettings'] = 'Test settings'; $string['type'] = 'Type'; $string['variablesubstitution'] = 'Variable substitution in messages.'; $string['variablesubstitution_help'] = 'In a badge message, certain variables can be inserted into the subject and/or body of a message so that they will be replaced with real values when the message is sent. The variables should be inserted into the text exactly as they are shown below. The following variables can be used: