Skip to content

Commit

Permalink
MBS-8337: Combine kanban visibility check with empty table message
Browse files Browse the repository at this point in the history
  • Loading branch information
fdagner committed Oct 28, 2024
1 parent 5174d61 commit 5164361
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
42 changes: 23 additions & 19 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,9 @@
$modulenameplural = get_string('modulenameplural', 'mod_kanban');
echo $OUTPUT->heading($modulenameplural);

require_capability('mod/kanban:view', $coursecontext);

$kanbans = get_all_instances_in_course('kanban', $course);

if (empty($kanbans)) {
notice(get_string('nokanbaninstances', 'mod_kanban'), new moodle_url('/course/view.php', ['id' => $course->id]));
}

$usesections = course_format_uses_sections($course->format);

$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';

Expand All @@ -63,24 +57,34 @@
$table->align = ['left'];
}

$kanbanfound = false;

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

$kanbanfound = true;
$linkcss = null;

if ($kanban->visible && has_capability('mod/kanban:view', $context)) {
if (!$kanban->visible) {
$linkcss = ['class' => 'dimmed'];
}
if (!$kanban->visible) {
$linkcss = ['class' => 'dimmed'];
}

$link = html_writer::link(new moodle_url('/mod/kanban/view.php', ['id' => $kanban->coursemodule]), $kanban->name, $linkcss);
$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 ($usesections) {
$table->data[] = [get_section_name($course, $kanban->section), $link];
} else {
$table->data[] = [$link];
}
}

echo html_writer::table($table);
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();
8 changes: 8 additions & 0 deletions lang/en/kanban.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
$string['messageprovider:due'] = 'Card due';
$string['messageprovider:moved'] = 'Card moved';
$string['modulename'] = 'Kanban board';
$string['modulename_help'] = 'This activity supports using kanban method for managing projects or learning processes.
Kanban is an agile project management method that organizes tasks through a visual board to optimize workflow. Tasks are categorized into columns such as "To Do," "In Progress," and "Done" to make progress transparent. The goal is to identify bottlenecks in the workflow and continuously improve efficiency.
Depending on the settings, there can be several types of boards within a Kanban activity:
* The course board, which is accessible to everyone who has access to the activity
* Personal boards for each user
* Group boards
* Template boards: Anyone who has the ability to manage boards can copy an existing board as a template.
';
$string['modulenameplural'] = 'Kanban boards';
$string['moveaftercard'] = 'Move after';
$string['movecard'] = 'Move card';
Expand Down

0 comments on commit 5164361

Please sign in to comment.