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


PHP grade_item::delete方法代码示例

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


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

示例1: grade_uninstalled_module

/**
 * Does gradebook cleanup when a module is uninstalled
 * Deletes all associated grade items
 *
 * @param string $modname The grade item module name to remove. For example 'forum'
 */
function grade_uninstalled_module($modname)
{
    global $CFG, $DB;
    $sql = "SELECT *\n              FROM {grade_items}\n             WHERE itemtype='mod' AND itemmodule=?";
    // go all items for this module and delete them including the grades
    $rs = $DB->get_recordset_sql($sql, array($modname));
    foreach ($rs as $item) {
        $grade_item = new grade_item($item, false);
        $grade_item->delete('moduninstall');
    }
    $rs->close();
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:18,代码来源:gradelib.php

示例2: grade_import_commit

/**
 * given an import code, commits all entries in buffer tables
 * (grade_import_value and grade_import_newitem)
 * If this function is called, we assume that all data collected
 * up to this point is fine and we can go ahead and commit
 * @param int courseid - id of the course
 * @param string importcode - import batch identifier
 * @param feedback print feedback and continue button
 * @return bool success
 */
function grade_import_commit($courseid, $importcode, $importfeedback = true, $verbose = true)
{
    global $CFG, $USER, $DB;
    $commitstart = time();
    // start time in case we need to roll back
    $newitemids = array();
    // array to hold new grade_item ids from grade_import_newitem table, mapping array
    /// first select distinct new grade_items with this batch
    $params = array($importcode, $USER->id);
    if ($newitems = $DB->get_records_sql("SELECT *\n                                           FROM {grade_import_newitem}\n                                          WHERE importcode = ? AND importer=?", $params)) {
        // instances of the new grade_items created, cached
        // in case grade_update fails, so that we can remove them
        $instances = array();
        $failed = false;
        foreach ($newitems as $newitem) {
            // get all grades with this item
            if ($grades = $DB->get_records('grade_import_values', array('newgradeitem' => $newitem->id))) {
                /// create a new grade item for this - must use false as second param!
                /// TODO: we need some bounds here too
                $gradeitem = new grade_item(array('courseid' => $courseid, 'itemtype' => 'manual', 'itemname' => $newitem->itemname), false);
                $gradeitem->insert('import');
                $instances[] = $gradeitem;
                // insert each individual grade to this new grade item
                foreach ($grades as $grade) {
                    if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback, FORMAT_MOODLE)) {
                        $failed = true;
                        break 2;
                    }
                }
            }
        }
        if ($failed) {
            foreach ($instances as $instance) {
                $gradeitem->delete('import');
            }
            import_cleanup($importcode);
            return false;
        }
    }
    /// then find all existing items
    if ($gradeitems = $DB->get_records_sql("SELECT DISTINCT (itemid)\n                                             FROM {grade_import_values}\n                                            WHERE importcode = ? AND importer=? AND itemid > 0", array($importcode, $USER->id))) {
        $modifieditems = array();
        foreach ($gradeitems as $itemid => $notused) {
            if (!($gradeitem = new grade_item(array('id' => $itemid)))) {
                // not supposed to happen, but just in case
                import_cleanup($importcode);
                return false;
            }
            // get all grades with this item
            if ($grades = $DB->get_records('grade_import_values', array('itemid' => $itemid))) {
                // make the grades array for update_grade
                foreach ($grades as $grade) {
                    if (!$importfeedback) {
                        $grade->feedback = false;
                        // ignore it
                    }
                    if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback)) {
                        $failed = 1;
                        break 2;
                    }
                }
                //$itemdetails -> idnumber = $gradeitem->idnumber;
                $modifieditems[] = $itemid;
            }
            if (!empty($failed)) {
                import_cleanup($importcode);
                return false;
            }
        }
    }
    if ($verbose) {
        notify(get_string('importsuccess', 'grades'), 'notifysuccess');
        $unenrolledusers = get_unenrolled_users_in_import($importcode, $courseid);
        if ($unenrolledusers) {
            $list = "<ul>\n";
            foreach ($unenrolledusers as $u) {
                $u->fullname = fullname($u);
                $list .= '<li>' . get_string('usergrade', 'grades', $u) . '</li>';
            }
            $list .= "</ul>\n";
            notify(get_string('unenrolledusersinimport', 'grades', $list), 'notifysuccess');
        }
        print_continue($CFG->wwwroot . '/grade/index.php?id=' . $courseid);
    }
    // clean up
    import_cleanup($importcode);
    return true;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:98,代码来源:lib.php

示例3: grade_uninstalled_module

/**
 * Does gradebook cleanup when module uninstalled.
 */
function grade_uninstalled_module($modname)
{
    global $CFG;
    $sql = "SELECT *\n              FROM {$CFG->prefix}grade_items\n             WHERE itemtype='mod' AND itemmodule='{$modname}'";
    // go all items for this module and delete them including the grades
    if ($rs = get_recordset_sql($sql)) {
        while ($item = rs_fetch_next_record($rs)) {
            $grade_item = new grade_item($item, false);
            $grade_item->delete('moduninstall');
        }
        rs_close($rs);
    }
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:16,代码来源:gradelib.php


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