Skip to content

Commit

Permalink
Merge branch 'MDL-82168-main' of https://github.com/junpataleta/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jul 11, 2024
2 parents 2845d8c + e559a3c commit 5597a4e
Show file tree
Hide file tree
Showing 32 changed files with 1,344 additions and 327 deletions.
5 changes: 5 additions & 0 deletions .upgradenotes/MDL-82168-2024062815382042.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
issueNumber: MDL-82168
notes:
core_badges:
- message: New webservices enable_badges and disable_badges have been added.
type: improved
64 changes: 0 additions & 64 deletions badges/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

$badgeid = required_param('id', PARAM_INT);
$copy = optional_param('copy', 0, PARAM_BOOL);
$activate = optional_param('activate', 0, PARAM_BOOL);
$deactivate = optional_param('lock', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$return = optional_param('return', 0, PARAM_LOCALURL);

require_login();
Expand Down Expand Up @@ -74,64 +71,3 @@
}
redirect(new moodle_url('/badges/overview.php', array('id' => $cloneid)));
}

if ($activate) {
require_capability('moodle/badges:configurecriteria', $context);

$PAGE->url->param('activate', 1);
$status = ($badge->status == BADGE_STATUS_INACTIVE) ? BADGE_STATUS_ACTIVE : BADGE_STATUS_ACTIVE_LOCKED;
if ($confirm == 1) {
require_sesskey();
$badge->set_status($status);
$returnurl->param('msg', 'activatesuccess');

if ($badge->type == BADGE_TYPE_SITE) {
// Review on cron if there are more than 1000 users who can earn a site-level badge.
$sql = 'SELECT COUNT(u.id) as num
FROM {user} u
LEFT JOIN {badge_issued} bi
ON u.id = bi.userid AND bi.badgeid = :badgeid
WHERE bi.badgeid IS NULL AND u.id != :guestid AND u.deleted = 0';
$toearn = $DB->get_record_sql($sql, array('badgeid' => $badge->id, 'guestid' => $CFG->siteguest));

if ($toearn->num < 1000) {
$awards = $badge->review_all_criteria();
$returnurl->param('awards', $awards);
} else {
$returnurl->param('awards', 'cron');
}
} else {
$awards = $badge->review_all_criteria();
$returnurl->param('awards', $awards);
}
redirect($returnurl);
}

$strheading = get_string('reviewbadge', 'badges');
$PAGE->navbar->add($strheading);
$PAGE->set_title($strheading);
$PAGE->set_heading($heading);
echo $OUTPUT->header();
echo $OUTPUT->heading($strheading);

$params = array('id' => $badge->id, 'activate' => 1, 'sesskey' => sesskey(), 'confirm' => 1, 'return' => $return);
$url = new moodle_url('/badges/action.php', $params);

if (!$badge->has_criteria()) {
redirect($returnurl, get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'), null, \core\output\notification::NOTIFY_ERROR);
} else {
$message = get_string('reviewconfirm', 'badges', $badge->name);
echo $OUTPUT->confirm($message, $url, $returnurl);
}
echo $OUTPUT->footer();
die;
}

if ($deactivate) {
require_sesskey();
require_capability('moodle/badges:configurecriteria', $context);

$status = ($badge->status == BADGE_STATUS_ACTIVE) ? BADGE_STATUS_INACTIVE : BADGE_STATUS_INACTIVE_LOCKED;
$badge->set_status($status);
redirect($returnurl);
}
10 changes: 10 additions & 0 deletions badges/amd/build/actions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions badges/amd/build/actions.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion badges/amd/build/selectors.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5597a4e

Please sign in to comment.