Skip to content

Commit b2b8ba8

Browse files
committed
Support course overview, resolves #111.
1 parent 601f7f0 commit b2b8ba8

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

classes/courseformat/overview.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace mod_subcourse\courseformat;
18+
19+
use core\output\action_link;
20+
use core\output\local\properties\button;
21+
use core\output\local\properties\text_align;
22+
use core\url;
23+
use core_courseformat\local\overview\overviewitem;
24+
25+
/**
26+
* Subcourse overview integration (for Moodle 5.1+)
27+
*
28+
* @package mod_subcourse
29+
* @copyright 2026 Luca Bösch <[email protected]>
30+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31+
*/
32+
class overview extends \core_courseformat\activityoverviewbase {
33+
/**
34+
* Constructor.
35+
*
36+
* @param \cm_info $cm the course module instance.
37+
* @param \core\output\renderer_helper $rendererhelper the renderer helper.
38+
*/
39+
public function __construct(
40+
\cm_info $cm,
41+
/** @var \core\output\renderer_helper $rendererhelper the renderer helper */
42+
protected readonly \core\output\renderer_helper $rendererhelper,
43+
) {
44+
parent::__construct($cm);
45+
}
46+
47+
#[\Override]
48+
public function get_actions_overview(): ?overviewitem {
49+
$url = new url(
50+
'/mod/verbalfeedback/view.php',
51+
['id' => $this->cm->id],
52+
);
53+
54+
if (defined('button::BODY_OUTLINE')) {
55+
$bodyoutline = button::BODY_OUTLINE;
56+
$buttonclass = $bodyoutline->classes();
57+
} else {
58+
$buttonclass = "btn btn-outline-secondary";
59+
}
60+
61+
$text = get_string('view');
62+
$content = new action_link(
63+
url: $url,
64+
text: $text,
65+
attributes: ['class' => $buttonclass],
66+
);
67+
68+
return new overviewitem(
69+
name: get_string('actions'),
70+
value: $text,
71+
content: $content,
72+
textalign: text_align::CENTER,
73+
);
74+
}
75+
}

index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@
2424

2525
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
2626
require_once(dirname(__FILE__) . '/lib.php');
27+
global $CFG;
2728

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

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

33+
if ($CFG->version > 2025041400) {
34+
\core_courseformat\activityoverviewbase::redirect_to_overview_page($id, 'subcourse');
35+
}
36+
3237
require_course_login($course);
3338

3439
$PAGE->set_url(new moodle_url('/mod/subcourse/index.php', ['id' => $id]));
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@mod @mod_subcourse
2+
Feature: Testing overview integration in subcourse activity
3+
In order to summarize the subcourse activity
4+
As a user
5+
I need to be able to see the subcourse activity overview
6+
7+
Background:
8+
Given the following "users" exist:
9+
| username | firstname | lastname | email |
10+
| teacher1 | Teacher | 1 | teacher1@example.com |
11+
| student1 | Student | 1 | student1@example.com |
12+
And the following "courses" exist:
13+
| fullname | shortname | category |
14+
| Course 1 | M | 0 |
15+
| RefCourse | R | 0 |
16+
And the following "course enrolments" exist:
17+
| user | course | role |
18+
| teacher1 | M | editingteacher |
19+
| student1 | M | student |
20+
| teacher1 | R | editingteacher |
21+
| student1 | R | student |
22+
And I log in as "teacher1"
23+
And I am on "Course 1" course homepage
24+
And I turn editing mode on
25+
And I add a "subcourse" activity to course "Course 1" section "1" and I fill the form with:
26+
| Subcourse name | Unit course 1 |
27+
| Fetch grades from | RefCourse (R) |
28+
| Redirect to the referenced course | 0 |
29+
30+
@javascript
31+
Scenario: The subcourse activity overview report should generate log events
32+
Given the site is running Moodle version 5.0 or higher
33+
And I am on the "Course 1" "course > activities > subcourse" page logged in as "teacher1"
34+
When I am on the "Course 1" "course" page logged in as "teacher1"
35+
And I navigate to "Reports" in current page administration
36+
And I click on "Logs" "link"
37+
And I click on "Get these logs" "button"
38+
Then I should see "Course activities overview page viewed"
39+
And I should see "viewed the instance list for the module 'subcourse'"
40+
41+
@javascript
42+
Scenario: The subcourse activity index redirect to the activities overview
43+
Given the site is running Moodle version 5.0 or higher
44+
And I am on "Course 1" course homepage with editing mode on
45+
And I add the "Activities" block
46+
And I click on "Subcourses" "link" in the "Activities" "block"
47+
Then I should see "An overview of all activities in the course"
48+
And I should see "Name" in the "subcourse_overview_collapsible" "region"
49+
And I should see "Actions" in the "subcourse_overview_collapsible" "region"

0 commit comments

Comments
 (0)