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


PHP glossary_reset_gradebook函数代码示例

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


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

示例1: glossary_reset_userdata

/**
 * Actual implementation of the rest coures functionality, delete all the
 * glossary responses for course $data->courseid.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function glossary_reset_userdata($data)
{
    global $CFG;
    require_once $CFG->libdir . '/filelib.php';
    $componentstr = get_string('modulenameplural', 'glossary');
    $status = array();
    $allentriessql = "SELECT e.id\n                        FROM {$CFG->prefix}glossary_entries e\n                             INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id\n                       WHERE g.course = {$data->courseid}";
    $allglossariessql = "SELECT g.id\n                            FROM {$CFG->prefix}glossary g\n                           WHERE g.course={$data->courseid}";
    // delete entries if requested
    if (!empty($data->reset_glossary_all) or !empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types)) {
        delete_records_select('glossary_ratings', "entryid IN ({$allentriessql})");
        delete_records_select('glossary_comments', "entryid IN ({$allentriessql})");
        delete_records_select('glossary_entries', "glossaryid IN ({$allglossariessql})");
        if ($glossaries = get_records_sql($allglossariessql)) {
            foreach ($glossaries as $glossaryid => $unused) {
                fulldelete($CFG->dataroot . "/{$data->courseid}/moddata/glossary/{$glossaryid}");
            }
        }
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('resetglossariesall', 'glossary'), 'error' => false);
    } else {
        if (!empty($data->reset_glossary_types)) {
            $mainentriessql = "{$allentries} AND g.mainglossary=1";
            $secondaryentriessql = "{$allentries} AND g.mainglossary=0";
            $mainglossariessql = "{$allglossariessql} AND g.mainglossary=1";
            $secondaryglossariessql = "{$allglossariessql} AND g.mainglossary=0";
            if (in_array('main', $data->reset_glossary_types)) {
                delete_records_select('glossary_ratings', "entryid IN ({$mainentriessql})");
                delete_records_select('glossary_comments', "entryid IN ({$mainentriessql})");
                delete_records_select('glossary_entries', "glossaryid IN ({$mainglossariessql})");
                if ($glossaries = get_records_sql($mainglossariessql)) {
                    foreach ($glossaries as $glossaryid => $unused) {
                        fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$glossaryid}");
                    }
                }
                // remove all grades from gradebook
                if (empty($data->reset_gradebook_grades)) {
                    glossary_reset_gradebook($data->courseid, 'main');
                }
                $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary'), 'error' => false);
            } else {
                if (in_array('secondary', $data->reset_glossary_types)) {
                    delete_records_select('glossary_ratings', "entryid IN ({$secondaryentriessql})");
                    delete_records_select('glossary_comments', "entryid IN ({$secondaryentriessql})");
                    delete_records_select('glossary_entries', "glossaryid IN ({$secondaryglossariessql})");
                    // remove exported source flag from entries in main glossary
                    execute_sql("UPDATE {$CFG->prefix}glossary_entries\n                            SET sourceglossaryid=0\n                          WHERE glossaryid IN ({$mainglossariessql})", false);
                    if ($glossaries = get_records_sql($secondaryglossariessql)) {
                        foreach ($glossaries as $glossaryid => $unused) {
                            fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$glossaryid}");
                        }
                    }
                    // remove all grades from gradebook
                    if (empty($data->reset_gradebook_grades)) {
                        glossary_reset_gradebook($data->courseid, 'secondary');
                    }
                    $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary') . ': ' . get_string('secondaryglossary', 'glossary'), 'error' => false);
                }
            }
        }
    }
    // remove entries by users not enrolled into course
    if (!empty($data->reset_glossary_notenrolled)) {
        $entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted\n                         FROM {$CFG->prefix}glossary_entries e\n                              INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id\n                              LEFT OUTER JOIN {$CFG->prefix}user u ON e.userid = u.id\n                        WHERE g.course = {$data->courseid} AND e.userid > 0";
        $course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
        $notenrolled = array();
        if ($rs = get_recordset_sql($entriessql)) {
            while ($entry = rs_fetch_next_record($rs)) {
                if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted or !has_capability('moodle/course:view', $course_context, $entry->userid)) {
                    delete_records('glossary_ratings', 'entryid', $entry->id);
                    delete_records('glossary_comments', 'entryid', $entry->id);
                    delete_records('glossary_entries', 'id', $entry->id);
                    fulldelete("{$CFG->dataroot}/{$data->courseid}/moddata/glossary/{$entry->glossaryid}");
                    $notenrolled[$entry->userid] = true;
                }
            }
            rs_close($rs);
            $status[] = array('component' => $componentstr, 'item' => get_string('deletenotenrolled', 'glossary'), 'error' => false);
        }
    }
    // remove all ratings
    if (!empty($data->reset_glossary_ratings)) {
        delete_records_select('glossary_ratings', "entryid IN ({$allentriessql})");
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('deleteallratings'), 'error' => false);
    }
    // remove all comments
    if (!empty($data->reset_glossary_comments)) {
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:101,代码来源:lib.php

示例2: glossary_reset_userdata

/**
 * Actual implementation of the reset course functionality, delete all the
 * glossary responses for course $data->courseid.
 *
 * @global object
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function glossary_reset_userdata($data) {
    global $CFG, $DB;
    require_once($CFG->dirroot.'/rating/lib.php');

    $componentstr = get_string('modulenameplural', 'glossary');
    $status = array();

    $allentriessql = "SELECT e.id
                        FROM {glossary_entries} e
                             JOIN {glossary} g ON e.glossaryid = g.id
                       WHERE g.course = ?";

    $allglossariessql = "SELECT g.id
                           FROM {glossary} g
                          WHERE g.course = ?";

    $params = array($data->courseid);

    $fs = get_file_storage();

    $rm = new rating_manager();
    $ratingdeloptions = new stdClass;
    $ratingdeloptions->component = 'mod_glossary';
    $ratingdeloptions->ratingarea = 'entry';

    // delete entries if requested
    if (!empty($data->reset_glossary_all)
         or (!empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types))) {

        $params[] = 'glossary_entry';
        $DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea=?", $params);
        $DB->delete_records_select('glossary_alias',    "entryid IN ($allentriessql)", $params);
        $DB->delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)", $params);

        // now get rid of all attachments
        if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
            foreach ($glossaries as $glossaryid=>$unused) {
                if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
                    continue;
                }
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                $fs->delete_area_files($context->id, 'mod_glossary', 'attachment');

                //delete ratings
                $ratingdeloptions->contextid = $context->id;
                $rm->delete_ratings($ratingdeloptions);
            }
        }

        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }

        $status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossariesall', 'glossary'), 'error'=>false);

    } else if (!empty($data->reset_glossary_types)) {
        $mainentriessql         = "$allentries AND g.mainglossary=1";
        $secondaryentriessql    = "$allentries AND g.mainglossary=0";

        $mainglossariessql      = "$allglossariessql AND g.mainglossary=1";
        $secondaryglossariessql = "$allglossariessql AND g.mainglossary=0";

        if (in_array('main', $data->reset_glossary_types)) {
            $params[] = 'glossary_entry';
            $DB->delete_records_select('comments', "itemid IN ($mainentriessql) AND commentarea=?", $params);
            $DB->delete_records_select('glossary_entries', "glossaryid IN ($mainglossariessql)", $params);

            if ($glossaries = $DB->get_records_sql($mainglossariessql, $params)) {
                foreach ($glossaries as $glossaryid=>$unused) {
                    if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
                        continue;
                    }
                    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                    $fs->delete_area_files($context->id, 'mod_glossary', 'attachment');

                    //delete ratings
                    $ratingdeloptions->contextid = $context->id;
                    $rm->delete_ratings($ratingdeloptions);
                }
            }

            // remove all grades from gradebook
            if (empty($data->reset_gradebook_grades)) {
                glossary_reset_gradebook($data->courseid, 'main');
            }

            $status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossaries', 'glossary'), 'error'=>false);

        } else if (in_array('secondary', $data->reset_glossary_types)) {
            $params[] = 'glossary_entry';
            $DB->delete_records_select('comments', "itemid IN ($secondaryentriessql) AND commentarea=?", $params);
//.........这里部分代码省略.........
开发者ID:rolandovanegas,项目名称:moodle,代码行数:101,代码来源:lib.php

示例3: glossary_reset_userdata

/**
 * Actual implementation of the rest coures functionality, delete all the
 * glossary responses for course $data->courseid.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function glossary_reset_userdata($data)
{
    global $CFG, $DB;
    $componentstr = get_string('modulenameplural', 'glossary');
    $status = array();
    $allentriessql = "SELECT e.id\n                        FROM {glossary_entries} e\n                             JOIN {glossary} g ON e.glossaryid = g.id\n                       WHERE g.course = ?";
    $allglossariessql = "SELECT g.id\n                           FROM {glossary} g\n                          WHERE g.course = ?";
    $params = array($data->courseid);
    $fs = get_file_storage();
    // delete entries if requested
    if (!empty($data->reset_glossary_all) or !empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types)) {
        $DB->delete_records_select('glossary_ratings', "entryid IN ({$allentriessql})", $params);
        $DB->delete_records_select('glossary_comments', "entryid IN ({$allentriessql})", $params);
        $DB->delete_records_select('glossary_entries', "glossaryid IN ({$allglossariessql})", $params);
        // now get rid of all attachments
        if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
            foreach ($glossaries as $glossaryid => $unused) {
                if (!($cm = get_coursemodule_from_instance('glossary', $glossaryid))) {
                    continue;
                }
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                $fs->delete_area_files($context->id, 'glossary_attachment');
            }
        }
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            glossary_reset_gradebook($data->courseid);
        }
        $status[] = array('component' => $componentstr, 'item' => get_string('resetglossariesall', 'glossary'), 'error' => false);
    } else {
        if (!empty($data->reset_glossary_types)) {
            $mainentriessql = "{$allentries} AND g.mainglossary=1";
            $secondaryentriessql = "{$allentries} AND g.mainglossary=0";
            $mainglossariessql = "{$allglossariessql} AND g.mainglossary=1";
            $secondaryglossariessql = "{$allglossariessql} AND g.mainglossary=0";
            if (in_array('main', $data->reset_glossary_types)) {
                $DB->delete_records_select('glossary_ratings', "entryid IN ({$mainentriessql})", $params);
                $DB->delete_records_select('glossary_comments', "entryid IN ({$mainentriessql})", $params);
                $DB->delete_records_select('glossary_entries', "glossaryid IN ({$mainglossariessql})", $params);
                if ($glossaries = $DB->get_records_sql($mainglossariessql, $params)) {
                    foreach ($glossaries as $glossaryid => $unused) {
                        if (!($cm = get_coursemodule_from_instance('glossary', $glossaryid))) {
                            continue;
                        }
                        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                        $fs->delete_area_files($context->id, 'glossary_attachment');
                    }
                }
                // remove all grades from gradebook
                if (empty($data->reset_gradebook_grades)) {
                    glossary_reset_gradebook($data->courseid, 'main');
                }
                $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary'), 'error' => false);
            } else {
                if (in_array('secondary', $data->reset_glossary_types)) {
                    $DB->delete_records_select('glossary_ratings', "entryid IN ({$secondaryentriessql})", $params);
                    $DB->delete_records_select('glossary_comments', "entryid IN ({$secondaryentriessql})", $params);
                    $DB->delete_records_select('glossary_entries', "glossaryid IN ({$secondaryglossariessql})", $params);
                    // remove exported source flag from entries in main glossary
                    $DB->execute("UPDATE {glossary_entries\n                             SET sourceglossaryid=0\n                           WHERE glossaryid IN ({$mainglossariessql})", $params);
                    if ($glossaries = $DB->get_records_sql($secondaryglossariessql, $params)) {
                        foreach ($glossaries as $glossaryid => $unused) {
                            if (!($cm = get_coursemodule_from_instance('glossary', $glossaryid))) {
                                continue;
                            }
                            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                            $fs->delete_area_files($context->id, 'glossary_attachment');
                        }
                    }
                    // remove all grades from gradebook
                    if (empty($data->reset_gradebook_grades)) {
                        glossary_reset_gradebook($data->courseid, 'secondary');
                    }
                    $status[] = array('component' => $componentstr, 'item' => get_string('resetglossaries', 'glossary') . ': ' . get_string('secondaryglossary', 'glossary'), 'error' => false);
                }
            }
        }
    }
    // remove entries by users not enrolled into course
    if (!empty($data->reset_glossary_notenrolled)) {
        $entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted\n                         FROM {glossary_entries} e\n                              JOIN {glossary} g ON e.glossaryid = g.id\n                              LEFT JOIN {user} u ON e.userid = u.id\n                        WHERE g.course = ? AND e.userid > 0";
        $course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
        $notenrolled = array();
        if ($rs = $DB->get_recordset_sql($entriessql, $params)) {
            foreach ($rs as $entry) {
                if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted or !has_capability('moodle/course:view', $course_context, $entry->userid)) {
                    $DB->delete_records('glossary_ratings', array('entryid' => $entry->id));
                    $DB->delete_records('glossary_comments', array('entryid' => $entry->id));
                    $DB->delete_records('glossary_entries', array('id' => $entry->id));
                    if ($cm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
                        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                        $fs->delete_area_files($context->id, 'glossary_attachment', $entry->id);
                    }
                }
//.........这里部分代码省略.........
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:lib.php


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