Skip to content

Commit cae3729

Browse files
author
David Monllao
committed
Merge branch 'MDL-59758-master' of git://github.com/damyon/moodle
2 parents 5243e93 + a6943eb commit cae3729

File tree

23 files changed

+573
-483
lines changed

23 files changed

+573
-483
lines changed

lang/en/deprecated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ privacy,core_hub
159159
privacy_help,core_hub
160160
configloginhttps,core_admin
161161
loginhttps,core_admin
162+
groupaddnewnote,core_notes
163+
selectnotestate,core_notes
164+
extendenrol,core
165+
groupextendenrol,core

lang/en/message.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@
111111
$string['sendingvia'] = 'Sending "{$a->provider}" via "{$a->processor}"';
112112
$string['sendingviawhen'] = 'Sending "{$a->provider}" via "{$a->processor}" when {$a->state}';
113113
$string['sendmessage'] = 'Send message';
114+
$string['sendbulkmessage'] = 'Send message to {$a} people';
115+
$string['sendbulkmessagesingle'] = 'Send message to 1 person';
116+
$string['sendbulkmessagesent'] = 'Message sent to {$a} people';
117+
$string['sendbulkmessagesentsingle'] = 'Message sent to 1 person';
114118
$string['sendmessageto'] = 'Send message to {$a}';
115119
$string['sendmessagetopopup'] = 'Send message to {$a} - new window';
116120
$string['settings'] = 'Settings';

lang/en/moodle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@
793793
$string['expandall'] = 'Expand all';
794794
$string['expandcategory'] = 'Expand {$a}';
795795
$string['explanation'] = 'Explanation';
796-
$string['extendenrol'] = 'Extend enrolment (individual)';
797796
$string['extendperiod'] = 'Extended period';
798797
$string['failedloginattempts'] = '{$a->attempts} failed logins since your last login';
799798
$string['feedback'] = 'Feedback';
@@ -904,7 +903,6 @@
904903
$string['group'] = 'Group';
905904
$string['groupadd'] = 'Add new group';
906905
$string['groupaddusers'] = 'Add selected to group';
907-
$string['groupextendenrol'] = 'Extend enrolment (common)';
908906
$string['groupfor'] = 'for group';
909907
$string['groupinfo'] = 'Info about selected group';
910908
$string['groupinfoedit'] = 'Edit group settings';
@@ -2165,3 +2163,5 @@
21652163

21662164
// Deprecated since Moodle 3.4.
21672165
$string['publish'] = 'Publish';
2166+
$string['extendenrol'] = 'Extend enrolment (individual)';
2167+
$string['groupextendenrol'] = 'Extend enrolment (common)';

lang/en/notes.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
*/
2525

2626
$string['addnewnote'] = 'Add a new note';
27+
$string['addbulknote'] = 'Add a new note to {$a} people';
28+
$string['addbulknotesingle'] = 'Add a new note to 1 person';
29+
$string['addbulknotedone'] = 'Note added to {$a} people';
30+
$string['addbulknotedonesingle'] = 'Note added to 1 person';
2731
$string['addnewnoteselect'] = 'Select users to write notes about';
2832
$string['bynameondate'] = 'by {$a->name} - {$a->date}';
2933
$string['configenablenotes'] = 'Enable storing of notes about individual users.';
@@ -39,7 +43,6 @@
3943
$string['eventnoteupdated'] = 'Note updated';
4044
$string['eventnotedeleted'] = 'Note deleted';
4145
$string['eventnotesviewed'] = 'Notes viewed';
42-
$string['groupaddnewnote'] = 'Add a common note';
4346
$string['invalidid'] = 'Invalid note ID specified';
4447
$string['invaliduserid'] = 'Invalid user id: {$a}';
4548
$string['myprofileownnotes'] = 'My notes';
@@ -61,8 +64,10 @@
6164
* Personal - The note will be visible only to you
6265
* Course - The note will be visible to teachers in this course
6366
* Site - The note will be visible to teachers in all courses';
64-
$string['selectnotestate'] = "Select note state";
6567
$string['site'] = 'site';
6668
$string['sitenotes'] = 'Site notes';
6769
$string['unknown'] = 'unknown';
6870

71+
// Deprecated since Moodle 3.4
72+
$string['groupaddnewnote'] = 'Add a common note';
73+
$string['selectnotestate'] = "Select note state";

lib/amd/build/auto_rows.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/amd/src/auto_rows.js

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ define(['jquery'], function($) {
4242
*/
4343
var calculateRows = function(element) {
4444
var currentRows = element.attr('rows');
45+
var minRows = element.data('min-rows');
4546
var maxRows = element.attr('data-max-rows');
4647

4748
var height = element.height();
@@ -58,13 +59,38 @@ define(['jquery'], function($) {
5859
// based on the row attribute.
5960
element.css('height', '');
6061

61-
if (maxRows && rows >= maxRows) {
62+
if (rows < minRows) {
63+
return minRows;
64+
} else if (maxRows && rows >= maxRows) {
6265
return maxRows;
6366
} else {
6467
return rows;
6568
}
6669
};
6770

71+
/**
72+
* Listener for change events to trigger resizing of the element.
73+
*
74+
* @method changeListener
75+
* @param {Event} e The triggered event.
76+
* @private
77+
*/
78+
var changeListener = function(e) {
79+
var element = $(e.target);
80+
var minRows = element.data('min-rows');
81+
var currentRows = element.attr('rows');
82+
83+
if (typeof minRows === "undefined") {
84+
element.data('min-rows', currentRows);
85+
}
86+
var rows = calculateRows(element);
87+
88+
if (rows != currentRows) {
89+
element.attr('rows', rows);
90+
element.trigger(EVENTS.ROW_CHANGE);
91+
}
92+
};
93+
6894
/**
6995
* Add the event listeners for all text areas within the given element.
7096
*
@@ -73,16 +99,11 @@ define(['jquery'], function($) {
7399
* @public
74100
*/
75101
var init = function(root) {
76-
$(root).on('input propertychange', SELECTORS.ELEMENT, function(e) {
77-
var element = $(e.target);
78-
var currentRows = element.attr('rows');
79-
var rows = calculateRows(element);
80-
81-
if (rows != currentRows) {
82-
element.attr('rows', rows);
83-
$(root).trigger(EVENTS.ROW_CHANGE);
84-
}
85-
});
102+
if ($(root).data('auto-rows')) {
103+
$(root).on('input propertychange', changeListener.bind(this));
104+
} else {
105+
$(root).on('input propertychange', SELECTORS.ELEMENT, changeListener.bind(this));
106+
}
86107
};
87108

88109
return /** @module core/auto_rows */ {

lib/db/services.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,7 @@
10341034
'classpath' => 'notes/externallib.php',
10351035
'description' => 'Create notes',
10361036
'type' => 'write',
1037+
'ajax' => true,
10371038
'capabilities' => 'moodle/notes:manage',
10381039
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
10391040
),

notes/lib.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ function note_save(&$note) {
113113
if (empty($note->publishstate)) {
114114
$note->publishstate = NOTES_STATE_PUBLIC;
115115
}
116+
117+
if (empty(trim($note->content))) {
118+
// Don't save empty notes.
119+
return false;
120+
}
116121
// Save data.
117122
if (empty($note->id)) {
118123
// Insert new note.

notes/tests/behat/participants_notes.feature

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@core @core_notes
1+
@core @core_notes @javascript
22
Feature: Add notes to course participants
33
In order to share information with other staff
44
As a teacher
@@ -34,15 +34,19 @@ Feature: Add notes to course participants
3434
And I am on "Course 1" course homepage
3535
And I follow "Participants"
3636
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "1"
37+
And I choose "Add a new note" from the participants page bulk action menu
38+
And I set the field "bulk-note" to "Student 1 needs to pick up his game"
39+
And I press "Add a new note to 1 person"
40+
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "0"
3741
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "1"
42+
And I choose "Add a new note" from the participants page bulk action menu
43+
And I set the field "bulk-note" to ""
44+
And I press "Add a new note to 1 person"
45+
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "0"
3846
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 3')]//input[@type='checkbox']" to "1"
39-
And I set the field "With selected users..." to "Add a new note"
40-
And I press "OK"
41-
# Add a note to student 1, but leave student 2 empty and student 3 with space.
42-
When I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//textarea" to "Student 1 needs to pick up his game"
43-
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//textarea" to ""
44-
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 3')]//textarea" to " "
45-
And I press "Save changes"
47+
And I choose "Add a new note" from the participants page bulk action menu
48+
And I set the field "bulk-note" to " "
49+
And I press "Add a new note to 1 person"
4650
And I follow "Student 1"
4751
And I follow "Notes"
4852
# Student 1 has note from Teacher

report/participation/index.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
require('../../config.php');
2727
require_once($CFG->dirroot.'/lib/tablelib.php');
28+
require_once($CFG->dirroot.'/notes/lib.php');
2829
require_once($CFG->dirroot.'/report/participation/locallib.php');
2930

3031
define('DEFAULT_PAGE_SIZE', 20);
@@ -336,7 +337,7 @@
336337
echo '<h2>'.get_string('counteditems', '', $a).'</h2>'."\n";
337338

338339
if (!empty($CFG->messaging)) {
339-
echo '<form action="'.$CFG->wwwroot.'/user/action_redir.php" method="post" id="studentsform">'."\n";
340+
echo '<form action="'.$CFG->wwwroot.'/user/action_redir.php" method="post" id="participantsform">'."\n";
340341
echo '<div>'."\n";
341342
echo '<input type="hidden" name="id" value="'.$id.'" />'."\n";
342343
echo '<input type="hidden" name="returnto" value="'. s($PAGE->url) .'" />'."\n";
@@ -372,23 +373,25 @@
372373
if (!empty($CFG->messaging)) {
373374
$buttonclasses = 'btn btn-secondary';
374375
echo '<div class="selectbuttons btn-group">';
375-
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" class="'. $buttonclasses .'"> '."\n";
376+
echo '<input type="button" id="checkallonpage" value="'.get_string('selectall').'" class="'. $buttonclasses .'"> '."\n";
376377
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" class="'. $buttonclasses .'"> '."\n";
377378
if ($perpage >= $matchcount) {
378-
echo '<input type="button" id="checknos" value="'.get_string('selectnos').'" class="'. $buttonclasses .'">'."\n";
379+
echo '<input type="button" id="checkallnos" value="'.get_string('selectnos').'" class="'. $buttonclasses .'">'."\n";
379380
}
380381
echo '</div>';
381382
echo '<div class="p-y-1">';
382383
echo html_writer::label(get_string('withselectedusers'), 'formactionselect');
383-
$displaylist['messageselect.php'] = get_string('messageselectadd');
384-
echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionselect'));
385-
echo $OUTPUT->help_icon('withselectedusers');
386-
echo '<input type="submit" value="' . get_string('ok') . '" class="'. $buttonclasses .'"/>'."\n";
384+
$displaylist['#messageselect'] = get_string('messageselectadd');
385+
echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid'));
387386
echo '</div>';
388387
echo '</div>'."\n";
389388
echo '</form>'."\n";
390389

391-
$PAGE->requires->js_init_call('M.report_participation.init');
390+
$options = new stdClass();
391+
$options->courseid = $course->id;
392+
$options->noteStateNames = note_get_state_names();
393+
$options->stateHelpIcon = $OUTPUT->help_icon('publishstate', 'notes');
394+
$PAGE->requires->js_call_amd('core_user/participants', 'init', [$options]);
392395
}
393396
echo '</div>'."\n";
394397
}

0 commit comments

Comments
 (0)