mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-76578 core_course: One section per page summary information
This commit is contained in:
parent
178aa05227
commit
ad8a10e7b6
course
format
tests/behat
@ -68,13 +68,14 @@ class cmsummary implements named_templatable, renderable {
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output): stdClass {
|
||||
|
||||
list($mods, $complete, $total) = $this->calculate_section_stats();
|
||||
list($mods, $complete, $total, $showcompletion) = $this->calculate_section_stats();
|
||||
|
||||
if (empty($mods)) {
|
||||
return new stdClass();
|
||||
}
|
||||
|
||||
$data = (object)[
|
||||
'showcompletion' => $showcompletion,
|
||||
'total' => $total,
|
||||
'complete' => $complete,
|
||||
'mods' => array_values($mods),
|
||||
@ -104,6 +105,7 @@ class cmsummary implements named_templatable, renderable {
|
||||
$cmids = $modinfo->sections[$section->section] ?? [];
|
||||
|
||||
$cancomplete = isloggedin() && !isguestuser();
|
||||
$showcompletion = false;
|
||||
foreach ($cmids as $cmid) {
|
||||
$thismod = $modinfo->cms[$cmid];
|
||||
|
||||
@ -116,6 +118,7 @@ class cmsummary implements named_templatable, renderable {
|
||||
$mods[$thismod->modname]['count'] = 1;
|
||||
}
|
||||
if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
|
||||
$showcompletion = true;
|
||||
$total++;
|
||||
$completiondata = $completioninfo->get_data($thismod, true);
|
||||
if ($completiondata->completionstate == COMPLETION_COMPLETE ||
|
||||
@ -126,6 +129,6 @@ class cmsummary implements named_templatable, renderable {
|
||||
}
|
||||
}
|
||||
|
||||
return [$mods, $complete, $total];
|
||||
return [$mods, $complete, $total, $showcompletion];
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"showcompletion": true,
|
||||
"mods": [
|
||||
{
|
||||
"name": "Forums",
|
||||
@ -39,6 +40,8 @@
|
||||
<span class="activity-count">{{name}}: {{count}}</span>
|
||||
{{/mods}}
|
||||
</div>
|
||||
<div class="section-summary-activities pr-2 mdl-right">
|
||||
<span class="activity-count">{{modprogress}}</span>
|
||||
</div>
|
||||
{{#showcompletion}}
|
||||
<div class="section-summary-activities pr-2 mdl-right">
|
||||
<span class="activity-count">{{modprogress}}</span>
|
||||
</div>
|
||||
{{/showcompletion}}
|
||||
|
72
course/tests/behat/paged_course_information.feature
Normal file
72
course/tests/behat/paged_course_information.feature
Normal file
@ -0,0 +1,72 @@
|
||||
@core @core_course
|
||||
Feature: Course paged mode information
|
||||
In order to split the course in parts
|
||||
As a teacher
|
||||
I need to display the proper section information in a paged mode course
|
||||
|
||||
@javascript
|
||||
Scenario Outline: Section summary information for teachers and students in paged courses
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | format | numsections | coursedisplay | enablecompletion |
|
||||
| Course 1 | C1 | 0 | <courseformat> | 3 | 1 | <completion> |
|
||||
And the following "activities" exist:
|
||||
| activity | course | name | section | completion |
|
||||
| chat | C1 | Chat room | 1 | <completion> |
|
||||
| data | C1 | Database | 1 | <completion> |
|
||||
| forum | C1 | First forum | 2 | <completion> |
|
||||
| forum | C1 | Second forum | 2 | <completion> |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | First | student1@example.com |
|
||||
| teacher1 | Teacher | First | teacher1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| student1 | C1 | student |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
When I log in as "<user>"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Chat: 1" in the "#section-1" "css_element"
|
||||
And I should see "Database: 1" in the "#section-1" "css_element"
|
||||
And I should <show> "Progress:" in the "#section-1" "css_element"
|
||||
And I should see "Forums: 2" in the "#section-2" "css_element"
|
||||
And I should <show> "Progress:" in the "#section-2" "css_element"
|
||||
|
||||
Examples:
|
||||
| user | courseformat | completion | show |
|
||||
| student1 | topics | 0 | not see |
|
||||
| student1 | weeks | 0 | not see |
|
||||
| student1 | topics | 1 | see |
|
||||
| student1 | weeks | 1 | see |
|
||||
| teacher1 | topics | 0 | not see |
|
||||
| teacher1 | weeks | 0 | not see |
|
||||
| teacher1 | topics | 1 | see |
|
||||
| teacher1 | weeks | 1 | see |
|
||||
|
||||
@javascript
|
||||
Scenario Outline: Section summary information for guest in paged courses
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category | format | numsections | coursedisplay | enablecompletion |
|
||||
| Course 1 | C1 | 0 | <courseformat> | 3 | 1 | <completion> |
|
||||
And the following "activities" exist:
|
||||
| activity | course | name | section | completion |
|
||||
| chat | C1 | Chat room | 1 | <completion> |
|
||||
| data | C1 | Database | 1 | <completion> |
|
||||
| forum | C1 | First forum | 2 | <completion> |
|
||||
| forum | C1 | Second forum | 2 | <completion> |
|
||||
And I am on the "Course 1" "enrolment methods" page logged in as admin
|
||||
And I click on "Enable" "link" in the "Guest access" "table_row"
|
||||
And I log out
|
||||
When I log in as "guest"
|
||||
And I am on "Course 1" course homepage
|
||||
Then I should see "Chat: 1" in the "#section-1" "css_element"
|
||||
And I should see "Database: 1" in the "#section-1" "css_element"
|
||||
And I should not see "Progress:" in the "#section-1" "css_element"
|
||||
And I should see "Forums: 2" in the "#section-2" "css_element"
|
||||
And I should not see "Progress:" in the "#section-2" "css_element"
|
||||
|
||||
Examples:
|
||||
| courseformat | completion |
|
||||
| topics | 0 |
|
||||
| weeks | 0 |
|
||||
| topics | 1 |
|
||||
| weeks | 1 |
|
Loading…
x
Reference in New Issue
Block a user