diff --git a/classes/courseformat/overview.php b/classes/courseformat/overview.php new file mode 100644 index 0000000..63c3ea4 --- /dev/null +++ b/classes/courseformat/overview.php @@ -0,0 +1,65 @@ +. + +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 + * @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); + } +} diff --git a/index.php b/index.php index 01484a7..bcce929 100644 --- a/index.php +++ b/index.php @@ -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]); diff --git a/lang/en/checklist.php b/lang/en/checklist.php index 47a6621..386e641 100644 --- a/lang/en/checklist.php +++ b/lang/en/checklist.php @@ -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'; diff --git a/lib.php b/lib.php index c410dd3..55aab14 100644 --- a/lib.php +++ b/lib.php @@ -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: @@ -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; diff --git a/tests/behat/overview_report.feature b/tests/behat/overview_report.feature new file mode 100644 index 0000000..1c91a33 --- /dev/null +++ b/tests/behat/overview_report.feature @@ -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" diff --git a/version.php b/version.php index 589cccf..332fcac 100644 --- a/version.php +++ b/version.php @@ -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.