Buenos dias, estoy usando la moodle 3.5, estoy intentando que el bloque People solo muestre el tutor que este en el mismo grupo que el alumno.
Me he quedado un poco atascado, necesito sacar el grupo al que pertenece el alumno, no se si hay una variable global o una función que lo haga, mi idea es una vez tenga el grupo del alumno usar algo así como:
if (groups_is_member($grupoalumno, $teacher->id))
Para que solo muestre el tutor si pertenece al mismo grupo, he probado esa linea poniendo el numero del grupo a mano y si que me funciona: (1, $teacher->id)).
Igualmente añado el trozo del código donde estoy toqueteando (block_people.php)
foreach ($teachers as $teacher) {
// If users should only be listed once.
if (groups_is_member($allgroups, $teacher->id)) {
if (!$multipleroles) {
// Continue if we have already shown this user.
if (isset($displayedteachers[$teacher->id])) {
continue;
}
// Remember that we have shown this user.
$displayedteachers[$teacher->id] = 1;
// Otherwise.
} else {
// Continue if we have already shown this user.
if (isset($displayedteachers[$teacher->id][$teacher->roleid])) {
continue;
}
// Remember that we have shown this user and his role.
$displayedteachers[$teacher->id][$teacher->roleid] = 1;
}
// If we have to process a new role.
if ($teacherrole != $teacher->roleid) {
// End previous role list if necessary.
if ($teacherrole != null) {
$this->content->text .= html_writer::end_tag('ul');
}
// Write heading and open new role list.
$teacherrole = $teacher->roleid;
$this->content->text .= html_writer::tag('h3', $rolenames[$teacherrole]);
$this->content->text .= html_writer::start_tag('ul');
}
// Start output teacher.
$this->content->text .= html_writer::start_tag('li');
// Create user object for picture output.
$user = new stdClass();
$user->id = $teacher->id;
$user->lastname = $teacher->lastname;
$user->firstname = $teacher->firstname;
$user->lastnamephonetic = $teacher->lastnamephonetic;
$user->firstnamephonetic = $teacher->firstnamephonetic;
$user->middlename = $teacher->middlename;
$user->alternatename = $teacher->alternatename;
$user->picture = $teacher->picture;
$user->imagealt = $teacher->imagealt;
$user->email = $teacher->email;
// Teacher image.
$this->content->text .= html_writer::start_tag('div', array('class' => 'image'));
if (has_capability('moodle/user:viewdetails', $currentcontext)) {
$this->content->text .= $OUTPUT->user_picture($user,
array('size' => 30, 'link' => true, 'courseid' => $COURSE->id, 'includefullname' => false));
} else {
$this->content->text .= $OUTPUT->user_picture($user,
array('size' => 30, 'link' => false, 'courseid' => $COURSE->id, 'includefullname' => false));
}
$this->content->text .= html_writer::end_tag('div');
// Teacher details.
$this->content->text .= html_writer::start_tag('div', array('class' => 'details'));
$this->content->text .= html_writer::start_tag('div', array('class' => 'name'));
$this->content->text .= fullname($teacher);
$this->content->text .= html_writer::end_tag('div');
$this->content->text .= html_writer::start_tag('div', array('class' => 'icons'));
if ($CFG->messaging && has_capability('moodle/site:sendmessage', $currentcontext) && $teacher->id != $USER->id) {
$this->content->text .= html_writer::start_tag('a',
array('href' => new moodle_url('/message/index.php', array('id' => $teacher->id)),
'title' => get_string('sendmessageto', 'core_message', fullname($teacher))));
$this->content->text .= $OUTPUT->pix_icon('t/email',
get_string('sendmessageto', 'core_message', fullname($teacher)), 'moodle');
$this->content->text .= html_writer::end_tag('a');
}
$this->content->text .= html_writer::end_tag('div');
$this->content->text .= html_writer::end_tag('div');
// End output teacher.
$this->content->text .= html_writer::end_tag('li');
}
}