MDL-68991 core: delete core_get_userfeedback_url webservice
This commit is contained in:
+2
-2
@@ -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 <shamim@moodle.com>
|
||||
* @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.
|
||||
*
|
||||
@@ -1,81 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External API to generate and return the URL of the feedback site.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2020 Shamim Rezaie <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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');
|
||||
}
|
||||
}
|
||||
+1
-11
@@ -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(
|
||||
|
||||
+11
-11
@@ -15,7 +15,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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 <shamim@moodle.com>
|
||||
* @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);
|
||||
@@ -1,118 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External functions test for generate_url.
|
||||
*
|
||||
* @package core
|
||||
* @category test
|
||||
* @copyright 2020 Shamim Rezaie <[email protected]>
|
||||
* @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 <[email protected]>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2020060900.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2020060900.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
|
||||
|
||||
Reference in New Issue
Block a user