Skip to content
Permalink
Browse files
Merge branch 'MDL-59758-master' of git://github.com/damyon/moodle
  • Loading branch information
David Monllao committed Nov 7, 2017
2 parents 5243e93 + a6943eb commit cae37299f321bba6a48141c7448565a861ca9883
@@ -159,3 +159,7 @@ privacy,core_hub
privacy_help,core_hub
configloginhttps,core_admin
loginhttps,core_admin
groupaddnewnote,core_notes
selectnotestate,core_notes
extendenrol,core
groupextendenrol,core
@@ -111,6 +111,10 @@
$string['sendingvia'] = 'Sending "{$a->provider}" via "{$a->processor}"';
$string['sendingviawhen'] = 'Sending "{$a->provider}" via "{$a->processor}" when {$a->state}';
$string['sendmessage'] = 'Send message';
$string['sendbulkmessage'] = 'Send message to {$a} people';
$string['sendbulkmessagesingle'] = 'Send message to 1 person';
$string['sendbulkmessagesent'] = 'Message sent to {$a} people';
$string['sendbulkmessagesentsingle'] = 'Message sent to 1 person';
$string['sendmessageto'] = 'Send message to {$a}';
$string['sendmessagetopopup'] = 'Send message to {$a} - new window';
$string['settings'] = 'Settings';
@@ -793,7 +793,6 @@
$string['expandall'] = 'Expand all';
$string['expandcategory'] = 'Expand {$a}';
$string['explanation'] = 'Explanation';
$string['extendenrol'] = 'Extend enrolment (individual)';
$string['extendperiod'] = 'Extended period';
$string['failedloginattempts'] = '{$a->attempts} failed logins since your last login';
$string['feedback'] = 'Feedback';
@@ -904,7 +903,6 @@
$string['group'] = 'Group';
$string['groupadd'] = 'Add new group';
$string['groupaddusers'] = 'Add selected to group';
$string['groupextendenrol'] = 'Extend enrolment (common)';
$string['groupfor'] = 'for group';
$string['groupinfo'] = 'Info about selected group';
$string['groupinfoedit'] = 'Edit group settings';
@@ -2165,3 +2163,5 @@

// Deprecated since Moodle 3.4.
$string['publish'] = 'Publish';
$string['extendenrol'] = 'Extend enrolment (individual)';
$string['groupextendenrol'] = 'Extend enrolment (common)';
@@ -24,6 +24,10 @@
*/

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

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

Some generated files are not rendered by default. Learn more.

@@ -42,6 +42,7 @@ define(['jquery'], function($) {
*/
var calculateRows = function(element) {
var currentRows = element.attr('rows');
var minRows = element.data('min-rows');
var maxRows = element.attr('data-max-rows');

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

if (maxRows && rows >= maxRows) {
if (rows < minRows) {
return minRows;
} else if (maxRows && rows >= maxRows) {
return maxRows;
} else {
return rows;
}
};

/**
* Listener for change events to trigger resizing of the element.
*
* @method changeListener
* @param {Event} e The triggered event.
* @private
*/
var changeListener = function(e) {
var element = $(e.target);
var minRows = element.data('min-rows');
var currentRows = element.attr('rows');

if (typeof minRows === "undefined") {
element.data('min-rows', currentRows);
}
var rows = calculateRows(element);

if (rows != currentRows) {
element.attr('rows', rows);
element.trigger(EVENTS.ROW_CHANGE);
}
};

/**
* Add the event listeners for all text areas within the given element.
*
@@ -73,16 +99,11 @@ define(['jquery'], function($) {
* @public
*/
var init = function(root) {
$(root).on('input propertychange', SELECTORS.ELEMENT, function(e) {
var element = $(e.target);
var currentRows = element.attr('rows');
var rows = calculateRows(element);

if (rows != currentRows) {
element.attr('rows', rows);
$(root).trigger(EVENTS.ROW_CHANGE);
}
});
if ($(root).data('auto-rows')) {
$(root).on('input propertychange', changeListener.bind(this));
} else {
$(root).on('input propertychange', SELECTORS.ELEMENT, changeListener.bind(this));
}
};

return /** @module core/auto_rows */ {
@@ -1034,6 +1034,7 @@
'classpath' => 'notes/externallib.php',
'description' => 'Create notes',
'type' => 'write',
'ajax' => true,
'capabilities' => 'moodle/notes:manage',
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
),
@@ -113,6 +113,11 @@ function note_save(&$note) {
if (empty($note->publishstate)) {
$note->publishstate = NOTES_STATE_PUBLIC;
}

if (empty(trim($note->content))) {
// Don't save empty notes.
return false;
}
// Save data.
if (empty($note->id)) {
// Insert new note.
@@ -1,4 +1,4 @@
@core @core_notes
@core @core_notes @javascript
Feature: Add notes to course participants
In order to share information with other staff
As a teacher
@@ -34,15 +34,19 @@ Feature: Add notes to course participants
And I am on "Course 1" course homepage
And I follow "Participants"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "1"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to "Student 1 needs to pick up his game"
And I press "Add a new note to 1 person"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "0"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "1"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to ""
And I press "Add a new note to 1 person"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "0"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 3')]//input[@type='checkbox']" to "1"
And I set the field "With selected users..." to "Add a new note"
And I press "OK"
# Add a note to student 1, but leave student 2 empty and student 3 with space.
When I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//textarea" to "Student 1 needs to pick up his game"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//textarea" to ""
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 3')]//textarea" to " "
And I press "Save changes"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to " "
And I press "Add a new note to 1 person"
And I follow "Student 1"
And I follow "Notes"
# Student 1 has note from Teacher
@@ -25,6 +25,7 @@

require('../../config.php');
require_once($CFG->dirroot.'/lib/tablelib.php');
require_once($CFG->dirroot.'/notes/lib.php');
require_once($CFG->dirroot.'/report/participation/locallib.php');

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

if (!empty($CFG->messaging)) {
echo '<form action="'.$CFG->wwwroot.'/user/action_redir.php" method="post" id="studentsform">'."\n";
echo '<form action="'.$CFG->wwwroot.'/user/action_redir.php" method="post" id="participantsform">'."\n";
echo '<div>'."\n";
echo '<input type="hidden" name="id" value="'.$id.'" />'."\n";
echo '<input type="hidden" name="returnto" value="'. s($PAGE->url) .'" />'."\n";
@@ -372,23 +373,25 @@
if (!empty($CFG->messaging)) {
$buttonclasses = 'btn btn-secondary';
echo '<div class="selectbuttons btn-group">';
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" class="'. $buttonclasses .'"> '."\n";
echo '<input type="button" id="checkallonpage" value="'.get_string('selectall').'" class="'. $buttonclasses .'"> '."\n";
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" class="'. $buttonclasses .'"> '."\n";
if ($perpage >= $matchcount) {
echo '<input type="button" id="checknos" value="'.get_string('selectnos').'" class="'. $buttonclasses .'">'."\n";
echo '<input type="button" id="checkallnos" value="'.get_string('selectnos').'" class="'. $buttonclasses .'">'."\n";
}
echo '</div>';
echo '<div class="p-y-1">';
echo html_writer::label(get_string('withselectedusers'), 'formactionselect');
$displaylist['messageselect.php'] = get_string('messageselectadd');
echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionselect'));
echo $OUTPUT->help_icon('withselectedusers');
echo '<input type="submit" value="' . get_string('ok') . '" class="'. $buttonclasses .'"/>'."\n";
$displaylist['#messageselect'] = get_string('messageselectadd');
echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid'));
echo '</div>';
echo '</div>'."\n";
echo '</form>'."\n";

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

This file was deleted.

@@ -46,12 +46,8 @@ Feature: Use the particiaption report to message groups of students
And I should see "No" in the "Student 2" "table_row"
And I should see "No" in the "Student 3" "table_row"
When I press "Select all 'No'"
And I set the field "With selected users..." to "Send a message"
And I press "OK"
Then I should see "Added 2 new recipients"
And I should see "Student 2" in the "Currently selected users" "table"
And I should see "Student 3" in the "Currently selected users" "table"
And I should not see "Student 1" in the "Currently selected users" "table"
And I choose "Send a message" from the participants page bulk action menu
Then I should see "Send message to 2 people"

Scenario: Ensure no message options when messaging is disabled
Given I log in as "admin"
@@ -30,13 +30,8 @@
$PAGE->set_url('/user/action_redir.php', array('formaction' => $formaction, 'id' => $id));
list($formaction) = explode('?', $formaction, 2);

// Add every page will be redirected by this script.
$actions = array(
'messageselect.php',
'addnote.php',
'groupaddnote.php',
'bulkchange.php'
);
// This page now only handles the bulk enrolment change actions, other actions are done with ajax.
$actions = array('bulkchange.php');

if (array_search($formaction, $actions) === false) {
print_error('unknownuseraction');
@@ -175,5 +170,5 @@
exit();

} else {
require_once($formaction);
throw new coding_exception('invalidaction');
}

0 comments on commit cae3729

Please sign in to comment.