Skip to content

Commit

Permalink
DEF-2237: Adding WS
Browse files Browse the repository at this point in the history
  • Loading branch information
ojnadjarm committed Oct 3, 2024
1 parent ce26f60 commit 446ffca
Show file tree
Hide file tree
Showing 43 changed files with 1,940 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
matrix:
include:
- php: '8.1'
moodle-branch: 'master'
moodle-branch: 'main'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_403_STABLE'
Expand Down
2 changes: 1 addition & 1 deletion amd/build/userselector.min.js

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

2 changes: 1 addition & 1 deletion amd/build/userselector.min.js.map

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

15 changes: 8 additions & 7 deletions amd/src/userselector.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ export function transport(selector, query, success, failure) {

.then((results) => {
// For each user in the result, render the display, and set it on the _label field.
return Promise.all(results.map((user) => {
return Templates.render('report_customsql/form-user-selector-suggestion', user)
.then((html) => {
user._label = html;
return user;
});
}));
return (async() => {
const users = await Promise.all(results.map(async(user) => {
const html = await Templates.render('report_customsql/form-user-selector-suggestion', user);
user._label = html;
return user;
}));
return users;
})();
})

.then(success)
Expand Down
99 changes: 99 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
image:
name: '271411534863.dkr.ecr.us-east-2.amazonaws.com/moodleusdev:latest'
aws:
access-key: "$AWS_ACCESS_KEY"
secret-key: "$AWS_SECRET_KEY"
definitions:
installscript: &baseInst
echo "Checking out Moodle\n" ;
moodle-plugin-ci install --branch='MOODLE_401_STABLE' ;
steps:
- step: &base
name: 'Moodle 4.1, PHP 7.4 and MariaDB 10.6'
caches:
- npm
- composer
- docker
services:
- mariadb
- docker
services:
mariadb:
image: mariadb:10.6
variables:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'yes'
caches:
npm: $HOME/.npm
pipelines:
default:
- parallel:
steps:
- step:
<<: *base
name: PHP Lint
script:
- *baseInst
- moodle-plugin-ci phplint
- step:
<<: *base
name: PHP Copy detector
script:
- *baseInst
- moodle-plugin-ci phpcpd
- step:
<<: *base
name: PHP Mess detector
script:
- *baseInst
- moodle-plugin-ci phpmd
- step:
<<: *base
name: PHP Code checker
script:
- *baseInst
- moodle-plugin-ci codechecker
- step:
<<: *base
name: PHP Validate
script:
- *baseInst
- moodle-plugin-ci validate
- step:
<<: *base
name: PHP Savepoints
script:
- *baseInst
- moodle-plugin-ci savepoints
- step:
<<: *base
name: PHP Mustache
script:
- *baseInst
- moodle-plugin-ci mustache
- step:
<<: *base
name: PHP Grunt
script:
- *baseInst
- moodle-plugin-ci grunt
- step:
<<: *base
name: PHP Doc
script:
- *baseInst
- moodle-plugin-ci phpdoc
- step:
<<: *base
name: PHPUnit
script:
- *baseInst
- moodle-plugin-ci phpunit
# Commented out Behat because there are no Behat tests in this project yet.
# - step:
# <<: *base
# name: Behat
# script:
# - *baseInst
# - preset-start-behat
# - moodle-plugin-ci behat
11 changes: 10 additions & 1 deletion categoryadd_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
*/
class report_customsql_addcategory_form extends moodleform {

// Form definition.
/**
* Define the form.
*/
public function definition() {
global $CFG, $DB;
$mform = $this->_form;
Expand All @@ -65,6 +67,13 @@ public function definition() {
$this->add_action_buttons(true, $strsubmit);
}

/**
* Validation.
*
* @param array $data Form data.
* @param array $files Form files.
* @return array Array of errors.
*/
public function validation($data, $files) {
global $DB;
$errors = parent::validation($data, $files);
Expand Down
19 changes: 19 additions & 0 deletions classes/event/query_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,39 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class query_deleted extends \core\event\base {

/**
* Event constructor.
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'report_customsql_queries';
}

/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('query_deleted', 'report_customsql');
}

/**
* Returns description of the query deleted event.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has deleted the SQL query with id {$this->objectid}.";
}

/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/report/customsql/index.php');
}
Expand Down
19 changes: 19 additions & 0 deletions classes/event/query_edited.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,39 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class query_edited extends \core\event\base {

/**
* Event constructor.
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'report_customsql_queries';
}

/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('query_edited', 'report_customsql');
}

/**
* Returns description of the query edited event.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has edited the SQL query with id {$this->objectid}.";
}

/**
* Returns url to view the query.
*
* @return string
*/
public function get_url() {
return new \moodle_url('/report/customsql/view.php', ['id' => $this->objectid]);
}
Expand Down
19 changes: 19 additions & 0 deletions classes/event/query_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,39 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class query_viewed extends \core\event\base {

/**
* Event constructor.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'report_customsql_queries';
}

/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('query_viewed', 'report_customsql');
}

/**
* Returns description of the query viewed event.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has viewed the SQL query with id {$this->objectid}.";
}

/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/report/customsql/view.php', ['id' => $this->objectid]);
}
Expand Down
Loading

0 comments on commit 446ffca

Please sign in to comment.