From a2547d7087099c2d812b7e1ce839bd437357e11c Mon Sep 17 00:00:00 2001 From: Yuliya Bozhko Date: Fri, 6 Sep 2013 15:46:38 +1200 Subject: [PATCH] MDL-40550 badges: Change wording of badge activation message Add confirmation check when activating badge from management page --- badges/action.php | 1 + badges/criteria.php | 4 ++-- badges/criteria_action.php | 1 + badges/criteria_settings.php | 4 +++- badges/index.php | 26 ++++---------------------- badges/recipients.php | 1 - badges/renderer.php | 10 +++++++--- lang/en/badges.php | 14 +++++++++++--- 8 files changed, 29 insertions(+), 32 deletions(-) diff --git a/badges/action.php b/badges/action.php index f6f9524fa9a..66c2b3b8afe 100644 --- a/badges/action.php +++ b/badges/action.php @@ -110,6 +110,7 @@ if ($activate) { 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. diff --git a/badges/criteria.php b/badges/criteria.php index 7a1e0e4f1ef..20848d294c2 100644 --- a/badges/criteria.php +++ b/badges/criteria.php @@ -72,7 +72,7 @@ if ((($update == BADGE_CRITERIA_AGGREGATION_ALL) || ($update == BADGE_CRITERIA_A $obj->id = $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]->id; $obj->method = $update; if ($DB->update_record('badge_criteria', $obj)) { - $msg = get_string('changessaved'); + $msg = 'criteriaupdated'; } else { $emsg = get_string('error:save', 'badges'); } @@ -84,7 +84,7 @@ echo $OUTPUT->heading(print_badge_image($badge, $context, 'small') . ' ' . $badg if ($emsg !== '') { echo $OUTPUT->notification($emsg); } else if ($msg !== '') { - echo $OUTPUT->notification($msg, 'notifysuccess'); + echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess'); } echo $output->print_badge_status_box($badge); diff --git a/badges/criteria_action.php b/badges/criteria_action.php index 74ff62c01c1..51b3e89780e 100644 --- a/badges/criteria_action.php +++ b/badges/criteria_action.php @@ -80,6 +80,7 @@ if ($delete && has_capability('moodle/badges:configurecriteria', $context)) { } else { $badge->criteria[$type]->delete(); } + $return->param('msg', 'criteriadeleted'); redirect($return); } diff --git a/badges/criteria_settings.php b/badges/criteria_settings.php index 486febda0e0..6f52fa050a6 100644 --- a/badges/criteria_settings.php +++ b/badges/criteria_settings.php @@ -71,8 +71,10 @@ $PAGE->navbar->add($badge->name, new moodle_url('overview.php', array('id' => $b $cparams = array('criteriatype' => $type, 'badgeid' => $badge->id); if ($edit) { $criteria = $badge->criteria[$type]; + $msg = 'criteriaupdated'; } else { $criteria = award_criteria::build($cparams); + $msg = 'criteriacreated'; } $mform = new edit_criteria_form($FULLME, array('criteria' => $criteria, 'addcourse' => $addcourse, 'course' => $badge->courseid)); @@ -96,7 +98,7 @@ if (!empty($addcourse)) { $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL)); } $criteria->save($data); - $return->param('msg', get_string('changessaved')); + $return->param('msg', $msg); redirect($return); } diff --git a/badges/index.php b/badges/index.php index 6b00bd2df35..a0d2f17f310 100644 --- a/badges/index.php +++ b/badges/index.php @@ -124,33 +124,15 @@ if ($delete && has_capability('moodle/badges:deletebadge', $PAGE->context)) { } } -if ($activate && has_capability('moodle/badges:configuredetails', $PAGE->context)) { - $badge = new badge($activate); - - if (!$badge->has_criteria()) { - $err = get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'); - } else { - if ($badge->is_locked()) { - $badge->set_status(BADGE_STATUS_ACTIVE_LOCKED); - $msg = get_string('activatesuccess', 'badges'); - } else { - require_sesskey(); - $badge->set_status(BADGE_STATUS_ACTIVE); - $msg = get_string('activatesuccess', 'badges'); - } - $returnurl->param('msg', $msg); - redirect($returnurl); - } -} else if ($deactivate && has_capability('moodle/badges:configuredetails', $PAGE->context)) { +if ($deactivate && has_capability('moodle/badges:configuredetails', $PAGE->context)) { + require_sesskey(); $badge = new badge($deactivate); if ($badge->is_locked()) { $badge->set_status(BADGE_STATUS_INACTIVE_LOCKED); - $msg = get_string('deactivatesuccess', 'badges'); } else { - require_sesskey(); $badge->set_status(BADGE_STATUS_INACTIVE); - $msg = get_string('deactivatesuccess', 'badges'); } + $msg = 'deactivatesuccess'; $returnurl->param('msg', $msg); redirect($returnurl); } @@ -178,7 +160,7 @@ if ($totalcount) { } if ($msg !== '') { - echo $OUTPUT->notification($msg, 'notifysuccess'); + echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess'); } $badges = new badge_management($records); diff --git a/badges/recipients.php b/badges/recipients.php index 539696b6ea7..4eac9545623 100644 --- a/badges/recipients.php +++ b/badges/recipients.php @@ -31,7 +31,6 @@ $badgeid = required_param('id', PARAM_INT); $sortby = optional_param('sort', 'dateissued', PARAM_ALPHA); $sorthow = optional_param('dir', 'DESC', PARAM_ALPHA); $page = optional_param('page', 0, PARAM_INT); -$updatepref = optional_param('updatepref', false, PARAM_BOOL); require_login(); diff --git a/badges/renderer.php b/badges/renderer.php index 32961d2753f..82a3ff90c35 100644 --- a/badges/renderer.php +++ b/badges/renderer.php @@ -228,12 +228,16 @@ class core_badges_renderer extends plugin_renderer_base { public function print_badge_table_actions($badge, $context) { $actions = ""; - if (has_capability('moodle/badges:configuredetails', $context)) { + if (has_capability('moodle/badges:configuredetails', $context) && $badge->has_criteria()) { // Activate/deactivate badge. if ($badge->status == BADGE_STATUS_INACTIVE || $badge->status == BADGE_STATUS_INACTIVE_LOCKED) { - $url = new moodle_url(qualified_me()); - $url->param('activate', $badge->id); + // "Activate" will go to another page and ask for confirmation. + $url = new moodle_url('/badges/action.php'); + $url->param('id', $badge->id); + $url->param('activate', true); $url->param('sesskey', sesskey()); + $return = new moodle_url(qualified_me()); + $url->param('return', $return->out_as_local_url(false)); $actions .= $this->output->action_icon($url, new pix_icon('t/show', get_string('activate', 'badges'))) . " "; } else { $url = new moodle_url(qualified_me()); diff --git a/lang/en/badges.php b/lang/en/badges.php index 09cc67510ff..8adeba50c36 100644 --- a/lang/en/badges.php +++ b/lang/en/badges.php @@ -139,6 +139,9 @@ $string['createbutton'] = 'Create badge'; $string['creatorbody'] = '

{$a->user} has completed all badge requirements and has been awarded the badge. View issued badge at {$a->link}

'; $string['creatorsubject'] = '\'{$a}\' has been awarded!'; $string['criteriasummary'] = 'Criteria summary'; +$string['criteriacreated'] = 'Badge criteria successfully created'; +$string['criteriadeleted'] = 'Badge criteria successfully deleted'; +$string['criteriaupdated'] = 'Badge criteria successfully updated'; $string['criteria_descr'] = 'Users are awarded this badge when they complete the following requirement:'; $string['criteria_descr_bydate'] = ' by {$a} '; $string['criteria_descr_grade'] = ' with minimum grade of {$a} '; @@ -313,9 +316,14 @@ $string['recipientidentificationproblem'] = 'Cannot find a recipient of this bad $string['recipientvalidationproblem'] = 'Current user cannot be verified as a recipient of this badge.'; $string['relative'] = 'Relative date'; $string['requiredcourse'] = 'At least one course should be added to the courseset criterion.'; -$string['reviewbadge'] = 'Review badge criteria'; -$string['reviewconfirm'] = '

This action will perform a check if any of the users have already completed all the requirements for \'{$a}\' badge?

-

Would you like to proceed?

'; +$string['reviewbadge'] = 'Changes in badge access'; +$string['reviewconfirm'] = '

This will make your badge visible to users and allow them to start earning it.

+ +

It is possible that some users already meet this badge\'s criteria and will be issued this badge immediately after you enable it.

+ +

Once a badge has been issued it will be locked - certain settings including the criteria and expiry settings can no longer be changed.

+ +

Are you sure you want to enable access to the badge \'{$a}\'?

'; $string['save'] = 'Save'; $string['searchname'] = 'Search by name'; $string['selectaward'] = 'Please select the role you would like to use to award this badge: ';