Skip to content

Commit bd55024

Browse files
committed
Merge branch '8330/update-to-51' into 'main'
8330/update to 51 See merge request amc/moodle/moodle-mod_publication!147
2 parents 04e313e + 3351afd commit bd55024

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1357
-447
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ workflow:
1414
- when: always
1515

1616
include:
17-
- component: $CI_SERVER_FQDN/amc/moodle/moodle-ci/moodle-plugin-ci@5.0
18-
- component: $CI_SERVER_FQDN/amc/moodle/moodle-ci/moodle-devil-app@5.0
17+
- component: $CI_SERVER_FQDN/amc/moodle/moodle-ci/moodle-plugin-ci@5.1
18+
- component: $CI_SERVER_FQDN/amc/moodle/moodle-ci/moodle-devil-app@5.1
19+

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@ CHANGELOG
22
=========
33

44

5+
5.1.0 (2026-01-14)
6+
-------------------
7+
* Moodle 5.1.0 compatible version
8+
* [BUG] #8440 - fix resetting of filters after applying changes on All files table - github #104
9+
* [FEATURE] #8332 - add support for multilang filter v2 in course name, activity name and group name when saving zip file
10+
* [BUG] #8092 - only show students/teachers who have mod/publication:upload in the table
11+
* [FEATURE] #8441 - use original filenames in zip file
12+
* [BUG] #8567 - fix incorrect count and title in group mode
13+
* [FEATURE] #8094 - implement new completion criteria for imported files from assignment activities
14+
* [FEAUTRE] #8581 - show which group the user belongs to, and also groups members
15+
* [FEATURE] #8617 - implement overview class - github #105
16+
517
5.0.1 (2025-09-29)
618
-------------------
7-
* [BUG] #8534 - fix incorrect usage of deprecated.txt
8-
* [BUG] #8535 - add missing privacy provider table coverage for table publication_overrides
19+
* [BUG] #8534 - fix incorrect usage of deprecated.txt - github #100
20+
* [BUG] #8535 - add missing privacy provider table coverage for table publication_overrides - github #101
921
* [BUG] #8551 - remove table borders in Moodle ≥ 5.0 - github pull request #102 - lucaboesch
1022

1123
5.0.0 (2025-06-11)

backup/moodle2/backup_publication_activity_task.class.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4141
*/
4242
class backup_publication_activity_task extends backup_activity_task {
43-
4443
/**
4544
* Define (add) particular settings this activity can have
4645
*/
@@ -75,6 +74,4 @@ public static function encode_content_links($content) {
7574

7675
return $content;
7776
}
78-
7977
}
80-

backup/moodle2/backup_publication_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3535
*/
3636
class backup_publication_activity_structure_step extends backup_activity_structure_step {
37-
3837
/**
3938
* Define the structure for the publication activity
4039
*
@@ -54,6 +53,7 @@ protected function define_structure() {
5453
'duedate',
5554
'allowsubmissionsfromdate',
5655
'completionupload',
56+
'completionassignsubmission',
5757
'timemodified',
5858
'cutoffdate',
5959
'approvalfromdate',

backup/moodle2/restore_publication_activity_task.class.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4141
*/
4242
class restore_publication_activity_task extends restore_activity_task {
43-
4443
/**
4544
* Define (add) particular settings this activity can have.
4645
*/
@@ -79,15 +78,18 @@ public static function define_decode_contents() {
7978
public static function define_decode_rules() {
8079
$rules = [];
8180

82-
$rules[] = new restore_decode_rule('PUBLICATIONVIEWBYID',
83-
'/mod/publication/view.php?id=$1',
84-
'course_module');
85-
$rules[] = new restore_decode_rule('PUBLICATIONINDEX',
86-
'/mod/publication/index.php?id=$1',
87-
'course_module');
81+
$rules[] = new restore_decode_rule(
82+
'PUBLICATIONVIEWBYID',
83+
'/mod/publication/view.php?id=$1',
84+
'course_module'
85+
);
86+
$rules[] = new restore_decode_rule(
87+
'PUBLICATIONINDEX',
88+
'/mod/publication/index.php?id=$1',
89+
'course_module'
90+
);
8891

8992
return $rules;
90-
9193
}
9294

9395
/**
@@ -125,5 +127,4 @@ public static function define_restore_log_rules_for_course() {
125127

126128
return $rules;
127129
}
128-
129130
}

backup/moodle2/restore_publication_stepslib.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3535
*/
3636
class restore_publication_activity_structure_step extends restore_activity_structure_step {
37-
3837
/**
3938
* Define the structure of the restore workflow.
4039
*
@@ -49,17 +48,23 @@ protected function define_structure() {
4948
// Define each element separated.
5049
$paths[] = new restore_path_element('publication', '/activity/publication');
5150
if ($userinfo) {
52-
$files = new restore_path_element('publication_file',
53-
'/activity/publication/files/file');
51+
$files = new restore_path_element(
52+
'publication_file',
53+
'/activity/publication/files/file'
54+
);
5455
$paths[] = $files;
5556

56-
$extduedates = new restore_path_element('publication_extduedates',
57-
'/activity/publication/extduedates/extduedate');
57+
$extduedates = new restore_path_element(
58+
'publication_extduedates',
59+
'/activity/publication/extduedates/extduedate'
60+
);
5861

5962
$paths[] = $extduedates;
6063

61-
$overrides = new restore_path_element('publication_overrides',
62-
'/activity/publication/overrides/override');
64+
$overrides = new restore_path_element(
65+
'publication_overrides',
66+
'/activity/publication/overrides/override'
67+
);
6368
$paths[] = $overrides;
6469
}
6570

@@ -243,6 +248,5 @@ protected function after_restore() {
243248
$DB->update_record('files', $record);
244249
}
245250
$rs->close();
246-
247251
}
248252
}

classes/completion/custom_completion.php

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3030
*/
3131
class custom_completion extends activity_custom_completion {
32-
3332
/**
3433
* Fetches the completion state for a given completion rule.
3534
*
@@ -38,26 +37,62 @@ class custom_completion extends activity_custom_completion {
3837
*/
3938
public function get_state(string $rule): int {
4039
global $CFG, $DB;
40+
require_once($CFG->dirroot . '/mod/publication/locallib.php');
41+
require_once($CFG->libdir . '/grouplib.php');
4142

4243
$this->validate_rule($rule);
4344

44-
$userid = $this->userid;
4545
$cm = $this->cm;
4646

47-
require_once($CFG->dirroot . '/mod/publication/locallib.php');
47+
$userid = $this->userid;
4848

4949
$publication = new \publication($cm, $cm->course, \context_module::instance($cm->id));
50-
$status = false;
51-
if ($publication->get_mode() == PUBLICATION_MODE_FILEUPLOAD) {
52-
$filescount = $DB->count_records('publication_file', [
53-
'publication' => $publication->get_instance()->id,
54-
'userid' => $userid,
55-
]);
56-
$status = $filescount > 0;
57-
} else {
58-
$status = true;
50+
$mode = $publication->get_mode();
51+
$status = COMPLETION_UNKNOWN;
52+
if ($rule == 'completionupload' && $publication->get_instance()->completionupload) {
53+
if ($mode == PUBLICATION_MODE_FILEUPLOAD) {
54+
$filescount = $DB->count_records('publication_file', [
55+
'publication' => $publication->get_instance()->id,
56+
'userid' => $userid,
57+
]);
58+
$status = $filescount > 0 ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
59+
} else {
60+
$status = COMPLETION_COMPLETE;
61+
}
62+
} else if ($rule == 'completionassignsubmission' && $publication->get_instance()->completionassignsubmission) {
63+
if ($mode == PUBLICATION_MODE_FILEUPLOAD) {
64+
$status = COMPLETION_COMPLETE;
65+
} else if ($mode == PUBLICATION_MODE_ASSIGN_IMPORT) {
66+
$filescount = $DB->count_records('publication_file', [
67+
'publication' => $publication->get_instance()->id,
68+
'userid' => $userid,
69+
]);
70+
$status = $filescount > 0 ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
71+
} else if ($mode == PUBLICATION_MODE_ASSIGN_TEAMSUBMISSION) {
72+
$status = COMPLETION_INCOMPLETE;
73+
$groups = \groups_get_user_groups($cm->course, $userid);
74+
$groupids = [];
75+
if (!empty($groups[0])) {
76+
$groupids = $groups[0];
77+
} else if (!$publication->requiregroup()) {
78+
$groupids[] = 0; // Use groupid 0 for users without groups.
79+
}
80+
if (empty($groupids)) {
81+
return $status; // User is not in any group and groups are required.
82+
}
83+
foreach ($groupids as $groupid) { // Iterate over all groups of the user.
84+
$filescount = $DB->count_records('publication_file', [
85+
'publication' => $publication->get_instance()->id,
86+
'userid' => $groupid,
87+
]);
88+
if ($filescount > 0) {
89+
$status = COMPLETION_COMPLETE;
90+
break;
91+
}
92+
}
93+
}
5994
}
60-
return $status ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
95+
return $status;
6196
}
6297

6398
/**
@@ -66,7 +101,7 @@ public function get_state(string $rule): int {
66101
* @return array
67102
*/
68103
public static function get_defined_custom_rules(): array {
69-
return ['completionupload'];
104+
return ['completionupload', 'completionassignsubmission'];
70105
}
71106

72107
/**
@@ -77,6 +112,7 @@ public static function get_defined_custom_rules(): array {
77112
public function get_custom_rule_descriptions(): array {
78113
return [
79114
'completionupload' => get_string('completiondetail:upload', 'publication'),
115+
'completionassignsubmission' => get_string('completiondetail:assignsubmission', 'publication'),
80116
];
81117
}
82118

@@ -89,6 +125,7 @@ public function get_sort_order(): array {
89125
return [
90126
'completionview',
91127
'completionupload',
128+
'completionassignsubmission',
92129
];
93130
}
94131
}

0 commit comments

Comments
 (0)