Exemplo n.º 1
0
 public function print_criteria_actions(badge $badge)
 {
     $table = new html_table();
     $table->attributes = array('class' => 'boxaligncenter', 'id' => 'badgeactions');
     $table->colclasses = array('activatebadge');
     $actions = array();
     if (!$badge->is_active() && !$badge->is_locked()) {
         $accepted = $badge->get_accepted_criteria();
         $potential = array_diff($accepted, array_keys($badge->criteria));
         if (!empty($potential)) {
             foreach ($potential as $p) {
                 if ($p != 0) {
                     $select[$p] = get_string('criteria_' . $p, 'badges');
                 }
             }
             $actions[] = get_string('addbadgecriteria', 'badges');
             $actions[] = $this->output->single_select(new moodle_url('/badges/criteria_settings.php', array('badgeid' => $badge->id, 'add' => true)), 'type', $select);
         } else {
             $actions[] = $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
         }
     }
     $table->data[] = $actions;
     return html_writer::table($table);
 }
require_once dirname(dirname(__FILE__)) . '/config.php';
require_once $CFG->libdir . '/badgeslib.php';
$badgeid = optional_param('badgeid', 0, PARAM_INT);
// Badge ID.
$crit = optional_param('crit', 0, PARAM_INT);
$type = optional_param('type', 0, PARAM_INT);
// Criteria type.
$delete = optional_param('delete', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
require_login();
$return = new moodle_url('/badges/criteria.php', array('id' => $badgeid));
$badge = new badge($badgeid);
$context = $badge->get_context();
$navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
// Make sure that no actions available for locked or active badges.
if ($badge->is_active() || $badge->is_locked()) {
    redirect($return);
}
if ($badge->type == BADGE_TYPE_COURSE) {
    require_login($badge->courseid);
    $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type, 'id' => $badge->courseid));
}
$PAGE->set_context($context);
$PAGE->set_url('/badges/criteria_action.php');
$PAGE->set_pagelayout('standard');
$PAGE->set_heading($badge->name);
$PAGE->set_title($badge->name);
navigation_node::override_active_url($navurl);
if ($delete && has_capability('moodle/badges:configurecriteria', $context)) {
    if (!$confirm) {
        $optionsyes = array('confirm' => 1, 'sesskey' => sesskey(), 'badgeid' => $badgeid, 'delete' => true, 'type' => $type);
Exemplo n.º 3
0
    } 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)) {
        $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');
        }
        $returnurl->param('msg', $msg);
        redirect($returnurl);
    }
}
echo $OUTPUT->header();
if ($type == BADGE_TYPE_SITE) {
    echo $OUTPUT->heading_with_help($PAGE->heading, 'sitebadges', 'badges');
} else {
Exemplo n.º 4
0
 public function print_criteria_actions(badge $badge)
 {
     $output = '';
     if (!$badge->is_active() && !$badge->is_locked()) {
         $accepted = $badge->get_accepted_criteria();
         $potential = array_diff($accepted, array_keys($badge->criteria));
         if (!empty($potential)) {
             foreach ($potential as $p) {
                 if ($p != 0) {
                     $select[$p] = get_string('criteria_' . $p, 'badges');
                 }
             }
             $output .= $this->output->single_select(new moodle_url('/badges/criteria_settings.php', array('badgeid' => $badge->id, 'add' => true)), 'type', $select, '', array('' => 'choosedots'), null, array('label' => get_string('addbadgecriteria', 'badges')));
         } else {
             $output .= $this->output->box(get_string('nothingtoadd', 'badges'), 'clearfix');
         }
     }
     return $output;
 }