Skip to content

Commit

Permalink
Merge branch 'MDL-40550_25' of https://github.com/totara/openbadges i…
Browse files Browse the repository at this point in the history
…nto MOODLE_25_STABLE
  • Loading branch information
marinaglancy committed Sep 24, 2013
2 parents 0184a31 + a2547d7 commit 9033689
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 32 deletions.
1 change: 1 addition & 0 deletions badges/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
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.
Expand Down
4 changes: 2 additions & 2 deletions badges/criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
$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');
}
Expand All @@ -84,7 +84,7 @@
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);
Expand Down
1 change: 1 addition & 0 deletions badges/criteria_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
} else {
$badge->criteria[$type]->delete();
}
$return->param('msg', 'criteriadeleted');
redirect($return);
}

Expand Down
4 changes: 3 additions & 1 deletion badges/criteria_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@
$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));
Expand All @@ -96,7 +98,7 @@
$criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL));
}
$criteria->save($data);
$return->param('msg', get_string('changessaved'));
$return->param('msg', $msg);
redirect($return);
}

Expand Down
26 changes: 4 additions & 22 deletions badges/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,15 @@
}
}

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);
}
Expand Down Expand Up @@ -178,7 +160,7 @@
}

if ($msg !== '') {
echo $OUTPUT->notification($msg, 'notifysuccess');
echo $OUTPUT->notification(get_string($msg, 'badges'), 'notifysuccess');
}

$badges = new badge_management($records);
Expand Down
1 change: 0 additions & 1 deletion badges/recipients.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
$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();

Expand Down
10 changes: 7 additions & 3 deletions badges/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,16 @@ public function print_badge_overview($badge, $context) {
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());
Expand Down
14 changes: 11 additions & 3 deletions lang/en/badges.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
$string['creatorbody'] = '<p>{$a->user} has completed all badge requirements and has been awarded the badge. View issued badge at {$a->link} </p>';
$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 <em>{$a}</em> ';
$string['criteria_descr_grade'] = ' with minimum grade of <em>{$a}</em> ';
Expand Down Expand Up @@ -325,9 +328,14 @@
$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'] = '<p>This action will perform a check if any of the users have already completed all the requirements for \'{$a}\' badge?</p>
<p>Would you like to proceed?</p>';
$string['reviewbadge'] = 'Changes in badge access';
$string['reviewconfirm'] = '<p>This will make your badge visible to users and allow them to start earning it.</p>
<p>It is possible that some users already meet this badge\'s criteria and will be issued this badge immediately after you enable it.</p>
<p>Once a badge has been issued it will be <strong>locked</strong> - certain settings including the criteria and expiry settings can no longer be changed.</p>
<p>Are you sure you want to enable access to the badge \'{$a}\'?</p>';
$string['save'] = 'Save';
$string['searchname'] = 'Search by name';
$string['selectaward'] = 'Please select the role you would like to use to award this badge: ';
Expand Down

0 comments on commit 9033689

Please sign in to comment.