Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #65 from moodlehq/backport-core-33
Browse files Browse the repository at this point in the history
Backport core 3.3
  • Loading branch information
sarjona authored Sep 7, 2018
2 parents baf9bf8 + bde59b6 commit 9166321
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 58 deletions.
2 changes: 1 addition & 1 deletion amd/build/policyactions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 43 additions & 31 deletions amd/src/policyactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,55 @@ function($, Ajax, Notification, ModalFactory, ModalEvents) {
args: params
};

var modalTitle = $.Deferred();
var modalBody = $.Deferred();

var modal = ModalFactory.create({
title: modalTitle,
body: modalBody,
large: true
})
.then(function(modal) {
// Handle hidden event.
modal.getRoot().on(ModalEvents.hidden, function() {
// Destroy when hidden.
modal.destroy();
});

return modal;
})
.then(function(modal) {
modal.show();

return modal;
})
.catch(Notification.exception);

// Make the request now that the modal is configured.
var promises = Ajax.call([request]);
var modalTitle = '';
var modalType = ModalFactory.types.DEFAULT;
$.when(promises[0]).then(function(data) {
if (data.result.policy) {
modalTitle = data.result.policy.name;
return data.result.policy.content;
modalTitle.resolve(data.result.policy.name);
modalBody.resolve(data.result.policy.content);

return data;
} else {
throw new Error(data.warnings[0].message);
}
// Fail.
Notification.addNotification({
message: data.warnings[0].message,
}).catch(function(message) {
modal.then(function(modal) {
modal.hide();
modal.destroy();

return modal;
})
.catch(Notification.exception);

return Notification.addNotification({
message: message,
type: 'error'
});
return false;

}).then(function(html) {
if (html != false) {
return ModalFactory.create({
title: modalTitle,
body: html,
type: modalType,
large: true
}).then(function(modal) {
// Handle hidden event.
modal.getRoot().on(ModalEvents.hidden, function() {
// Destroy when hidden.
modal.destroy();
});

return modal;
});
}
return false;
}).done(function(modal) {
// Show the modal.
modal.show();
}).fail(Notification.exception);
});
});

};
Expand Down
10 changes: 6 additions & 4 deletions classes/form/accept_policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ public function definition() {

$mform->addElement('hidden', 'returnurl');
$mform->setType('returnurl', PARAM_LOCALURL);

$mform->addElement('static', 'user', get_string('acceptanceusers', 'tool_policy'), join(', ', $usernames));
$mform->addElement('static', 'policy', get_string('acceptancepolicies', 'tool_policy'),
join(', ', $versionnames));
$useracceptancelabel = (count($usernames) > 1) ? get_string('acceptanceusers', 'tool_policy') :
get_string('user');
$mform->addElement('static', 'user', $useracceptancelabel, join(', ', $usernames));
$policyacceptancelabel = (count($versionnames) > 1) ? get_string('acceptancepolicies', 'tool_policy') :
get_string('policydochdrpolicy', 'tool_policy');
$mform->addElement('static', 'policy', $policyacceptancelabel, join(', ', $versionnames));

if ($revoke) {
$mform->addElement('static', 'ack', '', get_string('revokeacknowledgement', 'tool_policy'));
Expand Down
8 changes: 4 additions & 4 deletions lang/en/tool_policy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

defined('MOODLE_INTERNAL') || die();

$string['acceptanceacknowledgement'] = 'I acknowledge that I have received a request to give consent on behalf of user(s).';
$string['acceptanceacknowledgement'] = 'I acknowledge that I have received a request to give consent on behalf of the above user(s).';
$string['acceptancecount'] = '{$a->agreedcount} of {$a->policiescount}';
$string['acceptancenote'] = 'Remarks';
$string['acceptancepolicies'] = 'Policies';
Expand All @@ -52,7 +52,7 @@
$string['agreepolicies'] = 'Please agree to the following policies';
$string['backtotop'] = 'Back to top';
$string['consentbulk'] = 'Consent';
$string['consentdetails'] = 'Give consent on behalf of user';
$string['consentdetails'] = 'Give consent on behalf of user(s)';
$string['consentpagetitle'] = 'Consent';
$string['contactdpo'] = 'For any questions about the policies please contact the privacy officer.';
$string['dataproc'] = 'Personal data processing';
Expand All @@ -77,7 +77,7 @@
$string['guestconsent:continue'] = 'Continue';
$string['guestconsentmessage'] = 'If you continue browsing this website, you agree to our policies:';
$string['iagree'] = 'I agree to the {$a}';
$string['iagreetothepolicy'] = 'Give consent on behalf of user';
$string['iagreetothepolicy'] = 'Give consent';
$string['inactivate'] = 'Set status to "Inactive"';
$string['inactivating'] = 'Inactivating a policy';
$string['inactivatingconfirm'] = '<p>You are about to inactivate policy <em>\'{$a->name}\'</em> version <em>\'{$a->revision}\'</em>.</p>';
Expand Down Expand Up @@ -158,7 +158,7 @@
$string['privacysettings'] = 'Privacy settings';
$string['readpolicy'] = 'Please read our {$a}';
$string['refertofullpolicytext'] = 'Please refer to the full {$a} if you would like to review the text.';
$string['revokeacknowledgement'] = 'I acknowledge that I have received a request to withdraw consent on behalf of user(s).';
$string['revokeacknowledgement'] = 'I acknowledge that I have received a request to withdraw consent on behalf of the above user(s).';
$string['revokedetails'] = 'Withdraw user consent';
$string['save'] = 'Save';
$string['saveasdraft'] = 'Save as draft';
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
z-index: 9999999;
}

.behat-site .eupopup-container-bottom {
position: relative;
}

.eupopup-container-bottom {
position: fixed;
bottom: 0;
Expand Down
30 changes: 15 additions & 15 deletions tests/behat/acceptances.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Consent not given" "link" in the "User One" "table_row"
Then I should see "Give consent on behalf of user"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of user(s)."
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent on behalf of user"
And I press "Give consent"
And "Consent given on behalf of user" "icon" should exist in the "User One" "table_row"
And "Max Manager" "link" should exist in the "User One" "table_row"
And "Consent received from a parent" "text" should exist in the "User One" "table_row"
Expand All @@ -84,12 +84,12 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Consent not given" "link" in the "User One" "table_row"
Then I should see "Give consent on behalf of user"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of user(s)."
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent on behalf of user"
And I press "Give consent"
And "Consent given on behalf of user" "icon" should exist in the "User One" "table_row"
And "Max Manager" "link" should exist in the "User One" "table_row"
And "Consent received from a parent" "text" should exist in the "User One" "table_row"
Expand Down Expand Up @@ -151,12 +151,12 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Consent not given; click to give consent on behalf of user for This site policy" "link" in the "User One" "table_row"
Then I should see "Give consent on behalf of user"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of user(s)."
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent on behalf of user"
And I press "Give consent"
And "Consent given on behalf of user" "icon" should exist in the "User One" "table_row"
And "Consent not given; click to give consent on behalf of user for This privacy policy" "icon" should exist in the "User One" "table_row"
And I click on "1 of 2" "link" in the "User One" "table_row"
Expand Down Expand Up @@ -184,12 +184,12 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I press "Next"
And I navigate to "Users > Privacy and policies > User agreements" in site administration
And I click on "Consent not given; click to give consent on behalf of user for This site policy" "link" in the "User One" "table_row"
Then I should see "Give consent on behalf of user"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of user(s)."
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent on behalf of user"
And I press "Give consent"
And "Consent given on behalf of user" "icon" should exist in the "User One" "table_row"
And "Consent not given; click to give consent on behalf of user for This privacy policy" "icon" should exist in the "User One" "table_row"
And I click on "1 of 2" "link" in the "User One" "table_row"
Expand Down Expand Up @@ -249,12 +249,12 @@ Feature: Viewing acceptances reports and accepting on behalf of other users
And I navigate to "Users > Privacy and policies > Manage policies" in site administration
And I click on "1 of 4 (25%)" "link" in the "This site policy" "table_row"
And I click on "Consent not given" "link" in the "User One" "table_row"
Then I should see "Give consent on behalf of user"
Then I should see "Give consent"
And I should see "User One"
And I should see "This site policy"
And I should see "I acknowledge that I have received a request to give consent on behalf of user(s)."
And I should see "I acknowledge that I have received a request to give consent on behalf of the above user(s)."
And I set the field "Remarks" to "Consent received from a parent"
And I press "Give consent on behalf of user"
And I press "Give consent"
And "Consent given on behalf of user" "icon" should exist in the "User One" "table_row"
And "Max Manager" "link" should not exist in the "User One" "table_row"
And "Admin User" "link" should exist in the "User One" "table_row"
Expand Down
5 changes: 2 additions & 3 deletions tests/behat/consent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ Feature: User must accept policy managed by this plugin when logging in and sign
| This privacy policy | 1 | | full text3 | short text3 | active | loggedin |
| This guests policy | 0 | | full text4 | short text4 | active | guest |
And I am on site homepage
And I change window size to "large"
And I follow "Log in"
When I press "Log in as a guest"
Then I should see "If you continue browsing this website, you agree to our policies"
Expand All @@ -473,11 +472,11 @@ Feature: User must accept policy managed by this plugin when logging in and sign
# Confirm when clicking on the policy links, the policy content is displayed.
When I click on "This site policy" "link"
Then I should see "full text2"
And I click on "×" "button"
And I click on ".close" "css_element"
And I should not see "full text2"
When I click on "This guests policy" "link"
Then I should see "full text4"
And I click on "×" "button"
And I click on ".close" "css_element"
And I should not see "full text4"
# Confirm when agreeing to policies the pop-up is no longer displayed.
When I follow "Continue"
Expand Down

0 comments on commit 9166321

Please sign in to comment.