MDL-34129 show course info on enrolment page
This commit is contained in:
+2
-32
@@ -51,38 +51,8 @@
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start('generalbox info');
|
||||
|
||||
$course->summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', NULL);
|
||||
echo format_text($course->summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
|
||||
|
||||
if (!empty($CFG->coursecontact)) {
|
||||
$coursecontactroles = explode(',', $CFG->coursecontact);
|
||||
foreach ($coursecontactroles as $roleid) {
|
||||
if ($users = get_role_users($roleid, $context, true)) {
|
||||
foreach ($users as $teacher) {
|
||||
$role = new stdClass();
|
||||
$role->id = $teacher->roleid;
|
||||
$role->name = $teacher->rolename;
|
||||
$role->shortname = $teacher->roleshortname;
|
||||
$role->coursealias = $teacher->rolecoursealias;
|
||||
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
|
||||
$namesarray[] = role_get_name($role, $context).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$teacher->id.'&course='.SITEID.'">'.$fullname.'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($namesarray)) {
|
||||
echo "<ul class=\"teachers\">\n<li>";
|
||||
echo implode('</li><li>', $namesarray);
|
||||
echo "</li></ul>";
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: print some enrol icons
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
$courserenderer = $PAGE->get_renderer('core', 'course');
|
||||
echo $courserenderer->course_info_box($course);
|
||||
|
||||
echo "<br />";
|
||||
|
||||
|
||||
@@ -51,6 +51,51 @@ class core_course_renderer extends plugin_renderer_base {
|
||||
parent::__construct($page, $target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders course info box.
|
||||
*
|
||||
* @param stdClass $course
|
||||
* @return string
|
||||
*/
|
||||
public function course_info_box(stdClass $course) {
|
||||
global $CFG;
|
||||
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$content = '';
|
||||
$content .= $this->output->box_start('generalbox info');
|
||||
|
||||
$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
|
||||
$content .= format_text($summary, $course->summaryformat, array('overflowdiv'=>true), $course->id);
|
||||
if (!empty($CFG->coursecontact)) {
|
||||
$coursecontactroles = explode(',', $CFG->coursecontact);
|
||||
foreach ($coursecontactroles as $roleid) {
|
||||
if ($users = get_role_users($roleid, $context, true)) {
|
||||
foreach ($users as $teacher) {
|
||||
$role = new stdClass();
|
||||
$role->id = $teacher->roleid;
|
||||
$role->name = $teacher->rolename;
|
||||
$role->shortname = $teacher->roleshortname;
|
||||
$role->coursealias = $teacher->rolecoursealias;
|
||||
$fullname = fullname($teacher, has_capability('moodle/site:viewfullnames', $context));
|
||||
$namesarray[] = role_get_name($role, $context).': <a href="'.$CFG->wwwroot.'/user/view.php?id='.
|
||||
$teacher->id.'&course='.SITEID.'">'.$fullname.'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($namesarray)) {
|
||||
$content .= "<ul class=\"teachers\">\n<li>";
|
||||
$content .= implode('</li><li>', $namesarray);
|
||||
$content .= "</li></ul>";
|
||||
}
|
||||
}
|
||||
|
||||
$content .= $this->output->box_end();
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renderers a structured array of courses and categories into a nice
|
||||
* XHTML tree structure.
|
||||
|
||||
@@ -84,6 +84,9 @@ $PAGE->navbar->add(get_string('enrolmentoptions','enrol'));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('enrolmentoptions','enrol'));
|
||||
|
||||
$courserenderer = $PAGE->get_renderer('core', 'course');
|
||||
echo $courserenderer->course_info_box($course);
|
||||
|
||||
//TODO: find if future enrolments present and display some info
|
||||
|
||||
foreach ($forms as $form) {
|
||||
|
||||
Reference in New Issue
Block a user