mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-82804' of https://github.com/paulholden/moodle
This commit is contained in:
commit
2319636ebd
@ -77,8 +77,8 @@ class badges extends system_report {
|
||||
$this->add_filters();
|
||||
$this->add_actions();
|
||||
|
||||
// Set initial sorting by name.
|
||||
$this->set_initial_sort_column('badge:namewithlink', SORT_ASC);
|
||||
$this->set_default_no_results_notice(new lang_string('nomatchingbadges', 'core_badges'));
|
||||
|
||||
// Set if report can be downloaded.
|
||||
$this->set_downloadable(false);
|
||||
@ -155,13 +155,12 @@ class badges extends system_report {
|
||||
* unique identifier
|
||||
*/
|
||||
protected function add_filters(): void {
|
||||
$filters = [
|
||||
$this->add_filters_from_entities([
|
||||
'badge:name',
|
||||
'badge:version',
|
||||
'badge:status',
|
||||
'badge:expiry',
|
||||
];
|
||||
$this->add_filters_from_entities($filters);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,9 +70,12 @@ class course_badges extends system_report {
|
||||
$this->add_base_fields("{$badgeissuedalias}.uniquehash");
|
||||
|
||||
// Now we can call our helper methods to add the content we want to include in the report.
|
||||
$this->add_columns($badgeissuedalias);
|
||||
$this->add_columns();
|
||||
$this->add_filters();
|
||||
|
||||
$this->set_initial_sort_column('badge:name', SORT_ASC);
|
||||
$this->set_default_no_results_notice(new lang_string('nomatchingbadges', 'core_badges'));
|
||||
|
||||
// Set if report can be downloaded.
|
||||
$this->set_downloadable(false);
|
||||
}
|
||||
@ -91,18 +94,17 @@ class course_badges extends system_report {
|
||||
*
|
||||
* They are provided by the entities we previously added in the {@see initialise} method, referencing each by their
|
||||
* unique identifier. If custom columns are needed just for this report, they can be defined here.
|
||||
*
|
||||
* @param string $badgeissuedalias
|
||||
*/
|
||||
public function add_columns(string $badgeissuedalias): void {
|
||||
$columns = [
|
||||
protected function add_columns(): void {
|
||||
$badgeissuedalias = $this->get_entity('badge_issued')->get_table_alias('badge_issued');
|
||||
|
||||
$this->add_columns_from_entities([
|
||||
'badge:image',
|
||||
'badge:name',
|
||||
'badge:description',
|
||||
'badge:criteria',
|
||||
'badge_issued:issued',
|
||||
];
|
||||
$this->add_columns_from_entities($columns);
|
||||
]);
|
||||
|
||||
$this->get_column('badge_issued:issued')
|
||||
->set_title(new lang_string('awardedtoyou', 'core_badges'))
|
||||
@ -119,8 +121,6 @@ class course_badges extends system_report {
|
||||
$icon = new pix_icon('i/valid', get_string('dateearned', 'badges', $date));
|
||||
return $OUTPUT->action_icon($badgeurl, $icon, null, null, true);
|
||||
});
|
||||
|
||||
$this->set_initial_sort_column('badge:name', SORT_ASC);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,11 +130,9 @@ class course_badges extends system_report {
|
||||
* unique identifier
|
||||
*/
|
||||
protected function add_filters(): void {
|
||||
$filters = [
|
||||
$this->add_filters_from_entities([
|
||||
'badge:name',
|
||||
'badge_issued:issued',
|
||||
];
|
||||
|
||||
$this->add_filters_from_entities($filters);
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ class recipients extends system_report {
|
||||
$this->add_filters();
|
||||
$this->add_actions();
|
||||
|
||||
$this->set_initial_sort_column('badge_issued:issued', SORT_DESC);
|
||||
$this->set_default_no_results_notice(new lang_string('nomatchingawards', 'core_badges'));
|
||||
|
||||
// Set if report can be downloaded.
|
||||
$this->set_downloadable(false);
|
||||
}
|
||||
@ -81,14 +84,11 @@ class recipients extends system_report {
|
||||
* They are provided by the entities we previously added in the {@see initialise} method, referencing each by their
|
||||
* unique identifier. If custom columns are needed just for this report, they can be defined here.
|
||||
*/
|
||||
public function add_columns(): void {
|
||||
$columns = [
|
||||
protected function add_columns(): void {
|
||||
$this->add_columns_from_entities([
|
||||
'user:fullnamewithlink',
|
||||
'badge_issued:issued',
|
||||
];
|
||||
|
||||
$this->add_columns_from_entities($columns);
|
||||
$this->set_initial_sort_column('badge_issued:issued', SORT_DESC);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,12 +98,10 @@ class recipients extends system_report {
|
||||
* unique identifier
|
||||
*/
|
||||
protected function add_filters(): void {
|
||||
$filters = [
|
||||
$this->add_filters_from_entities([
|
||||
'user:fullname',
|
||||
'badge_issued:issued',
|
||||
];
|
||||
|
||||
$this->add_filters_from_entities($filters);
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,6 +89,8 @@ if (!has_any_capability(array(
|
||||
}
|
||||
|
||||
$PAGE->set_title($hdr);
|
||||
|
||||
/** @var core_badges_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'badges');
|
||||
|
||||
if ($delete || $archive) {
|
||||
@ -159,9 +161,8 @@ if ($msg !== '') {
|
||||
}
|
||||
|
||||
$report = system_report_factory::create(badges::class, $PAGE->context);
|
||||
$report->set_default_no_results_notice(new lang_string('nobadges', 'badges'));
|
||||
|
||||
echo $report->output();
|
||||
|
||||
$PAGE->requires->js_call_amd('core_badges/actions', 'init');
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -24,6 +24,9 @@
|
||||
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
|
||||
*/
|
||||
|
||||
use core_badges\reportbuilder\local\systemreports\recipients;
|
||||
use core_reportbuilder\system_report_factory;
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
@ -63,6 +66,7 @@ $PAGE->set_heading($heading);
|
||||
$PAGE->set_title($badge->name);
|
||||
$PAGE->navbar->add($badge->name);
|
||||
|
||||
/** @var core_badges_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'badges');
|
||||
|
||||
echo $output->header();
|
||||
@ -73,9 +77,7 @@ echo $output->render_tertiary_navigation($actionbar);
|
||||
echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badge->name);
|
||||
echo $output->print_badge_status_box($badge);
|
||||
|
||||
$report = \core_reportbuilder\system_report_factory::create(\core_badges\reportbuilder\local\systemreports\recipients::class,
|
||||
$PAGE->context, '', '', 0, ['badgeid' => $badge->id]);
|
||||
$report->set_default_no_results_notice(new lang_string('noawards', 'badges'));
|
||||
$report = system_report_factory::create(recipients::class, $PAGE->context, '', '', 0, ['badgeid' => $badge->id]);
|
||||
echo $report->output();
|
||||
|
||||
echo $output->footer();
|
||||
|
@ -17,7 +17,7 @@ Feature: Add badges to the system
|
||||
And I add the "Navigation" block if not present
|
||||
And I click on "Site pages" "list_item" in the "Navigation" "block"
|
||||
Given I click on "Site badges" "link" in the "Navigation" "block"
|
||||
Then I should see "There are currently no badges available for users to earn."
|
||||
Then I should see "There are no matching badges available for users to earn"
|
||||
|
||||
@javascript @_file_upload
|
||||
Scenario: Add a site badge
|
||||
@ -53,7 +53,7 @@ Feature: Add badges to the system
|
||||
And I should see "Math"
|
||||
And I should see "Physics"
|
||||
And I navigate to "Badges > Manage badges" in site administration
|
||||
And I should not see "There are currently no badges available for users to earn."
|
||||
And I should not see "There are no matching badges available for users to earn"
|
||||
|
||||
@javascript @_file_upload
|
||||
Scenario: Add a badge related
|
||||
@ -165,7 +165,7 @@ Feature: Add badges to the system
|
||||
And I should see "Alignments (0)"
|
||||
And I should not see "Create badge"
|
||||
And I navigate to "Badges > Manage badges" in site administration
|
||||
And I should not see "There are currently no badges available for users to earn."
|
||||
And I should not see "There are no matching badges available for users to earn"
|
||||
# See buttons from the "Site badges" page.
|
||||
And I am on homepage
|
||||
When I click on "Site pages" "list_item" in the "Navigation" "block"
|
||||
|
@ -90,7 +90,7 @@ Feature: Award badges
|
||||
And I add the "Navigation" block if not present
|
||||
And I click on "Site pages" "list_item" in the "Navigation" "block"
|
||||
And I click on "Site badges" "link" in the "Navigation" "block"
|
||||
Then I should see "There are currently no badges available for users to earn."
|
||||
Then I should see "There are no matching badges available for users to earn"
|
||||
And I should not see "Manage badges"
|
||||
And I should not see "Add a new badge"
|
||||
|
||||
@ -127,7 +127,6 @@ Feature: Award badges
|
||||
And I press "Update profile"
|
||||
And I follow "Profile" in the user menu
|
||||
Then I should see "Profile Badge"
|
||||
And I should not see "There are currently no badges available for users to earn."
|
||||
|
||||
@javascript
|
||||
Scenario: Award site badge
|
||||
|
@ -44,8 +44,7 @@ Feature: Delete course badge already awarded
|
||||
# Navigate to Badges page to confirm that no badges exist, hence, Manage badges would not exist
|
||||
And I navigate to "Badges" in current page administration
|
||||
# Confirm that badges are sucessfully deleted
|
||||
And I should see "There are currently no badges available for users to earn."
|
||||
|
||||
And I should see "There are no matching badges available for users to earn"
|
||||
Examples:
|
||||
| badgename | deleteoption | visibility |
|
||||
| Badge 1 | Delete and keep existing issued badges | should |
|
||||
|
@ -45,7 +45,7 @@ Feature: Manage badges
|
||||
And I navigate to "Badges > Manage badges" in site administration
|
||||
And I press "Delete" action in the "Badge #1" report row
|
||||
And I press "Delete and remove existing issued badges"
|
||||
Then I should see "There are currently no badges available for users to earn"
|
||||
Then I should see "There are no matching badges available for users to earn"
|
||||
|
||||
Scenario Outline: Filter managed badges
|
||||
Given the following "core_badges > Badges" exist:
|
||||
|
@ -4,7 +4,7 @@ Feature: Manage badges is not shown when there are no existing badges.
|
||||
Scenario: Check navigation at site level with no badges
|
||||
Given I log in as "admin"
|
||||
When I navigate to "Badges > Manage badges" in site administration
|
||||
And I should see "There are currently no badges available for users to earn"
|
||||
And I should see "There are no matching badges available for users to earn"
|
||||
Then "Manage badges" "button" should not exist
|
||||
|
||||
Scenario: Check navigation at course level with no badges
|
||||
@ -99,7 +99,7 @@ Feature: Manage badges is not shown when there are no existing badges.
|
||||
And I follow "Badges"
|
||||
And "Manage badges" "button" should not exist
|
||||
And "Add a new badge" "button" should not exist
|
||||
And I should not see "There are currently no badges available for users to earn."
|
||||
And the following should exist in the "reportbuilder-table" table:
|
||||
And I should not see "There are no matching badges available for users to earn"
|
||||
And the following should exist in the "Course badges" table:
|
||||
| Name | Description | Criteria |
|
||||
| Testing course badge | Testing course badge description | Awarded by: Teacher |
|
||||
|
@ -24,6 +24,9 @@
|
||||
* @author Yuliya Bozhko <yuliya.bozhko@totaralms.com>
|
||||
*/
|
||||
|
||||
use core_badges\reportbuilder\local\systemreports\course_badges;
|
||||
use core_reportbuilder\system_report_factory;
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
@ -67,6 +70,8 @@ if ($type == BADGE_TYPE_SITE) {
|
||||
require_capability('moodle/badges:viewbadges', $PAGE->context);
|
||||
|
||||
$PAGE->set_title($title);
|
||||
|
||||
/** @var core_badges_renderer $output */
|
||||
$output = $PAGE->get_renderer('core', 'badges');
|
||||
|
||||
// Display "Manage badges" button to users with proper capabilities.
|
||||
@ -98,9 +103,8 @@ if ($course && $course->startdate > time()) {
|
||||
echo $OUTPUT->box(get_string('error:notifycoursedate', 'badges'), 'generalbox notifyproblem');
|
||||
}
|
||||
|
||||
$report = \core_reportbuilder\system_report_factory::create(\core_badges\reportbuilder\local\systemreports\course_badges::class,
|
||||
$PAGE->context, '', '', 0, ['type' => $type, 'courseid' => $courseid]);
|
||||
$report->set_default_no_results_notice(new lang_string('nobadges', 'badges'));
|
||||
$report = system_report_factory::create(course_badges::class, $PAGE->context, '', '', 0,
|
||||
['type' => $type, 'courseid' => $courseid]);
|
||||
echo $report->output();
|
||||
|
||||
// Trigger event, badge listing viewed.
|
||||
|
@ -424,11 +424,13 @@ $string['newbadgedeprecated'] = 'You have been redirected from badges/newbadge.p
|
||||
$string['newimage'] = 'New image';
|
||||
$string['noalignment'] = 'This badge does not have any external skills or standards specified.';
|
||||
$string['noawards'] = 'This badge has not been earned yet.';
|
||||
$string['nomatchingawards'] = 'There are no matching recipients who have earned this badge yet';
|
||||
$string['nobackpack'] = 'There is no backpack service connected to this account.<br/>';
|
||||
$string['nobackpackbadgessummary'] = 'There are no badges in the collections you have selected.';
|
||||
$string['nobackpackcollectionssummary'] = 'No badge collections have been selected.';
|
||||
$string['nobackpacks'] = 'There are no backpacks available';
|
||||
$string['nobadges'] = 'There are currently no badges available for users to earn.';
|
||||
$string['nomatchingbadges'] = 'There are no matching badges available for users to earn';
|
||||
$string['nocompetencies'] = 'No competencies selected.';
|
||||
$string['nocriteria'] = 'Criteria for this badge have not been set up yet.';
|
||||
$string['noendorsement'] = 'This badge does not have an endorsement.';
|
||||
|
@ -855,8 +855,9 @@ abstract class base {
|
||||
/**
|
||||
* Set the default lang string for the notice used when no results are found.
|
||||
*
|
||||
* Note this should be called from within the report class instance itself (ideally it would be protected)
|
||||
*
|
||||
* @param lang_string|null $notice string, or null to tell the report to omit the notice entirely.
|
||||
* @return void
|
||||
*/
|
||||
public function set_default_no_results_notice(?lang_string $notice): void {
|
||||
$this->noresultsnotice = $notice;
|
||||
|
Loading…
x
Reference in New Issue
Block a user