当前位置: 首页>>代码示例>>PHP>>正文


PHP badge::review_all_criteria方法代码示例

本文整理汇总了PHP中badge::review_all_criteria方法的典型用法代码示例。如果您正苦于以下问题:PHP badge::review_all_criteria方法的具体用法?PHP badge::review_all_criteria怎么用?PHP badge::review_all_criteria使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在badge的用法示例。


在下文中一共展示了badge::review_all_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).');
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:40,代码来源:cron.php

示例2: COUNT

 $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($badge->name);
 echo $OUTPUT->header();
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:action.php

示例3: test_badges_observer_profile_criteria_review

 /**
  * Test badges observer when user_updated event is fired.
  */
 public function test_badges_observer_profile_criteria_review()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/user/profile/lib.php';
     // Add a custom field of textarea type.
     $customprofileid = $DB->insert_record('user_info_field', array('shortname' => 'newfield', 'name' => 'Description of new field', 'categoryid' => 1, 'datatype' => 'textarea'));
     $this->preventResetByRollback();
     // Messaging is not compatible with transactions.
     $badge = new badge($this->coursebadge);
     $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id));
     $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ANY));
     $criteria_overall1 = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_PROFILE, 'badgeid' => $badge->id));
     $criteria_overall1->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ALL, 'field_address' => 'address', 'field_aim' => 'aim', 'field_' . $customprofileid => $customprofileid));
     // Assert the badge will not be issued to the user as is.
     $badge = new badge($this->coursebadge);
     $badge->review_all_criteria();
     $this->assertFalse($badge->is_issued($this->user->id));
     // Set the required fields and make sure the badge got issued.
     $this->user->address = 'Test address';
     $this->user->aim = '999999999';
     $sink = $this->redirectEmails();
     profile_save_data((object) array('id' => $this->user->id, 'profile_field_newfield' => 'X'));
     user_update_user($this->user, false);
     $this->assertCount(1, $sink->get_messages());
     $sink->close();
     // Check if badge is awarded.
     $this->assertDebuggingCalled('Error baking badge image!');
     $this->assertTrue($badge->is_issued($this->user->id));
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:32,代码来源:badgeslib_test.php


注:本文中的badge::review_all_criteria方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。