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


PHP glossary_update_grades函数代码示例

本文整理汇总了PHP中glossary_update_grades函数的典型用法代码示例。如果您正苦于以下问题:PHP glossary_update_grades函数的具体用法?PHP glossary_update_grades怎么用?PHP glossary_update_grades使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了glossary_update_grades函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: xmldb_glossary_upgrade

function xmldb_glossary_upgrade($oldversion = 0)
{
    global $CFG, $THEME, $db;
    $result = true;
    /// And upgrade begins here. For each one, you'll need one
    /// block of code similar to the next one. Please, delete
    /// this comment lines once this file start handling proper
    /// upgrade code.
    /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
    ///     $result = result of "/lib/ddllib.php" function calls
    /// }
    if ($result && $oldversion < 2006111400) {
        /// MDL-10475, set override for legacy:student before dropping studentcanpost
        /// if the glossary disables student postings
        if ($glossaries = get_records('glossary', 'studentcanpost', '0')) {
            foreach ($glossaries as $glossary) {
                if ($cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
                    // add student override in this instance
                    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                    // find all roles with legacy:student
                    if ($studentroles = get_roles_with_capability('moodle/legacy:student', CAP_ALLOW)) {
                        foreach ($studentroles as $studentrole) {
                            assign_capability('mod/glossary:write', CAP_PREVENT, $studentrole->id, $context->id);
                        }
                    }
                }
            }
        }
        /// Define field studentcanpost to be dropped from glossary
        $table = new XMLDBTable('glossary');
        $field = new XMLDBField('studentcanpost');
        /// Launch drop field studentcanpost
        $result = $result && drop_field($table, $field);
    }
    if ($result && $oldversion < 2007072200) {
        require_once $CFG->dirroot . '/mod/glossary/lib.php';
        // too much debug output
        $db->debug = false;
        glossary_update_grades();
        $db->debug = true;
    }
    //===== 1.9.0 upgrade line ======//
    return $result;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:44,代码来源:upgrade.php

示例2: glossary_upgrade_grades

/**
 * Update all grades in gradebook.
 *
 * @global object
 */
function glossary_upgrade_grades() {
    global $DB;

    $sql = "SELECT COUNT('x')
              FROM {glossary} g, {course_modules} cm, {modules} m
             WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
    $count = $DB->count_records_sql($sql);

    $sql = "SELECT g.*, cm.idnumber AS cmidnumber, g.course AS courseid
              FROM {glossary} g, {course_modules} cm, {modules} m
             WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
    $rs = $DB->get_recordset_sql($sql);
    if ($rs->valid()) {
        $pbar = new progress_bar('glossaryupgradegrades', 500, true);
        $i=0;
        foreach ($rs as $glossary) {
            $i++;
            upgrade_set_timeout(60*5); // set up timeout, may also abort execution
            glossary_update_grades($glossary, 0, false);
            $pbar->update($i, $count, "Updating Glossary grades ($i/$count).");
        }
    }
    $rs->close();
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:29,代码来源:lib.php

示例3: array

            if ($rating == -999) {
                $DB->delete_records('glossary_ratings', array('userid' => $oldrating->userid, 'entryid' => $oldrating->entryid));
                glossary_update_grades($glossary, $entry->userid);
            } else {
                if ($rating != $oldrating->rating) {
                    $oldrating->rating = $rating;
                    $oldrating->time = time();
                    if (!$DB->update_record("glossary_ratings", $oldrating)) {
                        print_error('cannotinsertrate', 'error', '', (object) array('id' => $entry->id, 'rating' => $rating));
                    }
                    glossary_update_grades($glossary, $entry->userid);
                }
            }
        } else {
            if ($rating >= 0) {
                $newrating = new object();
                $newrating->userid = $USER->id;
                $newrating->time = time();
                $newrating->entryid = $entry->id;
                $newrating->rating = $rating;
                if (!$DB->insert_record("glossary_ratings", $newrating)) {
                    print_error('cannotinsertrate', 'error', '', (object) array('id' => $entry->id, 'rating' => $rating));
                }
                glossary_update_grades($glossary, $entry->userid);
            }
        }
    }
    redirect($returnurl, get_string("ratingssaved", "glossary"));
} else {
    print_error('invalidaccess');
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:rate.php

示例4: test_course_check_module_updates_since

 public function test_course_check_module_updates_since()
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . '/mod/glossary/lib.php';
     require_once $CFG->dirroot . '/rating/lib.php';
     require_once $CFG->dirroot . '/comment/lib.php';
     $this->resetAfterTest(true);
     $CFG->enablecompletion = true;
     $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
     $glossary = $this->getDataGenerator()->create_module('glossary', array('course' => $course->id, 'completion' => COMPLETION_TRACKING_AUTOMATIC, 'completionview' => 1, 'allowcomments' => 1, 'assessed' => RATING_AGGREGATE_AVERAGE, 'scale' => 100));
     $glossarygenerator = $this->getDataGenerator()->get_plugin_generator('mod_glossary');
     $context = context_module::instance($glossary->cmid);
     $modinfo = get_fast_modinfo($course);
     $cm = $modinfo->get_cm($glossary->cmid);
     $user = $this->getDataGenerator()->create_user();
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id);
     $from = time();
     $teacher = $this->getDataGenerator()->create_user();
     $teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
     $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
     assign_capability('mod/glossary:viewanyrating', CAP_ALLOW, $studentrole->id, $context->id, true);
     // Check nothing changed right now.
     $updates = course_check_module_updates_since($cm, $from);
     $this->assertFalse($updates->configuration->updated);
     $this->assertFalse($updates->completion->updated);
     $this->assertFalse($updates->gradeitems->updated);
     $this->assertFalse($updates->comments->updated);
     $this->assertFalse($updates->ratings->updated);
     $this->assertFalse($updates->introfiles->updated);
     $this->assertFalse($updates->outcomes->updated);
     $this->waitForSecond();
     // Do some changes.
     $this->setUser($user);
     $entry = $glossarygenerator->create_content($glossary);
     $this->setUser($teacher);
     // Name.
     set_coursemodule_name($glossary->cmid, 'New name');
     // Add some ratings.
     $rm = new rating_manager();
     $result = $rm->add_rating($cm, $context, 'mod_glossary', 'entry', $entry->id, 100, 50, $user->id, RATING_AGGREGATE_AVERAGE);
     // Change grades.
     $glossary->cmidnumber = $glossary->cmid;
     glossary_update_grades($glossary, $user->id);
     $this->setUser($user);
     // Completion status.
     glossary_view($glossary, $course, $cm, $context, 'letter');
     // Add one comment.
     $args = new stdClass();
     $args->context = $context;
     $args->course = $course;
     $args->cm = $cm;
     $args->area = 'glossary_entry';
     $args->itemid = $entry->id;
     $args->client_id = 1;
     $args->component = 'mod_glossary';
     $manager = new comment($args);
     $manager->add('blah blah blah');
     // Check upgrade status.
     $updates = course_check_module_updates_since($cm, $from);
     $this->assertTrue($updates->configuration->updated);
     $this->assertTrue($updates->completion->updated);
     $this->assertTrue($updates->gradeitems->updated);
     $this->assertTrue($updates->comments->updated);
     $this->assertTrue($updates->ratings->updated);
     $this->assertFalse($updates->introfiles->updated);
     $this->assertFalse($updates->outcomes->updated);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:68,代码来源:courselib_test.php

示例5: glossary_update_grades

/**
 * Update grades by firing grade_updated event
 *
 * @param object $glossary null means all glossaries (with extra cmidnumber property)
 * @param int $userid specific user only, 0 mean all
 */
function glossary_update_grades($glossary = null, $userid = 0, $nullifnone = true)
{
    global $CFG;
    require_once $CFG->libdir . '/gradelib.php';
    if ($glossary != null) {
        if ($grades = glossary_get_user_grades($glossary, $userid)) {
            glossary_grade_item_update($glossary, $grades);
        } else {
            if ($userid and $nullifnone) {
                $grade = new object();
                $grade->userid = $userid;
                $grade->rawgrade = NULL;
                glossary_grade_item_update($glossary, $grade);
            } else {
                glossary_grade_item_update($glossary);
            }
        }
    } else {
        $sql = "SELECT g.*, cm.idnumber as cmidnumber\n                  FROM {$CFG->prefix}glossary g, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m\n                 WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
        if ($rs = get_recordset_sql($sql)) {
            while ($glossary = rs_fetch_next_record($rs)) {
                if ($glossary->assessed) {
                    glossary_update_grades($glossary, 0, false);
                } else {
                    glossary_grade_item_update($glossary);
                }
            }
            rs_close($rs);
        }
    }
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:37,代码来源:lib.php


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