本文整理汇总了PHP中forum_get_user_involved_discussions函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_get_user_involved_discussions函数的具体用法?PHP forum_get_user_involved_discussions怎么用?PHP forum_get_user_involved_discussions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forum_get_user_involved_discussions函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forum_user_complete
/**
* @global object
* @global object
* @param object $coure
* @param object $user
* @param object $mod
* @param object $forum
*/
function forum_user_complete($course, $user, $mod, $forum) {
global $CFG,$USER, $OUTPUT;
require_once("$CFG->libdir/gradelib.php");
$grades = grade_get_grades($course->id, 'mod', 'forum', $forum->id, $user->id);
if (!empty($grades->items[0]->grades)) {
$grade = reset($grades->items[0]->grades);
echo $OUTPUT->container(get_string('grade').': '.$grade->str_long_grade);
if ($grade->str_feedback) {
echo $OUTPUT->container(get_string('feedback').': '.$grade->str_feedback);
}
}
if ($posts = forum_get_user_posts($forum->id, $user->id)) {
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
print_error('invalidcoursemodule');
}
$discussions = forum_get_user_involved_discussions($forum->id, $user->id);
foreach ($posts as $post) {
if (!isset($discussions[$post->discussion])) {
continue;
}
$discussion = $discussions[$post->discussion];
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
}
} else {
echo "<p>".get_string("noposts", "forum")."</p>";
}
}
示例2: forum_user_complete
/**
*
*/
function forum_user_complete($course, $user, $mod, $forum)
{
global $CFG, $USER;
require_once "{$CFG->libdir}/gradelib.php";
$grades = grade_get_grades($course->id, 'mod', 'forum', $forum->id, $user->id);
if (!empty($grades->items[0]->grades)) {
$grade = reset($grades->items[0]->grades);
echo '<p>' . get_string('grade') . ': ' . $grade->str_long_grade . '</p>';
if ($grade->str_feedback) {
echo '<p>' . get_string('feedback') . ': ' . $grade->str_feedback . '</p>';
}
}
if ($posts = forum_get_user_posts($forum->id, $user->id)) {
if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
error('Course Module ID was incorrect');
}
$discussions = forum_get_user_involved_discussions($forum->id, $user->id);
// preload all user ratings for these discussions - one query only and minimal memory
$cm->cache->ratings = array();
$cm->cache->myratings = array();
if ($postratings = forum_get_all_user_ratings($user->id, $discussions)) {
foreach ($postratings as $pr) {
if (!isset($cm->cache->ratings[$pr->postid])) {
$cm->cache->ratings[$pr->postid] = array();
}
$cm->cache->ratings[$pr->postid][$pr->id] = $pr->rating;
if ($pr->userid == $USER->id) {
$cm->cache->myratings[$pr->postid] = $pr->rating;
}
}
unset($postratings);
}
foreach ($posts as $post) {
if (!isset($discussions[$post->discussion])) {
continue;
}
$discussion = $discussions[$post->discussion];
$ratings = null;
if ($forum->assessed) {
if ($scale = make_grades_menu($forum->scale)) {
$ratings = new object();
$ratings->scale = $scale;
$ratings->assesstimestart = $forum->assesstimestart;
$ratings->assesstimefinish = $forum->assesstimefinish;
$ratings->allow = false;
}
}
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $ratings);
}
} else {
echo "<p>" . get_string("noposts", "forum") . "</p>";
}
}
示例3: forum_user_complete
/**
*
*/
function forum_user_complete($course, $user, $mod, $forum)
{
global $CFG;
if ($posts = forum_get_user_posts($forum->id, $user->id)) {
if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
error('Course Module ID was incorrect');
}
$discussions = forum_get_user_involved_discussions($forum->id, $user->id);
foreach ($posts as $post) {
if (!isset($discussions[$forum->discussion])) {
continue;
}
$discussion = $discussions[$forum->discussion];
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, false);
}
} else {
echo "<p>" . get_string("noposts", "forum") . "</p>";
}
}
示例4: forum_user_complete
/**
*
*/
function forum_user_complete($course, $user, $mod, $forum)
{
global $CFG, $USER;
if ($posts = forum_get_user_posts($forum->id, $user->id)) {
if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
print_error('invalidcoursemodule');
}
$discussions = forum_get_user_involved_discussions($forum->id, $user->id);
// preload all user ratings for these discussions - one query only and minimal memory
$cm->cache->ratings = array();
$cm->cache->myratings = array();
if ($postratings = forum_get_all_user_ratings($user->id, $discussions)) {
foreach ($postratings as $pr) {
if (!isset($cm->cache->ratings[$pr->postid])) {
$cm->cache->ratings[$pr->postid] = array();
}
$cm->cache->ratings[$pr->postid][$pr->id] = $pr->rating;
if ($pr->userid == $USER->id) {
$cm->cache->myratings[$pr->postid] = $pr->rating;
}
}
unset($postratings);
}
foreach ($posts as $post) {
if (!isset($discussions[$post->discussion])) {
continue;
}
$discussion = $discussions[$post->discussion];
$ratings = null;
if ($forum->assessed) {
if ($scale = make_grades_menu($forum->scale)) {
$ratings = new object();
$ratings->scale = $scale;
$ratings->assesstimestart = $forum->assesstimestart;
$ratings->assesstimefinish = $forum->assesstimefinish;
$ratings->allow = false;
}
}
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $ratings);
}
} else {
echo "<p>" . get_string("noposts", "forum") . "</p>";
}
}