Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
65 changes: 65 additions & 0 deletions classes/courseformat/overview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?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/>.

namespace mod_checklist\courseformat;

use core\output\action_link;
use core\output\local\properties\button;
use core\output\local\properties\text_align;
use core\url;
use core_courseformat\local\overview\overviewitem;

/**
* Checklist overview integration (for Moodle 5.1+)
*
* @package mod_checklist
* @copyright 2025 Luca Bösch <luca.boesch@bfh.ch>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class overview extends \core_courseformat\activityoverviewbase {
/**
* Constructor.
*
* @param \cm_info $cm the course module instance.
* @param \core\output\renderer_helper $rendererhelper the renderer helper.
*/
public function __construct(
\cm_info $cm,
\core\output\renderer_helper $rendererhelper
) {
parent::__construct($cm);
}

#[\Override]
public function get_actions_overview(): ?overviewitem {
$url = new url(
'/mod/checklist/view.php',
['id' => $this->cm->id],
);

$text = get_string('view');

if (defined('button::BODY_OUTLINE')) {
$bodyoutline = button::BODY_OUTLINE;
$buttonclass = $bodyoutline->classes();
} else {
$buttonclass = "btn btn-outline-secondary";
}

$content = new action_link($url, $text, null, ['class' => $buttonclass]);
return new overviewitem(get_string('actions'), $text, $content, text_align::CENTER);
}
}
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@

$id = required_param('id', PARAM_INT); // Course.

if ($CFG->version > 2025041400) {
\core_courseformat\activityoverviewbase::redirect_to_overview_page($id, 'checklist');
}

$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);

$PAGE->set_url('/mod/checklist/index.php', ['id' => $course->id]);
Expand Down
16 changes: 15 additions & 1 deletion lang/en/checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,22 @@
$string['lockteachermarkswarning'] = 'Note: Once you have saved these marks, you will be unable to change any \'Yes\' marks';
$string['missinguser'] = 'User does not exist';
$string['modulename'] = 'Checklist';
$string['modulename_help'] = 'The checklist module allows a teacher to create a checklist / todo list / task list for their students to work through.';
$string['modulename_help'] = '###### Key features
- Create checklists, to-do lists, or task lists for students
- Monitor student progress as they tick off items
- Indent items and mark them as optional
- Students can add private items and notes to their checklist
- Display progress visually with a progress bar and export to gradebook

###### Ways to use it
- Organize course tasks and track completion
- Help students manage assignments and deadlines
- Add optional tasks for extra credit or enrichment
- Import course activities and auto-check as completed
- Use comments and notes for personalized feedback
';
$string['modulename_link'] = 'mod/checklist/view';
$string['modulename_summary'] = 'A checklist / todo list / task list activity for students to work through';
$string['modulenameplural'] = 'Checklists';
$string['moveitemdown'] = 'Move item down';
$string['moveitemup'] = 'Move item up';
Expand Down
6 changes: 6 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,10 @@ function checklist_supports($feature) {
return MOD_PURPOSE_ASSESSMENT;
}
}
// For versions of Moodle prior to 5.1, we need to define that constant here.
if (!defined('FEATURE_MOD_OTHERPURPOSE')) {
define('FEATURE_MOD_OTHERPURPOSE', 'mod_otherpurpose');
}

switch ($feature) {
case FEATURE_GROUPS:
Expand All @@ -949,6 +953,8 @@ function checklist_supports($feature) {
return true;
case FEATURE_SHOW_DESCRIPTION:
return true;
case FEATURE_MOD_OTHERPURPOSE:
return MOD_PURPOSE_ADMINISTRATION;

default:
return null;
Expand Down
40 changes: 40 additions & 0 deletions tests/behat/overview_report.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@mod @mod_checklist
Feature: Testing overview integration in checklist activity
In order to summarize the checklist activity
As a user
I need to be able to see the checklist activity overview

Background:
Given the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "users" exist:
| username | firstname | lastname |
| student1 | Student | 1 |
| teacher1 | Teacher | 1 |
And the following "course enrolments" exist:
| course | user | role |
| C1 | student1 | student |
| C1 | teacher1 | editingteacher |
And the following "activity" exists:
| activity | checklist |
| name | Test checklist |
| course | C1 |
| idnumber | CHK001 |
| studentcomments | 1 |
And the following items exist in checklist "Test checklist":
| text | required |
| The first item | required |
| The second item | required |
| The third item | required |

Scenario: The Checklist activity index redirect to the activities overview
Given the site is running Moodle version 5.0 or higher
When I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add the "Activities" block
And I click on "Checklists" "link" in the "Activities" "block"
Then I should see "An overview of all activities in the course"
And I should see "Name" in the "checklist_overview_collapsible" "region"
And I should see "Actions" in the "checklist_overview_collapsible" "region"
And I should see "Test checklist"
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2025101800; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2025122100; // The current module version (Date: YYYYMMDDXX).
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '4.1.0.7';
$plugin->requires = 2022112800; // Moodle 4.1.0.
Expand Down