/** * * @param object $course * @param object $user * @param object $mod TODO this is not used in this function, refactor * @param object $forum * @return object A standard object with 2 variables: info (number of posts for this user) and time (last modified) */ function forum_user_outline($course, $user, $mod, $forum) { global $CFG; 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 = false; } else { $grade = reset($grades->items[0]->grades); } $count = forum_count_user_posts($forum->id, $user->id); if ($count && $count->postcount > 0) { $result = new stdClass(); $result->info = get_string("numposts", "forum", $count->postcount); $result->time = $count->lastpost; if ($grade) { $result->info .= ', ' . get_string('grade') . ': ' . $grade->str_long_grade; } return $result; } else if ($grade) { $result = new stdClass(); $result->info = get_string('grade') . ': ' . $grade->str_long_grade; $result->time = $grade->dategraded; return $result; } return NULL; }
/** * * @param object $course * @param object $user * @param object $mod TODO this is not used in this function, refactor * @param object $forum * @return object A standard object with 2 variables: info (number of posts for this user) and time (last modified) */ function forum_user_outline($course, $user, $mod, $forum) { global $CFG; 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 = false; } else { $grade = reset($grades->items[0]->grades); } $count = forum_count_user_posts($forum->id, $user->id); if ($count && $count->postcount > 0) { $result = new stdClass(); $result->info = get_string("numposts", "forum", $count->postcount); $result->time = $count->lastpost; if ($grade) { $result->info .= ', ' . get_string('grade') . ': ' . $grade->str_long_grade; } return $result; } else if ($grade) { $result = new stdClass(); $result->info = get_string('grade') . ': ' . $grade->str_long_grade; //datesubmitted == time created. dategraded == time modified or time overridden //if grade was last modified by the user themselves use date graded. Otherwise use date submitted //TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704 if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) { $result->time = $grade->dategraded; } else { $result->time = $grade->datesubmitted; } return $result; } return NULL; }
/** * * @param object $course * @param object $user * @param object $mod TODO this is not used in this function, refactor * @param object $forum * @return object A standard object with 2 variables: info (number of posts for this user) and time (last modified) */ function forum_user_outline($course, $user, $mod, $forum) { if ($count = forum_count_user_posts($forum->id, $user->id)) { if ($count->postcount > 0) { $result = new object(); $result->info = get_string("numposts", "forum", $count->postcount); $result->time = $count->lastpost; return $result; } } return NULL; }