mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-40843 recent_activity: corrections to grouping and user fields
This commit is contained in:
parent
d6f418cb77
commit
e19c086c36
@ -119,9 +119,6 @@ if ($param->modid === 'all') {
|
||||
$sections = array($sectionnum => $sections[$sectionnum]);
|
||||
}
|
||||
|
||||
|
||||
$modinfo->get_groups(); // load all my groups and cache it in modinfo
|
||||
|
||||
$activities = array();
|
||||
$index = 0;
|
||||
|
||||
|
@ -553,19 +553,14 @@ function assign_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($modinfo->get_groups())) {
|
||||
// Load all my groups and cache it in modinfo.
|
||||
$modinfo->groups = groups_get_user_groups($course->id);
|
||||
}
|
||||
|
||||
// This will be slow - show only users that share group with me in this cm.
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
continue;
|
||||
}
|
||||
$usersgroups = groups_get_all_groups($course->id, $submission->userid, $cm->groupingid);
|
||||
if (is_array($usersgroups)) {
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
$intersect = array_intersect($usersgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($usersgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
continue;
|
||||
}
|
||||
@ -665,17 +660,9 @@ function assign_get_recent_mod_activity(&$activities,
|
||||
$accessallgroups = has_capability('moodle/site:accessallgroups', $cmcontext);
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $cmcontext);
|
||||
|
||||
if (is_null($modinfo->get_groups())) {
|
||||
// Load all my groups and cache it in modinfo.
|
||||
$modinfo->groups = groups_get_user_groups($course->id);
|
||||
}
|
||||
|
||||
$showrecentsubmissions = get_config('assign', 'showrecentsubmissions');
|
||||
$show = array();
|
||||
$usersgroups = groups_get_all_groups($course->id, $USER->id, $cm->groupingid);
|
||||
if (is_array($usersgroups)) {
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
}
|
||||
foreach ($submissions as $submission) {
|
||||
if ($submission->userid == $USER->id) {
|
||||
$show[] = $submission;
|
||||
@ -696,11 +683,13 @@ function assign_get_recent_mod_activity(&$activities,
|
||||
}
|
||||
|
||||
// This will be slow - show only users that share group with me in this cm.
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
continue;
|
||||
}
|
||||
$usersgroups = groups_get_all_groups($course->id, $submission->userid, $cm->groupingid);
|
||||
if (is_array($usersgroups)) {
|
||||
$intersect = array_intersect($usersgroups, $modinfo->groups[$cm->id]);
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
$intersect = array_intersect($usersgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -289,12 +289,8 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
|
||||
}
|
||||
|
||||
// verify groups in separate mode
|
||||
if (!$mygroupids = $modinfo->groups[$cm->groupingid]) {
|
||||
if (!$mygroupids = $modinfo->get_groups($cm->groupingid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ function feedback_get_recent_mod_activity(&$activities, &$index,
|
||||
|
||||
$sqlargs = array();
|
||||
|
||||
$userfields = user_picture::fields('u', null, 'userid');
|
||||
$userfields = user_picture::fields('u', null, 'useridagain');
|
||||
$sql = " SELECT fk . * , fc . * , $userfields
|
||||
FROM {feedback_completed} fc
|
||||
JOIN {feedback} fk ON fk.id = fc.feedback
|
||||
@ -423,11 +423,6 @@ function feedback_get_recent_mod_activity(&$activities, &$index,
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $cm_context);
|
||||
$groupmode = groups_get_activity_groupmode($cm, $course);
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
// load all my groups and cache it in modinfo
|
||||
$modinfo->groups = groups_get_user_groups($course->id);
|
||||
}
|
||||
|
||||
$aname = format_string($cm->name, true);
|
||||
foreach ($feedbackitems as $feedbackitem) {
|
||||
if ($feedbackitem->userid != $USER->id) {
|
||||
@ -440,7 +435,7 @@ function feedback_get_recent_mod_activity(&$activities, &$index,
|
||||
continue;
|
||||
}
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
$intersect = array_intersect($usersgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($usersgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
continue;
|
||||
}
|
||||
@ -459,19 +454,7 @@ function feedback_get_recent_mod_activity(&$activities, &$index,
|
||||
$tmpactivity->content->feedbackid = $feedbackitem->id;
|
||||
$tmpactivity->content->feedbackuserid = $feedbackitem->userid;
|
||||
|
||||
$userfields = explode(',', user_picture::fields());
|
||||
$tmpactivity->user = new stdClass();
|
||||
foreach ($userfields as $userfield) {
|
||||
if ($userfield == 'id') {
|
||||
$tmpactivity->user->{$userfield} = $feedbackitem->userid; // aliased in SQL above
|
||||
} else {
|
||||
if (!empty($feedbackitem->{$userfield})) {
|
||||
$tmpactivity->user->{$userfield} = $feedbackitem->{$userfield};
|
||||
} else {
|
||||
$tmpactivity->user->{$userfield} = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
$tmpactivity->user = user_picture::unalias($feedbackitem, null, 'useridagain');
|
||||
$tmpactivity->user->fullname = fullname($feedbackitem, $viewfullnames);
|
||||
|
||||
$activities[$index++] = $tmpactivity;
|
||||
|
@ -335,13 +335,16 @@ function glossary_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
$cm = $modinfo->cms[$cmid];
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
if (!has_capability('mod/glossary:view', $context)) {
|
||||
if (!$cm->uservisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
$viewfullnames = has_capability('moodle/site:viewfullnames', $context);
|
||||
// Groups are not yet supported for glossary. See MDL-10728 .
|
||||
/*
|
||||
$accessallgroups = has_capability('moodle/site:accessallgroups', $context);
|
||||
$groupmode = groups_get_activity_groupmode($cm, $course);
|
||||
*/
|
||||
|
||||
$params['timestart'] = $timestart;
|
||||
|
||||
@ -361,17 +364,24 @@ function glossary_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
$groupjoin = '';
|
||||
}
|
||||
|
||||
$approvedselect = "";
|
||||
if (!has_capability('mod/glossary:approve', $context)) {
|
||||
$approvedselect = " AND ge.approved = 1 ";
|
||||
}
|
||||
|
||||
$params['timestart'] = $timestart;
|
||||
$params['glossaryid'] = $cm->instance;
|
||||
|
||||
$ufields = user_picture::fields('u', null, 'useridagain');
|
||||
$ufields = user_picture::fields('u', null, 'userid');
|
||||
$entries = $DB->get_records_sql("
|
||||
SELECT ge.id AS entryid, ge.*, $ufields
|
||||
SELECT ge.id AS entryid, ge.glossaryid, ge.concept, ge.definition, ge.approved,
|
||||
ge.timemodified, $ufields
|
||||
FROM {glossary_entries} ge
|
||||
JOIN {user} u ON u.id = ge.userid
|
||||
$groupjoin
|
||||
WHERE ge.timemodified > :timestart
|
||||
AND ge.glossaryid = :glossaryid
|
||||
$approvedselect
|
||||
$userselect
|
||||
$groupselect
|
||||
ORDER BY ge.timemodified ASC", $params);
|
||||
@ -381,6 +391,8 @@ function glossary_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
}
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
// Groups are not yet supported for glossary. See MDL-10728 .
|
||||
/*
|
||||
$usersgroups = null;
|
||||
if ($entry->userid != $USER->id) {
|
||||
if ($groupmode == SEPARATEGROUPS and !$accessallgroups) {
|
||||
@ -392,14 +404,15 @@ function glossary_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
$usersgroups = array();
|
||||
}
|
||||
}
|
||||
if (!array_intersect($usersgroups, $modinfo->get_groups($cm->id))) {
|
||||
if (!array_intersect($usersgroups, $modinfo->get_groups($cm->groupingid))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$tmpactivity = new stdClass();
|
||||
$tmpactivity->user = user_picture::unalias($entry, null, 'useridagain');
|
||||
$tmpactivity->user = user_picture::unalias($entry, null, 'userid');
|
||||
$tmpactivity->user->fullname = fullname($tmpactivity->user, $viewfullnames);
|
||||
$tmpactivity->type = 'glossary';
|
||||
$tmpactivity->cmid = $cm->id;
|
||||
@ -411,6 +424,7 @@ function glossary_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
$tmpactivity->content->entryid = $entry->entryid;
|
||||
$tmpactivity->content->concept = $entry->concept;
|
||||
$tmpactivity->content->definition = $entry->definition;
|
||||
$tmpactivity->content->approved = $entry->approved;
|
||||
|
||||
$activities[$index++] = $tmpactivity;
|
||||
}
|
||||
@ -440,14 +454,20 @@ function glossary_print_recent_mod_activity($activity, $courseid, $detail, $modn
|
||||
echo html_writer::start_tag('div', array('class'=>'glossary-activity-content'));
|
||||
echo html_writer::start_tag('div', array('class'=>'glossary-activity-entry'));
|
||||
|
||||
$urlparams = array('g' => $activity->glossaryid, 'mode' => 'entry', 'hook' => $activity->content->entryid);
|
||||
echo html_writer::tag('a', strip_tags($activity->content->concept),
|
||||
array('href' => new moodle_url('/mod/glossary/view.php', $urlparams)));
|
||||
if (isset($activity->content->approved) && !$activity->content->approved) {
|
||||
$urlparams = array('g' => $activity->glossaryid, 'mode' => 'approval', 'hook' => $activity->content->concept);
|
||||
$class = array('class' => 'dimmed_text');
|
||||
} else {
|
||||
$urlparams = array('g' => $activity->glossaryid, 'mode' => 'entry', 'hook' => $activity->content->entryid);
|
||||
$class = array();
|
||||
}
|
||||
echo html_writer::link(new moodle_url('/mod/glossary/view.php', $urlparams),
|
||||
strip_tags($activity->content->concept), $class);
|
||||
echo html_writer::end_tag('div');
|
||||
|
||||
$url = new moodle_url('/user/view.php', array('course'=>$courseid, 'id'=>$activity->user->id));
|
||||
$name = $activity->user->fullname;
|
||||
$link = html_writer::link($url, $name);
|
||||
$link = html_writer::link($url, $name, $class);
|
||||
|
||||
echo html_writer::start_tag('div', array('class'=>'user'));
|
||||
echo $link .' - '. userdate($activity->timestamp);
|
||||
|
@ -820,15 +820,10 @@ function quiz_refresh_events($courseid = 0) {
|
||||
*/
|
||||
function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
|
||||
$courseid, $cmid, $userid = 0, $groupid = 0) {
|
||||
global $CFG, $COURSE, $USER, $DB;
|
||||
global $CFG, $USER, $DB;
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
|
||||
if ($COURSE->id == $courseid) {
|
||||
$course = $COURSE;
|
||||
} else {
|
||||
$course = $DB->get_record('course', array('id' => $courseid));
|
||||
}
|
||||
|
||||
$course = get_course($courseid);
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
|
||||
$cm = $modinfo->cms[$cmid];
|
||||
@ -875,11 +870,6 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
|
||||
$grader = has_capability('mod/quiz:viewreports', $context);
|
||||
$groupmode = groups_get_activity_groupmode($cm, $course);
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
// Load all my groups and cache it in modinfo.
|
||||
$modinfo->groups = groups_get_user_groups($course->id);
|
||||
}
|
||||
|
||||
$usersgroups = null;
|
||||
$aname = format_string($cm->name, true);
|
||||
foreach ($attempts as $attempt) {
|
||||
@ -890,16 +880,10 @@ function quiz_get_recent_mod_activity(&$activities, &$index, $timestart,
|
||||
}
|
||||
|
||||
if ($groupmode == SEPARATEGROUPS and !$accessallgroups) {
|
||||
if (is_null($usersgroups)) {
|
||||
$usersgroups = groups_get_all_groups($course->id,
|
||||
$attempt->userid, $cm->groupingid);
|
||||
if (is_array($usersgroups)) {
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
} else {
|
||||
$usersgroups = array();
|
||||
}
|
||||
}
|
||||
if (!array_intersect($usersgroups, $modinfo->groups[$cm->id])) {
|
||||
$usersgroups = groups_get_all_groups($course->id,
|
||||
$attempt->userid, $cm->groupingid);
|
||||
$usersgroups = array_keys($usersgroups);
|
||||
if (!array_intersect($usersgroups, $modinfo->get_groups($cm->groupingid))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -442,18 +442,14 @@ function workshop_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
|
||||
}
|
||||
|
||||
// this might be slow - show only submissions by users who share group with me in this cm
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
break;
|
||||
}
|
||||
$authorsgroups = groups_get_all_groups($course->id, $s->authorid, $cm->groupingid);
|
||||
if (is_array($authorsgroups)) {
|
||||
$authorsgroups = array_keys($authorsgroups);
|
||||
$intersect = array_intersect($authorsgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($authorsgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
break;
|
||||
} else {
|
||||
@ -499,18 +495,14 @@ function workshop_print_recent_activity($course, $viewfullnames, $timestart) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
|
||||
}
|
||||
|
||||
// this might be slow - show only submissions by users who share group with me in this cm
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
break;
|
||||
}
|
||||
$reviewersgroups = groups_get_all_groups($course->id, $a->reviewerid, $cm->groupingid);
|
||||
if (is_array($reviewersgroups)) {
|
||||
$reviewersgroups = array_keys($reviewersgroups);
|
||||
$intersect = array_intersect($reviewersgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($reviewersgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
break;
|
||||
} else {
|
||||
@ -646,10 +638,6 @@ function workshop_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
$viewauthors = has_capability('mod/workshop:viewauthornames', $context);
|
||||
$viewreviewers = has_capability('mod/workshop:viewreviewernames', $context);
|
||||
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id); // load all my groups and cache it in modinfo
|
||||
}
|
||||
|
||||
$submissions = array(); // recent submissions indexed by submission id
|
||||
$assessments = array(); // recent assessments indexed by assessment id
|
||||
$users = array();
|
||||
@ -700,13 +688,13 @@ function workshop_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
}
|
||||
|
||||
// this might be slow - show only submissions by users who share group with me in this cm
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
break;
|
||||
}
|
||||
$authorsgroups = groups_get_all_groups($course->id, $s->authorid, $cm->groupingid);
|
||||
if (is_array($authorsgroups)) {
|
||||
$authorsgroups = array_keys($authorsgroups);
|
||||
$intersect = array_intersect($authorsgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($authorsgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
break;
|
||||
} else {
|
||||
@ -753,13 +741,13 @@ function workshop_get_recent_mod_activity(&$activities, &$index, $timestart, $co
|
||||
}
|
||||
|
||||
// this might be slow - show only submissions by users who share group with me in this cm
|
||||
if (empty($modinfo->groups[$cm->id])) {
|
||||
if (!$modinfo->get_groups($cm->groupingid)) {
|
||||
break;
|
||||
}
|
||||
$reviewersgroups = groups_get_all_groups($course->id, $a->reviewerid, $cm->groupingid);
|
||||
if (is_array($reviewersgroups)) {
|
||||
$reviewersgroups = array_keys($reviewersgroups);
|
||||
$intersect = array_intersect($reviewersgroups, $modinfo->groups[$cm->id]);
|
||||
$intersect = array_intersect($reviewersgroups, $modinfo->get_groups($cm->groupingid));
|
||||
if (empty($intersect)) {
|
||||
break;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user