Commit 349b705d authored by Adrian Greeve's avatar Adrian Greeve
Browse files

MDL-60515 groups: Display group information on the participants page.

parent 40f1801c
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Group details page.
*
* @package core_group
* @copyright 2017 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_group\output;
defined('MOODLE_INTERNAL') || die();
use renderable;
use renderer_base;
use stdClass;
use templatable;
use context_course;
use moodle_url;
/**
* Group details page class.
*
* @package core_group
* @copyright 2017 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class group_details implements renderable, templatable {
/** @var stdClass $group An object with the group information. */
protected $group;
/**
* group_details constructor.
*
* @param int $groupid Group ID to show details of.
*/
public function __construct($groupid) {
$this->group = groups_get_group($groupid, '*', MUST_EXIST);
}
/**
* Export the data.
*
* @param renderer_base $output
* @return stdClass
*/
public function export_for_template(renderer_base $output) {
if (!empty($this->group->description) || (!empty($this->group->picture) && empty($this->group->hidepicture))) {
$context = context_course::instance($this->group->courseid);
$description = file_rewrite_pluginfile_urls($this->group->description,
'pluginfile.php',
$context->id,
'group',
'description',
$this->group->id);
$descriptionformat = $this->group->descriptionformat ?? FORMAT_MOODLE;
$options = [
'overflowdiv' => true,
'context' => $context
];
$data = new stdClass();
$data->picture = print_group_picture($this->group, $this->group->courseid, true, true, false);
$data->name = format_string($this->group->name, true, ['context' => $context]);
$data->description = format_text($description, $descriptionformat, $options);
if (has_capability('moodle/course:managegroups', $context)) {
$url = new moodle_url('/group/group.php', ['id' => $this->group->id, 'courseid' => $this->group->courseid]);
$data->editurl = $url->out(false);
}
return $data;
} else {
return;
}
}
}
......@@ -47,4 +47,15 @@ class renderer extends plugin_renderer_base {
$data = $page->export_for_template($this);
return parent::render_from_template('core_group/index', $data);
}
/**
* Defer to template.
*
* @param group_details $page Group details page object.
* @return string HTML to render the group details.
*/
public function group_details(group_details $page) {
$data = $page->export_for_template($this);
return parent::render_from_template('core_group/group_details', $data);
}
}
......@@ -102,36 +102,11 @@ echo $OUTPUT->heading(get_string('adduserstogroup', 'group').": $groupname", 3);
// Store the rows we want to display in the group info.
$groupinforow = array();
// Check if there is a picture to display.
if (!empty($group->picture)) {
$picturecell = new html_table_cell();
$picturecell->attributes['class'] = 'left side picture';
$picturecell->text = print_group_picture($group, $course->id, true, true, false);
$groupinforow[] = $picturecell;
}
// Check if there is a description to display.
$group->description = file_rewrite_pluginfile_urls($group->description, 'pluginfile.php', $context->id, 'group', 'description', $group->id);
if (!empty($group->description)) {
if (!isset($group->descriptionformat)) {
$group->descriptionformat = FORMAT_MOODLE;
}
$options = new stdClass;
$options->overflowdiv = true;
$contentcell = new html_table_cell();
$contentcell->attributes['class'] = 'content';
$contentcell->text = format_text($group->description, $group->descriptionformat, $options);
$groupinforow[] = $contentcell;
}
// Check if we have something to show.
if (!empty($groupinforow)) {
$groupinfotable = new html_table();
$groupinfotable->attributes['class'] = 'groupinfobox';
$groupinfotable->data[] = new html_table_row($groupinforow);
echo html_writer::table($groupinfotable);
$grouprenderer = $PAGE->get_renderer('core_group');
$groupdetailpage = new \core_group\output\group_details($groupid);
echo $grouprenderer->group_details($groupdetailpage);
}
/// Print the editing form
......
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_group/group_details
Template for the Groups page.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
* name string Group Name
* picture string Group image HTML
* description string Group description
* edit string edit link to edit the group
Example context (json):
{
"name": "Group Name",
"picture": "",
"description": "This is the description for Group Name",
"editurl": ""
}
}}
{{#name}}
<div class="groupinfobox container-fluid p-y-1">
<div class="row-fluid">
{{#picture}}
<div class="group-image col-sm-1 span1">{{{picture}}}</div>
{{/picture}}
<div {{#picture}}class="col-sm-11 span11"{{/picture}}{{^picture}}class="col"{{/picture}}>
<div class="container-fluid">
<div class="row-fluid">
<div class="col">
<h3 class="d-inline-block">{{name}}</h3>
{{#editurl}}
<span class="group-edit"><a href="{{editurl}}">{{#pix}}t/edit, core, {{#str}}editgroupprofile{{/str}}{{/pix}}</a></span>
{{/editurl}}
</div>
</div>
<div class="row-fluid">
<div class="group-description col">{{{description}}}</div>
</div>
</div>
</div>
</div>
</div>
{{/name}}
......@@ -200,6 +200,10 @@
font-weight: bold;
}
.group-image {
min-width: 93px;
}
.groupinfobox {
@extend .card;
}
......
......@@ -202,6 +202,11 @@
width: 100px;
vertical-align: top;
}
.group-image {
min-width: 60px;
}
.course-participation #showall {
text-align: center;
margin: 10px 0;
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -196,6 +196,12 @@ if ($groupid !== false) {
}
}
if ($groupid && ($course->groupmode != SEPARATEGROUPS || $canaccessallgroups)) {
$grouprenderer = $PAGE->get_renderer('core_group');
$groupdetailpage = new \core_group\output\group_details($groupid);
echo $grouprenderer->group_details($groupdetailpage);
}
// Manage enrolments.
$manager = new course_enrolment_manager($PAGE, $course);
$enrolbuttons = $manager->get_manual_enrol_buttons();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment