Hi! Could anyone tell how to add hyperlink in the "Participants" section? And the requirements are, that this hyperlink is visible only for course teachers.
Peteris,
This is surprisingly straightforward provided you want this on every course!
Open the file... blocks/participants/block_participants.php in a text editor meant for php and html.
In version 1.9 this contains a class with 3 functions, including get_content().
In this function find the lines...
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
Make a duplicate of these two lines immediately after them, but wrap the new lines with a conditional that prevents them being seen by anyone below the Teacher role...
if (has_capability('moodle/course:update', $currentcontext)) {
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
}
Test this step by entering a course as a teacher. You should see...
Participants
Participants
...switch to a student role and one will disappear!
Note: if you don't want this to happen on the front page (for admins or teachers with a front page role), make the conditional...
if ((has_capability('moodle/course:update', $currentcontext)) && ($COURSE->id > 1)) {
Now you can edit you lines to provide your hyperlink and an icon to go with it.
Do not forget that all this will be lost on upgrades!
Regards,
John
This is surprisingly straightforward provided you want this on every course!
Open the file... blocks/participants/block_participants.php in a text editor meant for php and html.
In version 1.9 this contains a class with 3 functions, including get_content().
In this function find the lines...
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
Make a duplicate of these two lines immediately after them, but wrap the new lines with a conditional that prevents them being seen by anyone below the Teacher role...
if (has_capability('moodle/course:update', $currentcontext)) {
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
}
Test this step by entering a course as a teacher. You should see...
Participants
Participants
...switch to a student role and one will disappear!
Note: if you don't want this to happen on the front page (for admins or teachers with a front page role), make the conditional...
if ((has_capability('moodle/course:update', $currentcontext)) && ($COURSE->id > 1)) {
Now you can edit you lines to provide your hyperlink and an icon to go with it.
Do not forget that all this will be lost on upgrades!
Regards,
John
tnx, John! It works