Skip to content

Commit

Permalink
MDL-69002 core_badges: move backpack validation to a separate page
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sarjona committed Jun 10, 2020
1 parent 3a6950c commit 7d89621
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
8 changes: 8 additions & 0 deletions badges/backpacks.php
Expand Up @@ -67,6 +67,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'));
Expand Down
2 changes: 1 addition & 1 deletion badges/classes/output/external_backpacks_page.php
Expand Up @@ -68,9 +68,9 @@ public function export_for_template(\renderer_base $output) {
} else {
$backpack->canedit = false;
}
$backpack->cantest = ($backpack->apiversion == OPEN_BADGES_V2);
$data->backpacks[] = $backpack;
}
$data->warning = badges_verify_site_backpack();

return $data;
}
Expand Down
15 changes: 8 additions & 7 deletions badges/templates/external_backpacks_page.mustache
Expand Up @@ -25,9 +25,8 @@
Example context (json):
{
"backpacks": [
{"backpackweburl": "http://localhost/", "sitebackpack": true, "canedit": false}
],
"warning": "<span class='text-warning'>Could not login</span>"
{"backpackweburl": "http://localhost/", "sitebackpack": true, "canedit": false, "cantest": true}
]
}
}}
<table class="generaltable fullwidth">
Expand All @@ -46,13 +45,15 @@
<td> {{#sitebackpack}}Yes{{/sitebackpack}} </td>
<td>
{{#canedit}}
<a href="{{baseurl}}?id={{id}}&action=edit">
{{#str}}editsettings, core_badges{{/str}}
</a>
<a href="{{baseurl}}?id={{id}}&action=edit">{{#pix}}t/edit, core,{{#str}}editsettings{{/str}}{{/pix}}</a>
{{/canedit}}
{{#cantest}}
<a href="{{baseurl}}?id={{id}}&action=test">
{{#pix}}t/check, core,{{#str}}testsettings, core_badges{{/str}}{{/pix}}
</a>
{{/cantest}}
</td>
</tr>
{{/backpacks}}
</tbody>
</table>
{{{warning}}}
1 change: 1 addition & 0 deletions lang/en/badges.php
Expand Up @@ -539,6 +539,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:
Expand Down

0 comments on commit 7d89621

Please sign in to comment.