diff --git a/lib/amd/build/userfeedback.min.js b/lib/amd/build/userfeedback.min.js
index 3eee54bf623..03f8faf3389 100644
--- a/lib/amd/build/userfeedback.min.js
+++ b/lib/amd/build/userfeedback.min.js
@@ -1,2 +1,2 @@
-define ("core/userfeedback",["exports","core/ajax","core/notification"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=void 0;b=d(b);c=d(c);function d(a){return a&&a.__esModule?a:{default:a}}var f={regions:{root:"[data-region=\"core/userfeedback\"]"},actions:{}};f.actions.give="".concat(f.regions.root," [data-action=\"give\"]");f.actions.remind="".concat(f.regions.root," [data-action=\"remind\"]");a.registerEventListeners=function registerEventListeners(){document.addEventListener("click",function(a){var b=a.target.closest(f.actions.give);if(b){a.preventDefault();g().then(function(){return i(b)}).then(h).catch(c.default.exception)}var d=a.target.closest(f.actions.remind);if(d){a.preventDefault();Promise.resolve(d).then(i).then(h).catch(c.default.exception)}})};var g=function(){return b.default.call([{methodname:"core_get_userfeedback_url",args:{contextid:M.cfg.contextid}}])[0].then(function(a){if(!window.open(a)){throw new Error("Unable to open popup")}})},h=function(a){if(a.dataset.record){return b.default.call([{methodname:"core_create_userfeedback_action_record",args:{action:a.dataset.action,contextid:M.cfg.contextid}}])[0]}return Promise.resolve()},i=function(a){if(a.dataset.hide){a.closest(f.regions.root).remove()}return a}});
+define ("core/userfeedback",["exports","core/ajax","core/notification"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=void 0;b=d(b);c=d(c);function d(a){return a&&a.__esModule?a:{default:a}}var f={regions:{root:"[data-region=\"core/userfeedback\"]"},actions:{}};f.actions.give="".concat(f.regions.root," [data-action=\"give\"]");f.actions.remind="".concat(f.regions.root," [data-action=\"remind\"]");a.registerEventListeners=function registerEventListeners(){document.addEventListener("click",function(a){var b=a.target.closest(f.actions.give);if(b){a.preventDefault();if(!window.open(b.href)){throw new Error("Unable to open popup")}Promise.resolve(b).then(h).then(g).catch(c.default.exception)}var d=a.target.closest(f.actions.remind);if(d){a.preventDefault();Promise.resolve(d).then(h).then(g).catch(c.default.exception)}})};var g=function(a){if(a.dataset.record){return b.default.call([{methodname:"core_create_userfeedback_action_record",args:{action:a.dataset.action,contextid:M.cfg.contextid}}])[0]}return Promise.resolve()},h=function(a){if(a.dataset.hide){a.closest(f.regions.root).remove()}return a}});
//# sourceMappingURL=userfeedback.min.js.map
diff --git a/lib/amd/build/userfeedback.min.js.map b/lib/amd/build/userfeedback.min.js.map
index 2a4225f3097..71fb5b65041 100644
--- a/lib/amd/build/userfeedback.min.js.map
+++ b/lib/amd/build/userfeedback.min.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/userfeedback.js"],"names":["Selectors","regions","root","actions","give","remind","registerEventListeners","document","addEventListener","e","giveAction","target","closest","preventDefault","giveFeedback","then","hideRoot","recordAction","catch","Notification","exception","remindAction","Promise","resolve","Ajax","call","methodname","args","contextid","M","cfg","url","window","open","Error","clickedItem","dataset","record","action","hide","remove"],"mappings":"sLAuBA,OACA,O,mDAEA,GAAMA,CAAAA,CAAS,CAAG,CACdC,OAAO,CAAE,CACLC,IAAI,CAAE,qCADD,CADK,CAIdC,OAAO,CAAE,EAJK,CAAlB,CAMAH,CAAS,CAACG,OAAV,CAAkBC,IAAlB,WAA4BJ,CAAS,CAACC,OAAV,CAAkBC,IAA9C,4BACAF,CAAS,CAACG,OAAV,CAAkBE,MAAlB,WAA8BL,CAAS,CAACC,OAAV,CAAkBC,IAAhD,8B,yBAKsC,QAAzBI,CAAAA,sBAAyB,EAAM,CACxCC,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,CAAmC,SAAAC,CAAC,CAAI,CACpC,GAAMC,CAAAA,CAAU,CAAGD,CAAC,CAACE,MAAF,CAASC,OAAT,CAAiBZ,CAAS,CAACG,OAAV,CAAkBC,IAAnC,CAAnB,CACA,GAAIM,CAAJ,CAAgB,CACZD,CAAC,CAACI,cAAF,GAEAC,CAAY,GACPC,IADL,CACU,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AAZ,CAAoBG,IAAxB,CAA8B,CAC1BJ,CAAW,CAACvB,OAAZ,CAAoBZ,CAAS,CAACC,OAAV,CAAkBC,IAAtC,EAA4CsC,MAA5C,EACH,CAED,MAAOL,CAAAA,CACV,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle clicking on action links of the feedback alert.\n *\n * @module core/cta_feedback\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\nconst Selectors = {\n regions: {\n root: '[data-region=\"core/userfeedback\"]',\n },\n actions: {},\n};\nSelectors.actions.give = `${Selectors.regions.root} [data-action=\"give\"]`;\nSelectors.actions.remind = `${Selectors.regions.root} [data-action=\"remind\"]`;\n\n/**\n * Attach the necessary event handlers to the action links\n */\nexport const registerEventListeners = () => {\n document.addEventListener('click', e => {\n const giveAction = e.target.closest(Selectors.actions.give);\n if (giveAction) {\n e.preventDefault();\n\n giveFeedback()\n .then(() => hideRoot(giveAction))\n .then(recordAction)\n .catch(Notification.exception);\n }\n\n const remindAction = e.target.closest(Selectors.actions.remind);\n if (remindAction) {\n e.preventDefault();\n\n Promise.resolve(remindAction)\n .then(hideRoot)\n .then(recordAction)\n .catch(Notification.exception);\n }\n });\n};\n\n/**\n * The action function that is called when users choose to give feedback.\n *\n * @returns {Promise}\n */\nconst giveFeedback = () => {\n return Ajax.call([{\n methodname: 'core_get_userfeedback_url',\n args: {\n contextid: M.cfg.contextid,\n }\n }])[0]\n .then(url => {\n if (!window.open(url)) {\n throw new Error('Unable to open popup');\n }\n return;\n });\n};\n\n/**\n * Record the action that the user took.\n *\n * @param {HTMLElement} clickedItem The action element that the user chose.\n * @returns {Promise}\n */\nconst recordAction = clickedItem => {\n if (clickedItem.dataset.record) {\n return Ajax.call([{\n methodname: 'core_create_userfeedback_action_record',\n args: {\n action: clickedItem.dataset.action,\n contextid: M.cfg.contextid,\n }\n }])[0];\n }\n\n return Promise.resolve();\n};\n\n/**\n * Hide the root node of the CTA notification.\n *\n * @param {HTMLElement} clickedItem The action element that the user chose.\n * @returns {HTMLElement}\n */\nconst hideRoot = clickedItem => {\n if (clickedItem.dataset.hide) {\n clickedItem.closest(Selectors.regions.root).remove();\n }\n\n return clickedItem;\n};\n"],"file":"userfeedback.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/userfeedback.js"],"names":["Selectors","regions","root","actions","give","remind","registerEventListeners","document","addEventListener","e","giveAction","target","closest","preventDefault","window","open","href","Error","Promise","resolve","then","hideRoot","recordAction","catch","Notification","exception","remindAction","clickedItem","dataset","record","Ajax","call","methodname","args","action","contextid","M","cfg","hide","remove"],"mappings":"sLAuBA,OACA,O,mDAEA,GAAMA,CAAAA,CAAS,CAAG,CACdC,OAAO,CAAE,CACLC,IAAI,CAAE,qCADD,CADK,CAIdC,OAAO,CAAE,EAJK,CAAlB,CAMAH,CAAS,CAACG,OAAV,CAAkBC,IAAlB,WAA4BJ,CAAS,CAACC,OAAV,CAAkBC,IAA9C,4BACAF,CAAS,CAACG,OAAV,CAAkBE,MAAlB,WAA8BL,CAAS,CAACC,OAAV,CAAkBC,IAAhD,8B,yBAKsC,QAAzBI,CAAAA,sBAAyB,EAAM,CACxCC,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,CAAmC,SAAAC,CAAC,CAAI,CACpC,GAAMC,CAAAA,CAAU,CAAGD,CAAC,CAACE,MAAF,CAASC,OAAT,CAAiBZ,CAAS,CAACG,OAAV,CAAkBC,IAAnC,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["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle clicking on action links of the feedback alert.\n *\n * @module core/cta_feedback\n * @copyright 2020 Shamim Rezaie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\nconst Selectors = {\n regions: {\n root: '[data-region=\"core/userfeedback\"]',\n },\n actions: {},\n};\nSelectors.actions.give = `${Selectors.regions.root} [data-action=\"give\"]`;\nSelectors.actions.remind = `${Selectors.regions.root} [data-action=\"remind\"]`;\n\n/**\n * Attach the necessary event handlers to the action links\n */\nexport const registerEventListeners = () => {\n document.addEventListener('click', e => {\n const giveAction = e.target.closest(Selectors.actions.give);\n if (giveAction) {\n e.preventDefault();\n\n if (!window.open(giveAction.href)) {\n throw new Error('Unable to open popup');\n }\n\n Promise.resolve(giveAction)\n .then(hideRoot)\n .then(recordAction)\n .catch(Notification.exception);\n }\n\n const remindAction = e.target.closest(Selectors.actions.remind);\n if (remindAction) {\n e.preventDefault();\n\n Promise.resolve(remindAction)\n .then(hideRoot)\n .then(recordAction)\n .catch(Notification.exception);\n }\n });\n};\n\n/**\n * Record the action that the user took.\n *\n * @param {HTMLElement} clickedItem The action element that the user chose.\n * @returns {Promise}\n */\nconst recordAction = clickedItem => {\n if (clickedItem.dataset.record) {\n return Ajax.call([{\n methodname: 'core_create_userfeedback_action_record',\n args: {\n action: clickedItem.dataset.action,\n contextid: M.cfg.contextid,\n }\n }])[0];\n }\n\n return Promise.resolve();\n};\n\n/**\n * Hide the root node of the CTA notification.\n *\n * @param {HTMLElement} clickedItem The action element that the user chose.\n * @returns {HTMLElement}\n */\nconst hideRoot = clickedItem => {\n if (clickedItem.dataset.hide) {\n clickedItem.closest(Selectors.regions.root).remove();\n }\n\n return clickedItem;\n};\n"],"file":"userfeedback.min.js"}
\ No newline at end of file
diff --git a/lib/amd/src/userfeedback.js b/lib/amd/src/userfeedback.js
index c1b1a7f56e4..28a77eddcb3 100644
--- a/lib/amd/src/userfeedback.js
+++ b/lib/amd/src/userfeedback.js
@@ -42,8 +42,12 @@ export const registerEventListeners = () => {
if (giveAction) {
e.preventDefault();
- giveFeedback()
- .then(() => hideRoot(giveAction))
+ if (!window.open(giveAction.href)) {
+ throw new Error('Unable to open popup');
+ }
+
+ Promise.resolve(giveAction)
+ .then(hideRoot)
.then(recordAction)
.catch(Notification.exception);
}
@@ -60,26 +64,6 @@ export const registerEventListeners = () => {
});
};
-/**
- * The action function that is called when users choose to give feedback.
- *
- * @returns {Promise}
- */
-const giveFeedback = () => {
- return Ajax.call([{
- methodname: 'core_get_userfeedback_url',
- args: {
- contextid: M.cfg.contextid,
- }
- }])[0]
- .then(url => {
- if (!window.open(url)) {
- throw new Error('Unable to open popup');
- }
- return;
- });
-};
-
/**
* Record the action that the user took.
*
diff --git a/lib/classes/external/userfeedback/record_action.php b/lib/classes/external/record_userfeedback_action.php
similarity index 97%
rename from lib/classes/external/userfeedback/record_action.php
rename to lib/classes/external/record_userfeedback_action.php
index e8950f5951a..1066701afa3 100644
--- a/lib/classes/external/userfeedback/record_action.php
+++ b/lib/classes/external/record_userfeedback_action.php
@@ -22,7 +22,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-namespace core\external\userfeedback;
+namespace core\external;
defined('MOODLE_INTERNAL') || die();
@@ -38,7 +38,7 @@ use external_value;
* @copyright 2020 Shamim Rezaie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class record_action extends external_api {
+class record_userfeedback_action extends external_api {
/**
* Returns description of parameters.
*
diff --git a/lib/classes/external/userfeedback/generate_url.php b/lib/classes/external/userfeedback/generate_url.php
deleted file mode 100644
index 307bbc2d19e..00000000000
--- a/lib/classes/external/userfeedback/generate_url.php
+++ /dev/null
@@ -1,81 +0,0 @@
-.
-
-/**
- * External API to generate and return the URL of the feedback site.
- *
- * @package core
- * @copyright 2020 Shamim Rezaie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace core\external\userfeedback;
-
-defined('MOODLE_INTERNAL') || die();
-
-require_once("$CFG->libdir/externallib.php");
-
-use external_api;
-use external_function_parameters;
-use external_value;
-use external_single_structure;
-use external_multiple_structure;
-
-/**
- * The external API to generate and return the feedback url.
- *
- * @copyright 2020 Shamim Rezaie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class generate_url extends external_api {
- /**
- * Returns description of parameters.
- *
- * @return external_function_parameters
- */
- public static function execute_parameters() {
- return new external_function_parameters([
- 'contextid' => new external_value(PARAM_INT, 'The context id of the page the user is in'),
- ]);
- }
-
- /**
- * Prepare and return the URL of the feedback site
- *
- * @param int $contextid The context id
- * @return \stdClass
- */
- public static function execute(int $contextid) {
- global $PAGE;
-
- external_api::validate_parameters(self::execute_parameters(), ['contextid' => $contextid]);
-
- $context = \context::instance_by_id($contextid);
- self::validate_context($context);
- $PAGE->set_context($context);
-
- return \core_userfeedback::make_link()->out(false);
- }
-
- /**
- * Returns description of method result value
- *
- * @return external_value
- */
- public static function execute_returns() {
- return new external_value(PARAM_URL, 'Feedback site\'s URL');
- }
-}
diff --git a/lib/classes/userfeedback.php b/lib/classes/userfeedback.php
index 8128336cdf0..af2d7f8443e 100644
--- a/lib/classes/userfeedback.php
+++ b/lib/classes/userfeedback.php
@@ -57,9 +57,9 @@ class core_userfeedback {
$actions = [
[
'title' => get_string('calltofeedback_give'),
- 'url' => '#',
+ 'url' => static::make_link()->out(false),
'data' => [
- 'action' => 'give',
+ 'action' => 'give',
'record' => 1,
'hide' => 1,
],
@@ -103,13 +103,13 @@ class core_userfeedback {
$lastactiontime = max($give ?: 0, $remind ?: 0);
switch ($CFG->userfeedback_nextreminder) {
- case self::REMIND_AFTER_UPGRADE:
- $lastupgrade = self::last_major_upgrade_time();
+ case static::REMIND_AFTER_UPGRADE:
+ $lastupgrade = static::last_major_upgrade_time();
if ($lastupgrade >= $lastactiontime) {
return $lastupgrade + ($CFG->userfeedback_remindafter * DAYSECS) < time();
}
break;
- case self::REMIND_PERIODICALLY:
+ case static::REMIND_PERIODICALLY:
return $lastactiontime + ($CFG->userfeedback_remindafter * DAYSECS) < time();
break;
}
@@ -153,7 +153,7 @@ class core_userfeedback {
public static function can_give_feedback(): bool {
global $CFG;
- return $CFG->enableuserfeedback && isloggedin() && !isguestuser();
+ return !empty($CFG->enableuserfeedback) && isloggedin() && !isguestuser();
}
/**
diff --git a/lib/db/services.php b/lib/db/services.php
index 6b71aff8a7b..57038ef70c4 100644
--- a/lib/db/services.php
+++ b/lib/db/services.php
@@ -2809,7 +2809,7 @@ $functions = array(
'capabilities' => 'moodle/contentbank:manageowncontent',
],
'core_create_userfeedback_action_record' => [
- 'classname' => 'core\external\userfeedback\record_action',
+ 'classname' => 'core\external\record_userfeedback_action',
'methodname' => 'execute',
'classpath' => '',
'description' => 'Record the action that the user takes in the user feedback notification for future use.',
@@ -2817,16 +2817,6 @@ $functions = array(
'ajax' => 'true',
'capabilities' => '',
],
- 'core_get_userfeedback_url' => [
- 'classname' => 'core\external\userfeedback\generate_url',
- 'methodname' => 'execute',
- 'classpath' => '',
- 'description' => 'Generate a dynamic URL for the external user feedback site.' .
- ' The URL includes some parameters to pre-fill the user feedback form.',
- 'type' => 'read',
- 'ajax' => 'true',
- 'capabilities' => '',
- ],
);
$services = array(
diff --git a/lib/tests/behat/userfeedback.feature b/lib/tests/behat/userfeedback.feature
index b090f807f67..6cf33d6a21e 100644
--- a/lib/tests/behat/userfeedback.feature
+++ b/lib/tests/behat/userfeedback.feature
@@ -34,3 +34,17 @@ Feature: Gathering user feedback
And I reload the page
Then I should not see "Give feedback" in the "region-main" "region"
And I should not see "Remind me later" in the "region-main" "region"
+
+ @javascript
+ Scenario: Users should not see the notification after they click on the give feedback link
+ Given the following config values are set as admin:
+ | enableuserfeedback | 1 |
+ | userfeedback_nextreminder | 2 |
+ | userfeedback_remindafter | 90 |
+ When I log in as "admin"
+ And I follow "Dashboard" in the user menu
+ And I click on "Give feedback" "link"
+ And I close all opened windows
+ And I reload the page
+ Then I should not see "Give feedback" in the "region-main" "region"
+ And I should not see "Remind me later" in the "region-main" "region"
diff --git a/lib/tests/external/userfeedback/record_action_test.php b/lib/tests/external/record_userfeedback_action_test.php
similarity index 77%
rename from lib/tests/external/userfeedback/record_action_test.php
rename to lib/tests/external/record_userfeedback_action_test.php
index f67cf57b6d9..12055977a49 100644
--- a/lib/tests/external/userfeedback/record_action_test.php
+++ b/lib/tests/external/record_userfeedback_action_test.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see .
/**
- * External functions test for record_action.
+ * External functions test for record_feedback_action.
*
* @package core
* @category test
@@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-namespace core\external\userfeedback;
+namespace core\external;
defined('MOODLE_INTERNAL') || die();
@@ -35,20 +35,20 @@ global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
/**
- * Class record_action_testcase
+ * Class record_userfeedback_action_testcase
*
* @copyright 2020 Shamim Rezaie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass record_action
+ * @coversDefaultClass record_userfeedback_action
*/
-class record_action_testcase extends externallib_advanced_testcase {
+class record_userfeedback_action_testcase extends externallib_advanced_testcase {
/**
- * Data provider for test_record_action.
+ * Data provider for test_record_userfeedback_action.
*
* @return array
*/
- public function record_action_provider() {
+ public function record_userfeedback_action_provider() {
return [
'give action' => ['give'],
'remind action' => ['remind'],
@@ -56,14 +56,14 @@ class record_action_testcase extends externallib_advanced_testcase {
}
/**
- * Test the behaviour of record_action().
+ * Test the behaviour of record_userfeedback_action().
*
- * @dataProvider record_action_provider
+ * @dataProvider record_userfeedback_action_provider
* @param string $action The action taken by the user
*
* @covers ::execute
*/
- public function test_record_action(string $action) {
+ public function test_record_userfeedback_action(string $action) {
$this->resetAfterTest();
$context = context_system::instance();
@@ -74,7 +74,7 @@ class record_action_testcase extends externallib_advanced_testcase {
$now = time();
// Call the WS and check the action is recorded as expected.
- $result = record_action::execute($action, $context->id);
+ $result = record_userfeedback_action::execute($action, $context->id);
$this->assertNull($result);
$preference = get_user_preferences('core_userfeedback_' . $action);
diff --git a/lib/tests/external/userfeedback/generate_url_test.php b/lib/tests/external/userfeedback/generate_url_test.php
deleted file mode 100644
index c205038abf8..00000000000
--- a/lib/tests/external/userfeedback/generate_url_test.php
+++ /dev/null
@@ -1,118 +0,0 @@
-.
-
-/**
- * External functions test for generate_url.
- *
- * @package core
- * @category test
- * @copyright 2020 Shamim Rezaie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace core\external\userfeedback;
-
-defined('MOODLE_INTERNAL') || die();
-
-use externallib_advanced_testcase;
-use context_system;
-use context_course;
-use external_api;
-
-global $CFG;
-
-require_once($CFG->dirroot . '/webservice/tests/helpers.php');
-
-/**
- * Class generate_url_testcase
- *
- * @copyright 2020 Shamim Rezaie
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass generate_url
- */
-class generate_url_testcase extends externallib_advanced_testcase {
-
- /**
- * Test the behaviour of generate_url().
- *
- * @covers ::execute
- */
- public function test_record_action_system() {
- $this->resetAfterTest();
-
- $course = $this->getDataGenerator()->create_course();
- $user = $this->getDataGenerator()->create_and_enrol($course, 'student');
- $context = context_system::instance();
-
- $this->setUser($user);
-
- // Call the WS and check the requested data is returned as expected.
- $result = generate_url::execute($context->id);
- $result = external_api::clean_returnvalue(generate_url::execute_returns(), $result);
-
- $this->assertStringStartsWith('https://feedback.moodle.org/lms', $result);
- $this->assertStringContainsString('?lang=en', $result);
- $this->assertStringContainsString('&moodle_url=https%3A%2F%2Fwww.example.com%2Fmoodle', $result);
- $this->assertStringContainsString('&theme=boost', $result);
- }
-
- /**
- * Test the behaviour of generate_url() in a course with a course theme.
- *
- * @covers ::execute
- */
- public function test_record_action_course_theme() {
- $this->resetAfterTest();
-
- // Enable course themes.
- set_config('allowcoursethemes', 1);
-
- $course = $this->getDataGenerator()->create_course(['theme' => 'classic']);
- $user = $this->getDataGenerator()->create_and_enrol($course, 'student');
- $context = context_course::instance($course->id);
-
- $this->setUser($user);
-
- // Call the WS and check the requested data is returned as expected.
- $result = generate_url::execute($context->id);
- $result = external_api::clean_returnvalue(generate_url::execute_returns(), $result);
-
- $this->assertStringContainsString('&theme=classic', $result);
- }
-
- /**
- * Test the behaviour of generate_url() when a custom feedback url is set.
- *
- * @covers ::execute
- */
- public function test_record_action_custom_feedback_url() {
- $this->resetAfterTest();
-
- // Enable course themes.
- set_config('userfeedback_url', 'https://feedback.moodle.org/abc');
-
- $user = $this->getDataGenerator()->create_user();
- $context = context_system::instance();
-
- $this->setUser($user);
-
- // Call the WS and check the requested data is returned as expected.
- $result = generate_url::execute($context->id);
- $result = external_api::clean_returnvalue(generate_url::execute_returns(), $result);
-
- $this->assertStringStartsWith('https://feedback.moodle.org/abc', $result);
- }
-}
diff --git a/version.php b/version.php
index f61484ffaa7..2c8a25cd553 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2020061000.00; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2020061000.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '3.9rc1 (Build: 20200609)'; // Human-friendly version name