Skip to content

Commit

Permalink
Upgrading print_course to use roles properly
Browse files Browse the repository at this point in the history
Added list for the teacher names for better XHTML
  • Loading branch information
moodler committed Sep 16, 2006
1 parent 5b63066 commit 8876809
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1510,33 +1510,40 @@ function print_course($course, $width="100%") {

global $CFG, $USER;

require_once("$CFG->dirroot/enrol/enrol.class.php");

$enrol = enrolment_factory::factory($course->enrol);
$context = get_context_instance(CONTEXT_COURSE, $course->id);

print_simple_box_start("center", "$width", '', 5, "coursebox");
print_simple_box_start('center', $width, '', 5, 'coursebox');

$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
$linkcss = $course->visible ? '' : ' class="dimmed" ';

echo "<table width=\"100%\">";
echo '<table width="100%">';
echo '<tr valign="top">';
echo '<td valign="top" width="50%" class="info">';
echo '<b><a title="'.get_string('entercourse').'"'.
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
$course->fullname.'</a></b><br />';
if ($teachers = get_course_teachers($course->id)) {
echo "<span class=\"teachers\">\n";

if ($teachers = get_users_by_capability($context, 'moodle/course:update')) {
$canseehidden = has_capability('moodle/role:viewhiddenassigns', $context);
$namesarray = array();
foreach ($teachers as $teacher) {
if (empty($teacher->role)) {
$teacher->role = $course->teacher;
if (!$teacher->hidden || $canseehidden) {
$roles = get_user_roles($context, $teacher->id);
$role = array_shift($roles); // First one
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
$namesarray[] = format_string($role->name).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
$teacher->id.'&amp;course='.SITEID.'">'.$fullname.'</a>';
}
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); // is the USER a teacher of that course
echo $teacher->role.': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.
'&amp;course='.SITEID.'">'.$fullname.'</a><br />';
}
echo "</span>\n";
if ($namesarray) {
echo "<ul class=\"teachers\">\n<li>";
echo implode('</li><li>', $namesarray);
echo "</li></ul>";
}
}

require_once("$CFG->dirroot/enrol/enrol.class.php");
$enrol = enrolment_factory::factory($course->enrol);
echo $enrol->get_access_icons($course);

echo '</td><td valign="top" width="50%" class="summary">';
Expand Down

0 comments on commit 8876809

Please sign in to comment.