Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-8337: Show kanbans in block activity_modules #63

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,63 @@

$id = required_param('id', PARAM_INT);

require_login();
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
require_course_login($course);
PhMemmel marked this conversation as resolved.
Show resolved Hide resolved

redirect($CFG->wwwroot . '/mod/kanban/view.php?id=' . $id);
$coursecontext = context_course::instance($course->id);

$PAGE->set_url('/mod/kanban/index.php', ['id' => $id]);
$PAGE->set_title(format_string($course->fullname));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($coursecontext);

echo $OUTPUT->header();

$modulenameplural = get_string('modulenameplural', 'mod_kanban');
echo $OUTPUT->heading($modulenameplural);

$kanbans = get_all_instances_in_course('kanban', $course);
$usesections = course_format_uses_sections($course->format);

$table = new html_table();
PhMemmel marked this conversation as resolved.
Show resolved Hide resolved
$table->attributes['class'] = 'generaltable mod_index';

if ($usesections) {
$table->head = [get_string('sectionname', 'format_' . $course->format), get_string('name')];
$table->align = ['left', 'left'];
} else {
$table->head = [get_string('name')];
$table->align = ['left'];
}

$kanbanfound = false;

foreach ($kanbans as $kanban) {
$context = context_module::instance($kanban->coursemodule, IGNORE_MISSING);
if (!$context || !has_capability('mod/kanban:view', $context)) {
continue;
}

$kanbanfound = true;
$linkcss = null;

if (!$kanban->visible) {
PhMemmel marked this conversation as resolved.
Show resolved Hide resolved
$linkcss = ['class' => 'dimmed'];
}

$link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss);

if ($usesections) {
$table->data[] = [get_section_name($course, $kanban->section), $link];
} else {
$table->data[] = [$link];
}
}

if (!$kanbanfound) {
notice(get_string('nokanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id]));
} else {
echo html_writer::table($table);
}

echo $OUTPUT->footer();
1 change: 1 addition & 0 deletions lang/en/kanban.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
$string['newcard'] = 'New card';
$string['newcolumn'] = 'New column';
$string['nogroupavailable'] = 'No group available';
$string['nokanbaninstances'] = 'There are no kanban boards in this course';
PhMemmel marked this conversation as resolved.
Show resolved Hide resolved
$string['nouser'] = 'No user';
$string['nouserboards'] = 'No personal boards';
$string['pluginadministration'] = 'Kanban administration';
Expand Down
Loading