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


PHP forum_reset_gradebook函数代码示例

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


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

示例1: forum_reset_userdata


//.........这里部分代码省略.........
        $forumssql      = "$allforumssql $typesql";
        $forums = $forums = $DB->get_records_sql($forumssql, $params);
        $rm = new rating_manager();
        $ratingdeloptions = new stdClass;
        $ratingdeloptions->component = 'mod_forum';
        $ratingdeloptions->ratingarea = 'post';
    }

    if ($removeposts) {
        $discussionssql = "$alldiscussionssql $typesql";
        $postssql       = "$allpostssql $typesql";

        // now get rid of all attachments
        $fs = get_file_storage();
        if ($forums) {
            foreach ($forums as $forumid=>$unused) {
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
                    continue;
                }
                $context = context_module::instance($cm->id);
                $fs->delete_area_files($context->id, 'mod_forum', 'attachment');
                $fs->delete_area_files($context->id, 'mod_forum', 'post');

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

        // first delete all read flags
        $DB->delete_records_select('forum_read', "forumid IN ($forumssql)", $params);

        // remove tracking prefs
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($forumssql)", $params);

        // remove posts from queue
        $DB->delete_records_select('forum_queue', "discussionid IN ($discussionssql)", $params);

        // all posts - initial posts must be kept in single simple discussion forums
        $DB->delete_records_select('forum_posts', "discussion IN ($discussionssql) AND parent <> 0", $params); // first all children
        $DB->delete_records_select('forum_posts', "discussion IN ($discussionssql AND f.type <> 'single') AND parent = 0", $params); // now the initial posts for non single simple

        // finally all discussions except single simple forums
        $DB->delete_records_select('forum_discussions', "forum IN ($forumssql AND f.type <> 'single')", $params);

        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            if (empty($types)) {
                forum_reset_gradebook($data->courseid);
            } else {
                foreach ($types as $type) {
                    forum_reset_gradebook($data->courseid, $type);
                }
            }
        }

        $status[] = array('component'=>$componentstr, 'item'=>$typesstr, 'error'=>false);
    }

    // remove all ratings in this course's forums
    if (!empty($data->reset_forum_ratings)) {
        if ($forums) {
            foreach ($forums as $forumid=>$unused) {
                if (!$cm = get_coursemodule_from_instance('forum', $forumid)) {
                    continue;
                }
                $context = context_module::instance($cm->id);

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

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

    // remove all subscriptions unconditionally - even for users still enrolled in course
    if (!empty($data->reset_forum_subscriptions)) {
        $DB->delete_records_select('forum_subscriptions', "forum IN ($allforumssql)", $params);
        $status[] = array('component'=>$componentstr, 'item'=>get_string('resetsubscriptions','forum'), 'error'=>false);
    }

    // remove all tracking prefs unconditionally - even for users still enrolled in course
    if (!empty($data->reset_forum_track_prefs)) {
        $DB->delete_records_select('forum_track_prefs', "forumid IN ($allforumssql)", $params);
        $status[] = array('component'=>$componentstr, 'item'=>get_string('resettrackprefs','forum'), 'error'=>false);
    }

    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('forum', array('assesstimestart', 'assesstimefinish'), $data->timeshift, $data->courseid);
        $status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
    }

    return $status;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:lib.php

示例2: forum_reset_userdata

/**
 * This function is used by the reset_course_userdata function in moodlelib.
 * This function will remove all posts from the specified forum
 * and clean up any related data.
 * @param $data the data submitted from the reset course.
 * @return array status array
 */
function forum_reset_userdata($data)
{
    global $CFG;
    require_once $CFG->libdir . '/filelib.php';
    $componentstr = get_string('modulenameplural', 'forum');
    $status = array();
    $removeposts = false;
    if (!empty($data->reset_forum_all)) {
        $removeposts = true;
        $typesql = "";
        $typesstr = get_string('resetforumsall', 'forum');
        $types = array();
    } else {
        if (!empty($data->reset_forum_types)) {
            $removeposts = true;
            $typesql = "";
            $types = array();
            $forum_types_all = forum_get_forum_types_all();
            foreach ($data->reset_forum_types as $type) {
                if (!array_key_exists($type, $forum_types_all)) {
                    continue;
                }
                $typesql .= " AND f.type='{$type}'";
                $types[] = $forum_types_all[$type];
            }
            $typesstr = get_string('resetforums', 'forum') . ': ' . implode(', ', $types);
        }
    }
    $alldiscussionssql = "SELECT fd.id\n                            FROM {$CFG->prefix}forum_discussions fd, {$CFG->prefix}forum f\n                           WHERE f.course={$data->courseid} AND f.id=fd.forum";
    $allforumssql = "SELECT f.id\n                            FROM {$CFG->prefix}forum f\n                           WHERE f.course={$data->courseid}";
    $allpostssql = "SELECT fp.id\n                            FROM {$CFG->prefix}forum_posts fp, {$CFG->prefix}forum_discussions fd, {$CFG->prefix}forum f\n                           WHERE f.course={$data->courseid} AND f.id=fd.forum AND fd.id=fp.discussion";
    if ($removeposts) {
        $discussionssql = "{$alldiscussionssql} {$typesql}";
        $forumssql = "{$allforumssql} {$typesql}";
        $postssql = "{$allpostssql} {$typesql}";
        // first delete all read flags
        delete_records_select('forum_read', "forumid IN ({$forumssql})");
        // remove tracking prefs
        delete_records_select('forum_track_prefs', "forumid IN ({$forumssql})");
        // remove posts from queue
        delete_records_select('forum_queue', "discussionid IN ({$discussionssql})");
        // remove ratings
        delete_records_select('forum_ratings', "post IN ({$postssql})");
        // all posts
        delete_records_select('forum_posts', "discussion IN ({$discussionssql})");
        // finally all discussions
        delete_records_select('forum_discussions', "forum IN ({$forumssql})");
        // now get rid of all attachments
        if ($forums = get_records_sql($forumssql)) {
            foreach ($forums as $forumid => $unused) {
                fulldelete($CFG->dataroot . '/' . $data->courseid . '/moddata/forum/' . $forumid);
            }
        }
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            if (empty($types)) {
                forum_reset_gradebook($data->courseid);
            } else {
                foreach ($types as $type) {
                    forum_reset_gradebook($data->courseid, $type);
                }
            }
        }
        $status[] = array('component' => $componentstr, 'item' => $typesstr, 'error' => false);
    }
    // remove all ratings
    if (!empty($data->reset_forum_ratings)) {
        delete_records_select('forum_ratings', "post IN ({$allpostssql})");
        // remove all grades from gradebook
        if (empty($data->reset_gradebook_grades)) {
            forum_reset_gradebook($data->courseid);
        }
    }
    // remove all subscriptions unconditionally - even for users still enrolled in course
    if (!empty($data->reset_forum_subscriptions)) {
        delete_records_select('forum_subscriptions', "forum IN ({$allforumssql})");
        $status[] = array('component' => $componentstr, 'item' => get_string('resetsubscriptions', 'forum'), 'error' => false);
    }
    // remove all tracking prefs unconditionally - even for users still enrolled in course
    if (!empty($data->reset_forum_track_prefs)) {
        delete_records_select('forum_track_prefs', "forumid IN ({$allforumssql})");
        $status[] = array('component' => $componentstr, 'item' => get_string('resettrackprefs', 'forum'), 'error' => false);
    }
    /// updating dates - shift may be negative too
    if ($data->timeshift) {
        shift_course_mod_dates('forum', array('assesstimestart', 'assesstimefinish'), $data->timeshift, $data->courseid);
        $status[] = array('component' => $componentstr, 'item' => get_string('datechanged'), 'error' => false);
    }
    return $status;
}
开发者ID:r007,项目名称:PMoodle,代码行数:97,代码来源:lib.php


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