Skip to content

Instantly share code, notes, and snippets.

@samber
Last active November 25, 2019 22:54
Show Gist options
  • Save samber/c4b3a1298d8c42f36d20470fa188543d to your computer and use it in GitHub Desktop.
Save samber/c4b3a1298d8c42f36d20470fa188543d to your computer and use it in GitHub Desktop.
moodle add teams link
require_once($CFG->dirroot.'/mod/scheduler/renderer.php');
class theme_adaptable_mod_scheduler_renderer extends mod_scheduler_renderer {
public function render_scheduler_student_list(scheduler_student_list $studentlist) {
$o = '';
$toggleid = html_writer::random_id('toggle');
if ($studentlist->expandable && count($studentlist->students) > 0) {
$this->page->requires->yui_module('moodle-mod_scheduler-studentlist',
'M.mod_scheduler.studentlist.init',
array($toggleid, (boolean) $studentlist->expanded) );
$imgclass = 'studentlist-togglebutton';
$alttext = get_string('showparticipants', 'scheduler');
$o .= $this->output->pix_icon('t/switch', $alttext, 'moodle',
array('id' => $toggleid, 'class' => $imgclass));
}
$divprops = array('id' => 'list'.$toggleid);
$o .= html_writer::start_div('studentlist', $divprops);
if (count($studentlist->students) > 0) {
// CUSTOM @SAMBER (2019-11-25)
$teamsURL = "https://teams.microsoft.com/l/chat/0/0?users=";
foreach ($studentlist->students as $student) {
$teamsURL .= $student->user->username . ',';
var_dump($student->user->username);
}
$o .= html_writer::link($teamsURL, "Open in Teams", array('target' => '_blank'));
$o .= '<br><br>';
$editable = $studentlist->actionurl && $studentlist->editable;
if ($editable) {
$o .= html_writer::start_tag('form', array('action' => $studentlist->actionurl,
'method' => 'post', 'class' => 'studentselectform'));
}
foreach ($studentlist->students as $student) {
$class = 'otherstudent';
$checkbox = '';
if ($studentlist->checkboxname) {
if ($editable) {
$checkbox = html_writer::checkbox($studentlist->checkboxname, $student->entryid, $student->checked, '',
array('class' => 'studentselect'));
} else {
$img = $student->checked ? 'ticked' : 'unticked';
$checkbox = $this->render(new pix_icon($img, '', 'scheduler', array('class' => 'statictickbox')));
}
}
if ($studentlist->linkappointment) {
$name = $this->appointment_link($studentlist->scheduler, $student->user, $student->entryid);
} else {
$name = fullname($student->user);
}
$studicons = '';
$studprovided = array();
if ($student->notesprovided) {
$studprovided[] = get_string('message', 'scheduler');
}
if ($student->filesprovided) {
$studprovided[] = get_string('nfiles', 'scheduler', $student->filesprovided);
}
if ($studprovided) {
$providedstr = implode(', ', $studprovided);
$alttext = get_string('studentprovided', 'scheduler', $providedstr);
$attachicon = new pix_icon('attachment', $alttext, 'scheduler', array('class' => 'studdataicon'));
$studicons .= $this->render($attachicon);
}
if ($student->highlight) {
$class .= ' highlight';
}
$picture = $this->user_picture($student->user, array('courseid' => $studentlist->scheduler->courseid));
$grade = '';
if ($studentlist->showgrades && $student->grade) {
$grade = $this->format_grade($studentlist->scheduler, $student->grade, true);
}
$o .= html_writer::div($checkbox . $picture . ' ' . $name . $studicons . ' ' . $grade, $class);
}
if ($editable) {
$o .= html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'studentselectsubmit',
'value' => $studentlist->buttontext
));
$o .= html_writer::end_tag('form');
}
}
$o .= html_writer::end_div();
return $o;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment