本文整理汇总了PHP中badge::has_criteria方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::has_criteria方法的具体用法?PHP badge::has_criteria怎么用?PHP badge::has_criteria使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类badge
的用法示例。
在下文中一共展示了badge::has_criteria方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: badge_review_cron
/**
* Reviews criteria and awards badges
*
* First find all badges that can be earned, then reviews each badge.
* (Not sure how efficient this is timewise).
*/
function badge_review_cron()
{
global $DB, $CFG;
$total = 0;
$courseparams = array();
if (empty($CFG->badges_allowcoursebadges)) {
$coursesql = '';
} else {
$coursesql = ' OR EXISTS (SELECT id FROM {course} WHERE visible = :visible AND startdate < :current) ';
$courseparams = array('visible' => true, 'current' => time());
}
$sql = 'SELECT id
FROM {badge}
WHERE (status = :active OR status = :activelocked)
AND (type = :site ' . $coursesql . ')';
$badgeparams = array('active' => BADGE_STATUS_ACTIVE, 'activelocked' => BADGE_STATUS_ACTIVE_LOCKED, 'site' => BADGE_TYPE_SITE);
$params = array_merge($badgeparams, $courseparams);
$badges = $DB->get_fieldset_sql($sql, $params);
mtrace('Started reviewing available badges.');
foreach ($badges as $bid) {
$badge = new badge($bid);
if ($badge->has_criteria()) {
if (debugging()) {
mtrace('Processing badge "' . $badge->name . '"...');
}
$issued = $badge->review_all_criteria();
if (debugging()) {
mtrace('...badge was issued to ' . $issued . ' users.');
}
$total += $issued;
}
}
mtrace('Badges were issued ' . $total . ' time(s).');
}
示例2: print_badge_status_box
/**
* Prints badge status box.
* @return Either the status box html as a string or null
*/
public function print_badge_status_box(badge $badge)
{
if (has_capability('moodle/badges:configurecriteria', $badge->get_context())) {
$table = new html_table();
$table->attributes['class'] = 'boxaligncenter statustable';
if (!$badge->has_criteria()) {
$criteriaurl = new moodle_url('/badges/criteria.php', array('id' => $badge->id));
$status = get_string('nocriteria', 'badges');
if ($this->page->url != $criteriaurl) {
$action = $this->output->single_button($criteriaurl, get_string('addcriteria', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = '';
}
$row = array($status, $action);
} else {
$status = get_string('statusmessage_' . $badge->status, 'badges');
if ($badge->is_active()) {
$action = $this->output->single_button(new moodle_url('/badges/action.php', array('id' => $badge->id, 'lock' => 1, 'sesskey' => sesskey(), 'return' => $this->page->url->out_as_local_url(false))), get_string('deactivate', 'badges'), 'POST', array('class' => 'activatebadge'));
} else {
$action = $this->output->single_button(new moodle_url('/badges/action.php', array('id' => $badge->id, 'activate' => 1, 'sesskey' => sesskey(), 'return' => $this->page->url->out_as_local_url(false))), get_string('activate', 'badges'), 'POST', array('class' => 'activatebadge'));
}
$row = array($status . $this->output->help_icon('status', 'badges'), $action);
}
$table->data[] = $row;
$style = $badge->is_active() ? 'generalbox statusbox active' : 'generalbox statusbox inactive';
return $this->output->box(html_writer::table($table), $style);
}
return null;
}
示例3: badge
if ($delete && has_capability('moodle/badges:deletebadge', $PAGE->context)) {
$badge = new badge($delete);
if (!$confirm) {
echo $output->header();
echo $output->confirm(get_string('delconfirm', 'badges', $badge->name), new moodle_url($PAGE->url, array('delete' => $badge->id, 'confirm' => 1)), $returnurl);
echo $output->footer();
die;
} else {
require_sesskey();
$badge->delete();
redirect($returnurl);
}
}
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)) {