Skip to content

Commit

Permalink
Import externallib with use statements
Browse files Browse the repository at this point in the history
Resolves coding_exception in MOODLE_402_STABLE and up.
  • Loading branch information
ScottVerbeek committed Dec 28, 2023
1 parent 2d73855 commit b6ea12e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -17,7 +17,7 @@ This plugin currently supports Moodle:

| Moodle version | Branch |
| ------------------- | -------------------- |
| Moodle 3.10 to 3.11 | MOODLE_310_STABLE |
| Moodle 3.10 to 4.3 | MOODLE_310_STABLE |
| Moodle 3.5 to 3.9 | master |

## Elasticsearch Version Support
Expand Down Expand Up @@ -149,7 +149,7 @@ To use Amazon Webservices (AWS) to provide an Elasticsearch service for Moodle:

To use Elastic Cloud to provide an Elasticsearch service for Moodle:
1. Create an Elastic Cloud account and set up Elasticsearch: [Elasticsearch: Getting Started](https://www.elastic.co/webinars/getting-started-elasticsearch?baymax=default&elektra=docs&storm=top-video)
2. Generate API Key for your search index and set this key to the moodle plugin settings.
2. Generate API Key for your search index and set this key to the moodle plugin settings.

## Moodle Plugin Installation
Once you have setup an Elasticsearch service you can now install the Moodle plugin.
Expand Down Expand Up @@ -304,7 +304,7 @@ https://www.catalyst-au.net/

# Contributing and Support

Issues, and pull requests using github are welcome and encouraged!
Issues, and pull requests using github are welcome and encouraged!

https://github.com/catalyst/moodle-search_elastic/issues

Expand Down
7 changes: 5 additions & 2 deletions externallib.php
Expand Up @@ -23,9 +23,12 @@
*/
defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir . "/externallib.php");

use core_search\manager;
use core_external\external_api;
use core_external\external_function_parameters;
use core_external\external_multiple_structure;
use core_external\external_single_structure;
use core_external\external_value;

/**
* Elasticsearch Web Service
Expand Down
6 changes: 4 additions & 2 deletions tests/externallib_test.php
Expand Up @@ -24,6 +24,8 @@

namespace search_elastic;

use core_external\external_api;

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

global $CFG;
Expand Down Expand Up @@ -148,7 +150,7 @@ public function test_external_search() {
['core_mocksearch-mock_search_area']);

// We need to execute the return values cleaning process to simulate the web service server.
$results = \external_api::clean_returnvalue(\search_elastic_external::search_returns(), $results);
$results = external_api::clean_returnvalue(\search_elastic_external::search_returns(), $results);

// Check the results.
$this->assertEquals('this is a <span class="highlight">video</span>', $results[0]['content']);
Expand All @@ -165,7 +167,7 @@ public function test_external_search_areas() {
$results = \search_elastic_external::search_areas(false);

// We need to execute the return values cleaning process to simulate the web service server.
$results = \external_api::clean_returnvalue(\search_elastic_external::search_areas_returns(), $results);
$results = external_api::clean_returnvalue(\search_elastic_external::search_areas_returns(), $results);

$this->assertEquals('core_mocksearch-mock_search_area', $results[0]['areaid']);

Expand Down

0 comments on commit b6ea12e

Please sign in to comment.