My problem is the following. Teachers/Course creators are able to see 2 links on the left course admin links. "Teachers..." and "Students..." amongst other links like, course, backup, restore etc. I want to hide the links "Teachers..." and "Students..." for everybody except the admin. Since I do not want any teacher or course creator to enroll or unenroll students. I tried to modify the function print_course_admin_links() in moodleroot/course/lib.php but modification of that function does not seem to effect the output at all. Can somebody pinpoint and please let me know, which function in which file do I need to modify in order to accomplish this.
Re: How to modify code to hide certain options in course admin
Re: How to modify code to hide certain options in course admin
Re: How to modify code to hide certain options in course admin
file to edit... blocks/admin/block_admin.php
see sample: (in this sample only admin see the said link but not teachers...change the condition if you need to... of comment the code that you need to hide from admin)
if (isadmin()) {
$admindata[]="<a href=\"$CFG->wwwroot/backup/backup.php?id=$course->id\">".get_string("backup")."...</a>";
$adminicon[]="<img src=\"$CFG->pixpath/i/backup.gif\" height=16 width=16 alt=\"\">";
$admindata[]="<a href=\"$CFG->wwwroot/files/index.php?id=$course->id&wdir=/backupdata\">".get_string("restore")."...</a>";
$adminicon[]="<img src=\"$CFG->pixpath/i/restore.gif\" height=16 width=16 alt=\"\">";
}
Thank you very much. You have hit the nail. However, the code on my installation looks little different(I am using Moodle 1.3.1). But it worked anyway. I defined a variable in config.php called $CFG->TEACHER and $CFG->STUDENT = 0 or 1 depending on if you want to display "Teachers..." and "Students..." links in the admin menu so the the functionality can be changed on fly. Then I modified the code as shown below. Where START and END block indicate the start of my code and end of my code bock.
NOTE: The code in print_course_admin_links() in course/lib.php is almost identical to this, and I was trying to modify that......which did not work!.
//START BLOCK------------------------------------------------------------------------------------------------
if(isadmin() or $CFG->TEACHER==1){
//END BLOCK------------------------------------------------------------------------------------------------
$this->content->items[]='<a href="teacher.php?id='.$this->course->id.'">'.$this->course->teachers.'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
//START BLOCK------------------------------------------------------------------------------------------------
}
//END BLOCK------------------------------------------------------------------------------------------------
}
if (!$this->course->students) {
$this->course->students = get_string('defaultcoursestudents');
}
//START BLOCK------------------------------------------------------------------------------------------------
if(isadmin() or $CFG->STUDENT==1){
//END BLOCK------------------------------------------------------------------------------------------------
$this->content->items[]='<a href="student.php?id='.$this->course->id.'">'.$this->course->students.'...</a>';
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
//START BLOCK------------------------------------------------------------------------------------------------
}
//END BLOCK------------------------------------------------------------------------------------------------