Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d09dc52b0a | |||
| 6e19850f6e | |||
| 5d30474242 | |||
| 1b972c31ac | |||
| 29b6ac23e9 | |||
| 44b6ffb68c | |||
| 79abbd9adc | |||
| 270524858e | |||
| 60f9a401a9 | |||
| ac0b8201a9 | |||
| be27fc0fe3 | |||
| ebd104448f | |||
| c69f425a7a | |||
| e38e718441 |
+5
-4
@@ -6,7 +6,6 @@ vendor/
|
||||
admin/tool/policy/amd/src/jquery-eu-cookie-law-popup.js
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
auth/cas/CAS/
|
||||
cache/stores/mongodb/MongoDB/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
@@ -64,8 +63,6 @@ lib/amd/src/adapter.js
|
||||
lib/validateurlsyntax.php
|
||||
lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
lib/php-jwt/
|
||||
lib/mdn-polyfills/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
@@ -86,4 +83,8 @@ theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/bootstrapbase/less/bootstrap/
|
||||
theme/bootstrapbase/javascript/html5shiv.js
|
||||
theme/bootstrapbase/amd/src/bootstrap.js
|
||||
theme/bootstrapbase/less/fontawesome/
|
||||
@@ -203,7 +203,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["**/amd/src/*.js", "Gruntfile.js"],
|
||||
files: ["**/amd/src/*.js"],
|
||||
// Check AMD with some slightly stricter rules.
|
||||
rules: {
|
||||
'no-unused-vars': 'error',
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
**/yui/build/** -diff
|
||||
**/amd/build/** -diff
|
||||
lib/dml/oci_native_moodle_package.sql text eol=lf
|
||||
theme/bootstrapbase/style/editor.css -diff
|
||||
theme/bootstrapbase/style/moodle.css -diff
|
||||
|
||||
+2
-10
@@ -9,18 +9,10 @@
|
||||
#
|
||||
# See gitignore(5) man page for more details
|
||||
#
|
||||
|
||||
# Swap files (vim)
|
||||
[._]*.s[a-v][a-z]
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
# Temporary files including undo
|
||||
*~
|
||||
#
|
||||
/config.php
|
||||
/lib/editor/tinymce/extra/tools/temp/
|
||||
*~
|
||||
*.swp
|
||||
/tags
|
||||
/TAGS
|
||||
/cscope.*
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
**/amd/**
|
||||
/*.js
|
||||
+8
-5
@@ -1,13 +1,14 @@
|
||||
# Generated by "grunt ignorefiles"
|
||||
**/yui/build/*
|
||||
theme/bootstrapbase/style/
|
||||
theme/clean/style/custom.css
|
||||
theme/more/style/custom.css
|
||||
theme/boost/style/moodle.css
|
||||
theme/classic/style/moodle.css
|
||||
node_modules/
|
||||
vendor/
|
||||
admin/tool/policy/amd/src/jquery-eu-cookie-law-popup.js
|
||||
admin/tool/usertours/amd/src/tour.js
|
||||
auth/cas/CAS/
|
||||
cache/stores/mongodb/MongoDB/
|
||||
enrol/lti/ims-blti/
|
||||
filter/algebra/AlgParser.pm
|
||||
filter/tex/mimetex.*
|
||||
@@ -65,8 +66,6 @@ lib/amd/src/adapter.js
|
||||
lib/validateurlsyntax.php
|
||||
lib/amd/src/popper.js
|
||||
lib/geopattern-php/
|
||||
lib/php-jwt/
|
||||
lib/mdn-polyfills/
|
||||
media/player/videojs/amd/src/video-lazy.js
|
||||
media/player/videojs/amd/src/Youtube-lazy.js
|
||||
media/player/videojs/videojs/
|
||||
@@ -87,4 +86,8 @@ theme/boost/amd/src/tab.js
|
||||
theme/boost/amd/src/tooltip.js
|
||||
theme/boost/amd/src/util.js
|
||||
theme/boost/amd/src/tether.js
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/boost/scss/fontawesome/
|
||||
theme/bootstrapbase/less/bootstrap/
|
||||
theme/bootstrapbase/javascript/html5shiv.js
|
||||
theme/bootstrapbase/amd/src/bootstrap.js
|
||||
theme/bootstrapbase/less/fontawesome/
|
||||
+35
-49
@@ -2,27 +2,30 @@
|
||||
# process (which uses our internal CI system) this file is here for the benefit
|
||||
# of community developers git clones - see MDL-51458.
|
||||
|
||||
sudo: required
|
||||
|
||||
# We currently disable Travis notifications entirely until https://github.com/travis-ci/travis-ci/issues/4976
|
||||
# is fixed.
|
||||
notifications:
|
||||
email:
|
||||
if: env(MOODLE_EMAIL) != no
|
||||
email: false
|
||||
|
||||
language: php
|
||||
|
||||
os: linux
|
||||
|
||||
dist: xenial
|
||||
|
||||
services:
|
||||
- mysql
|
||||
- docker
|
||||
|
||||
php:
|
||||
# We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
|
||||
- 7.3
|
||||
- 7.1.30 # Make this sticky because current default version (7.1.11) has a bug with redis-extension output (MDL-66062)
|
||||
- 7.2
|
||||
- 7.0
|
||||
|
||||
addons:
|
||||
postgresql: "9.6"
|
||||
packages:
|
||||
- mysql-server-5.6
|
||||
- mysql-client-core-5.6
|
||||
- mysql-client-5.6
|
||||
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# services:
|
||||
# - redis-server
|
||||
|
||||
env:
|
||||
# Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
|
||||
@@ -32,6 +35,9 @@ env:
|
||||
# CI Tests should be second-highest in priority as these only take <= 60 seconds to run under normal circumstances.
|
||||
# Postgres is significantly is pretty reasonable in its run-time.
|
||||
|
||||
# Run unit tests on MySQL
|
||||
- DB=mysqli TASK=PHPUNIT
|
||||
|
||||
# Run CI Tests without running PHPUnit.
|
||||
- DB=none TASK=CITEST
|
||||
|
||||
@@ -41,40 +47,39 @@ env:
|
||||
# Perform an upgrade test too.
|
||||
- DB=pgsql TASK=UPGRADE
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
# Enable fast finish.
|
||||
# This will fail the build if a single job fails (except those in allow_failures).
|
||||
# It will not stop the jobs from running.
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
# Run mysql only on 7.3 - it's just too slow
|
||||
- php: 7.3
|
||||
env: DB=mysqli TASK=PHPUNIT
|
||||
# Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
|
||||
- php: 7.2
|
||||
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
|
||||
|
||||
exclude:
|
||||
# MySQL - it's just too slow.
|
||||
# Exclude it on all versions except for 7.2
|
||||
|
||||
- env: DB=mysqli TASK=PHPUNIT
|
||||
php: 7.0
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.npm
|
||||
|
||||
before_install:
|
||||
- docker run -d -p 127.0.0.1:8080:80 --name exttests moodlehq/moodle-exttests
|
||||
# Avoid IPv6 default binding as service (causes redis not to start).
|
||||
- sudo service redis-server start --bind 127.0.0.1
|
||||
|
||||
install:
|
||||
- >
|
||||
if [ "$DB" = 'mysqli' ];
|
||||
then
|
||||
sudo mkdir /mnt/ramdisk
|
||||
sudo mount -t tmpfs -o size=1024m tmpfs /mnt/ramdisk
|
||||
sudo service mysql stop
|
||||
sudo stop mysql
|
||||
sudo mv /var/lib/mysql /mnt/ramdisk
|
||||
sudo ln -s /mnt/ramdisk/mysql /var/lib/mysql
|
||||
sudo service mysql restart
|
||||
sudo start mysql
|
||||
fi
|
||||
- >
|
||||
if [ "$DB" = 'pgsql' ];
|
||||
@@ -94,8 +99,10 @@ install:
|
||||
echo 'auth.json' >> .git/info/exclude
|
||||
fi
|
||||
|
||||
echo 'extension="redis.so"' > /tmp/redis.ini
|
||||
phpenv config-add /tmp/redis.ini
|
||||
# Enable Redis.
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# echo 'extension="redis.so"' > /tmp/redis.ini
|
||||
# phpenv config-add /tmp/redis.ini
|
||||
|
||||
# Install composer dependencies.
|
||||
# We need --no-interaction in case we hit API limits for composer. This causes it to fall back to a standard clone.
|
||||
@@ -166,25 +173,12 @@ before_script:
|
||||
mkdir -p "$HOME"/roots/phpunit
|
||||
|
||||
# The phpunit dataroot and prefix..
|
||||
# Redis tests are currently failing on php 7.2 due to https://bugs.php.net/bug.php?id=75628
|
||||
# -e "/require_once/i \\define('TEST_SESSION_REDIS_HOST', '127.0.0.1');" \
|
||||
sed -i \
|
||||
-e "/require_once/i \\\$CFG->phpunit_dataroot = '\/home\/travis\/roots\/phpunit';" \
|
||||
-e "/require_once/i \\\$CFG->phpunit_prefix = 'p_';" \
|
||||
config.php ;
|
||||
# Enable test external resources
|
||||
sed -i \
|
||||
-e "/require_once/i \\define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://127.0.0.1:8080');" \
|
||||
-e "/require_once/i \\define('TEST_EXTERNAL_FILES_HTTPS_URL', 'http://127.0.0.1:8080');" \
|
||||
config.php ;
|
||||
|
||||
# Redis cache store tests
|
||||
sed -i \
|
||||
-e "/require_once/i \\define('TEST_CACHESTORE_REDIS_TESTSERVERS', '127.0.0.1');" \
|
||||
config.php ;
|
||||
# Redis session tests, but not for PHP 7.2 and up. See MDL-60978 for more info.
|
||||
redissession="define('TEST_SESSION_REDIS_HOST', '127.0.0.1');"
|
||||
sed -i \
|
||||
-e "/require_once/i \\${redissession}" \
|
||||
config.php ;
|
||||
|
||||
# Initialise PHPUnit for Moodle.
|
||||
php admin/tool/phpunit/cli/init.php
|
||||
@@ -213,7 +207,7 @@ before_script:
|
||||
# We need the official upstream for comparison
|
||||
git remote add upstream https://github.com/moodle/moodle.git;
|
||||
|
||||
git fetch upstream MOODLE_37_STABLE;
|
||||
git fetch upstream MOODLE_36_STABLE;
|
||||
export GIT_PREVIOUS_COMMIT="`git merge-base FETCH_HEAD $TRAVIS_COMMIT`";
|
||||
export GIT_COMMIT="$TRAVIS_COMMIT";
|
||||
export UPSTREAM_FETCH_HEAD=`git rev-parse FETCH_HEAD`
|
||||
@@ -291,11 +285,3 @@ script:
|
||||
exit 1 ;
|
||||
fi
|
||||
fi
|
||||
|
||||
after_script:
|
||||
- >
|
||||
if [ "$TASK" = 'PHPUNIT' ];
|
||||
then
|
||||
EXTTESTS_HITS=$(docker logs exttests 2>&1 | grep -Fv -e 'AH00558' -e '[pid 1]' | wc -l)
|
||||
echo -e "\nTest local resources number of hits: ${EXTTESTS_HITS}.\n"
|
||||
fi
|
||||
|
||||
+49
-37
@@ -24,7 +24,6 @@
|
||||
* Grunt configuration
|
||||
*/
|
||||
|
||||
/* eslint-env node */
|
||||
module.exports = function(grunt) {
|
||||
var path = require('path'),
|
||||
tasks = {},
|
||||
@@ -112,13 +111,7 @@ module.exports = function(grunt) {
|
||||
eslint: {
|
||||
// Even though warnings dont stop the build we don't display warnings by default because
|
||||
// at this moment we've got too many core warnings.
|
||||
// To display warnings call: grunt eslint --show-lint-warnings
|
||||
// To fail on warnings call: grunt eslint --max-lint-warnings=0
|
||||
// Also --max-lint-warnings=-1 can be used to display warnings but not fail.
|
||||
options: {
|
||||
quiet: (!grunt.option('show-lint-warnings')) && (typeof grunt.option('max-lint-warnings') === 'undefined'),
|
||||
maxWarnings: ((typeof grunt.option('max-lint-warnings') !== 'undefined') ? grunt.option('max-lint-warnings') : -1)
|
||||
},
|
||||
options: {quiet: !grunt.option('show-lint-warnings')},
|
||||
amd: {src: amdSrc},
|
||||
// Check YUI module source files.
|
||||
yui: {src: ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js']}
|
||||
@@ -133,15 +126,25 @@ module.exports = function(grunt) {
|
||||
options: {report: 'none'}
|
||||
}
|
||||
},
|
||||
less: {
|
||||
bootstrapbase: {
|
||||
files: {
|
||||
"theme/bootstrapbase/style/moodle.css": "theme/bootstrapbase/less/moodle.less",
|
||||
"theme/bootstrapbase/style/editor.css": "theme/bootstrapbase/less/editor.less",
|
||||
},
|
||||
options: {
|
||||
compress: false // We must not compress to keep the comments.
|
||||
}
|
||||
}
|
||||
},
|
||||
sass: {
|
||||
dist: {
|
||||
files: {
|
||||
"theme/boost/style/moodle.css": "theme/boost/scss/preset/default.scss",
|
||||
"theme/classic/style/moodle.css": "theme/classic/scss/classicgrunt.scss"
|
||||
"theme/boost/style/moodle.css": "theme/boost/scss/preset/default.scss"
|
||||
}
|
||||
},
|
||||
options: {
|
||||
includePaths: ["theme/boost/scss/", "theme/classic/scss/"]
|
||||
includePaths: ["theme/boost/scss/"]
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -152,14 +155,15 @@ module.exports = function(grunt) {
|
||||
files: ['**/amd/src/**/*.js'],
|
||||
tasks: ['amd']
|
||||
},
|
||||
bootstrapbase: {
|
||||
files: ["theme/bootstrapbase/less/**/*.less"],
|
||||
tasks: ["css"]
|
||||
},
|
||||
yui: {
|
||||
files: ['**/yui/src/**/*.js'],
|
||||
tasks: ['yui']
|
||||
},
|
||||
gherkinlint: {
|
||||
options: {
|
||||
nospawn: false,
|
||||
},
|
||||
files: ['**/tests/behat/*.feature'],
|
||||
tasks: ['gherkinlint']
|
||||
}
|
||||
@@ -176,6 +180,18 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
stylelint: {
|
||||
less: {
|
||||
options: {
|
||||
syntax: 'less',
|
||||
configOverrides: {
|
||||
rules: {
|
||||
// These rules have to be disabled in .stylelintrc for scss compat.
|
||||
"at-rule-no-unknown": true,
|
||||
}
|
||||
}
|
||||
},
|
||||
src: ['theme/**/*.less']
|
||||
},
|
||||
scss: {
|
||||
options: {syntax: 'scss'},
|
||||
src: ['*/**/*.scss']
|
||||
@@ -207,8 +223,10 @@ module.exports = function(grunt) {
|
||||
var stylelintIgnores = [
|
||||
'# Generated by "grunt ignorefiles"',
|
||||
'**/yui/build/*',
|
||||
'theme/boost/style/moodle.css',
|
||||
'theme/classic/style/moodle.css',
|
||||
'theme/bootstrapbase/style/',
|
||||
'theme/clean/style/custom.css',
|
||||
'theme/more/style/custom.css',
|
||||
'theme/boost/style/moodle.css'
|
||||
].concat(thirdPartyPaths);
|
||||
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n'));
|
||||
};
|
||||
@@ -302,27 +320,19 @@ module.exports = function(grunt) {
|
||||
};
|
||||
|
||||
tasks.gherkinlint = function() {
|
||||
const done = this.async();
|
||||
const options = grunt.config('gherkinlint.options');
|
||||
var done = this.async(),
|
||||
options = grunt.config('gherkinlint.options');
|
||||
|
||||
// Grab the gherkin-lint linter and required scaffolding.
|
||||
const linter = require('gherkin-lint/src/linter.js');
|
||||
const featureFinder = require('gherkin-lint/src/feature-finder.js');
|
||||
const configParser = require('gherkin-lint/src/config-parser.js');
|
||||
const formatter = require('gherkin-lint/src/formatters/stylish.js');
|
||||
|
||||
// Run the linter.
|
||||
const results = linter.lint(
|
||||
featureFinder.getFeatureFiles(grunt.file.expand(options.files)),
|
||||
configParser.getConfiguration(configParser.defaultConfigFileName)
|
||||
);
|
||||
|
||||
// Print the results out uncondtionally.
|
||||
formatter.printResults(results);
|
||||
|
||||
// Report on the results.
|
||||
// The done function takes a bool whereby a falsey statement causes the task to fail.
|
||||
done(results.every(result => result.errors.length === 0));
|
||||
var args = grunt.file.expand(options.files);
|
||||
args.unshift(path.normalize(__dirname + '/node_modules/.bin/gherkin-lint'));
|
||||
grunt.util.spawn({
|
||||
cmd: 'node',
|
||||
args: args,
|
||||
opts: {stdio: 'inherit', env: process.env}
|
||||
}, function(error, result, code) {
|
||||
// Propagate the exit code.
|
||||
done(code === 0);
|
||||
});
|
||||
};
|
||||
|
||||
tasks.startup = function() {
|
||||
@@ -350,6 +360,7 @@ module.exports = function(grunt) {
|
||||
grunt.config('eslint.yui.src', files);
|
||||
grunt.config('uglify.amd.files', [{expand: true, src: files, rename: uglifyRename}]);
|
||||
grunt.config('shifter.options.paths', files);
|
||||
grunt.config('stylelint.less.src', files);
|
||||
grunt.config('gherkinlint.options.files', files);
|
||||
changedFiles = Object.create(null);
|
||||
}, 200);
|
||||
@@ -361,6 +372,7 @@ module.exports = function(grunt) {
|
||||
|
||||
// Register NPM tasks.
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-less');
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-sass');
|
||||
grunt.loadNpmTasks('grunt-eslint');
|
||||
@@ -375,7 +387,7 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('js', ['amd', 'yui']);
|
||||
|
||||
// Register CSS taks.
|
||||
grunt.registerTask('css', ['stylelint:scss', 'sass', 'stylelint:css']);
|
||||
grunt.registerTask('css', ['stylelint:scss', 'sass', 'stylelint:less', 'less:bootstrapbase', 'stylelint:css']);
|
||||
|
||||
// Register the startup task.
|
||||
grunt.registerTask('startup', 'Run the correct tasks for the current directory', tasks.startup);
|
||||
|
||||
@@ -1,59 +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/>.
|
||||
|
||||
/**
|
||||
* Testing outgoing mail configuration form
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2019 Victor Deniz <victor@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_admin\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Test mail form
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2019 Victor Deniz <victor@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class testoutgoingmailconf_form extends \moodleform {
|
||||
/**
|
||||
* Add elements to form
|
||||
*/
|
||||
public function definition() {
|
||||
$mform = $this->_form;
|
||||
|
||||
// Recipient.
|
||||
$options = ['maxlength' => '100', 'size' => '25'];
|
||||
$mform->addElement('text', 'recipient', get_string('testoutgoingmailconf_toemail', 'admin'), $options);
|
||||
$mform->setType('recipient', PARAM_EMAIL);
|
||||
$mform->addRule('recipient', get_string('required'), 'required');
|
||||
|
||||
$buttonarray = array();
|
||||
$buttonarray[] = $mform->createElement('submit', 'send', get_string('testoutgoingmailconf_sendtest', 'admin'));
|
||||
$buttonarray[] = $mform->createElement('cancel');
|
||||
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$mform->closeHeaderBefore('buttonar');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,289 +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/>.
|
||||
|
||||
/**
|
||||
* Task log table.
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace core_admin;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/tablelib.php');
|
||||
|
||||
/**
|
||||
* Table to display list of task logs.
|
||||
*
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class task_log_table extends \table_sql {
|
||||
|
||||
/**
|
||||
* Constructor for the task_log table.
|
||||
*
|
||||
* @param string $filter
|
||||
* @param int $resultfilter
|
||||
*/
|
||||
public function __construct(string $filter = '', int $resultfilter = null) {
|
||||
global $DB;
|
||||
|
||||
if (-1 === $resultfilter) {
|
||||
$resultfilter = null;
|
||||
}
|
||||
|
||||
parent::__construct('tasklogs');
|
||||
|
||||
$columnheaders = [
|
||||
'classname' => get_string('name'),
|
||||
'type' => get_string('tasktype', 'admin'),
|
||||
'userid' => get_string('user', 'admin'),
|
||||
'timestart' => get_string('task_starttime', 'admin'),
|
||||
'duration' => get_string('task_duration', 'admin'),
|
||||
'db' => get_string('task_dbstats', 'admin'),
|
||||
'result' => get_string('task_result', 'admin'),
|
||||
'actions' => '',
|
||||
];
|
||||
$this->define_columns(array_keys($columnheaders));
|
||||
$this->define_headers(array_values($columnheaders));
|
||||
|
||||
// The name column is a header.
|
||||
$this->define_header_column('classname');
|
||||
|
||||
// This table is not collapsible.
|
||||
$this->collapsible(false);
|
||||
|
||||
// The actions class should not wrap. Use the BS text utility class.
|
||||
$this->column_class('actions', 'text-nowrap');
|
||||
|
||||
// Allow pagination.
|
||||
$this->pageable(true);
|
||||
|
||||
// Allow sorting. Default to sort by timestarted DESC.
|
||||
$this->sortable(true, 'timestart', SORT_DESC);
|
||||
|
||||
// Add filtering.
|
||||
$where = [];
|
||||
$params = [];
|
||||
if (!empty($filter)) {
|
||||
$orwhere = [];
|
||||
$filter = str_replace('\\', '\\\\', $filter);
|
||||
|
||||
// Check the class name.
|
||||
$orwhere[] = $DB->sql_like('classname', ':classfilter', false, false);
|
||||
$params['classfilter'] = '%' . $DB->sql_like_escape($filter) . '%';
|
||||
|
||||
$orwhere[] = $DB->sql_like('output', ':outputfilter', false, false);
|
||||
$params['outputfilter'] = '%' . $DB->sql_like_escape($filter) . '%';
|
||||
|
||||
$where[] = "(" . implode(' OR ', $orwhere) . ")";
|
||||
}
|
||||
|
||||
if (null !== $resultfilter) {
|
||||
$where[] = 'tl.result = :result';
|
||||
$params['result'] = $resultfilter;
|
||||
}
|
||||
|
||||
$where = implode(' AND ', $where);
|
||||
|
||||
$this->set_sql('', '', $where, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the db. Store results in the table object for use by build_table.
|
||||
*
|
||||
* @param int $pagesize size of page for paginated displayed table.
|
||||
* @param bool $useinitialsbar do you want to use the initials bar. Bar
|
||||
* will only be used if there is a fullname column defined for the table.
|
||||
*/
|
||||
public function query_db($pagesize, $useinitialsbar = true) {
|
||||
global $DB;
|
||||
|
||||
// Fetch the attempts.
|
||||
$sort = $this->get_sql_sort();
|
||||
if ($sort) {
|
||||
$sort = "ORDER BY $sort";
|
||||
}
|
||||
|
||||
$extrafields = get_extra_user_fields(\context_system::instance());
|
||||
$userfields = \user_picture::fields('u', $extrafields, 'userid2', 'user');
|
||||
|
||||
$where = '';
|
||||
if (!empty($this->sql->where)) {
|
||||
$where = "WHERE {$this->sql->where}";
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
tl.id, tl.type, tl.component, tl.classname, tl.userid, tl.timestart, tl.timeend,
|
||||
tl.dbreads, tl.dbwrites, tl.result,
|
||||
tl.dbreads + tl.dbwrites AS db,
|
||||
tl.timeend - tl.timestart AS duration,
|
||||
{$userfields}
|
||||
FROM {task_log} tl
|
||||
LEFT JOIN {user} u ON u.id = tl.userid
|
||||
{$where}
|
||||
{$sort}";
|
||||
|
||||
$this->pagesize($pagesize, $DB->count_records_sql("SELECT COUNT('x') FROM {task_log} tl {$where}", $this->sql->params));
|
||||
if (!$this->is_downloading()) {
|
||||
$this->rawdata = $DB->get_records_sql($sql, $this->sql->params, $this->get_page_start(), $this->get_page_size());
|
||||
} else {
|
||||
$this->rawdata = $DB->get_records_sql($sql, $this->sql->params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the name cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_classname($row) : string {
|
||||
$output = '';
|
||||
if (class_exists($row->classname)) {
|
||||
$task = new $row->classname;
|
||||
if ($task instanceof \core\task\scheduled_task) {
|
||||
$output = $task->get_name();
|
||||
}
|
||||
}
|
||||
|
||||
$output .= \html_writer::tag('div', "\\{$row->classname}", [
|
||||
'class' => 'task-class',
|
||||
]);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the type cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_type($row) : string {
|
||||
if (\core\task\database_logger::TYPE_SCHEDULED == $row->type) {
|
||||
return get_string('task_type:scheduled', 'admin');
|
||||
} else {
|
||||
return get_string('task_type:adhoc', 'admin');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the timestart cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_result($row) : string {
|
||||
if ($row->result) {
|
||||
return get_string('task_result:failed', 'admin');
|
||||
} else {
|
||||
return get_string('success');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the timestart cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_timestart($row) : string {
|
||||
return userdate($row->timestart, get_string('strftimedatetimeshort', 'langconfig'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the duration cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_duration($row) : string {
|
||||
$duration = round($row->timeend - $row->timestart, 2);
|
||||
|
||||
if (empty($duration)) {
|
||||
// The format_time function returns 'now' when the difference is exactly 0.
|
||||
// Note: format_time performs concatenation in exactly this fashion so we should do this for consistency.
|
||||
return '0 ' . get_string('secs', 'moodle');
|
||||
}
|
||||
|
||||
return format_time($duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the DB details cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_db($row) : string {
|
||||
$output = '';
|
||||
|
||||
$output .= \html_writer::div(get_string('task_stats:dbreads', 'admin', $row->dbreads));
|
||||
$output .= \html_writer::div(get_string('task_stats:dbwrites', 'admin', $row->dbwrites));
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the actions cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_actions($row) : string {
|
||||
global $OUTPUT;
|
||||
|
||||
$actions = [];
|
||||
|
||||
$url = new \moodle_url('/admin/tasklogs.php', ['logid' => $row->id]);
|
||||
|
||||
// Quick view.
|
||||
$actions[] = $OUTPUT->action_icon(
|
||||
$url,
|
||||
new \pix_icon('e/search', get_string('view')),
|
||||
new \popup_action('click', $url)
|
||||
);
|
||||
|
||||
// Download.
|
||||
$actions[] = $OUTPUT->action_icon(
|
||||
new \moodle_url($url, ['download' => true]),
|
||||
new \pix_icon('t/download', get_string('download'))
|
||||
);
|
||||
|
||||
return implode(' ', $actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the user cell.
|
||||
*
|
||||
* @param \stdClass $row
|
||||
* @return string
|
||||
*/
|
||||
public function col_userid($row) : string {
|
||||
if (empty($row->userid)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$user = (object) [];
|
||||
username_load_fields_from_object($user, $row, 'user');
|
||||
|
||||
return fullname($user);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -83,7 +83,7 @@ Examples:
|
||||
Stores the given configuration variable in the shell variable, escaped
|
||||
so that it can be safely used as a shell argument.
|
||||
|
||||
# php cfg.php --name=theme --set=classic
|
||||
# php cfg.php --name=theme --set=clean
|
||||
Sets the given configuration variable to the given value.
|
||||
|
||||
# php cfg.php --name=noemailever --unset
|
||||
|
||||
+89
-98
@@ -514,105 +514,100 @@ if ($interactive) {
|
||||
$database = $databases[$CFG->dbtype];
|
||||
|
||||
|
||||
// We cannot do any validation until all DB connection data is provided.
|
||||
$hintdatabase = '';
|
||||
do {
|
||||
echo $hintdatabase;
|
||||
|
||||
// Ask for db host.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasehost', 'install'));
|
||||
if ($options['dbhost'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbhost']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbhost = cli_input($prompt, $options['dbhost']);
|
||||
|
||||
// ask for db host
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasehost', 'install'));
|
||||
if ($options['dbhost'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbhost']);
|
||||
} else {
|
||||
$CFG->dbhost = $options['dbhost'];
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbhost = cli_input($prompt, $options['dbhost']);
|
||||
|
||||
// Ask for db name.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasename', 'install'));
|
||||
if ($options['dbname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbname']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbname = cli_input($prompt, $options['dbname']);
|
||||
} else {
|
||||
$CFG->dbhost = $options['dbhost'];
|
||||
}
|
||||
|
||||
// ask for db name
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasename', 'install'));
|
||||
if ($options['dbname'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbname']);
|
||||
} else {
|
||||
$CFG->dbname = $options['dbname'];
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbname = cli_input($prompt, $options['dbname']);
|
||||
|
||||
// Ask for db prefix.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('dbprefix', 'install'));
|
||||
//TODO: solve somehow the prefix trouble for oci.
|
||||
if ($options['prefix'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['prefix']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->prefix = cli_input($prompt, $options['prefix']);
|
||||
} else {
|
||||
$CFG->dbname = $options['dbname'];
|
||||
}
|
||||
|
||||
// ask for db prefix
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('dbprefix', 'install'));
|
||||
//TODO: solve somehow the prefix trouble for oci
|
||||
if ($options['prefix'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['prefix']);
|
||||
} else {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->prefix = cli_input($prompt, $options['prefix']);
|
||||
|
||||
// Ask for db port.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int) cli_input($prompt, $options['dbport']);
|
||||
} else {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db port
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int)cli_input($prompt, $options['dbport']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int)$options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
}
|
||||
|
||||
// ask for db socket
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseuser', 'install'));
|
||||
if ($options['dbuser'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbuser']);
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int) $options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbuser = cli_input($prompt, $options['dbuser']);
|
||||
|
||||
// Ask for db socket.
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// Ask for db user.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseuser', 'install'));
|
||||
if ($options['dbuser'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbuser']);
|
||||
} else {
|
||||
$prompt = get_string('clitypevalue', 'admin');
|
||||
}
|
||||
$CFG->dbuser = cli_input($prompt, $options['dbuser']);
|
||||
|
||||
} else {
|
||||
$CFG->dbuser = $options['dbuser'];
|
||||
}
|
||||
|
||||
// Ask for db password.
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasepass', 'install'));
|
||||
} else {
|
||||
$CFG->dbuser = $options['dbuser'];
|
||||
}
|
||||
|
||||
// ask for db password
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasepass', 'install'));
|
||||
do {
|
||||
if ($options['dbpass'] !== '') {
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbpass']);
|
||||
} else {
|
||||
@@ -620,23 +615,19 @@ do {
|
||||
}
|
||||
|
||||
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation.
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix,
|
||||
array('dbpersist' => 0, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket']),
|
||||
$distro);
|
||||
if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
|
||||
$distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']), $distro);
|
||||
}
|
||||
$hintdatabase = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix,
|
||||
array('dbpersist' => 0, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket']));
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
} while ($hint_database !== '');
|
||||
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hintdatabase = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix,
|
||||
array('dbpersist' => 0, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket']));
|
||||
if ($hintdatabase !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
} else {
|
||||
$CFG->dbpass = $options['dbpass'];
|
||||
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbport'=>$CFG->dboptions['dbport'], 'dbsocket'=>$CFG->dboptions['dbsocket']));
|
||||
if ($hint_database !== '') {
|
||||
cli_error(get_string('dbconnectionerror', 'install'));
|
||||
}
|
||||
} while ($hintdatabase !== '');
|
||||
}
|
||||
|
||||
// ask for fullname
|
||||
if ($interactive) {
|
||||
@@ -719,7 +710,7 @@ if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('cliadminemail', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['adminemail']);
|
||||
$options['adminemail'] = cli_input($prompt, $options['adminemail']);
|
||||
$options['adminemail'] = cli_input($prompt);
|
||||
}
|
||||
|
||||
// Validate that the address provided was an e-mail address.
|
||||
|
||||
@@ -82,6 +82,11 @@ require_once($CFG->libdir.'/installlib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/componentlib.class.php');
|
||||
|
||||
// make sure no tables are installed yet
|
||||
if ($DB->get_tables() ) {
|
||||
cli_error(get_string('clitablesexist', 'install'));
|
||||
}
|
||||
|
||||
$CFG->early_install_lang = true;
|
||||
get_string_manager(true);
|
||||
|
||||
@@ -104,17 +109,12 @@ list($options, $unrecognized) = cli_get_params(
|
||||
)
|
||||
);
|
||||
|
||||
// We show help text even if tables are installed.
|
||||
|
||||
if ($options['help']) {
|
||||
echo $help;
|
||||
die;
|
||||
}
|
||||
|
||||
// Make sure no tables are installed yet.
|
||||
if ($DB->get_tables() ) {
|
||||
cli_error(get_string('clitablesexist', 'install'));
|
||||
}
|
||||
|
||||
if (!$options['agree-license']) {
|
||||
cli_error('You have to agree to the license. --help prints out the help'); // TODO: localize
|
||||
}
|
||||
|
||||
@@ -1,163 +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/>.
|
||||
|
||||
/**
|
||||
* CLI script to uninstall plugins.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage cli
|
||||
* @copyright 2018 Dmitrii Metelkin <dmitriim@catalyst-au.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define('CLI_SCRIPT', true);
|
||||
|
||||
require(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$help = "Command line tool to uninstall plugins.
|
||||
|
||||
Options:
|
||||
-h --help Print this help.
|
||||
--show-all Displays a list of all installed plugins.
|
||||
--show-missing Displays a list of plugins missing from disk.
|
||||
--purge-missing Uninstall all missing from disk plugins.
|
||||
--plugins=<plugin name> A comma separated list of plugins to be uninstalled. E.g. mod_assign,mod_forum
|
||||
--run Execute uninstall. If this option is not set, then the script will be run in a dry mode.
|
||||
|
||||
Examples:
|
||||
|
||||
# php uninstall_plugins.php --show-all
|
||||
Prints tab-separated list of all installed plugins.
|
||||
|
||||
# php uninstall_plugins.php --show-missing
|
||||
Prints tab-separated list of all missing from disk plugins.
|
||||
|
||||
# php uninstall_plugins.php --purge-missing
|
||||
A dry run of uninstalling all missing plugins.
|
||||
|
||||
# php uninstall_plugins.php --purge-missing --run
|
||||
Run uninstall of all missing plugins.
|
||||
|
||||
# php uninstall_plugins.php --plugins=mod_assign,mod_forum
|
||||
A dry run of uninstalling mod_assign and mod_forum plugins.
|
||||
|
||||
# php uninstall_plugins.php --plugins=mod_assign,mod_forum --run
|
||||
Run uninstall for mod_assign and mod_forum plugins.
|
||||
";
|
||||
|
||||
list($options, $unrecognised) = cli_get_params([
|
||||
'help' => false,
|
||||
'show-all' => false,
|
||||
'show-missing' => false,
|
||||
'purge-missing' => false,
|
||||
'plugins' => false,
|
||||
'run' => false,
|
||||
], [
|
||||
'h' => 'help'
|
||||
]);
|
||||
|
||||
if ($unrecognised) {
|
||||
$unrecognised = implode(PHP_EOL.' ', $unrecognised);
|
||||
cli_error(get_string('cliunknowoption', 'core_admin', $unrecognised));
|
||||
}
|
||||
|
||||
if ($options['help']) {
|
||||
cli_writeln($help);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
$plugininfo = $pluginman->get_plugins();
|
||||
|
||||
if ($options['show-all'] || $options['show-missing']) {
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
$pluginstring = $plugin->component . "\t" . $plugin->displayname;
|
||||
|
||||
if ($options['show-all']) {
|
||||
cli_writeln($pluginstring);
|
||||
} else {
|
||||
if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
cli_writeln($pluginstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['purge-missing']) {
|
||||
foreach ($plugininfo as $type => $plugins) {
|
||||
foreach ($plugins as $name => $plugin) {
|
||||
if ($plugin->get_status() === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
|
||||
$pluginstring = $plugin->component . "\t" . $plugin->displayname;
|
||||
|
||||
if ($pluginman->can_uninstall_plugin($plugin->component)) {
|
||||
if ($options['run']) {
|
||||
cli_writeln('Uninstalling: ' . $pluginstring);
|
||||
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), true);
|
||||
$pluginman->uninstall_plugin($plugin->component, $progress);
|
||||
$progress->finished();
|
||||
cli_write($progress->get_buffer());
|
||||
} else {
|
||||
cli_writeln('Will be uninstalled: ' . $pluginstring);
|
||||
}
|
||||
} else {
|
||||
cli_writeln('Can not be uninstalled: ' . $pluginstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['plugins']) {
|
||||
$components = explode(',', $options['plugins']);
|
||||
foreach ($components as $component) {
|
||||
$plugin = $pluginman->get_plugin_info($component);
|
||||
|
||||
if (is_null($plugin)) {
|
||||
cli_writeln('Unknown plugin: ' . $component);
|
||||
} else {
|
||||
$pluginstring = $plugin->component . "\t" . $plugin->displayname;
|
||||
|
||||
if ($pluginman->can_uninstall_plugin($plugin->component)) {
|
||||
if ($options['run']) {
|
||||
cli_writeln('Uninstalling: ' . $pluginstring);
|
||||
$progress = new progress_trace_buffer(new text_progress_trace(), true);
|
||||
$pluginman->uninstall_plugin($plugin->component, $progress);
|
||||
$progress->finished();
|
||||
cli_write($progress->get_buffer());
|
||||
} else {
|
||||
cli_writeln('Will be uninstalled: ' . $pluginstring);
|
||||
}
|
||||
} else {
|
||||
cli_writeln('Can not be uninstalled: ' . $pluginstring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
cli_writeln($help);
|
||||
exit(0);
|
||||
@@ -1,62 +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/>.
|
||||
|
||||
/**
|
||||
* Allows the admin to enable, disable and uninstall custom fields
|
||||
*
|
||||
* @package core_admin
|
||||
* @copyright 2018 Daniel Neis Araujo
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$customfieldname = required_param('field', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/customfields.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_login();
|
||||
require_capability('moodle/site:config', $syscontext);
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', array('section' => 'managecustomfields'));
|
||||
|
||||
$customfieldplugins = core_plugin_manager::instance()->get_plugins_of_type('customfield');
|
||||
$sortorder = array_flip(array_keys($customfieldplugins));
|
||||
|
||||
if (!isset($customfieldplugins[$customfieldname])) {
|
||||
print_error('customfieldnotfound', 'error', $return, $customfieldname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($customfieldplugins[$customfieldname]->is_enabled()) {
|
||||
set_config('disabled', 1, 'customfield_'. $customfieldname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$customfieldplugins[$customfieldname]->is_enabled()) {
|
||||
unset_config('disabled', 'customfield_'. $customfieldname);
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
break;
|
||||
}
|
||||
redirect($return);
|
||||
@@ -2451,7 +2451,6 @@
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.0.0" level="required">
|
||||
<RESTRICT function="restrict_php_version_74" message="unsupportedphpversion74" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
@@ -2619,729 +2618,4 @@
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.7" requires="3.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.6" />
|
||||
<VENDOR name="postgres" version="9.4" />
|
||||
<VENDOR name="mssql" version="10.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.1.0" level="required">
|
||||
<RESTRICT function="restrict_php_version_74" message="unsupportedphpversion74" />
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.8" requires="3.2">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="5.5.31" />
|
||||
<VENDOR name="mysql" version="5.6" />
|
||||
<VENDOR name="postgres" version="9.4" />
|
||||
<VENDOR name="mssql" version="11.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.1.0" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.9" requires="3.5">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="10.2.29" />
|
||||
<VENDOR name="mysql" version="5.6" />
|
||||
<VENDOR name="postgres" version="9.5" />
|
||||
<VENDOR name="mssql" version="11.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.2.0" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mbstringrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
<MOODLE version="3.10" requires="3.5">
|
||||
<UNICODE level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unicoderequired" />
|
||||
</FEEDBACK>
|
||||
</UNICODE>
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mariadb" version="10.2.29" />
|
||||
<VENDOR name="mysql" version="5.7" />
|
||||
<VENDOR name="postgres" version="9.6" />
|
||||
<VENDOR name="mssql" version="11.0" />
|
||||
<VENDOR name="oracle" version="11.2" />
|
||||
</DATABASE>
|
||||
<PHP version="7.2.0" level="required">
|
||||
</PHP>
|
||||
<PCREUNICODE level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="pcreunicodewarning" />
|
||||
</FEEDBACK>
|
||||
</PCREUNICODE>
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="iconvrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mbstringrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="curl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="curlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="openssl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="opensslrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="tokenizer" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="tokenizerrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlrpc" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="xmlrpcrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="soap" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="soaprecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="ctype" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ctyperequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zip" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="ziprequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="zlib" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="gd" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="gdrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="simplexml" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="simplexmlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="spl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="splrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="pcre" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="dom" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xml" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="xmlreader" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="intl" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="intlrequired" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="json" level="required">
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="hash" level="required"/>
|
||||
<PHP_EXTENSION name="fileinfo" level="required"/>
|
||||
</PHP_EXTENSIONS>
|
||||
<PHP_SETTINGS>
|
||||
<PHP_SETTING name="memory_limit" value="96M" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="settingmemorylimit" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="file_uploads" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="settingfileuploads" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
<PHP_SETTING name="opcache.enable" value="1" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="opcacherecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_SETTING>
|
||||
</PHP_SETTINGS>
|
||||
<CUSTOM_CHECKS>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_storage_engine" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbstorageengine" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="question/engine/upgrade/upgradelib.php" function="quiz_attempts_upgraded" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="quizattemptsupgradedmessage" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_slasharguments" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="slashargumentswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_database_tables_row_format" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unsupporteddbtablerowformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_unoconv_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="unoconvwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_libcurl_version" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="libcurlwarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_format" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfileformat" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_file_per_table" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddbfilepertable" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_large_prefix" level="required">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="unsupporteddblargeprefix" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_is_https" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="ishttpswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_mysql_incomplete_unicode_support" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="incompleteunicodesupport" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_sixtyfour_bits" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="sixtyfourbitswarning" />
|
||||
</FEEDBACK>
|
||||
</CUSTOM_CHECK>
|
||||
</CUSTOM_CHECKS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+11
-30
@@ -226,7 +226,7 @@ if (!core_tables_exist()) {
|
||||
}
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environmentresults) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
@@ -235,7 +235,7 @@ if (!core_tables_exist()) {
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environmentresults, $release);
|
||||
echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
|
||||
die();
|
||||
}
|
||||
|
||||
@@ -358,9 +358,9 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
echo $output->upgrade_confirm_page($a->newversion, $maturity, $testsite);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmrelease)) {
|
||||
} else if (empty($confirmrelease)){
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
list($envstatus, $environmentresults) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
list($envstatus, $environment_results) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
@@ -368,7 +368,7 @@ if (!$cache and $version > $CFG->version) { // upgrade
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environmentresults);
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environment_results);
|
||||
die();
|
||||
|
||||
} else if (empty($confirmplugins)) {
|
||||
@@ -533,10 +533,7 @@ if (!$cache and $branch <> $CFG->branch) { // Update the branch
|
||||
|
||||
if (!$cache and moodle_needs_upgrading()) {
|
||||
|
||||
$PAGE->set_url(new moodle_url($PAGE->url, array(
|
||||
'confirmrelease' => $confirmrelease,
|
||||
'confirmplugincheck' => $confirmplugins,
|
||||
)));
|
||||
$PAGE->set_url(new moodle_url($PAGE->url, array('confirmplugincheck' => $confirmplugins)));
|
||||
|
||||
check_upgrade_key($upgradekeyhash);
|
||||
|
||||
@@ -546,21 +543,7 @@ if (!$cache and moodle_needs_upgrading()) {
|
||||
$pluginman = core_plugin_manager::instance();
|
||||
$output = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
if (empty($confirmrelease)) {
|
||||
require_once($CFG->libdir . '/environmentlib.php');
|
||||
|
||||
list($envstatus, $environmentresults) = check_moodle_environment($release, ENV_SELECT_RELEASE);
|
||||
$strcurrentrelease = get_string('currentrelease');
|
||||
|
||||
$PAGE->navbar->add($strcurrentrelease);
|
||||
$PAGE->set_title($strcurrentrelease);
|
||||
$PAGE->set_heading($strcurrentrelease);
|
||||
$PAGE->set_cacheable(false);
|
||||
|
||||
echo $output->upgrade_environment_page($release, $envstatus, $environmentresults);
|
||||
die();
|
||||
|
||||
} else if (!$confirmplugins) {
|
||||
if (!$confirmplugins) {
|
||||
$strplugincheck = get_string('plugincheck');
|
||||
|
||||
$PAGE->navbar->add($strplugincheck);
|
||||
@@ -819,7 +802,7 @@ $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
|
||||
$adminroot = admin_get_root();
|
||||
|
||||
// Check if there are any new admin settings which have still yet to be set
|
||||
if (any_new_admin_settings($adminroot)) {
|
||||
if (any_new_admin_settings($adminroot)){
|
||||
redirect('upgradesettings.php');
|
||||
}
|
||||
|
||||
@@ -840,11 +823,9 @@ if (isset($SESSION->pluginuninstallreturn)) {
|
||||
// Print default admin page with notifications.
|
||||
$errorsdisplayed = defined('WARN_DISPLAY_ERRORS_ENABLED');
|
||||
|
||||
$lastcron = get_config('tool_task', 'lastcronstart');
|
||||
// We make the assumption that at least one schedule task should run once per day.
|
||||
$lastcron = $DB->get_field_sql('SELECT MAX(lastruntime) FROM {task_scheduled}');
|
||||
$cronoverdue = ($lastcron < time() - 3600 * 24);
|
||||
$lastcroninterval = get_config('tool_task', 'lastcroninterval');
|
||||
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
|
||||
$croninfrequent = !$cronoverdue && ($lastcroninterval > $expectedfrequency || $lastcron < time() - $expectedfrequency);
|
||||
$dbproblems = $DB->diagnose();
|
||||
$maintenancemode = !empty($CFG->maintenance_enabled);
|
||||
|
||||
@@ -905,4 +886,4 @@ $output = $PAGE->get_renderer('core', 'admin');
|
||||
echo $output->admin_notifications_page($maturity, $insecuredataroot, $errorsdisplayed, $cronoverdue, $dbproblems,
|
||||
$maintenancemode, $availableupdates, $availableupdatesfetch, $buggyiconvnomb,
|
||||
$registered, $cachewarnings, $eventshandlers, $themedesignermode, $devlibdir,
|
||||
$mobileconfigured, $overridetossl, $invalidforgottenpasswordurl, $croninfrequent);
|
||||
$mobileconfigured, $overridetossl, $invalidforgottenpasswordurl);
|
||||
|
||||
+27
-101
@@ -25,121 +25,47 @@ require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->dirroot . '/message/lib.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page.
|
||||
// This is an admin page
|
||||
admin_externalpage_setup('managemessageoutputs');
|
||||
|
||||
// Fetch processors.
|
||||
$allprocessors = get_message_processors();
|
||||
$processors = array_filter($allprocessors, function($processor) {
|
||||
return $processor->enabled;
|
||||
});
|
||||
$disabledprocessors = array_filter($allprocessors, function($processor) {
|
||||
return !$processor->enabled;
|
||||
});
|
||||
// Get the submitted params
|
||||
$disable = optional_param('disable', 0, PARAM_INT);
|
||||
$enable = optional_param('enable', 0, PARAM_INT);
|
||||
|
||||
// Fetch message providers.
|
||||
$providers = get_message_providers();
|
||||
// Fetch the manage message outputs interface.
|
||||
$preferences = get_message_output_default_preferences();
|
||||
$headingtitle = get_string('managemessageoutputs', 'message');
|
||||
|
||||
if (($form = data_submitted()) && confirm_sesskey()) {
|
||||
$newpreferences = array();
|
||||
// Prepare default message outputs settings.
|
||||
foreach ($providers as $provider) {
|
||||
$componentproviderbase = $provider->component.'_'.$provider->name;
|
||||
$disableprovidersetting = $componentproviderbase.'_disable';
|
||||
$providerdisabled = false;
|
||||
if (!isset($form->$disableprovidersetting)) {
|
||||
$providerdisabled = true;
|
||||
$newpreferences[$disableprovidersetting] = 1;
|
||||
} else {
|
||||
$newpreferences[$disableprovidersetting] = 0;
|
||||
}
|
||||
|
||||
foreach (array('permitted', 'loggedin', 'loggedoff') as $setting) {
|
||||
$value = null;
|
||||
$componentprovidersetting = $componentproviderbase.'_'.$setting;
|
||||
if ($setting == 'permitted') {
|
||||
// If we deal with permitted select element, we need to create individual
|
||||
// setting for each possible processor. Note that this block will
|
||||
// always be processed first after entring parental foreach iteration
|
||||
// so we can change form values on this stage.
|
||||
foreach ($processors as $processor) {
|
||||
$value = '';
|
||||
if (isset($form->{$componentprovidersetting}[$processor->name])) {
|
||||
$value = $form->{$componentprovidersetting}[$processor->name];
|
||||
}
|
||||
// Ensure that loggedin loggedoff options are set correctly for this permission.
|
||||
if (($value == 'disallowed') || $providerdisabled) {
|
||||
// It might be better to unset them, but I can't figure out why that cause error.
|
||||
$form->{$componentproviderbase.'_loggedin'}[$processor->name] = 0;
|
||||
$form->{$componentproviderbase.'_loggedoff'}[$processor->name] = 0;
|
||||
} else if ($value == 'forced') {
|
||||
$form->{$componentproviderbase.'_loggedin'}[$processor->name] = 1;
|
||||
$form->{$componentproviderbase.'_loggedoff'}[$processor->name] = 1;
|
||||
}
|
||||
// Record the site preference.
|
||||
$newpreferences[$processor->name.'_provider_'.$componentprovidersetting] = $value;
|
||||
}
|
||||
} else {
|
||||
$newsettings = array();
|
||||
if (property_exists($form, $componentprovidersetting)) {
|
||||
// We must be processing loggedin or loggedoff checkboxes.
|
||||
// Store defained comma-separated processors as setting value.
|
||||
// Using array_filter eliminates elements set to 0 above.
|
||||
$newsettings = array_keys(array_filter($form->{$componentprovidersetting}));
|
||||
}
|
||||
|
||||
// Let's join existing setting values for disabled processors.
|
||||
$property = 'message_provider_'.$componentprovidersetting;
|
||||
if (property_exists($preferences, $property)) {
|
||||
$existingsetting = $preferences->$property;
|
||||
foreach ($disabledprocessors as $disable) {
|
||||
if (strpos($existingsetting, $disable->name) > -1) {
|
||||
$newsettings[] = $disable->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$value = join(',', $newsettings);
|
||||
if (empty($value)) {
|
||||
$value = null;
|
||||
}
|
||||
}
|
||||
if ($setting != 'permitted') {
|
||||
// We have already recoded site preferences for 'permitted' type.
|
||||
$newpreferences['message_provider_'.$componentprovidersetting] = $value;
|
||||
}
|
||||
}
|
||||
if (!empty($disable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$disable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
|
||||
// Update database.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
// Save processors enabled/disabled status.
|
||||
foreach ($allprocessors as $processor) {
|
||||
$enabled = isset($form->{$processor->name});
|
||||
\core_message\api::update_processor_status($processor, $enabled);
|
||||
}
|
||||
|
||||
foreach ($newpreferences as $name => $value) {
|
||||
set_config($name, $value, 'message');
|
||||
}
|
||||
$transaction->allow_commit();
|
||||
|
||||
\core_message\api::update_processor_status($processor, 0); // Disable output.
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if (!empty($enable) && confirm_sesskey()) {
|
||||
if (!$processor = $DB->get_record('message_processors', array('id'=>$enable))) {
|
||||
print_error('outputdoesnotexist', 'message');
|
||||
}
|
||||
\core_message\api::update_processor_status($processor, 1); // Enable output.
|
||||
core_plugin_manager::reset_caches();
|
||||
}
|
||||
|
||||
if ($disable || $enable) {
|
||||
$url = new moodle_url('message.php');
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
// Page settings
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->requires->js_init_call('M.core_message.init_defaultoutputs');
|
||||
|
||||
// Grab the renderer
|
||||
$renderer = $PAGE->get_renderer('core', 'message');
|
||||
|
||||
// Display the page.
|
||||
// Display the manage message outputs interface
|
||||
$processors = get_message_processors();
|
||||
$messageoutputs = $renderer->manage_messageoutputs($processors);
|
||||
|
||||
// Display the page
|
||||
echo $OUTPUT->header();
|
||||
echo $renderer->manage_messageoutput_settings($allprocessors, $processors, $providers, $preferences);
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
echo $messageoutputs;
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -45,8 +45,8 @@ $error = optional_param('error', '', PARAM_ALPHANUM);
|
||||
|
||||
admin_externalpage_setup('registrationmoodleorg');
|
||||
|
||||
if (parse_url($url, PHP_URL_HOST) !== parse_url(HUB_MOODLEORGHUBURL, PHP_URL_HOST)) {
|
||||
// Allow other plugins to confirm registration on custom hubs. Plugins implementing this
|
||||
if ($url !== HUB_MOODLEORGHUBURL) {
|
||||
// Allow other plugins to confirm registration on hubs other than moodle.net . Plugins implementing this
|
||||
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
|
||||
$callbacks = get_plugins_with_function('hub_registration');
|
||||
foreach ($callbacks as $plugintype => $plugins) {
|
||||
|
||||
@@ -32,4 +32,5 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
debugging('Support for alternative hubs has been removed from Moodle in 3.4.', DEBUG_DEVELOPER);
|
||||
debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' .
|
||||
'see lib/classes/hub/ .', DEBUG_DEVELOPER);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
|
||||
* @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
*
|
||||
* This page displays the site registration form.
|
||||
* This page displays the site registration form for Moodle.net.
|
||||
* It handles redirection to the hub to continue the registration workflow process.
|
||||
* It also handles update operation by web service.
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ if ($unregistration && \core\hub\registration::is_registered()) {
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorgremove', 'core_hub'), 3, 'main');
|
||||
echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', 'Moodle.net'), 3, 'main');
|
||||
$siteunregistrationform->display();
|
||||
echo $OUTPUT->footer();
|
||||
exit;
|
||||
@@ -82,7 +82,7 @@ if ($fromform = $siteregistrationform->get_data()) {
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// Current status of registration.
|
||||
// Current status of registration on Moodle.net.
|
||||
|
||||
$notificationtype = \core\output\notification::NOTIFY_ERROR;
|
||||
if (\core\hub\registration::is_registered()) {
|
||||
@@ -104,11 +104,11 @@ if (\core\hub\registration::is_registered()) {
|
||||
|
||||
// Heading.
|
||||
if (\core\hub\registration::is_registered()) {
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorgupdate', 'core_hub'));
|
||||
echo $OUTPUT->heading(get_string('updatesite', 'hub', 'Moodle.net'));
|
||||
} else if ($isinitialregistration) {
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorgcomplete', 'core_hub'));
|
||||
echo $OUTPUT->heading(get_string('completeregistration', 'hub'));
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'core_hub'));
|
||||
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('core', 'admin');
|
||||
|
||||
@@ -39,8 +39,8 @@ $token = optional_param('token', '', PARAM_TEXT);
|
||||
|
||||
admin_externalpage_setup('registrationmoodleorg');
|
||||
|
||||
if (parse_url($url, PHP_URL_HOST) !== parse_url(HUB_MOODLEORGHUBURL, PHP_URL_HOST)) {
|
||||
// Allow other plugins to renew registration on custom hubs. Plugins implementing this
|
||||
if ($url !== HUB_MOODLEORGHUBURL) {
|
||||
// Allow other plugins to renew registration on hubs other than moodle.net . Plugins implementing this
|
||||
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
|
||||
$callbacks = get_plugins_with_function('hub_registration');
|
||||
foreach ($callbacks as $plugintype => $plugins) {
|
||||
@@ -56,7 +56,7 @@ if (parse_url($url, PHP_URL_HOST) !== parse_url(HUB_MOODLEORGHUBURL, PHP_URL_HOS
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
|
||||
$hublink = html_writer::tag('a', HUB_MOODLEORGHUBURL, array('href' => HUB_MOODLEORGHUBURL));
|
||||
$hublink = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL));
|
||||
|
||||
$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);
|
||||
|
||||
|
||||
+70
-121
@@ -281,7 +281,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @param bool $mobileconfigured Whether the mobile web services have been enabled
|
||||
* @param bool $overridetossl Whether or not ssl is being forced.
|
||||
* @param bool $invalidforgottenpasswordurl Whether the forgotten password URL does not link to a valid URL.
|
||||
* @param bool $croninfrequent If true, warn that cron hasn't run in the past few minutes
|
||||
*
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
@@ -289,7 +288,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$cronoverdue, $dbproblems, $maintenancemode, $availableupdates, $availableupdatesfetch,
|
||||
$buggyiconvnomb, $registered, array $cachewarnings = array(), $eventshandlers = 0,
|
||||
$themedesignermode = false, $devlibdir = false, $mobileconfigured = false,
|
||||
$overridetossl = false, $invalidforgottenpasswordurl = false, $croninfrequent = false) {
|
||||
$overridetossl = false, $invalidforgottenpasswordurl = false) {
|
||||
global $CFG;
|
||||
$output = '';
|
||||
|
||||
@@ -303,7 +302,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output .= $this->display_errors_warning($errorsdisplayed);
|
||||
$output .= $this->buggy_iconv_warning($buggyiconvnomb);
|
||||
$output .= $this->cron_overdue_warning($cronoverdue);
|
||||
$output .= $this->cron_infrequent_warning($croninfrequent);
|
||||
$output .= $this->db_problems($dbproblems);
|
||||
$output .= $this->maintenance_mode_warning($maintenancemode);
|
||||
$output .= $this->overridetossl_warning($overridetossl);
|
||||
@@ -361,15 +359,14 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$output = '';
|
||||
|
||||
if ($checker->enabled()) {
|
||||
$output .= $this->container_start('checkforupdates mb-4');
|
||||
$output .= $this->container_start('checkforupdates');
|
||||
$output .= $this->single_button(
|
||||
new moodle_url($reloadurl, array('fetchupdates' => 1)),
|
||||
get_string('checkforupdates', 'core_plugin')
|
||||
);
|
||||
if ($timefetched = $checker->get_last_timefetched()) {
|
||||
$timefetched = userdate($timefetched, get_string('strftimedatetime', 'core_langconfig'));
|
||||
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched),
|
||||
'lasttimefetched small text-muted mt-1');
|
||||
$output .= $this->container(get_string('checkforupdateslast', 'core_plugin', $timefetched), 'lasttimefetched');
|
||||
}
|
||||
$output .= $this->container_end();
|
||||
}
|
||||
@@ -617,24 +614,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if cron is not being run frequently (recommended every minute).
|
||||
*
|
||||
* @param bool $croninfrequent
|
||||
* @return string HTML to output.
|
||||
*/
|
||||
public function cron_infrequent_warning(bool $croninfrequent) : string {
|
||||
global $CFG;
|
||||
|
||||
if (!$croninfrequent) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$expectedfrequency = $CFG->expectedcronfrequency ?? 200;
|
||||
return $this->warning(get_string('croninfrequent', 'admin', $expectedfrequency) . ' ' .
|
||||
$this->help_icon('cron', 'admin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an appropriate message if there are any problems with the DB set-up.
|
||||
* @param bool $dbproblems
|
||||
@@ -824,7 +803,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$updateinfo .= $this->container_start('checkforupdates mt-1');
|
||||
$updateinfo .= $this->container_start('checkforupdates');
|
||||
$fetchurl = new moodle_url('/admin/index.php', array('fetchupdates' => 1, 'sesskey' => sesskey(), 'cache' => 0));
|
||||
$updateinfo .= $this->single_button($fetchurl, get_string('checkforupdates', 'core_plugin'));
|
||||
if ($fetch) {
|
||||
@@ -844,7 +823,8 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
protected function registration_warning($registered) {
|
||||
|
||||
if (!$registered && site_is_public()) {
|
||||
if (!$registered) {
|
||||
|
||||
if (has_capability('moodle/site:config', context_system::instance())) {
|
||||
$registerbutton = $this->single_button(new moodle_url('/admin/registration/index.php'),
|
||||
get_string('register', 'admin'));
|
||||
@@ -913,7 +893,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
protected function moodle_available_update_info(\core\update\info $updateinfo) {
|
||||
|
||||
$boxclasses = 'moodleupdateinfo mb-2';
|
||||
$boxclasses = 'moodleupdateinfo';
|
||||
$info = array();
|
||||
|
||||
if (isset($updateinfo->release)) {
|
||||
@@ -933,8 +913,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
if (isset($updateinfo->download)) {
|
||||
$info[] = html_writer::link($updateinfo->download, get_string('download'),
|
||||
array('class' => 'info download btn btn-secondary'));
|
||||
$info[] = html_writer::link($updateinfo->download, get_string('download'), array('class' => 'info download'));
|
||||
}
|
||||
|
||||
if (isset($updateinfo->url)) {
|
||||
@@ -942,9 +921,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
array('class' => 'info more'));
|
||||
}
|
||||
|
||||
$box = $this->output->container_start($boxclasses);
|
||||
$box .= $this->output->container(implode(html_writer::tag('span', ' | ', array('class' => 'separator')), $info), '');
|
||||
$box .= $this->output->container_end();
|
||||
$box = $this->output->box_start($boxclasses);
|
||||
$box .= $this->output->box(implode(html_writer::tag('span', ' ', array('class' => 'separator')), $info), '');
|
||||
$box .= $this->output->box_end();
|
||||
|
||||
return $box;
|
||||
}
|
||||
@@ -1056,7 +1035,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$displayname = new html_table_cell(
|
||||
$icon.
|
||||
html_writer::span($plugin->displayname, 'pluginname').
|
||||
html_writer::div($plugin->get_dir(), 'plugindir text-muted small')
|
||||
html_writer::div($plugin->get_dir(), 'plugindir')
|
||||
);
|
||||
|
||||
$versiondb = new html_table_cell($plugin->versiondb);
|
||||
@@ -1064,10 +1043,10 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
if ($isstandard = $plugin->is_standard()) {
|
||||
$row->attributes['class'] .= ' standard';
|
||||
$sourcelabel = html_writer::span(get_string('sourcestd', 'core_plugin'), 'sourcetext badge badge-secondary');
|
||||
$sourcelabel = html_writer::span(get_string('sourcestd', 'core_plugin'), 'sourcetext label');
|
||||
} else {
|
||||
$row->attributes['class'] .= ' extension';
|
||||
$sourcelabel = html_writer::span(get_string('sourceext', 'core_plugin'), 'sourcetext badge badge-info');
|
||||
$sourcelabel = html_writer::span(get_string('sourceext', 'core_plugin'), 'sourcetext label label-info');
|
||||
}
|
||||
|
||||
$coredependency = $plugin->is_core_dependency_satisfied($version);
|
||||
@@ -1076,22 +1055,22 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
|
||||
$statuscode = $plugin->get_status();
|
||||
$row->attributes['class'] .= ' status-' . $statuscode;
|
||||
$statusclass = 'statustext badge ';
|
||||
$statusclass = 'statustext label ';
|
||||
switch ($statuscode) {
|
||||
case core_plugin_manager::PLUGIN_STATUS_NEW:
|
||||
$statusclass .= $dependenciesok ? 'badge-success' : 'badge-warning';
|
||||
$statusclass .= $dependenciesok ? 'label-success' : 'label-warning';
|
||||
break;
|
||||
case core_plugin_manager::PLUGIN_STATUS_UPGRADE:
|
||||
$statusclass .= $dependenciesok ? 'badge-info' : 'badge-warning';
|
||||
$statusclass .= $dependenciesok ? 'label-info' : 'label-warning';
|
||||
break;
|
||||
case core_plugin_manager::PLUGIN_STATUS_MISSING:
|
||||
case core_plugin_manager::PLUGIN_STATUS_DOWNGRADE:
|
||||
case core_plugin_manager::PLUGIN_STATUS_DELETE:
|
||||
$statusclass .= 'badge-danger';
|
||||
$statusclass .= 'label-important';
|
||||
break;
|
||||
case core_plugin_manager::PLUGIN_STATUS_NODB:
|
||||
case core_plugin_manager::PLUGIN_STATUS_UPTODATE:
|
||||
$statusclass .= $dependenciesok ? 'badge-light' : 'badge-warning';
|
||||
$statusclass .= $dependenciesok ? '' : 'label-warning';
|
||||
break;
|
||||
}
|
||||
$status = html_writer::span(get_string('status_' . $statuscode, 'core_plugin'), $statusclass);
|
||||
@@ -1101,7 +1080,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortinstall' => $plugin->component)),
|
||||
get_string('cancelinstallone', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'actionbutton cancelinstallone d-block mt-1')
|
||||
array('class' => 'actionbutton cancelinstallone')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1110,7 +1089,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortupgrade' => $plugin->component)),
|
||||
get_string('cancelupgradeone', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'actionbutton cancelupgradeone d-block mt-1')
|
||||
array('class' => 'actionbutton cancelupgradeone')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1180,7 +1159,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$out .= $this->output->container_start('actions mb-2');
|
||||
$out .= $this->output->container_start('actions');
|
||||
|
||||
$installableupdates = $pluginman->filter_installable($pluginman->available_updates());
|
||||
if ($installableupdates) {
|
||||
@@ -1188,7 +1167,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('installupdatex' => 1)),
|
||||
get_string('updateavailableinstallall', 'core_admin', count($installableupdates)),
|
||||
'post',
|
||||
array('class' => 'singlebutton updateavailableinstallall mr-1')
|
||||
array('class' => 'singlebutton updateavailableinstallall')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1197,7 +1176,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortinstallx' => 1)),
|
||||
get_string('cancelinstallall', 'core_plugin', count($installabortable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton cancelinstallall mr-1')
|
||||
array('class' => 'singlebutton cancelinstallall')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1206,17 +1185,15 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('abortupgradex' => 1)),
|
||||
get_string('cancelupgradeall', 'core_plugin', count($upgradeabortable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton cancelupgradeall mr-1')
|
||||
array('class' => 'singlebutton cancelupgradeall')
|
||||
);
|
||||
}
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 0)),
|
||||
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge badge-light'),
|
||||
'btn btn-link mr-1');
|
||||
get_string('plugincheckattention', 'core_plugin')).' '.html_writer::span($sumattention, 'badge'));
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url($this->page->url, array('showallplugins' => 1)),
|
||||
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge badge-light'),
|
||||
'btn btn-link mr-1');
|
||||
get_string('plugincheckall', 'core_plugin')).' '.html_writer::span($sumtotal, 'badge'));
|
||||
|
||||
$out .= $this->output->container_end(); // End of .actions container.
|
||||
$out .= $this->output->container_end(); // End of #plugins-check-info container.
|
||||
@@ -1284,13 +1261,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
}
|
||||
|
||||
$out = $this->output->container_start('plugins-check-dependencies mb-4');
|
||||
$out = $this->output->container_start('plugins-check-dependencies');
|
||||
|
||||
if ($unavailable or $unknown) {
|
||||
$out .= $this->output->heading(get_string('misdepsunavail', 'core_plugin'));
|
||||
if ($unknown) {
|
||||
$out .= $this->output->render((new \core\output\notification(get_string('misdepsunknownlist', 'core_plugin',
|
||||
implode(', ', $unknown))))->set_show_closebutton(false));
|
||||
$out .= $this->output->notification(get_string('misdepsunknownlist', 'core_plugin', implode($unknown, ', ')));
|
||||
}
|
||||
if ($unavailable) {
|
||||
$unavailablelist = array();
|
||||
@@ -1304,18 +1280,18 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$unavailablelist[] = $unavailablelistitem;
|
||||
}
|
||||
$out .= $this->output->render((new \core\output\notification(get_string('misdepsunavaillist', 'core_plugin',
|
||||
implode(', ', $unavailablelist))))->set_show_closebutton(false));
|
||||
$out .= $this->output->notification(get_string('misdepsunavaillist', 'core_plugin',
|
||||
implode($unavailablelist, ', ')));
|
||||
}
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions mb-4');
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions');
|
||||
$out .= ' '.html_writer::link(new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-secondary'));
|
||||
get_string('dependencyuploadmissing', 'core_plugin'));
|
||||
$out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container.
|
||||
}
|
||||
|
||||
if ($available) {
|
||||
$out .= $this->output->heading(get_string('misdepsavail', 'core_plugin'));
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions mb-2');
|
||||
$out .= $this->output->container_start('plugins-check-dependencies-actions');
|
||||
|
||||
$installable = $pluginman->filter_installable($available);
|
||||
if ($installable) {
|
||||
@@ -1323,13 +1299,12 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
new moodle_url($this->page->url, array('installdepx' => 1)),
|
||||
get_string('dependencyinstallmissing', 'core_plugin', count($installable)),
|
||||
'post',
|
||||
array('class' => 'singlebutton dependencyinstallmissing d-inline-block mr-1')
|
||||
array('class' => 'singlebutton dependencyinstallmissing')
|
||||
);
|
||||
}
|
||||
|
||||
$out .= html_writer::div(html_writer::link(new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'), array('class' => 'btn btn-link')),
|
||||
'dependencyuploadmissing d-inline-block mr-1');
|
||||
get_string('dependencyuploadmissing', 'core_plugin')), 'dependencyuploadmissing');
|
||||
|
||||
$out .= $this->output->container_end(); // End of .plugins-check-dependencies-actions container.
|
||||
|
||||
@@ -1368,9 +1343,9 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$supportedmoodles = array();
|
||||
foreach ($plugin->version->supportedmoodles as $moodle) {
|
||||
if ($CFG->branch == str_replace('.', '', $moodle->release)) {
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-success');
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'label label-success');
|
||||
} else {
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'badge badge-light');
|
||||
$supportedmoodles[] = html_writer::span($moodle->release, 'label');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1384,7 +1359,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
}
|
||||
$info = html_writer::div(
|
||||
get_string('requiredby', 'core_plugin', implode(', ', $requriedby)),
|
||||
'requiredby mb-1'
|
||||
'requiredby'
|
||||
);
|
||||
} else {
|
||||
$info = '';
|
||||
@@ -1395,36 +1370,35 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$info .= html_writer::div(
|
||||
html_writer::link('https://moodle.org/plugins/view.php?plugin='.$plugin->component,
|
||||
get_string('misdepinfoplugin', 'core_plugin')),
|
||||
'misdepinfoplugin d-inline-block mr-3 mb-1'
|
||||
'misdepinfoplugin'
|
||||
);
|
||||
|
||||
$info .= html_writer::div(
|
||||
html_writer::link('https://moodle.org/plugins/pluginversion.php?id='.$plugin->version->id,
|
||||
get_string('misdepinfoversion', 'core_plugin')),
|
||||
'misdepinfoversion d-inline-block mr-3 mb-1'
|
||||
'misdepinfoversion'
|
||||
);
|
||||
|
||||
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')),
|
||||
'misdepdownload d-inline-block mr-3 mb-1');
|
||||
$info .= html_writer::div(html_writer::link($plugin->version->downloadurl, get_string('download')), 'misdepdownload');
|
||||
|
||||
if ($pluginman->is_remote_plugin_installable($plugin->component, $plugin->version->version, $reason)) {
|
||||
$info .= $this->output->single_button(
|
||||
new moodle_url($this->page->url, array('installdep' => $plugin->component)),
|
||||
get_string('dependencyinstall', 'core_plugin'),
|
||||
'post',
|
||||
array('class' => 'singlebutton dependencyinstall mr-3 mb-1')
|
||||
array('class' => 'singlebutton dependencyinstall')
|
||||
);
|
||||
} else {
|
||||
$reasonhelp = $this->info_remote_plugin_not_installable($reason);
|
||||
if ($reasonhelp) {
|
||||
$info .= html_writer::div($reasonhelp, 'reasonhelp dependencyinstall d-inline-block mr-3 mb-1');
|
||||
$info .= html_writer::div($reasonhelp, 'reasonhelp dependencyinstall');
|
||||
}
|
||||
}
|
||||
|
||||
$info .= $this->output->container_end(); // End of .actions container.
|
||||
|
||||
$table->data[] = array(
|
||||
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component text-muted small'),
|
||||
html_writer::div($plugin->name, 'name').' '.html_writer::div($plugin->component, 'component'),
|
||||
$plugin->version->release,
|
||||
$plugin->version->version,
|
||||
implode($supportedmoodles, ' '),
|
||||
@@ -1470,29 +1444,27 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
foreach ($pluginman->resolve_requirements($plugin, $version) as $reqname => $reqinfo) {
|
||||
if ($reqname === 'core') {
|
||||
if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) {
|
||||
$class = 'requires-ok text-muted';
|
||||
$class = 'requires-ok';
|
||||
$label = '';
|
||||
} else {
|
||||
$class = 'requires-failed';
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
|
||||
}
|
||||
if ($reqinfo->reqver != ANY_VERSION) {
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires), 'dep dep-core').
|
||||
' '.$label, array('class' => $class));
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-important');
|
||||
}
|
||||
$requires[] = html_writer::tag('li',
|
||||
html_writer::span(get_string('moodleversion', 'core_plugin', $plugin->versionrequires), 'dep dep-core').
|
||||
' '.$label, array('class' => $class));
|
||||
|
||||
} else {
|
||||
$actions = array();
|
||||
|
||||
if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OK) {
|
||||
$label = '';
|
||||
$class = 'requires-ok text-muted';
|
||||
$class = 'requires-ok';
|
||||
|
||||
} else if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_MISSING) {
|
||||
if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) {
|
||||
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-warning');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
|
||||
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'label label-warning');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'label label-warning');
|
||||
$class = 'requires-failed requires-missing requires-available';
|
||||
$actions[] = html_writer::link(
|
||||
new moodle_url('https://moodle.org/plugins/view.php', array('plugin' => $reqname)),
|
||||
@@ -1500,24 +1472,24 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
);
|
||||
|
||||
} else {
|
||||
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'badge badge-danger');
|
||||
$label = html_writer::span(get_string('dependencymissing', 'core_plugin'), 'label label-important');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyunavailable', 'core_plugin'),
|
||||
'badge badge-danger');
|
||||
'label label-important');
|
||||
$class = 'requires-failed requires-missing requires-unavailable';
|
||||
}
|
||||
$displayuploadlink = true;
|
||||
|
||||
} else if ($reqinfo->status == $pluginman::REQUIREMENT_STATUS_OUTDATED) {
|
||||
if ($reqinfo->availability == $pluginman::REQUIREMENT_AVAILABLE) {
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-warning');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'badge badge-warning');
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-warning');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyavailable', 'core_plugin'), 'label label-warning');
|
||||
$class = 'requires-failed requires-outdated requires-available';
|
||||
$displayupdateslink = true;
|
||||
|
||||
} else {
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'badge badge-danger');
|
||||
$label = html_writer::span(get_string('dependencyfails', 'core_plugin'), 'label label-important');
|
||||
$label .= ' '.html_writer::span(get_string('dependencyunavailable', 'core_plugin'),
|
||||
'badge badge-danger');
|
||||
'label label-important');
|
||||
$class = 'requires-failed requires-outdated requires-unavailable';
|
||||
}
|
||||
$displayuploadlink = true;
|
||||
@@ -1541,14 +1513,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
$out = html_writer::tag('ul', implode("\n", $requires), array('class' => 'm-0'));
|
||||
$out = html_writer::tag('ul', implode("\n", $requires));
|
||||
|
||||
if ($displayuploadlink) {
|
||||
$out .= html_writer::div(
|
||||
html_writer::link(
|
||||
new moodle_url('/admin/tool/installaddon/'),
|
||||
get_string('dependencyuploadmissing', 'core_plugin'),
|
||||
array('class' => 'btn btn-secondary btn-sm m-1')
|
||||
get_string('dependencyuploadmissing', 'core_plugin')
|
||||
),
|
||||
'dependencyuploadmissing'
|
||||
);
|
||||
@@ -1558,8 +1529,7 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$out .= html_writer::div(
|
||||
html_writer::link(
|
||||
new moodle_url($this->page->url, array('sesskey' => sesskey(), 'fetchupdates' => 1)),
|
||||
get_string('checkforupdates', 'core_plugin'),
|
||||
array('class' => 'btn btn-secondary btn-sm m-1')
|
||||
get_string('checkforupdates', 'core_plugin')
|
||||
),
|
||||
'checkforupdates'
|
||||
);
|
||||
@@ -1783,13 +1753,13 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
$source = '';
|
||||
} else {
|
||||
$row->attributes['class'] .= ' extension';
|
||||
$source = html_writer::div(get_string('sourceext', 'core_plugin'), 'source badge badge-info');
|
||||
$source = html_writer::div(get_string('sourceext', 'core_plugin'), 'source label label-info');
|
||||
}
|
||||
|
||||
if ($status === core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$msg = html_writer::div(get_string('status_missing', 'core_plugin'), 'statusmsg badge badge-danger');
|
||||
$msg = html_writer::div(get_string('status_missing', 'core_plugin'), 'statusmsg label label-important');
|
||||
} else if ($status === core_plugin_manager::PLUGIN_STATUS_NEW) {
|
||||
$msg = html_writer::div(get_string('status_new', 'core_plugin'), 'statusmsg badge badge-success');
|
||||
$msg = html_writer::div(get_string('status_new', 'core_plugin'), 'statusmsg label label-success');
|
||||
} else {
|
||||
$msg = '';
|
||||
}
|
||||
@@ -2028,15 +1998,15 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
// Format error or warning line
|
||||
if ($errorline) {
|
||||
$messagetype = 'error';
|
||||
$statusclass = 'badge-danger';
|
||||
$statusclass = 'label-important';
|
||||
} else if ($warningline) {
|
||||
$messagetype = 'warn';
|
||||
$statusclass = 'badge-warning';
|
||||
$statusclass = 'label-warning';
|
||||
} else {
|
||||
$messagetype = 'ok';
|
||||
$statusclass = 'badge-success';
|
||||
$statusclass = 'label-success';
|
||||
}
|
||||
$status = html_writer::span($status, 'badge ' . $statusclass);
|
||||
$status = html_writer::span($status, 'label ' . $statusclass);
|
||||
// Here we'll store all the feedback found
|
||||
$feedbacktext = '';
|
||||
// Append the feedback if there is some
|
||||
@@ -2121,27 +2091,6 @@ class core_admin_renderer extends plugin_renderer_base {
|
||||
* @return string
|
||||
*/
|
||||
public function moodleorg_registration_message() {
|
||||
|
||||
$out = format_text(get_string('registerwithmoodleorginfo', 'core_hub'), FORMAT_MARKDOWN);
|
||||
|
||||
$out .= html_writer::link(
|
||||
new moodle_url('/admin/settings.php', ['section' => 'moodleservices']),
|
||||
$this->output->pix_icon('i/info', '').' '.get_string('registerwithmoodleorginfoapp', 'core_hub'),
|
||||
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
|
||||
);
|
||||
|
||||
$out .= html_writer::link(
|
||||
HUB_MOODLEORGHUBURL,
|
||||
$this->output->pix_icon('i/stats', '').' '.get_string('registerwithmoodleorginfostats', 'core_hub'),
|
||||
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
|
||||
);
|
||||
|
||||
$out .= html_writer::link(
|
||||
HUB_MOODLEORGHUBURL.'/sites',
|
||||
$this->output->pix_icon('i/location', '').' '.get_string('registerwithmoodleorginfosites', 'core_hub'),
|
||||
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
|
||||
);
|
||||
|
||||
return $this->output->box($out);
|
||||
return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,15 @@ if (!is_siteadmin()) {
|
||||
}
|
||||
|
||||
$admisselector = new core_role_admins_existing_selector();
|
||||
$admisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
$potentialadmisselector = new core_role_admins_potential_selector();
|
||||
$potentialadmisselector->set_extra_fields(array('username', 'email'));
|
||||
|
||||
if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
if ($userstoadd = $potentialadmisselector->get_selected_users()) {
|
||||
$user = reset($userstoadd);
|
||||
$username = $potentialadmisselector->output_user($user);
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmadd'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmaddadmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
@@ -55,7 +58,7 @@ if (optional_param('add', false, PARAM_BOOL) and confirm_sesskey()) {
|
||||
if ($USER->id == $user->id) {
|
||||
// Can not remove self.
|
||||
} else {
|
||||
$username = $admisselector->output_user($user);
|
||||
$username = fullname($user) . " ($user->username, $user->email)";
|
||||
echo $OUTPUT->header();
|
||||
$yesurl = new moodle_url('/admin/roles/admins.php', array('confirmdel'=>$user->id, 'sesskey'=>sesskey()));
|
||||
echo $OUTPUT->confirm(get_string('confirmdeladmin', 'core_role', $username), $yesurl, $PAGE->url);
|
||||
|
||||
@@ -69,11 +69,8 @@ class core_role_check_users_selector extends user_selector_base {
|
||||
|
||||
if ($coursecontext and $coursecontext != SITEID) {
|
||||
$sql1 = " FROM {user} u
|
||||
JOIN (SELECT DISTINCT subu.id
|
||||
FROM {user} subu
|
||||
JOIN {user_enrolments} ue ON (ue.userid = subu.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
) subq ON subq.id = u.id
|
||||
JOIN {user_enrolments} ue ON (ue.userid = u.id)
|
||||
JOIN {enrol} e ON (e.id = ue.enrolid AND e.courseid = :courseid1)
|
||||
WHERE $wherecondition";
|
||||
$params['courseid1'] = $coursecontext->instanceid;
|
||||
|
||||
|
||||
@@ -157,19 +157,19 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
// Allowed roles.
|
||||
$allow = optional_param_array('allowassign', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowassign = array_filter($allow);
|
||||
$this->allowassign = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowoverride', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowoverride = array_filter($allow);
|
||||
$this->allowoverride = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowswitch', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowswitch = array_filter($allow);
|
||||
$this->allowswitch = $allow;
|
||||
}
|
||||
$allow = optional_param_array('allowview', null, PARAM_INT);
|
||||
if (!is_null($allow)) {
|
||||
$this->allowview = array_filter($allow);
|
||||
$this->allowview = $allow;
|
||||
}
|
||||
|
||||
// Now read the permissions for each capability.
|
||||
@@ -589,9 +589,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
if ($this->roleid == 0) {
|
||||
$options[-1] = get_string('thisnewrole', 'core_role');
|
||||
}
|
||||
return
|
||||
html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'allow'.$type.'[]', 'value' => "")) .
|
||||
html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple',
|
||||
return html_writer::select($options, 'allow'.$type.'[]', $selected, false, array('multiple' => 'multiple',
|
||||
'size' => 10, 'class' => 'form-control'));
|
||||
}
|
||||
|
||||
@@ -625,7 +623,7 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
|
||||
echo "</label>\n";
|
||||
}
|
||||
if ($helpicon) {
|
||||
echo '<span class="float-sm-right text-nowrap">'.$helpicon.'</span>';
|
||||
echo '<span class="pull-xs-right text-nowrap">'.$helpicon.'</span>';
|
||||
}
|
||||
echo '</div>';
|
||||
if (isset($this->errors[$name])) {
|
||||
|
||||
@@ -96,7 +96,7 @@ class core_role_permissions_table extends core_role_capability_table_base {
|
||||
"linkclass" => "preventlink", "adminurl" => $adminurl->out(), "icon" => "", "iconalt" => "");
|
||||
if (isset($overridableroles[$id]) and ($allowoverrides or ($allowsafeoverrides and is_safe_capability($capability)))) {
|
||||
$templatecontext['icon'] = 't/delete';
|
||||
$templatecontext['iconalt'] = get_string('deletexrole', 'core_role', $name);
|
||||
$templatecontext['iconalt'] = get_string('delete');
|
||||
}
|
||||
$neededroles[$id] = $renderer->render_from_template('core/permissionmanager_role', $templatecontext);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class core_role_permissions_table extends core_role_capability_table_base {
|
||||
"icon" => "", "iconalt" => "");
|
||||
if (isset($overridableroles[$id]) and prohibit_is_removable($id, $context, $capability->name)) {
|
||||
$templatecontext['icon'] = 't/delete';
|
||||
$templatecontext['iconalt'] = get_string('deletexrole', 'core_role', $name);
|
||||
$templatecontext['iconalt'] = get_string('delete');
|
||||
}
|
||||
$forbiddenroles[$id] = $renderer->render_from_template('core/permissionmanager_role', $templatecontext);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ M.core_role.init_cap_table_filter = function(Y, tableid, contextid) {
|
||||
marginRight : 'auto'
|
||||
});
|
||||
// Create the capability search input.
|
||||
this.input = Y.Node.create('<input class="form-control mx-1" type="text"' +
|
||||
this.input = Y.Node.create('<input class="form-control m-x-1" type="text"' +
|
||||
' id="'+this.table.get('id')+'capabilitysearch" value="'+Y.Escape.html(filtervalue)+'" />');
|
||||
// Create a label for the search input.
|
||||
this.label = Y.Node.create('<label for="' + this.input.get('id') + '">' +
|
||||
|
||||
@@ -213,7 +213,7 @@ $arguments = array('contextid' => $contextid,
|
||||
$PAGE->requires->strings_for_js(
|
||||
array('roleprohibitinfo', 'roleprohibitheader', 'roleallowinfo', 'roleallowheader',
|
||||
'confirmunassigntitle', 'confirmroleunprohibit', 'confirmroleprevent', 'confirmunassignyes',
|
||||
'confirmunassignno', 'deletexrole'), 'core_role');
|
||||
'confirmunassignno'), 'core_role');
|
||||
$PAGE->requires->js_call_amd('core/permissionmanager', 'initialize', array($arguments));
|
||||
$table = new core_role_permissions_table($context, $contextname, $allowoverrides, $allowsafeoverrides, $overridableroles);
|
||||
echo $OUTPUT->box_start('generalbox capbox');
|
||||
|
||||
@@ -153,7 +153,6 @@ $table = new html_table();
|
||||
$table->id = 'core-search-areas';
|
||||
$table->head = [
|
||||
get_string('searcharea', 'search'),
|
||||
get_string('searchareacategories', 'search'),
|
||||
get_string('enable'),
|
||||
get_string('newestdocindexed', 'admin'),
|
||||
get_string('searchlastrun', 'admin'),
|
||||
@@ -166,14 +165,6 @@ foreach ($searchareas as $area) {
|
||||
$areaid = $area->get_area_id();
|
||||
$columns = array(new html_table_cell($area->get_visible_name()));
|
||||
|
||||
$areacategories = [];
|
||||
foreach (\core_search\manager::get_search_area_categories() as $category) {
|
||||
if (key_exists($areaid, $category->get_areas())) {
|
||||
$areacategories[] = $category->get_visiblename();
|
||||
}
|
||||
}
|
||||
$columns[] = new html_table_cell(implode(', ', $areacategories));
|
||||
|
||||
if ($area->is_enabled()) {
|
||||
$columns[] = $OUTPUT->action_icon(admin_searcharea_action_url('disable', $areaid),
|
||||
new pix_icon('t/hide', get_string('disable'), 'moodle', array('title' => '', 'class' => 'iconsmall')),
|
||||
|
||||
@@ -156,11 +156,4 @@ $PAGE->requires->yui_module('moodle-core-formchangechecker',
|
||||
);
|
||||
$PAGE->requires->string_for_js('changesmadereallygoaway', 'moodle');
|
||||
|
||||
if ($settingspage->has_dependencies()) {
|
||||
$opts = [
|
||||
'dependencies' => $settingspage->get_dependencies_for_javascript()
|
||||
];
|
||||
$PAGE->requires->js_call_amd('core/showhidesettings', 'init', [$opts]);
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -25,52 +25,10 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
|
||||
$settings = new admin_settingpage('analyticssite', new lang_string('analyticssiteinfo', 'analytics'));
|
||||
$ADMIN->add('analytics', $settings);
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$modeinstructions = [
|
||||
'facetoface' => get_string('modeinstructionfacetoface', 'analytics'),
|
||||
'blendedhybrid' => get_string('modeinstructionblendedhybrid', 'analytics'),
|
||||
'fullyonline' => get_string('modeinstructionfullyonline', 'analytics'),
|
||||
];
|
||||
$settings->add(new admin_setting_configmultiselect('analytics/modeinstruction', get_string('modeinstruction', 'analytics'),
|
||||
'', [], $modeinstructions));
|
||||
|
||||
$settings->add(new admin_setting_configtext_with_maxlength('analytics/percentonline',
|
||||
get_string('percentonline', 'analytics'),
|
||||
get_string('percentonline_help', 'analytics'), '', PARAM_INT, 3, 3));
|
||||
|
||||
$typeinstitutions = [
|
||||
'typeinstitutionacademic' => get_string('typeinstitutionacademic', 'analytics'),
|
||||
'typeinstitutiontraining' => get_string('typeinstitutiontraining', 'analytics'),
|
||||
'typeinstitutionngo' => get_string('typeinstitutionngo', 'analytics'),
|
||||
];
|
||||
$settings->add(new admin_setting_configmultiselect('analytics/typeinstitution', get_string('typeinstitution', 'analytics'),
|
||||
'', [], $typeinstitutions));
|
||||
|
||||
$levelinstitutions = [
|
||||
'levelinstitutionisced0' => get_string('levelinstitutionisced0', 'analytics'),
|
||||
'levelinstitutionisced1' => get_string('levelinstitutionisced1', 'analytics'),
|
||||
'levelinstitutionisced2' => get_string('levelinstitutionisced2', 'analytics'),
|
||||
'levelinstitutionisced3' => get_string('levelinstitutionisced3', 'analytics'),
|
||||
'levelinstitutionisced4' => get_string('levelinstitutionisced4', 'analytics'),
|
||||
'levelinstitutionisced5' => get_string('levelinstitutionisced5', 'analytics'),
|
||||
'levelinstitutionisced6' => get_string('levelinstitutionisced6', 'analytics'),
|
||||
'levelinstitutionisced7' => get_string('levelinstitutionisced7', 'analytics'),
|
||||
'levelinstitutionisced8' => get_string('levelinstitutionisced8', 'analytics'),
|
||||
];
|
||||
$settings->add(new admin_setting_configmultiselect('analytics/levelinstitution',
|
||||
get_string('levelinstitution', 'analytics'), '', [], $levelinstitutions));
|
||||
}
|
||||
|
||||
$settings = new admin_settingpage('analyticssettings', new lang_string('analyticssettings', 'analytics'));
|
||||
$ADMIN->add('analytics', $settings);
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
|
||||
// Select the site prediction's processor.
|
||||
$predictionprocessors = \core_analytics\manager::get_all_prediction_processors();
|
||||
$predictors = array();
|
||||
@@ -117,7 +75,7 @@ if ($hassiteconfig) {
|
||||
$defaultreader, $options));
|
||||
|
||||
// Enable/disable time splitting methods.
|
||||
$alltimesplittings = \core_analytics\manager::get_time_splitting_methods_for_evaluation(true);
|
||||
$alltimesplittings = \core_analytics\manager::get_all_time_splittings();
|
||||
|
||||
$timesplittingoptions = array();
|
||||
$timesplittingdefaults = array('\core\analytics\time_splitting\quarters_accum',
|
||||
@@ -125,9 +83,8 @@ if ($hassiteconfig) {
|
||||
foreach ($alltimesplittings as $key => $timesplitting) {
|
||||
$timesplittingoptions[$key] = $timesplitting->get_name();
|
||||
}
|
||||
$settings->add(new admin_setting_configmultiselect('analytics/defaulttimesplittingsevaluation',
|
||||
new lang_string('defaulttimesplittingmethods', 'analytics'),
|
||||
new lang_string('defaulttimesplittingmethods_help', 'analytics'),
|
||||
$settings->add(new admin_setting_configmultiselect('analytics/timesplittings',
|
||||
new lang_string('enabledtimesplittings', 'analytics'), new lang_string('timesplittingmethod_help', 'analytics'),
|
||||
$timesplittingdefaults, $timesplittingoptions)
|
||||
);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp
|
||||
$temp->add(new admin_setting_configcheckbox('allowcohortthemes', new lang_string('allowcohortthemes', 'admin'), new lang_string('configallowcohortthemes', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowthemechangeonurl', new lang_string('allowthemechangeonurl', 'admin'), new lang_string('configallowthemechangeonurl', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('allowuserblockhiding', new lang_string('allowuserblockhiding', 'admin'), new lang_string('configallowuserblockhiding', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('allowblockstodock', new lang_string('allowblockstodock', 'admin'), new lang_string('configallowblockstodock', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configtextarea('custommenuitems', new lang_string('custommenuitems', 'admin'),
|
||||
new lang_string('configcustommenuitems', 'admin'), '', PARAM_RAW, '50', '10'));
|
||||
$temp->add(new admin_setting_configtextarea(
|
||||
|
||||
@@ -57,11 +57,9 @@ if (($hassiteconfig || has_any_capability(array(
|
||||
new lang_string('badgesalt_desc', 'badges'),
|
||||
'badges' . $SITE->timecreated, PARAM_ALPHANUM));
|
||||
|
||||
$backpacks = badges_get_site_backpacks();
|
||||
$choices = array();
|
||||
foreach ($backpacks as $backpack) {
|
||||
$choices[$backpack->id] = $backpack->backpackweburl;
|
||||
}
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowexternalbackpack',
|
||||
new lang_string('allowexternalbackpack', 'badges'),
|
||||
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
|
||||
|
||||
$globalsettings->add(new admin_setting_configcheckbox('badges_allowcoursebadges',
|
||||
new lang_string('allowcoursebadges', 'badges'),
|
||||
@@ -93,25 +91,4 @@ if (($hassiteconfig || has_any_capability(array(
|
||||
array('moodle/badges:createbadge'), empty($CFG->enablebadges)
|
||||
)
|
||||
);
|
||||
$backpacksettings = new admin_settingpage('backpacksettings', new lang_string('backpacksettings', 'badges'),
|
||||
array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges));
|
||||
|
||||
$backpacksettings->add(new admin_setting_configcheckbox('badges_allowexternalbackpack',
|
||||
new lang_string('allowexternalbackpack', 'badges'),
|
||||
new lang_string('allowexternalbackpack_desc', 'badges'), 1));
|
||||
|
||||
$backpacksettings->add(new admin_setting_configselect('badges_site_backpack',
|
||||
new lang_string('sitebackpack', 'badges'),
|
||||
new lang_string('sitebackpack_help', 'badges'),
|
||||
1, $choices));
|
||||
|
||||
$ADMIN->add('badges', $backpacksettings);
|
||||
|
||||
$ADMIN->add('badges',
|
||||
new admin_externalpage('managebackpacks',
|
||||
new lang_string('managebackpacks', 'badges'),
|
||||
new moodle_url('/badges/backpacks.php'),
|
||||
array('moodle/badges:manageglobalsettings'), empty($CFG->enablebadges) || empty($CFG->badges_allowexternalbackpack)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -37,12 +37,6 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
array('moodle/category:manage', 'moodle/course:create')
|
||||
)
|
||||
);
|
||||
$ADMIN->add('courses',
|
||||
new admin_externalpage('course_customfield', new lang_string('course_customfield', 'admin'),
|
||||
$CFG->wwwroot . '/course/customfield.php',
|
||||
array('moodle/course:configurecustomfields')
|
||||
)
|
||||
);
|
||||
$ADMIN->add('courses',
|
||||
new admin_externalpage('addcategory', new lang_string('addcategory', 'admin'),
|
||||
new moodle_url('/course/editcategory.php', array('parent' => 0)),
|
||||
@@ -336,7 +330,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_skip_modif_prev', new lang_string('skipmodifprev', 'backup'), new lang_string('skipmodifprevhelp', 'backup'), 0));
|
||||
|
||||
// Automated defaults section.
|
||||
$temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), new lang_string('recyclebin_desc', 'backup')));
|
||||
$temp->add(new admin_setting_heading('automatedsettings', new lang_string('automatedsettings','backup'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_users', new lang_string('generalusers', 'backup'), new lang_string('configgeneralusers', 'backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_role_assignments', new lang_string('generalroleassignments','backup'), new lang_string('configgeneralroleassignments','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_activities', new lang_string('generalactivities','backup'), new lang_string('configgeneralactivities','backup'), 1));
|
||||
@@ -458,32 +452,4 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for asynchronous backup and restore configuration and defaults.
|
||||
$temp = new admin_settingpage('asyncgeneralsettings', new lang_string('asyncgeneralsettings', 'backup'));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox('enableasyncbackup', new lang_string('enableasyncbackup', 'backup'),
|
||||
new lang_string('enableasyncbackup_help', 'backup'), 0, 1, 0));
|
||||
|
||||
$temp->add(new admin_setting_configcheckbox(
|
||||
'backup/backup_async_message_users',
|
||||
new lang_string('asyncemailenable', 'backup'),
|
||||
new lang_string('asyncemailenabledetail', 'backup'), 0));
|
||||
$temp->hide_if('backup/backup_async_message_users', 'enableasyncbackup');
|
||||
|
||||
$temp->add(new admin_setting_configtext(
|
||||
'backup/backup_async_message_subject',
|
||||
new lang_string('asyncmessagesubject', 'backup'),
|
||||
new lang_string('asyncmessagesubjectdetail', 'backup'),
|
||||
new lang_string('asyncmessagesubjectdefault', 'backup')));
|
||||
$temp->hide_if('backup/backup_async_message_subject', 'backup/backup_async_message_users');
|
||||
|
||||
$temp->add(new admin_setting_confightmleditor(
|
||||
'backup/backup_async_message',
|
||||
new lang_string('asyncmessagebody', 'backup'),
|
||||
new lang_string('asyncmessagebodydetail', 'backup'),
|
||||
new lang_string('asyncmessagebodydefault', 'backup')));
|
||||
$temp->hide_if('backup/backup_async_message', 'backup/backup_async_message_users');
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowme', new lang_string('profilingallowme', 'admin'), new lang_string('profilingallowme_help', 'admin'), false));
|
||||
// Allow PROFILEALL/PROFILEALLSTOP GPC.
|
||||
$temp->add(new admin_setting_configcheckbox('profilingallowall', new lang_string('profilingallowall', 'admin'), new lang_string('profilingallowall_help', 'admin'), false));
|
||||
$temp->add(new admin_setting_configtext('profilingslow', new lang_string('profilingslow', 'admin'),
|
||||
new lang_string('profilingslow_help', 'admin'), 0, PARAM_FLOAT));
|
||||
// TODO: Allow to skip PHP functions (XHPROF_FLAGS_NO_BUILTINS)
|
||||
// TODO: Allow to skip call_user functions (ignored_functions array)
|
||||
// Specify the life time (in minutes) of profiling runs.
|
||||
|
||||
@@ -1,78 +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/>.
|
||||
|
||||
/**
|
||||
* Adds messaging related settings links for Messaging category to admin tree.
|
||||
*
|
||||
* @copyright 2019 Amaia Anabitarte <amaia@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$temp = new admin_settingpage('messages', new lang_string('messagingssettings', 'admin'));
|
||||
$temp->add(new admin_setting_configcheckbox('messaging',
|
||||
new lang_string('messaging', 'admin'),
|
||||
new lang_string('configmessaging', 'admin'),
|
||||
1));
|
||||
$temp->add(new admin_setting_configcheckbox('messagingallusers',
|
||||
new lang_string('messagingallusers', 'admin'),
|
||||
new lang_string('configmessagingallusers', 'admin'),
|
||||
0)
|
||||
);
|
||||
$temp->add(new admin_setting_configcheckbox('messagingdefaultpressenter',
|
||||
new lang_string('messagingdefaultpressenter', 'admin'),
|
||||
new lang_string('configmessagingdefaultpressenter', 'admin'),
|
||||
1)
|
||||
);
|
||||
$options = array(
|
||||
DAYSECS => new lang_string('secondstotime86400'),
|
||||
WEEKSECS => new lang_string('secondstotime604800'),
|
||||
2620800 => new lang_string('nummonths', 'moodle', 1),
|
||||
7862400 => new lang_string('nummonths', 'moodle', 3),
|
||||
15724800 => new lang_string('nummonths', 'moodle', 6),
|
||||
0 => new lang_string('never')
|
||||
);
|
||||
$temp->add(new admin_setting_configselect(
|
||||
'messagingdeletereadnotificationsdelay',
|
||||
new lang_string('messagingdeletereadnotificationsdelay', 'admin'),
|
||||
new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'),
|
||||
604800,
|
||||
$options)
|
||||
);
|
||||
$temp->add(new admin_setting_configselect(
|
||||
'messagingdeleteallnotificationsdelay',
|
||||
new lang_string('messagingdeleteallnotificationsdelay', 'admin'),
|
||||
new lang_string('configmessagingdeleteallnotificationsdelay', 'admin'),
|
||||
2620800,
|
||||
$options)
|
||||
);
|
||||
$temp->add(new admin_setting_configcheckbox('messagingallowemailoverride',
|
||||
new lang_string('messagingallowemailoverride', 'admin'),
|
||||
new lang_string('configmessagingallowemailoverride', 'admin'),
|
||||
0));
|
||||
$ADMIN->add('messaging', $temp);
|
||||
$ADMIN->add('messaging', new admin_page_managemessageoutputs());
|
||||
|
||||
// Notification outputs plugins.
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('message');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\message $plugin */
|
||||
$plugin->load_settings($ADMIN, 'messaging', $hassiteconfig);
|
||||
}
|
||||
}
|
||||
+12
-36
@@ -59,18 +59,6 @@ if ($hassiteconfig) {
|
||||
$plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// Custom fields.
|
||||
$ADMIN->add('modules', new admin_category('customfieldsettings', new lang_string('customfields', 'core_customfield')));
|
||||
$temp = new admin_settingpage('managecustomfields', new lang_string('managecustomfields', 'core_admin'));
|
||||
$temp->add(new admin_setting_managecustomfields());
|
||||
$ADMIN->add('customfieldsettings', $temp);
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('customfield');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\customfield $plugin */
|
||||
$plugin->load_settings($ADMIN, 'customfieldsettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// blocks
|
||||
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
|
||||
$ADMIN->add('blocksettings', new admin_page_manageblocks());
|
||||
@@ -81,6 +69,17 @@ if ($hassiteconfig) {
|
||||
$plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
|
||||
}
|
||||
|
||||
// message outputs
|
||||
$ADMIN->add('modules', new admin_category('messageoutputs', new lang_string('messageoutputs', 'message')));
|
||||
$ADMIN->add('messageoutputs', new admin_page_managemessageoutputs());
|
||||
$ADMIN->add('messageoutputs', new admin_page_defaultmessageoutputs());
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('message');
|
||||
core_collator::asort_objects_by_property($plugins, 'displayname');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\message $plugin */
|
||||
$plugin->load_settings($ADMIN, 'messageoutputs', $hassiteconfig);
|
||||
}
|
||||
|
||||
// authentication plugins
|
||||
$ADMIN->add('modules', new admin_category('authsettings', new lang_string('authentication', 'admin')));
|
||||
|
||||
@@ -565,37 +564,14 @@ if ($hassiteconfig) {
|
||||
$temp->add(new admin_setting_configduration('searchindextime',
|
||||
new lang_string('searchindextime', 'admin'), new lang_string('searchindextime_desc', 'admin'),
|
||||
600));
|
||||
$temp->add(new admin_setting_heading('searchcoursesheading', new lang_string('searchablecourses', 'admin'), ''));
|
||||
$options = [
|
||||
0 => new lang_string('searchallavailablecourses_off', 'admin'),
|
||||
1 => new lang_string('searchallavailablecourses_on', 'admin')
|
||||
];
|
||||
$temp->add(new admin_setting_configselect('searchallavailablecourses',
|
||||
new lang_string('searchallavailablecourses', 'admin'),
|
||||
new lang_string('searchallavailablecoursesdesc', 'admin'),
|
||||
new lang_string('searchallavailablecourses_desc', 'admin'),
|
||||
0, $options));
|
||||
$temp->add(new admin_setting_configcheckbox('searchincludeallcourses',
|
||||
new lang_string('searchincludeallcourses', 'admin'), new lang_string('searchincludeallcourses_desc', 'admin'),
|
||||
0));
|
||||
|
||||
// Search display options.
|
||||
$temp->add(new admin_setting_heading('searchdisplay', new lang_string('searchdisplay', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configcheckbox('searchenablecategories',
|
||||
new lang_string('searchenablecategories', 'admin'),
|
||||
new lang_string('searchenablecategories_desc', 'admin'),
|
||||
0));
|
||||
$options = [];
|
||||
foreach (\core_search\manager::get_search_area_categories() as $category) {
|
||||
$options[$category->get_name()] = $category->get_visiblename();
|
||||
}
|
||||
$temp->add(new admin_setting_configselect('searchdefaultcategory',
|
||||
new lang_string('searchdefaultcategory', 'admin'),
|
||||
new lang_string('searchdefaultcategory_desc', 'admin'),
|
||||
\core_search\manager::SEARCH_AREA_CATEGORY_ALL, $options));
|
||||
$temp->add(new admin_setting_configcheckbox('searchhideallcategory',
|
||||
new lang_string('searchhideallcategory', 'admin'),
|
||||
new lang_string('searchhideallcategory_desc', 'admin'),
|
||||
0));
|
||||
|
||||
$ADMIN->add('searchplugins', $temp);
|
||||
$ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
|
||||
// "systempaths" settingpage
|
||||
$temp = new admin_settingpage('systempaths', new lang_string('systempaths','admin'));
|
||||
$temp->add(new admin_setting_configexecutable('pathtophp', new lang_string('pathtophp', 'admin'),
|
||||
@@ -97,10 +98,7 @@ $options = array(
|
||||
GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'HTTP_X_FORWARDED_FOR, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR => 'HTTP_CLIENT, REMOTE_ADDR',
|
||||
GETREMOTEADDR_SKIP_HTTP_X_FORWARDED_FOR|GETREMOTEADDR_SKIP_HTTP_CLIENT_IP => 'REMOTE_ADDR');
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'),
|
||||
new lang_string('configgetremoteaddrconf', 'admin'),
|
||||
GETREMOTEADDR_SKIP_DEFAULT, $options));
|
||||
$temp->add(new admin_setting_configtext('reverseproxyignore', new lang_string('reverseproxyignore', 'admin'), new lang_string('configreverseproxyignore', 'admin'), ''));
|
||||
$temp->add(new admin_setting_configselect('getremoteaddrconf', new lang_string('getremoteaddrconf', 'admin'), new lang_string('configgetremoteaddrconf', 'admin'), 0, $options));
|
||||
|
||||
$temp->add(new admin_setting_heading('webproxy', new lang_string('webproxy', 'admin'), new lang_string('webproxyinfo', 'admin')));
|
||||
$temp->add(new admin_setting_configtext('proxyhost', new lang_string('proxyhost', 'admin'), new lang_string('configproxyhost', 'admin'), '', PARAM_HOST));
|
||||
@@ -179,8 +177,6 @@ $ADMIN->add('server', $temp);
|
||||
|
||||
$ADMIN->add('server', new admin_externalpage('environment', new lang_string('environment','admin'), "$CFG->wwwroot/$CFG->admin/environment.php"));
|
||||
$ADMIN->add('server', new admin_externalpage('phpinfo', new lang_string('phpinfo'), "$CFG->wwwroot/$CFG->admin/phpinfo.php"));
|
||||
$ADMIN->add('server', new admin_externalpage('testoutgoingmailconf', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
new moodle_url("$CFG->wwwroot/$CFG->admin/testoutgoingmailconf.php"), 'moodle/site:config', true));
|
||||
|
||||
|
||||
// "performance" settingpage
|
||||
@@ -216,92 +212,6 @@ $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string('
|
||||
$ADMIN->add('server', $temp);
|
||||
|
||||
|
||||
$ADMIN->add('server', new admin_category('taskconfig', new lang_string('taskadmintitle', 'admin')));
|
||||
$temp = new admin_settingpage('taskprocessing', new lang_string('taskprocessing','admin'));
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_scheduled_concurrency_limit',
|
||||
new lang_string('task_scheduled_concurrency_limit', 'admin'),
|
||||
new lang_string('task_scheduled_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_scheduled_max_runtime',
|
||||
new lang_string('task_scheduled_max_runtime', 'admin'),
|
||||
new lang_string('task_scheduled_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_adhoc_concurrency_limit',
|
||||
new lang_string('task_adhoc_concurrency_limit', 'admin'),
|
||||
new lang_string('task_adhoc_concurrency_limit_desc', 'admin'),
|
||||
3,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_adhoc_max_runtime',
|
||||
new lang_string('task_adhoc_max_runtime', 'admin'),
|
||||
new lang_string('task_adhoc_max_runtime_desc', 'admin'),
|
||||
30 * MINSECS
|
||||
)
|
||||
);
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
$temp = new admin_settingpage('tasklogging', new lang_string('tasklogging','admin'));
|
||||
$temp->add(
|
||||
new admin_setting_configselect(
|
||||
'task_logmode',
|
||||
new lang_string('task_logmode', 'admin'),
|
||||
new lang_string('task_logmode_desc', 'admin'),
|
||||
\core\task\logmanager::MODE_ALL,
|
||||
[
|
||||
\core\task\logmanager::MODE_ALL => new lang_string('task_logmode_all', 'admin'),
|
||||
\core\task\logmanager::MODE_FAILONLY => new lang_string('task_logmode_failonly', 'admin'),
|
||||
\core\task\logmanager::MODE_NONE => new lang_string('task_logmode_none', 'admin'),
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$temp->add(
|
||||
new admin_setting_configduration(
|
||||
'task_logretention',
|
||||
new \lang_string('task_logretention', 'admin'),
|
||||
new \lang_string('task_logretention_desc', 'admin'),
|
||||
28 * DAYSECS
|
||||
)
|
||||
);
|
||||
|
||||
$temp->add(
|
||||
new admin_setting_configtext(
|
||||
'task_logretainruns',
|
||||
new \lang_string('task_logretainruns', 'admin'),
|
||||
new \lang_string('task_logretainruns_desc', 'admin'),
|
||||
20,
|
||||
PARAM_INT
|
||||
)
|
||||
);
|
||||
}
|
||||
$ADMIN->add('taskconfig', $temp);
|
||||
|
||||
if (\core\task\logmanager::uses_standard_settings()) {
|
||||
$ADMIN->add('taskconfig', new admin_externalpage(
|
||||
'tasklogs',
|
||||
new lang_string('tasklogs','admin'),
|
||||
"{$CFG->wwwroot}/{$CFG->admin}/tasklogs.php"
|
||||
));
|
||||
}
|
||||
|
||||
// E-mail settings.
|
||||
$ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin')));
|
||||
|
||||
@@ -331,10 +241,6 @@ $temp->add(new admin_setting_configtextarea('allowedemaildomains',
|
||||
new lang_string('allowedemaildomains', 'admin'),
|
||||
new lang_string('configallowedemaildomains', 'admin'),
|
||||
''));
|
||||
$url = new moodle_url('/admin/testoutgoingmailconf.php');
|
||||
$link = html_writer::link($url, get_string('testoutgoingmailconf', 'admin'));
|
||||
$temp->add(new admin_setting_heading('testoutgoinmailc', new lang_string('testoutgoingmailconf', 'admin'),
|
||||
new lang_string('testoutgoingmaildetail', 'admin', $link)));
|
||||
$temp->add(new admin_setting_heading('emaildoesnotfit', new lang_string('doesnotfit', 'admin'),
|
||||
new lang_string('doesnotfitdetail', 'admin')));
|
||||
$charsets = get_list_of_charsets();
|
||||
@@ -357,8 +263,6 @@ $choices = array(new lang_string('never', 'admin'),
|
||||
new lang_string('onlynoreply', 'admin'));
|
||||
$temp->add(new admin_setting_configselect('emailfromvia', new lang_string('emailfromvia', 'admin'),
|
||||
new lang_string('configemailfromvia', 'admin'), 1, $choices));
|
||||
$temp->add(new admin_setting_configtext('emailsubjectprefix', new lang_string('emailsubjectprefix', 'admin'),
|
||||
new lang_string('configemailsubjectprefix', 'admin'), '', PARAM_RAW));
|
||||
|
||||
$ADMIN->add('email', $temp);
|
||||
|
||||
|
||||
@@ -13,6 +13,19 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('enablewebservices', new lang_string('enablewebservices', 'admin'), new lang_string('configenablewebservices', 'admin'), 0));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('messaging', new lang_string('messaging', 'admin'), new lang_string('configmessaging','admin'), 1));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('messagingallusers',
|
||||
new lang_string('messagingallusers', 'admin'),
|
||||
new lang_string('configmessagingallusers', 'admin'),
|
||||
0)
|
||||
);
|
||||
|
||||
$options = array(DAYSECS=>new lang_string('secondstotime86400'), WEEKSECS=>new lang_string('secondstotime604800'), 2620800=>new lang_string('nummonths', 'moodle', 1), 15724800=>new lang_string('nummonths', 'moodle', 6),0=>new lang_string('never'));
|
||||
$optionalsubsystems->add(new admin_setting_configselect('messagingdeletereadnotificationsdelay', new lang_string('messagingdeletereadnotificationsdelay', 'admin'), new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'), 604800, $options));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('messagingallowemailoverride', new lang_string('messagingallowemailoverride', 'admin'), new lang_string('configmessagingallowemailoverride','admin'), 0));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('enablestats', new lang_string('enablestats', 'admin'), new lang_string('configenablestats', 'admin'), 0));
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', new lang_string('enablerssfeeds', 'admin'), new lang_string('configenablerssfeeds', 'admin'), 0));
|
||||
|
||||
@@ -33,7 +33,6 @@ $ADMIN->add('root', new admin_category('competencies', new lang_string('competen
|
||||
$ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empty($CFG->enablebadges)));
|
||||
$ADMIN->add('root', new admin_category('location', new lang_string('location','admin')));
|
||||
$ADMIN->add('root', new admin_category('language', new lang_string('language')));
|
||||
$ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('modules', new lang_string('plugins', 'admin')));
|
||||
$ADMIN->add('root', new admin_category('security', new lang_string('security','admin')));
|
||||
$ADMIN->add('root', new admin_category('appearance', new lang_string('appearance','admin')));
|
||||
|
||||
@@ -174,11 +174,12 @@ if ($hassiteconfig
|
||||
// Options include fields from the user table that might be helpful to
|
||||
// distinguish when adding or listing users ('I want to add the John
|
||||
// Smith from Science faculty').
|
||||
// Username is not included as an option because in some sites, it might
|
||||
// be a security problem to reveal usernames even to trusted staff.
|
||||
// Custom user profile fields are not currently supported.
|
||||
$temp->add(new admin_setting_configmulticheckbox('showuseridentity',
|
||||
new lang_string('showuseridentity', 'admin'),
|
||||
new lang_string('showuseridentity_desc', 'admin'), array('email' => 1), array(
|
||||
'username' => new lang_string('username'),
|
||||
'idnumber' => new lang_string('idnumber'),
|
||||
'email' => new lang_string('email'),
|
||||
'phone1' => new lang_string('phone1'),
|
||||
@@ -254,4 +255,4 @@ if ($hassiteconfig) {
|
||||
new lang_string('sitepolicyguest_help', 'core_admin'), (isset($CFG->sitepolicy) ? $CFG->sitepolicy : ''), PARAM_RAW));
|
||||
|
||||
$ADMIN->add('privacy', $temp);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +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/>.
|
||||
|
||||
/**
|
||||
* Task log.
|
||||
*
|
||||
* @package admin
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once("{$CFG->libdir}/adminlib.php");
|
||||
require_once("{$CFG->libdir}/tablelib.php");
|
||||
require_once("{$CFG->libdir}/filelib.php");
|
||||
|
||||
$filter = optional_param('filter', '', PARAM_RAW);
|
||||
$result = optional_param('result', null, PARAM_INT);
|
||||
|
||||
$pageurl = new \moodle_url('/admin/tasklogs.php');
|
||||
$pageurl->param('filter', $filter);
|
||||
|
||||
$PAGE->set_url($pageurl);
|
||||
$PAGE->set_context(context_system::instance());
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$strheading = get_string('tasklogs', 'tool_task');
|
||||
$PAGE->set_title($strheading);
|
||||
$PAGE->set_heading($strheading);
|
||||
|
||||
require_login();
|
||||
|
||||
require_capability('moodle/site:config', context_system::instance());
|
||||
admin_externalpage_setup('tasklogs');
|
||||
|
||||
$logid = optional_param('logid', null, PARAM_INT);
|
||||
$download = optional_param('download', false, PARAM_BOOL);
|
||||
|
||||
if (null !== $logid) {
|
||||
// Raise memory limit in case the log is large.
|
||||
raise_memory_limit(MEMORY_HUGE);
|
||||
$log = $DB->get_record('task_log', ['id' => $logid], '*', MUST_EXIST);
|
||||
|
||||
if ($download) {
|
||||
$filename = str_replace('\\', '_', $log->classname) . "-{$log->id}.log";
|
||||
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
||||
}
|
||||
|
||||
readstring_accel($log->output, 'text/plain', false);
|
||||
exit;
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_task');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->render_from_template('core_admin/tasklogs', (object) [
|
||||
'action' => $pageurl->out(),
|
||||
'filter' => htmlentities($filter),
|
||||
'resultfilteroptions' => [
|
||||
(object) [
|
||||
'value' => -1,
|
||||
'title' => get_string('all'),
|
||||
'selected' => (-1 === $result),
|
||||
],
|
||||
(object) [
|
||||
'value' => 0,
|
||||
'title' => get_string('success'),
|
||||
'selected' => (0 === $result),
|
||||
],
|
||||
(object) [
|
||||
'value' => 1,
|
||||
'title' => get_string('task_result:failed', 'admin'),
|
||||
'selected' => (1 === $result),
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$table = new \core_admin\task_log_table($filter, $result);
|
||||
$table->baseurl = $pageurl;
|
||||
$table->out(100, false);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
@@ -29,7 +29,6 @@
|
||||
* element - The Element HTML
|
||||
* forceltr - Force this element to be displayed LTR
|
||||
* default - Default value
|
||||
* dependenton - optional message listing the settings this one is dependent on
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
@@ -44,11 +43,8 @@
|
||||
"default": "Default value"
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting.
|
||||
}}
|
||||
<div class="form-item row" id="{{id}}">
|
||||
<div class="form-label col-sm-3 text-sm-right">
|
||||
<div class="form-item clearfix" id="{{id}}">
|
||||
<div class="form-label">
|
||||
<label {{#labelfor}}for="{{labelfor}}"{{/labelfor}}>
|
||||
{{{title}}}
|
||||
{{#override}}
|
||||
@@ -58,17 +54,16 @@
|
||||
<div class="form-warning">{{warning}}</div>
|
||||
{{/warning}}
|
||||
</label>
|
||||
<span class="form-shortname d-block small text-muted">{{{name}}}</span>
|
||||
<span class="form-shortname">{{{name}}}</span>
|
||||
</div>
|
||||
<div class="form-setting col-sm-9">
|
||||
<div class="form-setting">
|
||||
{{#error}}
|
||||
<div><span class="error">{{error}}</span></div>
|
||||
{{/error}}
|
||||
{{{element}}}
|
||||
{{#default}}
|
||||
<div class="form-defaultinfo text-muted {{#forceltr}}text-ltr{{/forceltr}}">{{{default}}}</div>
|
||||
<div class="form-defaultinfo {{#forceltr}}text-ltr{{/forceltr}}">{{{default}}}</div>
|
||||
{{/default}}
|
||||
<div class="form-description mt-3">{{{description}}}</div>
|
||||
{{#dependenton}}<div class="form-dependenton mb-4 text-muted">{{{.}}}</div>{{/dependenton}}
|
||||
</div>
|
||||
<div class="form-description">{{{description}}}</div>
|
||||
</div>
|
||||
|
||||
@@ -35,16 +35,13 @@
|
||||
"haspreviewconfig": false
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configcolourpicker.
|
||||
}}
|
||||
<div class="form-colourpicker defaultsnext">
|
||||
<div class="admin_colourpicker clearfix">
|
||||
{{#icon}}
|
||||
{{>core/pix_icon}}
|
||||
{{/icon}}
|
||||
</div>
|
||||
<input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="form-control text-ltr">
|
||||
<input type="text" name="{{name}}" id="{{id}}" value="{{value}}" size="12" class="text-ltr">
|
||||
{{#haspreviewconfig}}
|
||||
<input type="button" id="{{id}}_preview" value={{#quote}}{{#str}}preview{{/str}}{{/quote}} class="admin_colourpicker_preview">
|
||||
{{/haspreviewconfig}}
|
||||
|
||||
@@ -33,18 +33,13 @@
|
||||
"options": [ { "name": "Minutes", "value": "mins", "selected": true } ]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configduration.
|
||||
}}
|
||||
<div class="form-duration defaultsnext">
|
||||
<div class="form-inline">
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="form-control text-ltr">
|
||||
<label class="sr-only" for="{{id}}u">{{#str}}durationunits, admin{{/str}}</label>
|
||||
<select id="{{id}}u" name="{{name}}[u]" class="form-control custom-select">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
</div>
|
||||
<input type="text" size="5" id="{{id}}v" name="{{name}}[v]" value="{{value}}" class="text-ltr">
|
||||
<label class="accesshide" for="{{id}}u">{{#str}}durationunits, admin{{/str}}</label>
|
||||
<select id="{{id}}u" name="{{name}}[u]">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -38,20 +38,15 @@
|
||||
"valid": false
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configfile.
|
||||
}}
|
||||
<div class="form-file defaultsnext">
|
||||
<div class="form-inline">
|
||||
<input type="text" name="{{name}}" id="{{id}}" size="{{size}}" value="{{value}}" class="form-control text-ltr" {{#readonly}}readonly{{/readonly}}>
|
||||
{{#showvalidity}}
|
||||
{{#valid}}
|
||||
<span class="text-success">✔</span>
|
||||
{{/valid}}
|
||||
{{^valid}}
|
||||
<span class="text-danger">✘</span>
|
||||
{{/valid}}
|
||||
{{/showvalidity}}
|
||||
</div>
|
||||
<input type="text" name="{{name}}" id="{{id}}" size="{{size}}" value="{{value}}" class="text-ltr" {{#readonly}}readonly{{/readonly}}>
|
||||
{{#showvalidity}}
|
||||
{{#valid}}
|
||||
<span class="pathok">✔</span>
|
||||
{{/valid}}
|
||||
{{^valid}}
|
||||
<span class="patherror">✘</span>
|
||||
{{/valid}}
|
||||
{{/showvalidity}}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -34,12 +34,9 @@
|
||||
{ "name": "Option 2", "value": "V", "selected": true } ]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configmultiselect.
|
||||
}}
|
||||
<div class="form-select">
|
||||
<input type="hidden" name="{{name}}[xxxxx]" value="1">
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" multiple>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -53,16 +53,13 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configmultiselect with optgroup support.
|
||||
}}
|
||||
<div class="form-select">
|
||||
<input type="hidden" name="{{name}}[xxxxx]" value="1">
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" class="form-control" multiple>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
{{#optgroups}}
|
||||
<select id="{{id}}" name="{{name}}[]" size="{{size}}" multiple>
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
{{#optgroups}}
|
||||
<optgroup label="{{label}}">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
|
||||
@@ -34,11 +34,8 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configselect.
|
||||
}}
|
||||
<div class="form-select defaultsnext">
|
||||
<select id="{{id}}" name="{{name}}" class="custom-select">
|
||||
<select id="{{id}}" name="{{name}}">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -51,11 +51,8 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configselect with optgroup support.
|
||||
}}
|
||||
<div class="form-select defaultsnext">
|
||||
<select id="{{id}}" name="{{name}}" class="custom-select">
|
||||
<select id="{{id}}" name="{{name}}">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
@@ -69,4 +66,3 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
"attributes": [ { "name": "readonly", "value": "readonly" } ]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configtext.
|
||||
}}
|
||||
<div class="form-text defaultsnext">
|
||||
<input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">
|
||||
<input type="text" name="{{name}}" value="{{value}}" size="{{size}}" id="{{id}}" class="{{#forceltr}}text-ltr{{/forceltr}}"{{#attributes}} {{name}}="{{value}}"{{/attributes}}>
|
||||
</div>
|
||||
|
||||
@@ -36,9 +36,6 @@
|
||||
"id": "test0"
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configtextarea.
|
||||
}}
|
||||
<div class="form-textarea">
|
||||
<textarea rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="form-control {{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
|
||||
<textarea rows="{{rows}}" cols="{{cols}}" id="{{id}}" name="{{name}}" spellcheck="true" class="{{#forceltr}}text-ltr{{/forceltr}}">{{value}}</textarea>
|
||||
</div>
|
||||
|
||||
@@ -39,23 +39,18 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configtime.
|
||||
}}
|
||||
<div class="form-time defaultsnext">
|
||||
<div class="form-inline text-ltr">
|
||||
<label class="sr-only" for="{{id}}h">{{#str}}hours{{/str}}</label>
|
||||
<select id="{{id}}h" name="{{name}}[h]" class="custom-select">
|
||||
{{#hours}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/hours}}
|
||||
</select>:
|
||||
<label class="sr-only" for="{{id}}m">{{#str}}minutes{{/str}}</label>
|
||||
<select id="{{id}}m" name="{{name}}[m]" class="custom-select">
|
||||
{{#minutes}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/minutes}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-time defaultsnext text-ltr">
|
||||
<label class="accesshide" for="{{id}}h">{{#str}}hours{{/str}}</label>
|
||||
<select id="{{id}}h" name="{{name}}[h]">
|
||||
{{#hours}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/hours}}
|
||||
</select>:
|
||||
<label class="accesshide" for="{{id}}m">{{#str}}minutes{{/str}}</label>
|
||||
<select id="{{id}}m" name="{{name}}[m]">
|
||||
{{#minutes}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/minutes}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,12 +37,9 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting courselist_frontpage.
|
||||
}}
|
||||
<div class="form-group">
|
||||
{{#selects}}
|
||||
<select id="{{id}}{{key}}" name="{{name}}[]" class="custom-select">
|
||||
<select id="{{id}}{{key}}" name="{{name}}[]" class="form-select">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -34,13 +34,12 @@
|
||||
{{!
|
||||
Setting description.
|
||||
}}
|
||||
<div class="form-item row">
|
||||
<div class="form-label col-sm-3 text-sm-right">
|
||||
<div class="form-item form-horizontal clearfix">
|
||||
<div class="form-label">
|
||||
<label>
|
||||
{{{title}}}
|
||||
</label>
|
||||
<span class="form-shortname ">{{{name}}}</span>
|
||||
</div>
|
||||
<div class="form-setting col-sm-9">
|
||||
<div class="form-description">{{{description}}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="controls felement fstatic">{{{description}}}</div>
|
||||
</div>
|
||||
@@ -29,10 +29,7 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting devicedetectregex.
|
||||
}}
|
||||
<table class="table table-striped">
|
||||
<table class="generaltable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{#str}}devicedetectregexexpression, admin{{/str}}</th>
|
||||
@@ -43,10 +40,10 @@
|
||||
{{#expressions}}
|
||||
<tr>
|
||||
<td class="c{{index}}">
|
||||
<input type="text" name="{{name}}[expression{{index}}]" class="form-control" value="{{expression}}">
|
||||
<input type="text" name="{{name}}[expression{{index}}]" class="form-text text-ltr" value="{{expression}}">
|
||||
</td>
|
||||
<td class="c{{index}}">
|
||||
<input type="text" name="{{name}}[value{{index}}]" class="form-control" value="{{value}}">
|
||||
<input type="text" name="{{name}}[value{{index}}]" class="form-text text-ltr" value="{{value}}">
|
||||
</td>
|
||||
</tr>
|
||||
{{/expressions}}
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
]
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting emoticons.
|
||||
}}
|
||||
<div class="form-group">
|
||||
<table id="emoticonsetting" class="admintable generaltable">
|
||||
<thead>
|
||||
@@ -51,7 +48,7 @@
|
||||
<tr>
|
||||
{{#fields}}
|
||||
<td class="c{{index}}">
|
||||
<input type="text" name="{{name}}[{{field}}]" class="form-text form-control text-ltr" value="{{value}}">
|
||||
<input type="text" name="{{name}}[{{field}}]" class="form-text text-ltr" value="{{value}}">
|
||||
</td>
|
||||
{{/fields}}
|
||||
<td>
|
||||
|
||||
@@ -37,11 +37,8 @@
|
||||
"advanced": true
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Setting configselect.
|
||||
}}
|
||||
<div class="form-group">
|
||||
<select id="{{id}}" name="{{name}}[value]" class="form-select custom-select">
|
||||
<select id="{{id}}" name="{{name}}[value]" class="form-select">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
|
||||
@@ -36,11 +36,8 @@
|
||||
"showsave": true
|
||||
}
|
||||
}}
|
||||
{{!
|
||||
Settings.
|
||||
}}
|
||||
<form action="{{actionurl}}" method="post" id="adminsettings">
|
||||
<div class="settingsform">
|
||||
<div class="settingsform clearfix">
|
||||
{{#params}}
|
||||
<input type="hidden" name="{{name}}" value="{{value}}">
|
||||
<input type="hidden" name="action" value="save-settings">
|
||||
@@ -52,10 +49,8 @@
|
||||
{{/title}}
|
||||
{{{settings}}}
|
||||
{{#showsave}}
|
||||
<div class="row">
|
||||
<div class="offset-sm-3 col-sm-3">
|
||||
<button type="submit" class="btn btn-primary">{{#str}}savechanges, admin{{/str}}</button>
|
||||
</div>
|
||||
<div class="form-buttons">
|
||||
<input type="submit" class="form-submit" value={{#quote}}{{#str}}savechanges, admin{{/str}}{{/quote}}>
|
||||
</div>
|
||||
{{/showsave}}
|
||||
</div>
|
||||
|
||||
@@ -58,10 +58,8 @@
|
||||
</fieldset>
|
||||
{{/results}}
|
||||
{{#showsave}}
|
||||
<div class="row">
|
||||
<div class="offset-sm-3 col-sm-3">
|
||||
<button type="submit" class="btn btn-primary">{{#str}}savechanges, admin{{/str}}</button>
|
||||
</div>
|
||||
<div class="form-buttons">
|
||||
<input type="submit" class="form-submit" value={{#quote}}{{#str}}savechanges, admin{{/str}}{{/quote}}>
|
||||
</div>
|
||||
{{/showsave}}
|
||||
{{/hasresults}}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_admin/tasklogs
|
||||
|
||||
Task Logs template.
|
||||
}}
|
||||
<form class="form-inline" method="GET" action="{{{action}}}">
|
||||
<label class="sr-only" for="tasklog-filter">{{#str}}filter{{/str}}</label>
|
||||
<input class="form-control" type="text" id="tasklog-filter" name="filter" value="{{{filter}}}">
|
||||
|
||||
<label class="sr-only" for="tasklog-resultfilter">{{#str}}resultfilter, admin{{/str}}</label>
|
||||
<select class="form-control custom-select" name="result" id="tasklog-resultfilter">
|
||||
{{#resultfilteroptions}}
|
||||
<option value="{{{value}}}"{{#selected}} selected="selected"{{/selected}}>{{title}}</option>
|
||||
{{/resultfilteroptions}}
|
||||
</select>
|
||||
|
||||
<input class="btn btn-primary" type="submit" value="{{#str}}filter{{/str}}">
|
||||
</form>
|
||||
@@ -1,98 +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/>.
|
||||
|
||||
/**
|
||||
* Test output mail configuration page
|
||||
*
|
||||
* @copyright 2019 Victor Deniz <victor@moodle.com>, based on Michael Milette <michael.milette@tngconsulting.ca> code
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
|
||||
// This is an admin page.
|
||||
admin_externalpage_setup('testoutgoingmailconf');
|
||||
|
||||
$headingtitle = get_string('testoutgoingmailconf', 'admin');
|
||||
$homeurl = new moodle_url('/admin/category.php', array('category' => 'email'));
|
||||
$returnurl = new moodle_url('/admin/testoutgoingconf.php');
|
||||
|
||||
$form = new core_admin\form\testoutgoingmailconf_form(null, ['returnurl' => $returnurl]);
|
||||
if ($form->is_cancelled()) {
|
||||
redirect($homeurl);
|
||||
}
|
||||
|
||||
// Display the page.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($headingtitle);
|
||||
|
||||
$data = $form->get_data();
|
||||
if ($data) {
|
||||
$emailuser = new stdClass();
|
||||
$emailuser->email = $data->recipient;
|
||||
$emailuser->id = -99;
|
||||
|
||||
$subject = get_string('testoutgoingmailconf_subject', 'admin',
|
||||
format_string($SITE->fullname, true, ['context' => context_system::instance()]));
|
||||
$messagetext = get_string('testoutgoingmailconf_message', 'admin');
|
||||
|
||||
// Manage Moodle debugging options.
|
||||
$debuglevel = $CFG->debug;
|
||||
$debugdisplay = $CFG->debugdisplay;
|
||||
$debugsmtp = $CFG->debugsmtp ?? null; // This might not be set as it's optional.
|
||||
$CFG->debugdisplay = true;
|
||||
$CFG->debugsmtp = true;
|
||||
$CFG->debug = 15;
|
||||
|
||||
// Send test email.
|
||||
ob_start();
|
||||
$success = email_to_user($emailuser, $USER, $subject, $messagetext);
|
||||
$smtplog = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// Restore Moodle debugging options.
|
||||
$CFG->debug = $debuglevel;
|
||||
$CFG->debugdisplay = $debugdisplay;
|
||||
|
||||
// Restore the debugsmtp config, if it was set originally.
|
||||
unset($CFG->debugsmtp);
|
||||
if (!is_null($debugsmtp)) {
|
||||
$CFG->debugsmtp = $debugsmtp;
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
$msgparams = new stdClass();
|
||||
$msgparams->fromemail = $USER->email;
|
||||
$msgparams->toemail = $emailuser->email;
|
||||
$msg = get_string('testoutgoingmailconf_sentmail', 'admin', $msgparams);
|
||||
$notificationtype = 'notifysuccess';
|
||||
} else {
|
||||
$notificationtype = 'notifyproblem';
|
||||
// No communication between Moodle and the SMTP server - no error output.
|
||||
if (trim($smtplog) == false) {
|
||||
$msg = get_string('testoutgoingmailconf_errorcommunications', 'admin');
|
||||
} else {
|
||||
$msg = $smtplog;
|
||||
}
|
||||
}
|
||||
|
||||
// Show result.
|
||||
echo $OUTPUT->notification($msg, $notificationtype);
|
||||
}
|
||||
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -48,16 +48,26 @@ class behat_admin extends behat_base {
|
||||
* @param TableNode $table
|
||||
*/
|
||||
public function i_set_the_following_administration_settings_values(TableNode $table) {
|
||||
|
||||
if (!$data = $table->getRowsHash()) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($data as $label => $value) {
|
||||
$this->execute('behat_navigation::i_select_from_flat_navigation_drawer', [get_string('administrationsite')]);
|
||||
|
||||
// We expect admin block to be visible, otherwise go to homepage.
|
||||
if (!$this->getSession()->getPage()->find('css', '.block_settings')) {
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
$this->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
|
||||
}
|
||||
|
||||
// Search by label.
|
||||
$this->execute('behat_forms::i_set_the_field_to', [get_string('query', 'admin'), $label]);
|
||||
$this->execute("behat_forms::press_button", get_string('search', 'admin'));
|
||||
$searchbox = $this->find_field(get_string('searchinsettings', 'admin'));
|
||||
$searchbox->setValue($label);
|
||||
$submitsearch = $this->find('css', 'form.adminsearchform input[type=submit]');
|
||||
$submitsearch->press();
|
||||
|
||||
$this->wait(self::TIMEOUT * 1000, self::PAGE_READY_JS);
|
||||
|
||||
// Admin settings does not use the same DOM structure than other moodle forms
|
||||
// but we also need to use lib/behat/form_field/* to deal with the different moodle form elements.
|
||||
@@ -68,23 +78,40 @@ class behat_admin extends behat_base {
|
||||
|
||||
// Single element settings.
|
||||
try {
|
||||
$fieldxpath = "//*[self::input | self::textarea | self::select]" .
|
||||
"[not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" .
|
||||
"[@id=//label[contains(normalize-space(.), $label)]/@for or " .
|
||||
"@id=//span[contains(normalize-space(.), $label)]/preceding-sibling::label[1]/@for]";
|
||||
$fieldxpath = "//*[self::input | self::textarea | self::select][not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]" .
|
||||
"[@id=//label[contains(normalize-space(.), $label)]/@for or " .
|
||||
"@id=//span[contains(normalize-space(.), $label)]/preceding-sibling::label[1]/@for]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath, $exception);
|
||||
|
||||
$formfieldtypenode = $this->find('xpath', $fieldxpath . "/ancestor::div[@class='form-setting']" .
|
||||
"/child::div[contains(concat(' ', @class, ' '), ' form-')]/child::*/parent::div");
|
||||
|
||||
} catch (ElementNotFoundException $e) {
|
||||
|
||||
// Multi element settings, interacting only the first one.
|
||||
$fieldxpath = "//*[label[contains(., $label)]|span[contains(., $label)]]" .
|
||||
"/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" .
|
||||
"/descendant::div[contains(concat(' ', @class, ' '), ' form-group ')]" .
|
||||
"/descendant::*[self::input | self::textarea | self::select]" .
|
||||
"[not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
|
||||
$fieldxpath = "//*[label[normalize-space(.)= $label]|span[normalize-space(.)= $label]]/" .
|
||||
"ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' form-item ')]" .
|
||||
"/descendant::div[@class='form-group']/descendant::*[self::input | self::textarea | self::select]" .
|
||||
"[not(./@type = 'submit' or ./@type = 'image' or ./@type = 'hidden')]";
|
||||
$fieldnode = $this->find('xpath', $fieldxpath);
|
||||
|
||||
// It is the same one that contains the type.
|
||||
$formfieldtypenode = $fieldnode;
|
||||
}
|
||||
|
||||
$this->execute('behat_forms::i_set_the_field_with_xpath_to', [$fieldxpath, $value]);
|
||||
$this->execute("behat_general::i_click_on", [get_string('savechanges'), 'button']);
|
||||
// Getting the class which contains the field type.
|
||||
$classes = explode(' ', $formfieldtypenode->getAttribute('class'));
|
||||
foreach ($classes as $class) {
|
||||
if (substr($class, 0, 5) == 'form-') {
|
||||
$type = substr($class, 5);
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiating the appropiate field type.
|
||||
$field = behat_field_manager::get_field_instance($type, $fieldnode, $this->getSession());
|
||||
$field->set_value($value);
|
||||
|
||||
$this->find_button(get_string('savechanges'))->press();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,74 +1,57 @@
|
||||
@core @core_admin @core_user
|
||||
Feature: Allowing multiple accounts to have the same email address
|
||||
In order to manage user accounts
|
||||
@core @core_admin
|
||||
Feature: Enable multiple accounts to have the same email address
|
||||
In order to have multiple accounts registerd on the system with the same email address
|
||||
As an admin
|
||||
I need to be able to set whether to allow multiple accounts with the same email or not
|
||||
I need to enable multiple accounts to be registered with the same email address and verify it is applied
|
||||
|
||||
Scenario Outline: Create a user with the same email as an existing user
|
||||
Background:
|
||||
Given I log in as "admin"
|
||||
|
||||
Scenario: Enable registration of multiple accounts with the same email address
|
||||
Given the following config values are set as admin:
|
||||
| allowaccountssameemail | <allowsameemail> |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| s1 | John | Doe | s1@example.com |
|
||||
When I log in as "admin"
|
||||
And I navigate to "Users > Accounts > Add a new user" in site administration
|
||||
| allowaccountssameemail | 1 |
|
||||
When I navigate to "Users > Accounts > Add a new user" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Username | s2 |
|
||||
| First name | Jane |
|
||||
| Surname | Doe |
|
||||
| Email address | <email> |
|
||||
| New password | test |
|
||||
| Username | testmultiemailuser1 |
|
||||
| Choose an authentication method | Manual accounts |
|
||||
| New password | test@User1 |
|
||||
| First name | Test |
|
||||
| Surname | Multi1 |
|
||||
| Email address | testmultiemailuser@example.com |
|
||||
And I press "Create user"
|
||||
Then I should <expect> "This email address is already registered."
|
||||
And I should see "Test Multi1"
|
||||
And I press "Add a new user"
|
||||
And I set the following fields to these values:
|
||||
| Username | testmultiemailuser2 |
|
||||
| Choose an authentication method | Manual accounts |
|
||||
| New password | test@User2 |
|
||||
| First name | Test |
|
||||
| Surname | Multi2 |
|
||||
| Email address | testmultiemailuser@example.com |
|
||||
And I press "Create user"
|
||||
Then I should see "Test Multi2"
|
||||
And I should not see "This email address is already registered"
|
||||
|
||||
Examples:
|
||||
| allowsameemail | email | expect |
|
||||
| 0 | s1@example.com | see |
|
||||
| 0 | S1@EXAMPLE.COM | see |
|
||||
| 1 | s1@example.com | not see |
|
||||
| 1 | S1@EXAMPLE.COM | not see |
|
||||
|
||||
Scenario Outline: Update a user with the same email as an existing user
|
||||
Scenario: Disable registration of multiple accounts with the same email address
|
||||
Given the following config values are set as admin:
|
||||
| allowaccountssameemail | <allowsameemail> |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| s1 | John | Doe | s1@example.com |
|
||||
| s2 | Jane | Doe | s2@example.com |
|
||||
When I log in as "admin"
|
||||
And I navigate to "Users > Accounts > Browse list of users" in site administration
|
||||
And I click on "Edit" "link" in the "Jane Doe" "table_row"
|
||||
And I set the field "Email address" to "<email>"
|
||||
And I press "Update profile"
|
||||
Then I should <expect> "This email address is already registered."
|
||||
|
||||
Examples:
|
||||
| allowsameemail | email | expect |
|
||||
| 0 | s1@example.com | see |
|
||||
| 0 | S1@EXAMPLE.COM | see |
|
||||
| 1 | s1@example.com | not see |
|
||||
| 1 | S1@EXAMPLE.COM | not see |
|
||||
| 0 | S2@EXAMPLE.COM | not see |
|
||||
| 1 | S2@EXAMPLE.COM | not see |
|
||||
|
||||
Scenario Outline: Update own user profile with the same email as an existing user
|
||||
Given the following config values are set as admin:
|
||||
| allowaccountssameemail | <allowsameemail> |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| s1 | John | Doe | s1@example.com |
|
||||
| s2 | Jane | Doe | s2@example.com |
|
||||
When I log in as "s2"
|
||||
And I open my profile in edit mode
|
||||
And I set the field "Email address" to "<email>"
|
||||
And I press "Update profile"
|
||||
Then I should <expect> "This email address is already registered."
|
||||
|
||||
Examples:
|
||||
| allowsameemail | email | expect |
|
||||
| 0 | s1@example.com | see |
|
||||
| 0 | S1@EXAMPLE.COM | see |
|
||||
| 1 | s1@example.com | not see |
|
||||
| 1 | S1@EXAMPLE.COM | not see |
|
||||
| 0 | S2@EXAMPLE.COM | not see |
|
||||
| 1 | S2@EXAMPLE.COM | not see |
|
||||
| allowaccountssameemail | 0 |
|
||||
When I navigate to "Users > Accounts > Add a new user" in site administration
|
||||
And I set the following fields to these values:
|
||||
| Username | testmultiemailuser1 |
|
||||
| Choose an authentication method | Manual accounts |
|
||||
| New password | test@User1 |
|
||||
| First name | Test |
|
||||
| Surname | Multi1 |
|
||||
| Email address | testmultiemailuser@example.com |
|
||||
And I press "Create user"
|
||||
And I should see "Test Multi1"
|
||||
And I press "Add a new user"
|
||||
And I set the following fields to these values:
|
||||
| Username | testmultiemailuser2 |
|
||||
| Choose an authentication method | Manual accounts |
|
||||
| New password | test@User2 |
|
||||
| First name | Test |
|
||||
| Surname | Multi2 |
|
||||
| Email address | testmultiemailuser@example.com |
|
||||
And I press "Create user"
|
||||
Then I should see "This email address is already registered"
|
||||
@@ -9,7 +9,6 @@ Feature: Manage tokens
|
||||
| username | password | firstname | lastname |
|
||||
| testuser | testuser | Joe | Bloggs |
|
||||
| testuser2 | testuser2 | TestFirstname | TestLastname |
|
||||
And I change window size to "small"
|
||||
And I log in as "admin"
|
||||
And I am on site homepage
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/log","core/notification","core/modal_factory","core/modal_events","core/templates"],function(a,b,c,d,e,f,g){var h={clear:{title:{key:"clearpredictions",component:"tool_analytics"},body:{key:"clearmodelpredictions",component:"tool_analytics"}},"delete":{title:{key:"delete",component:"tool_analytics"},body:{key:"deletemodelconfirmation",component:"tool_analytics"}}},i=function(b){var d=a(b).closest("[data-model-name]");return d.length?d.attr("data-model-name"):(c.error("Unexpected DOM error - unable to obtain the model name"),"")};return{confirmAction:function(g,j){a('[data-action-id="'+g+'"]').on("click",function(g){g.preventDefault();var k=a(g.currentTarget);if("undefined"==typeof h[j])return void c.error('Action "'+j+'" is not allowed.');var l=[h[j].title,h[j].body];l[1].param=i(k);var m=b.get_strings(l),n=e.create({type:e.types.SAVE_CANCEL});a.when(m,n).then(function(a,b){return b.setTitle(a[0]),b.setBody(a[1]),b.setSaveButtonText(a[0]),b.getRoot().on(f.save,function(){window.location.href=k.attr("href")}),b.show(),b}).fail(d.exception)})},selectEvaluationOptions:function(c,h,i){a('[data-action-id="'+c+'"]').on("click",function(c){c.preventDefault();var j=a(c.currentTarget),k=b.get_strings([{key:"evaluatemodel",component:"tool_analytics"},{key:"evaluate",component:"tool_analytics"}]),l=e.create({type:e.types.SAVE_CANCEL}),m=g.render("tool_analytics/evaluation_options",{trainedexternally:h,timesplittingmethods:i});a.when(k,l).then(function(b,c){return c.getRoot().on(f.hidden,c.destroy.bind(c)),c.setTitle(b[0]),c.setSaveButtonText(b[1]),c.setBody(m),c.getRoot().on(f.save,function(){var b=a("input[name='evaluationmode']:checked").val();"trainedmodel"==b&&j.attr("href",j.attr("href")+"&mode=trainedmodel");var c=a("#id-evaluation-timesplitting").val();j.attr("href",j.attr("href")+"×plitting="+c),window.location.href=j.attr("href")}),c.show(),c}).fail(d.exception)})},selectExportOptions:function(c,h){a('[data-action-id="'+c+'"]').on("click",function(c){c.preventDefault();var i=a(c.currentTarget);if(!h)return i.attr("href",i.attr("href")+"&action=exportmodel&includeweights=0"),void(window.location.href=i.attr("href"));var j=b.get_strings([{key:"export",component:"tool_analytics"}]),k=e.create({type:e.types.SAVE_CANCEL}),l=g.render("tool_analytics/export_options",{});a.when(j,k).then(function(b,c){return c.getRoot().on(f.hidden,c.destroy.bind(c)),c.setTitle(b[0]),c.setSaveButtonText(b[0]),c.setBody(l),c.getRoot().on(f.save,function(){var b=a("input[name='exportoption']:checked").val();"exportdata"==b?i.attr("href",i.attr("href")+"&action=exportdata"):(i.attr("href",i.attr("href")+"&action=exportmodel"),a("#id-includeweights").is(":checked")?i.attr("href",i.attr("href")+"&includeweights=1"):i.attr("href",i.attr("href")+"&includeweights=0")),window.location.href=i.attr("href")}),c.show(),c}).fail(d.exception)})}}});
|
||||
define(["jquery","core/str","core/log","core/notification","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f){var g={clear:{title:{key:"clearpredictions",component:"tool_analytics"},body:{key:"clearmodelpredictions",component:"tool_analytics"}}},h=function(b){return a(b.closest("tr")[0]).find("span.target-name").text()};return{confirmAction:function(i,j){a('[data-action-id="'+i+'"]').on("click",function(i){i.preventDefault();var k=a(i.currentTarget);if("undefined"==typeof g[j])return void c.error('Action "'+j+'" is not allowed.');var l=[g[j].title,g[j].body];l[1].param=h(k);var m=b.get_strings(l),n=e.create({type:e.types.SAVE_CANCEL});a.when(m,n).then(function(a,b){return b.setTitle(a[0]),b.setBody(a[1]),b.setSaveButtonText(a[0]),b.getRoot().on(f.save,function(){window.location.href=k.attr("href")}),b.show(),b}).fail(d.exception)})}}});
|
||||
@@ -20,8 +20,8 @@
|
||||
* @copyright 2017 David Monllao
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],
|
||||
function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {
|
||||
define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events'],
|
||||
function($, Str, log, Notification, ModalFactory, ModalEvents) {
|
||||
|
||||
/**
|
||||
* List of actions that require confirmation and confirmation message.
|
||||
@@ -36,15 +36,6 @@ define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_facto
|
||||
component: 'tool_analytics'
|
||||
}
|
||||
|
||||
},
|
||||
'delete': {
|
||||
title: {
|
||||
key: 'delete',
|
||||
component: 'tool_analytics'
|
||||
}, body: {
|
||||
key: 'deletemodelconfirmation',
|
||||
component: 'tool_analytics'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,15 +46,7 @@ define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_facto
|
||||
* @return {String}
|
||||
*/
|
||||
var getModelName = function(actionItem) {
|
||||
var wrap = $(actionItem).closest('[data-model-name]');
|
||||
|
||||
if (wrap.length) {
|
||||
return wrap.attr('data-model-name');
|
||||
|
||||
} else {
|
||||
log.error('Unexpected DOM error - unable to obtain the model name');
|
||||
return '';
|
||||
}
|
||||
return $(actionItem.closest('tr')[0]).find('span.target-name').text();
|
||||
};
|
||||
|
||||
/** @alias module:tool_analytics/model */
|
||||
@@ -102,129 +85,6 @@ define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_facto
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
window.location.href = a.attr('href');
|
||||
});
|
||||
modal.show();
|
||||
return modal;
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays evaluation mode and time-splitting method choices.
|
||||
*
|
||||
* @param {String} actionId
|
||||
* @param {Boolean} trainedOnlyExternally
|
||||
*/
|
||||
selectEvaluationOptions: function(actionId, trainedOnlyExternally, timeSplittingMethods) {
|
||||
$('[data-action-id="' + actionId + '"]').on('click', function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var a = $(ev.currentTarget);
|
||||
|
||||
var stringsPromise = Str.get_strings([
|
||||
{
|
||||
key: 'evaluatemodel',
|
||||
component: 'tool_analytics'
|
||||
}, {
|
||||
key: 'evaluate',
|
||||
component: 'tool_analytics'
|
||||
}
|
||||
]);
|
||||
var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});
|
||||
var bodyPromise = Templates.render('tool_analytics/evaluation_options', {
|
||||
trainedexternally: trainedOnlyExternally,
|
||||
timesplittingmethods: timeSplittingMethods
|
||||
});
|
||||
|
||||
$.when(stringsPromise, modalPromise).then(function(strings, modal) {
|
||||
|
||||
|
||||
modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));
|
||||
|
||||
modal.setTitle(strings[0]);
|
||||
modal.setSaveButtonText(strings[1]);
|
||||
modal.setBody(bodyPromise);
|
||||
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
|
||||
// Evaluation mode.
|
||||
var evaluationMode = $("input[name='evaluationmode']:checked").val();
|
||||
if (evaluationMode == 'trainedmodel') {
|
||||
a.attr('href', a.attr('href') + '&mode=trainedmodel');
|
||||
}
|
||||
|
||||
// Selected time-splitting id.
|
||||
var timeSplittingMethod = $("#id-evaluation-timesplitting").val();
|
||||
a.attr('href', a.attr('href') + '×plitting=' + timeSplittingMethod);
|
||||
|
||||
window.location.href = a.attr('href');
|
||||
return;
|
||||
});
|
||||
|
||||
modal.show();
|
||||
return modal;
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays export options.
|
||||
*
|
||||
* We have two main options: export training data and export configuration.
|
||||
* The 2nd option has an extra option: include the trained algorithm weights.
|
||||
*
|
||||
* @param {String} actionId
|
||||
* @param {Boolean} isTrained
|
||||
*/
|
||||
selectExportOptions: function(actionId, isTrained) {
|
||||
$('[data-action-id="' + actionId + '"]').on('click', function(ev) {
|
||||
ev.preventDefault();
|
||||
|
||||
var a = $(ev.currentTarget);
|
||||
|
||||
if (!isTrained) {
|
||||
// Export the model configuration if the model is not trained. We can't export anything else.
|
||||
a.attr('href', a.attr('href') + '&action=exportmodel&includeweights=0');
|
||||
window.location.href = a.attr('href');
|
||||
return;
|
||||
}
|
||||
|
||||
var stringsPromise = Str.get_strings([
|
||||
{
|
||||
key: 'export',
|
||||
component: 'tool_analytics'
|
||||
}
|
||||
]);
|
||||
var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});
|
||||
var bodyPromise = Templates.render('tool_analytics/export_options', {});
|
||||
|
||||
$.when(stringsPromise, modalPromise).then(function(strings, modal) {
|
||||
|
||||
modal.getRoot().on(ModalEvents.hidden, modal.destroy.bind(modal));
|
||||
|
||||
modal.setTitle(strings[0]);
|
||||
modal.setSaveButtonText(strings[0]);
|
||||
modal.setBody(bodyPromise);
|
||||
|
||||
modal.getRoot().on(ModalEvents.save, function() {
|
||||
|
||||
var exportOption = $("input[name='exportoption']:checked").val();
|
||||
|
||||
if (exportOption == 'exportdata') {
|
||||
a.attr('href', a.attr('href') + '&action=exportdata');
|
||||
|
||||
} else {
|
||||
a.attr('href', a.attr('href') + '&action=exportmodel');
|
||||
if ($("#id-includeweights").is(':checked')) {
|
||||
a.attr('href', a.attr('href') + '&includeweights=1');
|
||||
} else {
|
||||
a.attr('href', a.attr('href') + '&includeweights=0');
|
||||
}
|
||||
}
|
||||
|
||||
window.location.href = a.attr('href');
|
||||
return;
|
||||
});
|
||||
|
||||
modal.show();
|
||||
return modal;
|
||||
}).fail(Notification.exception);
|
||||
|
||||
@@ -48,7 +48,7 @@ class clihelper {
|
||||
foreach ($models as $model) {
|
||||
$modelid = $model->get_id();
|
||||
$isenabled = $model->is_enabled() ? get_string('enabled', 'tool_analytics') : get_string('disabled', 'tool_analytics');
|
||||
$name = $model->get_name();
|
||||
$name = $model->get_target()->get_name();
|
||||
echo str_pad($modelid, 15, ' ') . ' ' . str_pad($name, 50, ' ') . ' ' . str_pad($isenabled, 15, ' ') . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,76 +45,54 @@ class edit_model extends \moodleform {
|
||||
|
||||
$mform = $this->_form;
|
||||
|
||||
if ($this->_customdata['trainedmodel'] && $this->_customdata['staticmodel'] === false) {
|
||||
if ($this->_customdata['model']->is_trained()) {
|
||||
$message = get_string('edittrainedwarning', 'tool_analytics');
|
||||
$mform->addElement('html', $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING));
|
||||
}
|
||||
|
||||
$mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'tool_analytics'));
|
||||
|
||||
// Target.
|
||||
if (!empty($this->_customdata['targets'])) {
|
||||
$targets = array('' => '');
|
||||
foreach ($this->_customdata['targets'] as $classname => $target) {
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$targets[$optionname] = $target->get_name();
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'target', get_string('target', 'tool_analytics'), $targets);
|
||||
$mform->addHelpButton('target', 'target', 'tool_analytics');
|
||||
$mform->addRule('target', get_string('required'), 'required', null, 'client');
|
||||
$indicators = array();
|
||||
foreach ($this->_customdata['indicators'] as $classname => $indicator) {
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$indicators[$optionname] = $indicator->get_name();
|
||||
}
|
||||
$options = array(
|
||||
'multiple' => true
|
||||
);
|
||||
$mform->addElement('autocomplete', 'indicators', get_string('indicators', 'tool_analytics'), $indicators, $options);
|
||||
$mform->setType('indicators', PARAM_ALPHANUMEXT);
|
||||
|
||||
// Indicators.
|
||||
if (!$this->_customdata['staticmodel']) {
|
||||
$indicators = array();
|
||||
foreach ($this->_customdata['indicators'] as $classname => $indicator) {
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$indicators[$optionname] = $indicator->get_name();
|
||||
}
|
||||
$options = array(
|
||||
'multiple' => true
|
||||
);
|
||||
$mform->addElement('autocomplete', 'indicators', get_string('indicators', 'tool_analytics'), $indicators, $options);
|
||||
$mform->setType('indicators', PARAM_ALPHANUMEXT);
|
||||
$mform->addHelpButton('indicators', 'indicators', 'tool_analytics');
|
||||
}
|
||||
|
||||
// Time-splitting methods.
|
||||
$timesplittings = array('' => '');
|
||||
foreach ($this->_customdata['timesplittings'] as $classname => $timesplitting) {
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$timesplittings[$optionname] = $timesplitting->get_name();
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'timesplitting', get_string('timesplittingmethod', 'analytics'), $timesplittings);
|
||||
$mform->addHelpButton('timesplitting', 'timesplittingmethod', 'analytics');
|
||||
|
||||
// Predictions processor.
|
||||
if (!$this->_customdata['staticmodel']) {
|
||||
$defaultprocessor = \core_analytics\manager::get_predictions_processor_name(
|
||||
\core_analytics\manager::get_predictions_processor()
|
||||
);
|
||||
$predictionprocessors = ['' => get_string('defaultpredictoroption', 'analytics', $defaultprocessor)];
|
||||
foreach ($this->_customdata['predictionprocessors'] as $classname => $predictionsprocessor) {
|
||||
if ($predictionsprocessor->is_ready() !== true) {
|
||||
continue;
|
||||
}
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$predictionprocessors[$optionname] = \core_analytics\manager::get_predictions_processor_name($predictionsprocessor);
|
||||
$defaultprocessor = \core_analytics\manager::get_predictions_processor_name(
|
||||
\core_analytics\manager::get_predictions_processor()
|
||||
);
|
||||
$predictionprocessors = ['' => get_string('defaultpredictoroption', 'analytics', $defaultprocessor)];
|
||||
foreach ($this->_customdata['predictionprocessors'] as $classname => $predictionsprocessor) {
|
||||
if ($predictionsprocessor->is_ready() !== true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'predictionsprocessor', get_string('predictionsprocessor', 'analytics'),
|
||||
$predictionprocessors);
|
||||
$mform->addHelpButton('predictionsprocessor', 'predictionsprocessor', 'analytics');
|
||||
$optionname = \tool_analytics\output\helper::class_to_option($classname);
|
||||
$predictionprocessors[$optionname] = \core_analytics\manager::get_predictions_processor_name($predictionsprocessor);
|
||||
}
|
||||
|
||||
if (!empty($this->_customdata['id'])) {
|
||||
$mform->addElement('hidden', 'id', $this->_customdata['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('select', 'predictionsprocessor', get_string('predictionsprocessor', 'analytics'),
|
||||
$predictionprocessors);
|
||||
$mform->addHelpButton('predictionsprocessor', 'predictionsprocessor', 'analytics');
|
||||
|
||||
$mform->addElement('hidden', 'action', 'edit');
|
||||
$mform->setType('action', PARAM_ALPHANUMEXT);
|
||||
}
|
||||
$mform->addElement('hidden', 'id', $this->_customdata['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'action', 'edit');
|
||||
$mform->setType('action', PARAM_ALPHANUMEXT);
|
||||
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
@@ -137,15 +115,13 @@ class edit_model extends \moodleform {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_customdata['staticmodel']) {
|
||||
if (empty($data['indicators'])) {
|
||||
$errors['indicators'] = get_string('errornoindicators', 'analytics');
|
||||
} else {
|
||||
foreach ($data['indicators'] as $indicator) {
|
||||
$realindicatorname = \tool_analytics\output\helper::option_to_class($indicator);
|
||||
if (\core_analytics\manager::is_valid($realindicatorname, '\core_analytics\local\indicator\base') === false) {
|
||||
$errors['indicators'] = get_string('errorinvalidindicator', 'analytics', $realindicatorname);
|
||||
}
|
||||
if (empty($data['indicators'])) {
|
||||
$errors['indicators'] = get_string('errornoindicators', 'analytics');
|
||||
} else {
|
||||
foreach ($data['indicators'] as $indicator) {
|
||||
$realindicatorname = \tool_analytics\output\helper::option_to_class($indicator);
|
||||
if (\core_analytics\manager::is_valid($realindicatorname, '\core_analytics\local\indicator\base') === false) {
|
||||
$errors['indicators'] = get_string('errorinvalidindicator', 'analytics', $realindicatorname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,58 +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/>.
|
||||
|
||||
/**
|
||||
* Model upload form.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_analytics\output\form;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
/**
|
||||
* Model upload form.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class import_model extends \moodleform {
|
||||
|
||||
/**
|
||||
* Form definition.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function definition () {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'settingsheader', get_string('importmodel', 'tool_analytics'));
|
||||
|
||||
$mform->addElement('filepicker', 'modelfile', get_string('file'), null, ['accepted_types' => '.zip']);
|
||||
$mform->addRule('modelfile', null, 'required');
|
||||
|
||||
$mform->addElement('advcheckbox', 'ignoreversionmismatches', get_string('ignoreversionmismatches', 'tool_analytics'),
|
||||
get_string('ignoreversionmismatchescheckbox', 'tool_analytics'));
|
||||
|
||||
$this->add_action_buttons(true, get_string('import'));
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class helper {
|
||||
// Form field is PARAM_ALPHANUMEXT and we are sending fully qualified class names
|
||||
// as option names, but replacing the backslash for a string that is really unlikely
|
||||
// to ever be part of a class name.
|
||||
return str_replace('\\', '__', $class);
|
||||
return str_replace('\\', '2015102400ouuu', $class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,53 +56,6 @@ class helper {
|
||||
*/
|
||||
public static function option_to_class($option) {
|
||||
// Really unlikely but yeah, I'm a bad booyyy.
|
||||
return str_replace('__', '\\', $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an analytics > analytics models > $title breadcrumb.
|
||||
*
|
||||
* @param string $title
|
||||
* @param \moodle_url $url
|
||||
* @param \context|null $context Defaults to context_system
|
||||
* @return null
|
||||
*/
|
||||
public static function set_navbar(string $title, \moodle_url $url, ?\context $context = null) {
|
||||
global $PAGE;
|
||||
|
||||
if (!$context) {
|
||||
$context = \context_system::instance();
|
||||
}
|
||||
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if ($siteadmin = $PAGE->settingsnav->find('root', \navigation_node::TYPE_SITE_ADMIN)) {
|
||||
$PAGE->navbar->add($siteadmin->get_content(), $siteadmin->action());
|
||||
}
|
||||
if ($analytics = $PAGE->settingsnav->find('analytics', \navigation_node::TYPE_SETTING)) {
|
||||
$PAGE->navbar->add($analytics->get_content(), $analytics->action());
|
||||
}
|
||||
if ($analyticmodels = $PAGE->settingsnav->find('analyticmodels', \navigation_node::TYPE_SETTING)) {
|
||||
$PAGE->navbar->add($analyticmodels->get_content(), $analyticmodels->action());
|
||||
}
|
||||
$PAGE->navbar->add($title);
|
||||
|
||||
$PAGE->set_pagelayout('report');
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the current page.
|
||||
*
|
||||
* Note that this function can only be used by analytics pages that work at the system context.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function reset_page() {
|
||||
global $PAGE;
|
||||
$PAGE->reset_theme_and_output();
|
||||
$PAGE->set_context(\context_system::instance());
|
||||
return str_replace('2015102400ouuu', '\\', $option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,17 +76,13 @@ class invalid_analysables implements \renderable, \templatable {
|
||||
|
||||
$offset = $this->page * $this->perpage;
|
||||
|
||||
$analysables = $this->model->get_analyser(['notimesplitting' => true])->get_analysables_iterator();
|
||||
$analysables = $this->model->get_analyser(['notimesplitting' => true])->get_analysables();
|
||||
|
||||
$skipped = 0;
|
||||
$enoughresults = false;
|
||||
$morepages = false;
|
||||
$results = array();
|
||||
foreach ($analysables as $analysable) {
|
||||
|
||||
if (!$analysable) {
|
||||
continue;
|
||||
}
|
||||
foreach ($analysables as $key => $analysable) {
|
||||
|
||||
$validtraining = $this->model->get_target()->is_valid_analysable($analysable, true);
|
||||
if ($validtraining === true) {
|
||||
@@ -121,11 +117,13 @@ class invalid_analysables implements \renderable, \templatable {
|
||||
$morepages = true;
|
||||
break;
|
||||
}
|
||||
|
||||
unset($analysables[$key]);
|
||||
}
|
||||
|
||||
// Prepare the context object.
|
||||
$data = new \stdClass();
|
||||
$data->modelname = $this->model->get_name();
|
||||
$data->modelname = $this->model->get_target()->get_name();
|
||||
|
||||
if ($this->page > 0) {
|
||||
$prev = clone $PAGE->url;
|
||||
@@ -155,12 +153,6 @@ class invalid_analysables implements \renderable, \templatable {
|
||||
$data->analysables[] = $obj;
|
||||
}
|
||||
|
||||
if (empty($data->analysables)) {
|
||||
$data->noanalysables = [
|
||||
'message' => get_string('noinvalidanalysables', 'tool_analytics'),
|
||||
'announce' => true,
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,6 @@ class model_logs extends \table_sql {
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* @var string|false
|
||||
*/
|
||||
protected $evaluationmode = false;
|
||||
|
||||
/**
|
||||
* Sets up the table_log parameters.
|
||||
*
|
||||
@@ -62,32 +57,21 @@ class model_logs extends \table_sql {
|
||||
$this->set_attribute('class', 'modellog generaltable generalbox');
|
||||
$this->set_attribute('aria-live', 'polite');
|
||||
|
||||
$this->define_columns(array('time', 'version', 'evaluationmode', 'indicators', 'timesplitting',
|
||||
'accuracy', 'info', 'usermodified'));
|
||||
$this->define_columns(array('time', 'version', 'indicators', 'timesplitting', 'accuracy', 'info', 'usermodified'));
|
||||
$this->define_headers(array(
|
||||
get_string('time'),
|
||||
get_string('version'),
|
||||
get_string('evaluationmode', 'tool_analytics'),
|
||||
get_string('indicators', 'tool_analytics'),
|
||||
get_string('timesplittingmethod', 'analytics'),
|
||||
get_string('accuracy', 'tool_analytics'),
|
||||
get_string('info', 'tool_analytics'),
|
||||
get_string('fullnameuser'),
|
||||
));
|
||||
|
||||
$evaluationmodehelp = new \help_icon('evaluationmode', 'tool_analytics');
|
||||
$this->define_help_for_headers([null, null, $evaluationmodehelp, null, null, null, null, null]);
|
||||
|
||||
$this->pageable(true);
|
||||
$this->collapsible(false);
|
||||
$this->sortable(false);
|
||||
$this->is_downloadable(false);
|
||||
|
||||
$this->evaluationmode = optional_param('evaluationmode', false, PARAM_ALPHANUM);
|
||||
if ($this->evaluationmode && $this->evaluationmode != 'configuration' && $this->evaluationmode != 'trainedmodel') {
|
||||
$this->evaluationmode = '';
|
||||
}
|
||||
|
||||
$this->define_baseurl($PAGE->url);
|
||||
}
|
||||
|
||||
@@ -102,15 +86,6 @@ class model_logs extends \table_sql {
|
||||
return userdate($log->version, $recenttimestr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the evaluation mode column.
|
||||
*
|
||||
* @param \stdClass $log log data.
|
||||
* @return string HTML for the evaluationmode column
|
||||
*/
|
||||
public function col_evaluationmode($log) {
|
||||
return get_string('evaluationmodecol' . $log->evaluationmode, 'tool_analytics');
|
||||
}
|
||||
/**
|
||||
* Generate the time column.
|
||||
*
|
||||
|
||||
@@ -63,53 +63,15 @@ class models_list implements \renderable, \templatable {
|
||||
|
||||
$data = new \stdClass();
|
||||
|
||||
$newmodelmenu = new \action_menu();
|
||||
$newmodelmenu->set_menu_trigger(get_string('newmodel', 'tool_analytics'), 'btn btn-default');
|
||||
$newmodelmenu->set_alignment(\action_menu::TL, \action_menu::BL);
|
||||
|
||||
$newmodelmenu->add(new \action_menu_link(
|
||||
new \moodle_url('/admin/tool/analytics/createmodel.php'),
|
||||
new \pix_icon('i/edit', ''),
|
||||
get_string('createmodel', 'tool_analytics'),
|
||||
false
|
||||
));
|
||||
|
||||
$newmodelmenu->add(new \action_menu_link(
|
||||
new \moodle_url('/admin/tool/analytics/importmodel.php'),
|
||||
new \pix_icon('i/import', ''),
|
||||
get_string('importmodel', 'tool_analytics'),
|
||||
false
|
||||
));
|
||||
|
||||
$newmodelmenu->add(new \action_menu_link(
|
||||
new \moodle_url('/admin/tool/analytics/restoredefault.php'),
|
||||
new \pix_icon('i/reload', ''),
|
||||
get_string('restoredefault', 'tool_analytics'),
|
||||
false
|
||||
));
|
||||
|
||||
$data->newmodelmenu = $newmodelmenu->export_for_template($output);
|
||||
|
||||
$onlycli = get_config('analytics', 'onlycli');
|
||||
if ($onlycli === false) {
|
||||
// Default applied if no config found.
|
||||
$onlycli = 1;
|
||||
}
|
||||
|
||||
// Evaluation options.
|
||||
$timesplittingmethods = [
|
||||
['id' => 'all', 'text' => get_string('alltimesplittingmethods', 'tool_analytics')],
|
||||
];
|
||||
foreach (\core_analytics\manager::get_time_splitting_methods_for_evaluation(true) as $timesplitting) {
|
||||
$timesplittingmethods[] = [
|
||||
'id' => \tool_analytics\output\helper::class_to_option($timesplitting->get_id()),
|
||||
'text' => $timesplitting->get_name()->out(),
|
||||
];
|
||||
}
|
||||
|
||||
$data->models = array();
|
||||
foreach ($this->models as $model) {
|
||||
$modeldata = $model->export($output);
|
||||
$modeldata = $model->export();
|
||||
|
||||
// Check if there is a help icon for the target to show.
|
||||
$identifier = $modeldata->target->get_identifier();
|
||||
@@ -145,8 +107,6 @@ class models_list implements \renderable, \templatable {
|
||||
$modeldata->indicators = $indicators;
|
||||
}
|
||||
|
||||
$modeldata->indicatorsnum = count($modeldata->indicators);
|
||||
|
||||
// Check if there is a help icon for the time splitting method.
|
||||
if (!empty($modeldata->timesplitting)) {
|
||||
$identifier = $modeldata->timesplitting->get_identifier();
|
||||
@@ -181,7 +141,7 @@ class models_list implements \renderable, \templatable {
|
||||
if ($contextid == SYSCONTEXTID) {
|
||||
$contextname = get_string('allpredictions', 'tool_analytics');
|
||||
} else {
|
||||
$contextname = shorten_text($context->get_context_name(false, true), 40);
|
||||
$contextname = shorten_text($context->get_context_name(true, true), 90);
|
||||
}
|
||||
$predictioncontexts[$contextid] = $contextname;
|
||||
}
|
||||
@@ -225,30 +185,15 @@ class models_list implements \renderable, \templatable {
|
||||
|
||||
// Evaluate machine-learning-based models.
|
||||
if (!$onlycli && $model->get_indicators() && !$model->is_static()) {
|
||||
|
||||
// Extra is_trained call as trained_locally returns false if the model has not been trained yet.
|
||||
$trainedonlyexternally = !$model->trained_locally() && $model->is_trained();
|
||||
|
||||
$actionid = 'evaluate-' . $model->get_id();
|
||||
|
||||
$modeltimesplittingmethods = $timesplittingmethods;
|
||||
// Include the current time-splitting method as the default selection method the model already have one.
|
||||
if ($model->get_model_obj()->timesplitting) {
|
||||
$currenttimesplitting = ['id' => 'current', 'text' => get_string('currenttimesplitting', 'tool_analytics')];
|
||||
array_unshift($modeltimesplittingmethods, $currenttimesplitting);
|
||||
}
|
||||
|
||||
$evaluateparams = [$actionid, $trainedonlyexternally, $modeltimesplittingmethods];
|
||||
$PAGE->requires->js_call_amd('tool_analytics/model', 'selectEvaluationOptions', $evaluateparams);
|
||||
$urlparams['action'] = 'evaluate';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/calc', get_string('evaluate', 'tool_analytics')),
|
||||
get_string('evaluate', 'tool_analytics'), ['data-action-id' => $actionid]);
|
||||
get_string('evaluate', 'tool_analytics'));
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
|
||||
// Machine-learning-based models evaluation log.
|
||||
if (!$model->is_static() && $model->get_logs()) {
|
||||
if (!$model->is_static()) {
|
||||
$urlparams['action'] = 'log';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/report', get_string('viewlog', 'tool_analytics')),
|
||||
@@ -257,10 +202,12 @@ class models_list implements \renderable, \templatable {
|
||||
}
|
||||
|
||||
// Edit model.
|
||||
$urlparams['action'] = 'edit';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('t/edit', get_string('edit')), get_string('edit'));
|
||||
$actionsmenu->add($icon);
|
||||
if (!$model->is_static()) {
|
||||
$urlparams['action'] = 'edit';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('t/edit', get_string('edit')), get_string('edit'));
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
|
||||
// Enable / disable.
|
||||
if ($model->is_enabled() || !empty($modeldata->timesplitting)) {
|
||||
@@ -280,27 +227,13 @@ class models_list implements \renderable, \templatable {
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
|
||||
// Export.
|
||||
if (!$model->is_static()) {
|
||||
|
||||
$fullysetup = $model->get_indicators() && !empty($modeldata->timesplitting);
|
||||
$istrained = $model->is_trained();
|
||||
|
||||
if ($fullysetup || $istrained) {
|
||||
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
// Clear the previous action param from the URL, we will set it in JS.
|
||||
$url->remove_params('action');
|
||||
|
||||
$actionid = 'export-' . $model->get_id();
|
||||
$PAGE->requires->js_call_amd('tool_analytics/model', 'selectExportOptions',
|
||||
[$actionid, $istrained]);
|
||||
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/export',
|
||||
get_string('export', 'tool_analytics')), get_string('export', 'tool_analytics'),
|
||||
['data-action-id' => $actionid]);
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
// Export training data.
|
||||
if (!$model->is_static() && $model->is_trained()) {
|
||||
$urlparams['action'] = 'export';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('i/export',
|
||||
get_string('exporttrainingdata', 'tool_analytics')), get_string('export', 'tool_analytics'));
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
|
||||
// Invalid analysables.
|
||||
@@ -314,7 +247,7 @@ class models_list implements \renderable, \templatable {
|
||||
}
|
||||
|
||||
// Clear model.
|
||||
if (!empty($predictioncontexts) || $model->is_trained()) {
|
||||
if (!empty($predictioncontexts)) {
|
||||
$actionid = 'clear-' . $model->get_id();
|
||||
$PAGE->requires->js_call_amd('tool_analytics/model', 'confirmAction', [$actionid, 'clear']);
|
||||
$urlparams['action'] = 'clear';
|
||||
@@ -325,16 +258,6 @@ class models_list implements \renderable, \templatable {
|
||||
$actionsmenu->add($icon);
|
||||
}
|
||||
|
||||
// Delete model.
|
||||
$actionid = 'delete-' . $model->get_id();
|
||||
$PAGE->requires->js_call_amd('tool_analytics/model', 'confirmAction', [$actionid, 'delete']);
|
||||
$urlparams['action'] = 'delete';
|
||||
$url = new \moodle_url('model.php', $urlparams);
|
||||
$icon = new \action_menu_link_secondary($url, new \pix_icon('t/delete',
|
||||
get_string('delete', 'tool_analytics')), get_string('delete', 'tool_analytics'),
|
||||
['data-action-id' => $actionid]);
|
||||
$actionsmenu->add($icon);
|
||||
|
||||
$modeldata->actions = $actionsmenu->export_for_template($output);
|
||||
|
||||
$data->models[] = $modeldata;
|
||||
|
||||
@@ -81,7 +81,7 @@ class renderer extends plugin_renderer_base {
|
||||
foreach ($results as $timesplittingid => $result) {
|
||||
|
||||
if (!CLI_SCRIPT) {
|
||||
$output .= $OUTPUT->box_start('generalbox mb-3');
|
||||
$output .= $OUTPUT->box_start('generalbox m-b-3');
|
||||
}
|
||||
|
||||
// Check that the array key is a string, not all results depend on time splitting methods (e.g. general errors).
|
||||
@@ -177,7 +177,7 @@ class renderer extends plugin_renderer_base {
|
||||
}
|
||||
|
||||
if ($predictresults || (!empty($predictlogs) && debugging())) {
|
||||
$output .= $OUTPUT->heading(get_string('predictionresults', 'tool_analytics'), 3, 'main mt-3');
|
||||
$output .= $OUTPUT->heading(get_string('predictionresults', 'tool_analytics'), 3, 'main m-t-3');
|
||||
}
|
||||
|
||||
if ($predictresults) {
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - https://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/>.
|
||||
|
||||
/**
|
||||
* Provides {@link \tool_analytics\output\restorable_models} class.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @category output
|
||||
* @copyright 2019 David Mudrák <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace tool_analytics\output;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Represents the list of default models that can be eventually restored.
|
||||
*
|
||||
* @copyright 2019 David Mudrák <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class restorable_models implements \renderable, \templatable {
|
||||
|
||||
/** @var array */
|
||||
protected $models;
|
||||
|
||||
/**
|
||||
* Instantiate an object of this class.
|
||||
*
|
||||
* @param array $models List of models as returned by {@link \core_analytics\manager::load_default_models_for_all_components()}
|
||||
*/
|
||||
public function __construct(array $models) {
|
||||
|
||||
$this->models = $models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the list of models to be rendered.
|
||||
*
|
||||
* @param renderer_base $output
|
||||
* @return string
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
|
||||
$components = [];
|
||||
|
||||
foreach ($this->models as $componentname => $modelslist) {
|
||||
$component = [
|
||||
'name' => $this->component_name($componentname),
|
||||
'component' => $componentname,
|
||||
'models' => [],
|
||||
];
|
||||
|
||||
foreach ($modelslist as $definition) {
|
||||
list($target, $indicators) = \core_analytics\manager::get_declared_target_and_indicators_instances($definition);
|
||||
|
||||
if (\core_analytics\model::exists($target, $indicators)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$targetnamelangstring = $target->get_name();
|
||||
|
||||
$model = [
|
||||
'defid' => \core_analytics\manager::model_declaration_identifier($definition),
|
||||
'targetname' => $targetnamelangstring,
|
||||
'targetclass' => $definition['target'],
|
||||
'indicatorsnum' => count($definition['indicators']),
|
||||
'indicators' => [],
|
||||
];
|
||||
|
||||
if (get_string_manager()->string_exists($targetnamelangstring->get_identifier().'_help',
|
||||
$targetnamelangstring->get_component())) {
|
||||
$helpicon = new \help_icon($targetnamelangstring->get_identifier(), $targetnamelangstring->get_component());
|
||||
$model['targethelp'] = $helpicon->export_for_template($output);
|
||||
}
|
||||
|
||||
foreach ($indicators as $indicator) {
|
||||
$indicatornamelangstring = $indicator->get_name();
|
||||
$indicatordata = [
|
||||
'name' => $indicatornamelangstring,
|
||||
'classname' => $indicator->get_id(),
|
||||
];
|
||||
|
||||
if (get_string_manager()->string_exists($indicatornamelangstring->get_identifier().'_help',
|
||||
$indicatornamelangstring->get_component())) {
|
||||
$helpicon = new \help_icon($indicatornamelangstring->get_identifier(),
|
||||
$indicatornamelangstring->get_component());
|
||||
$indicatordata['indicatorhelp'] = $helpicon->export_for_template($output);
|
||||
}
|
||||
|
||||
$model['indicators'][] = $indicatordata;
|
||||
}
|
||||
|
||||
$component['models'][] = $model;
|
||||
}
|
||||
|
||||
if (!empty($component['models'])) {
|
||||
$components[] = $component;
|
||||
}
|
||||
}
|
||||
|
||||
$result = [
|
||||
'hasdata' => !empty($components),
|
||||
'components' => array_values($components),
|
||||
'submiturl' => new \moodle_url('/admin/tool/analytics/restoredefault.php'),
|
||||
'backurl' => new \moodle_url('/admin/tool/analytics/index.php'),
|
||||
'sesskey' => sesskey(),
|
||||
];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a human readable name for the given frankenstyle component.
|
||||
*
|
||||
* @param string $component Frankenstyle component such as 'core', 'core_analytics' or 'mod_workshop'
|
||||
* @return string Human readable name of the component
|
||||
*/
|
||||
protected function component_name(string $component): string {
|
||||
|
||||
if ($component === 'core' || strpos($component, 'core_')) {
|
||||
return get_string('componentcore', 'tool_analytics');
|
||||
|
||||
} else {
|
||||
return get_string('pluginname', $component);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,16 +59,10 @@ class predict_models extends \core\task\scheduled_task {
|
||||
}
|
||||
|
||||
foreach ($models as $model) {
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$result = $model->predict();
|
||||
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
|
||||
if ($result) {
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name()));
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_target()->get_name()));
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_get_predictions_results(false, array(), $result, $model->get_analyser()->get_logs());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,15 +70,11 @@ class train_models extends \core\task\scheduled_task {
|
||||
continue;
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$result = $model->train();
|
||||
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
|
||||
if ($result) {
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_name()));
|
||||
echo $OUTPUT->heading(get_string('modelresults', 'tool_analytics', $model->get_target()->get_name()));
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_get_predictions_results($result, $model->get_analyser()->get_logs());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ Options:
|
||||
--non-interactive Not interactive questions
|
||||
--timesplitting Restrict the evaluation to 1 single time splitting method (Optional)
|
||||
--filter Analyser dependant. e.g. A courseid would evaluate the model using a single course (Optional)
|
||||
--mode 'configuration' or 'trainedmodel'. You can only use mode=trainedmodel when the trained" .
|
||||
" model was imported" . "
|
||||
--reuse-prev-analysed Reuse recently analysed courses instead of analysing the whole site. Set it to false while" .
|
||||
" coding indicators. Defaults to true (Optional)" . "
|
||||
-h, --help Print out this help
|
||||
@@ -52,7 +50,6 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'modelid' => false,
|
||||
'list' => false,
|
||||
'timesplitting' => false,
|
||||
'mode' => 'configuration',
|
||||
'reuse-prev-analysed' => true,
|
||||
'non-interactive' => false,
|
||||
'filter' => false
|
||||
@@ -67,30 +64,16 @@ if ($options['help']) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['list']) {
|
||||
if ($options['list'] || $options['modelid'] === false) {
|
||||
\tool_analytics\clihelper::list_models();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ($options['modelid'] === false) {
|
||||
// All actions but --list require a modelid.
|
||||
echo $help;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Reformat them as an array.
|
||||
if ($options['filter'] !== false) {
|
||||
$options['filter'] = explode(',', $options['filter']);
|
||||
}
|
||||
|
||||
if ($options['mode'] !== 'configuration' && $options['mode'] !== 'trainedmodel') {
|
||||
cli_error('Error: The provided mode is not supported');
|
||||
}
|
||||
|
||||
if ($options['mode'] == 'trainedmodel' && $options['timesplitting']) {
|
||||
cli_error('Sorry, no time splitting method can be specified when using \'trainedmodel\' mode.');
|
||||
}
|
||||
|
||||
// We need admin permissions.
|
||||
\core\session\manager::set_user(get_admin());
|
||||
|
||||
@@ -102,20 +85,15 @@ if ($options['reuse-prev-analysed']) {
|
||||
mtrace(get_string('evaluationinbatches', 'tool_analytics'));
|
||||
}
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
|
||||
$analyseroptions = array(
|
||||
'filter' => $options['filter'],
|
||||
'timesplitting' => $options['timesplitting'],
|
||||
'reuseprevanalysed' => $options['reuse-prev-analysed'],
|
||||
'mode' => $options['mode'],
|
||||
);
|
||||
// Evaluate its suitability to predict accurately.
|
||||
$results = $model->evaluate($analyseroptions);
|
||||
|
||||
// Reset the page as some indicators may call external functions that overwrite the page context.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_evaluate_results($results, $model->get_analyser()->get_logs());
|
||||
|
||||
// Check that we have, at leasa,t 1 valid dataset (not necessarily good) to use.
|
||||
|
||||
@@ -173,8 +173,7 @@ function tool_analytics_calculate_course_dates($course, $options) {
|
||||
$formatoptions = $format->get_format_options();
|
||||
|
||||
// Change this for a course formats API level call in MDL-60702.
|
||||
if ((get_class($format) == 'format_weeks' || is_subclass_of($format, 'format_weeks')) &&
|
||||
method_exists($format, 'update_end_date') && $formatoptions['automaticenddate']) {
|
||||
if (method_exists($format, 'update_end_date') && $formatoptions['automaticenddate']) {
|
||||
// Special treatment for weeks-based formats with automatic end date.
|
||||
|
||||
if ($options['update']) {
|
||||
@@ -205,9 +204,9 @@ function tool_analytics_calculate_course_dates($course, $options) {
|
||||
|
||||
$updateit = false;
|
||||
if ($course->enddate < $course->startdate) {
|
||||
$notification .= PHP_EOL . ' ' . get_string('errorendbeforestart', 'course', userdate($course->enddate));
|
||||
$notification .= PHP_EOL . ' ' . get_string('errorendbeforestart', 'analytics', userdate($course->enddate));
|
||||
} else if ($course->startdate + (YEARSECS + (WEEKSECS * 4)) > $course->enddate) {
|
||||
$notification .= PHP_EOL . ' ' . get_string('coursetoolong', 'course');
|
||||
$notification .= PHP_EOL . ' ' . get_string('coursetoolong', 'analytics');
|
||||
} else {
|
||||
$notification .= PHP_EOL . ' ' . get_string('enddate') . ': ' . userdate($course->enddate);
|
||||
$updateit = true;
|
||||
|
||||
@@ -1,95 +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/>.
|
||||
|
||||
/**
|
||||
* Create model form.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2019 David Monllao {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login();
|
||||
\core_analytics\manager::check_can_manage_models();
|
||||
|
||||
$returnurl = new \moodle_url('/admin/tool/analytics/index.php');
|
||||
$url = new \moodle_url('/admin/tool/analytics/createmodel.php');
|
||||
$title = get_string('createmodel', 'tool_analytics');
|
||||
|
||||
\tool_analytics\output\helper::set_navbar($title, $url);
|
||||
|
||||
// Static targets are not editable, we discard them.
|
||||
$targets = array_filter(\core_analytics\manager::get_all_targets(), function($target) {
|
||||
return (!$target->based_on_assumptions());
|
||||
});
|
||||
|
||||
$customdata = array(
|
||||
'trainedmodel' => false,
|
||||
'staticmodel' => false,
|
||||
'targets' => $targets,
|
||||
'indicators' => \core_analytics\manager::get_all_indicators(),
|
||||
'timesplittings' => \core_analytics\manager::get_all_time_splittings(),
|
||||
'predictionprocessors' => \core_analytics\manager::get_all_prediction_processors(),
|
||||
);
|
||||
$mform = new \tool_analytics\output\form\edit_model(null, $customdata);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
|
||||
// Converting option names to class names.
|
||||
$targetclass = \tool_analytics\output\helper::option_to_class($data->target);
|
||||
if (empty($targets[$targetclass])) {
|
||||
throw new \moodle_exception('errorinvalidtarget', 'analytics', '', $targetclass);
|
||||
}
|
||||
$target = $targets[$targetclass];
|
||||
|
||||
$indicators = array();
|
||||
foreach ($data->indicators as $indicator) {
|
||||
$indicatorinstance = \core_analytics\manager::get_indicator(
|
||||
\tool_analytics\output\helper::option_to_class($indicator)
|
||||
);
|
||||
$indicators[$indicatorinstance->get_id()] = $indicatorinstance;
|
||||
}
|
||||
$timesplitting = \tool_analytics\output\helper::option_to_class($data->timesplitting);
|
||||
$predictionsprocessor = \tool_analytics\output\helper::option_to_class($data->predictionsprocessor);
|
||||
|
||||
// Insert the model into db.
|
||||
$model = \core_analytics\model::create($target, []);
|
||||
|
||||
// Filter out indicators that can not be used by this target.
|
||||
$invalidindicators = array_diff_key($indicators, $model->get_potential_indicators());
|
||||
if ($invalidindicators) {
|
||||
$indicators = array_diff_key($indicators, $invalidindicators);
|
||||
}
|
||||
|
||||
// Update the model with the valid list of indicators.
|
||||
$model->update($data->enabled, $indicators, $timesplitting, $predictionsprocessor);
|
||||
|
||||
$message = '';
|
||||
$messagetype = \core\output\notification::NOTIFY_SUCCESS;
|
||||
if (!empty($invalidindicators)) {
|
||||
$message = get_string('invalidindicatorsremoved', 'tool_analytics');
|
||||
}
|
||||
redirect($returnurl, $message, 0, $messagetype);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,59 +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/>.
|
||||
|
||||
/**
|
||||
* Import models tool frontend.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2017 onwards Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login();
|
||||
\core_analytics\manager::check_can_manage_models();
|
||||
|
||||
$returnurl = new \moodle_url('/admin/tool/analytics/index.php');
|
||||
$url = new \moodle_url('/admin/tool/analytics/importmodel.php');
|
||||
$title = get_string('importmodel', 'tool_analytics');
|
||||
|
||||
\tool_analytics\output\helper::set_navbar($title, $url);
|
||||
|
||||
$form = new \tool_analytics\output\form\import_model();
|
||||
if ($form->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
} else if ($data = $form->get_data()) {
|
||||
|
||||
$modelconfig = new \core_analytics\model_config();
|
||||
|
||||
$zipfilepath = $form->save_temp_file('modelfile');
|
||||
|
||||
list ($modeldata, $unused) = $modelconfig->extract_import_contents($zipfilepath);
|
||||
|
||||
if ($error = $modelconfig->check_dependencies($modeldata, $data->ignoreversionmismatches)) {
|
||||
// The file is not available until the form is validated so we need an alternative method to show errors.
|
||||
redirect($url, $error, 0, \core\output\notification::NOTIFY_ERROR);
|
||||
}
|
||||
\core_analytics\model::import_model($zipfilepath);
|
||||
|
||||
redirect($returnurl, get_string('importedsuccessfully', 'tool_analytics'), 0,
|
||||
\core\output\notification::NOTIFY_SUCCESS);
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$form->display();
|
||||
echo $OUTPUT->footer();
|
||||
@@ -24,26 +24,16 @@
|
||||
|
||||
$string['accuracy'] = 'Accuracy';
|
||||
$string['allpredictions'] = 'All predictions';
|
||||
$string['alltimesplittingmethods'] = 'All time-splitting methods';
|
||||
$string['analysingsitedata'] = 'Analysing the site';
|
||||
$string['analyticmodels'] = 'Analytics models';
|
||||
$string['bettercli'] = 'Evaluating models and generating predictions may involve heavy processing. It is recommended to run these actions from the command line.';
|
||||
$string['cantguessstartdate'] = 'Can\'t guess the start date';
|
||||
$string['cantguessenddate'] = 'Can\'t guess the end date';
|
||||
$string['classdoesnotexist'] = 'Class {$a} does not exist';
|
||||
$string['clearpredictions'] = 'Clear predictions';
|
||||
$string['clearmodelpredictions'] = 'Are you sure you want to clear all "{$a}" predictions?';
|
||||
$string['clienablemodel'] = 'You can enable the model by selecting a time-splitting method by its ID. Note that you can also enable it later using the web interface (\'none\' to exit).';
|
||||
$string['clievaluationandpredictions'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. You can allow these processes to be executed manually via the web interface by disabling the <a href="{$a}">\'onlycli\'</a> analytics setting.';
|
||||
$string['clievaluationandpredictionsnoadmin'] = 'A scheduled task iterates through enabled models and gets predictions. Models evaluation via the web interface is disabled. It may be enabled by a site administrator.';
|
||||
$string['component'] = 'Component';
|
||||
$string['componentcore'] = 'Core';
|
||||
$string['componentselect'] = 'Select all models provided by the component \'{$a}\'';
|
||||
$string['componentselectnone'] = 'Unselect all';
|
||||
$string['createmodel'] = 'Create model';
|
||||
$string['currenttimesplitting'] = 'Current time-splitting method';
|
||||
$string['delete'] = 'Delete';
|
||||
$string['deletemodelconfirmation'] = 'Are you sure you want to delete "{$a}"? These changes cannot be reverted.';
|
||||
$string['disabled'] = 'Disabled';
|
||||
$string['editmodel'] = 'Edit "{$a}" model';
|
||||
$string['edittrainedwarning'] = 'This model has already been trained. Note that changing its indicators or its time-splitting method will delete its previous predictions and start generating new predictions.';
|
||||
@@ -52,64 +42,39 @@ $string['errorcantenablenotimesplitting'] = 'You need to select a time-splitting
|
||||
$string['errornoenabledandtrainedmodels'] = 'There are no enabled and trained models to predict.';
|
||||
$string['errornoenabledmodels'] = 'There are no enabled models to train.';
|
||||
$string['errornoexport'] = 'Only trained models can be exported';
|
||||
$string['errornostaticedit'] = 'Models based on assumptions cannot be edited.';
|
||||
$string['errornostaticevaluated'] = 'Models based on assumptions cannot be evaluated. They are always 100% correct according to how they were defined.';
|
||||
$string['errornostaticlog'] = 'Models based on assumptions cannot be evaluated because there is no performance log.';
|
||||
$string['erroronlycli'] = 'Execution only allowed via command line';
|
||||
$string['errortrainingdataexport'] = 'The model training data could not be exported';
|
||||
$string['evaluate'] = 'Evaluate';
|
||||
$string['evaluatemodel'] = 'Evaluate model';
|
||||
$string['evaluationmode'] = 'Evaluation mode';
|
||||
$string['evaluationmode_help'] = 'There are two evaluation modes:
|
||||
|
||||
* Trained model - Site data is used as testing data to evaluate the accuracy of the trained model.
|
||||
* Configuration - Site data is split into training and testing data, to both train and test the accuracy of the model configuration.
|
||||
|
||||
Trained model is only available if a trained model has been imported into the site, and has not yet been re-trained using site data.';
|
||||
$string['evaluationmodeinfo'] = 'This model has been imported into the site. You can either evaluate the performance of the model, or you can evaluate the performance of the model configuration using site data.';
|
||||
$string['evaluationmodetrainedmodel'] = 'Evaluate the trained model';
|
||||
$string['evaluationmodecoltrainedmodel'] = 'Trained model';
|
||||
$string['evaluationmodecolconfiguration'] = 'Configuration';
|
||||
$string['evaluationmodeconfiguration'] = 'Evaluate the model configuration';
|
||||
$string['evaluationinbatches'] = 'The site contents are calculated and stored in batches. The evaluation process may be stopped at any time. The next time it is run, it will continue from the point when it was stopped.';
|
||||
$string['export'] = 'Export';
|
||||
$string['exportincludeweights'] = 'Include the weights of the trained model';
|
||||
$string['exportmodel'] = 'Export configuration';
|
||||
$string['exporttrainingdata'] = 'Export training data';
|
||||
$string['getpredictionsresultscli'] = 'Results using {$a->name} (id: {$a->id}) time-splitting method';
|
||||
$string['getpredictionsresults'] = 'Results using {$a->name} time-splitting method';
|
||||
$string['getpredictionsresultscli'] = 'Results using {$a->name} (id: {$a->id}) course duration splitting';
|
||||
$string['getpredictionsresults'] = 'Results using {$a->name} course duration splitting';
|
||||
$string['extrainfo'] = 'Info';
|
||||
$string['generalerror'] = 'Evaluation error. Status code {$a}';
|
||||
$string['getpredictions'] = 'Get predictions';
|
||||
$string['goodmodel'] = 'This is a good model for using to obtain predictions. Enable it to start obtaining predictions.';
|
||||
$string['importmodel'] = 'Import model';
|
||||
$string['indicators'] = 'Indicators';
|
||||
$string['indicators_help'] = 'The indicators are what you think will lead to an accurate prediction of the target.';
|
||||
$string['indicators_link'] = 'Indicators';
|
||||
$string['indicatorsnum'] = 'Number of indicators: {$a}';
|
||||
$string['info'] = 'Info';
|
||||
$string['ignoreversionmismatches'] = 'Ignore version mismatches';
|
||||
$string['ignoreversionmismatchescheckbox'] = 'Ignore the differences between this site version and the original site version.';
|
||||
$string['importedsuccessfully'] = 'The model has been successfully imported.';
|
||||
$string['insights'] = 'Insights';
|
||||
$string['invalidanalysables'] = 'Invalid site elements';
|
||||
$string['invalidanalysablesinfo'] = 'This page lists analysable elements that can\'t be used by this prediction model. The listed elements can\'t be used either to train the prediction model nor can the prediction model obtain predictions for them.';
|
||||
$string['invalidanalysablesinfo'] = 'This pages lists this site analysable elements that can not be used by this prediction model. The listed elements can not be used neither to train the prediction model nor the prediction model can get predictions for them.';
|
||||
$string['invalidanalysablestable'] = 'Invalid site analysable elements table';
|
||||
$string['invalidindicatorsremoved'] = 'A new model has been added. Indicators that do not work with the selected target have been automatically removed.';
|
||||
$string['invalidprediction'] = 'Invalid to get predictions';
|
||||
$string['invalidtraining'] = 'Invalid to train the model';
|
||||
$string['loginfo'] = 'Log extra info';
|
||||
$string['missingmoodleversion'] = 'Imported file doesn\'t define a version number';
|
||||
$string['modelid'] = 'Model ID';
|
||||
$string['modelinvalidanalysables'] = 'Invalid analysable elements for "{$a}" model';
|
||||
$string['modelname'] = 'Model name';
|
||||
$string['modelresults'] = '{$a} results';
|
||||
$string['modeltimesplitting'] = 'Time splitting';
|
||||
$string['newmodel'] = 'New model';
|
||||
$string['nextpage'] = 'Next page';
|
||||
$string['nodatatoevaluate'] = 'There is no data to evaluate the model';
|
||||
$string['nodatatopredict'] = 'No new elements to get predictions for';
|
||||
$string['nodatatotrain'] = 'There is no new data that can be used for training';
|
||||
$string['noinvalidanalysables'] = 'This site does not contain any invalid analysable element.';
|
||||
$string['notdefined'] = 'Not yet defined';
|
||||
$string['pluginname'] = 'Analytic models';
|
||||
$string['predictionresults'] = 'Prediction results';
|
||||
@@ -117,26 +82,16 @@ $string['predictmodels'] = 'Predict models';
|
||||
$string['predictorresultsin'] = 'Predictor logged information in {$a} directory';
|
||||
$string['predictionprocessfinished'] = 'Prediction process finished';
|
||||
$string['previouspage'] = 'Previous page';
|
||||
$string['restoredefault'] = 'Restore default models';
|
||||
$string['restoredefaultempty'] = 'Please select models to be restored.';
|
||||
$string['restoredefaultinfo'] = 'These default models are missing or have changed since being installed. You can restore selected default models.';
|
||||
$string['restoredefaultnone'] = 'All default models provided by core and installed plugins have been created. No new models were found; there is nothing to restore.';
|
||||
$string['restoredefaultsome'] = 'Succesfully re-created {$a->count} new model(s).';
|
||||
$string['restoredefaultsubmit'] = 'Restore selected';
|
||||
$string['samestartdate'] = 'Current start date is good';
|
||||
$string['sameenddate'] = 'Current end date is good';
|
||||
$string['selecttimesplittingforevaluation'] = 'Select the time-splitting method you want to use to evaluate the model configuration.';
|
||||
$string['target'] = 'Target';
|
||||
$string['target_help'] = 'The target is what the model will predict.';
|
||||
$string['target_link'] = 'Targets';
|
||||
$string['timesplittingnotdefined'] = 'Time splitting is not defined.';
|
||||
$string['timesplittingnotdefined_help'] = 'You need to select a time-splitting method before enabling the model.';
|
||||
$string['trainandpredictmodel'] = 'Training model and calculating predictions';
|
||||
$string['trainingprocessfinished'] = 'Training process finished';
|
||||
$string['trainingresults'] = 'Training results';
|
||||
$string['trainmodels'] = 'Train models';
|
||||
$string['versionnotsame'] = 'Imported file was from a different version ({$a->importedversion}) than the current one ({$a->version})';
|
||||
$string['viewlog'] = 'Evaluation log';
|
||||
$string['viewlog'] = 'Log';
|
||||
$string['weeksenddateautomaticallyset'] = 'End date automatically set based on start date and the number of sections';
|
||||
$string['weeksenddatedefault'] = 'End date automatically calculated from the course start date.';
|
||||
$string['privacy:metadata'] = 'The Analytic models plugin does not store any personal data.';
|
||||
|
||||
@@ -23,24 +23,24 @@
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
|
||||
$context = context_system::instance();
|
||||
|
||||
require_login();
|
||||
|
||||
$model = new \core_analytics\model($id);
|
||||
\core_analytics\manager::check_can_manage_models();
|
||||
|
||||
$returnurl = new \moodle_url('/admin/tool/analytics/index.php');
|
||||
$params = array('id' => $id, 'action' => $action);
|
||||
$url = new \moodle_url('/admin/tool/analytics/model.php', $params);
|
||||
|
||||
switch ($action) {
|
||||
|
||||
case 'edit':
|
||||
$title = get_string('editmodel', 'tool_analytics', $model->get_name());
|
||||
$title = get_string('editmodel', 'tool_analytics', $model->get_target()->get_name());
|
||||
break;
|
||||
case 'evaluate':
|
||||
$title = get_string('evaluatemodel', 'tool_analytics');
|
||||
@@ -57,14 +57,8 @@ switch ($action) {
|
||||
case 'disable':
|
||||
$title = get_string('disable');
|
||||
break;
|
||||
case 'delete':
|
||||
$title = get_string('delete');
|
||||
break;
|
||||
case 'exportdata':
|
||||
$title = get_string('exporttrainingdata', 'tool_analytics');
|
||||
break;
|
||||
case 'exportmodel':
|
||||
$title = get_string('exportmodel', 'tool_analytics');
|
||||
case 'export':
|
||||
$title = get_string('export', 'tool_analytics');
|
||||
break;
|
||||
case 'clear':
|
||||
$title = get_string('clearpredictions', 'tool_analytics');
|
||||
@@ -76,7 +70,11 @@ switch ($action) {
|
||||
throw new moodle_exception('errorunknownaction', 'analytics');
|
||||
}
|
||||
|
||||
\tool_analytics\output\helper::set_navbar($title, $url);
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('report');
|
||||
$PAGE->set_title($title);
|
||||
$PAGE->set_heading($title);
|
||||
|
||||
$onlycli = get_config('analytics', 'onlycli');
|
||||
if ($onlycli === false) {
|
||||
@@ -90,59 +88,48 @@ switch ($action) {
|
||||
confirm_sesskey();
|
||||
|
||||
$model->enable();
|
||||
redirect($returnurl);
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||
break;
|
||||
|
||||
case 'disable':
|
||||
confirm_sesskey();
|
||||
|
||||
$model->update(0, false, false);
|
||||
redirect($returnurl);
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
confirm_sesskey();
|
||||
|
||||
$model->delete();
|
||||
redirect($returnurl);
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
confirm_sesskey();
|
||||
|
||||
if ($model->is_static()) {
|
||||
echo $OUTPUT->header();
|
||||
throw new moodle_exception('errornostaticedit', 'tool_analytics');
|
||||
}
|
||||
|
||||
$customdata = array(
|
||||
'id' => $model->get_id(),
|
||||
'trainedmodel' => $model->is_trained(),
|
||||
'staticmodel' => $model->is_static(),
|
||||
'model' => $model,
|
||||
'indicators' => $model->get_potential_indicators(),
|
||||
'timesplittings' => \core_analytics\manager::get_all_time_splittings(),
|
||||
'timesplittings' => \core_analytics\manager::get_enabled_time_splitting_methods(),
|
||||
'predictionprocessors' => \core_analytics\manager::get_all_prediction_processors()
|
||||
);
|
||||
$mform = new \tool_analytics\output\form\edit_model(null, $customdata);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
|
||||
$timesplitting = \tool_analytics\output\helper::option_to_class($data->timesplitting);
|
||||
|
||||
if (!$model->is_static()) {
|
||||
// Converting option names to class names.
|
||||
$indicators = array();
|
||||
foreach ($data->indicators as $indicator) {
|
||||
$indicatorclass = \tool_analytics\output\helper::option_to_class($indicator);
|
||||
$indicators[] = \core_analytics\manager::get_indicator($indicatorclass);
|
||||
}
|
||||
$predictionsprocessor = \tool_analytics\output\helper::option_to_class($data->predictionsprocessor);
|
||||
} else {
|
||||
// These fields can not be modified.
|
||||
$indicators = false;
|
||||
$predictionsprocessor = false;
|
||||
// Converting option names to class names.
|
||||
$indicators = array();
|
||||
foreach ($data->indicators as $indicator) {
|
||||
$indicatorclass = \tool_analytics\output\helper::option_to_class($indicator);
|
||||
$indicators[] = \core_analytics\manager::get_indicator($indicatorclass);
|
||||
}
|
||||
|
||||
$timesplitting = \tool_analytics\output\helper::option_to_class($data->timesplitting);
|
||||
$predictionsprocessor = \tool_analytics\output\helper::option_to_class($data->predictionsprocessor);
|
||||
$model->update($data->enabled, $indicators, $timesplitting, $predictionsprocessor);
|
||||
redirect($returnurl);
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
@@ -160,6 +147,8 @@ switch ($action) {
|
||||
case 'evaluate':
|
||||
confirm_sesskey();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($model->is_static()) {
|
||||
throw new moodle_exception('errornostaticevaluate', 'tool_analytics');
|
||||
}
|
||||
@@ -171,31 +160,7 @@ switch ($action) {
|
||||
// Web interface is used by people who can not use CLI nor code stuff, always use
|
||||
// cached stuff as they will change the model through the web interface as well
|
||||
// which invalidates the previously analysed stuff.
|
||||
$options = ['reuseprevanalysed' => true];
|
||||
|
||||
$mode = optional_param('mode', false, PARAM_ALPHANUM);
|
||||
if ($mode == 'trainedmodel') {
|
||||
$options['mode'] = 'trainedmodel';
|
||||
} else {
|
||||
|
||||
// All is the default in core_analytics\model::evaluate() as well.
|
||||
$timesplitting = optional_param('timesplitting', 'all', PARAM_ALPHANUMEXT);
|
||||
if ($timesplitting === 'current') {
|
||||
$options['timesplitting'] = \core_analytics\manager::get_time_splitting($model->get_model_obj()->timesplitting);
|
||||
} else if ($timesplitting !== 'all') {
|
||||
$options['timesplitting'] = \core_analytics\manager::get_time_splitting(
|
||||
\tool_analytics\output\helper::option_to_class($timesplitting)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$results = $model->evaluate($options);
|
||||
|
||||
// We reset the theme and the output as some indicators may be using external functions
|
||||
// which reset $PAGE.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$results = $model->evaluate(array('reuseprevanalysed' => true));
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_evaluate_results($results, $model->get_analyser()->get_logs());
|
||||
break;
|
||||
@@ -203,6 +168,8 @@ switch ($action) {
|
||||
case 'getpredictions':
|
||||
confirm_sesskey();
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if ($onlycli) {
|
||||
throw new moodle_exception('erroronlycli', 'tool_analytics');
|
||||
}
|
||||
@@ -220,11 +187,6 @@ switch ($action) {
|
||||
$predictlogs = array();
|
||||
}
|
||||
|
||||
// We reset the theme and the output as some indicators may be using external functions
|
||||
// which reset $PAGE.
|
||||
\tool_analytics\output\helper::reset_page();
|
||||
echo $OUTPUT->header();
|
||||
|
||||
$renderer = $PAGE->get_renderer('tool_analytics');
|
||||
echo $renderer->render_get_predictions_results($trainresults, $trainlogs, $predictresults, $predictlogs);
|
||||
break;
|
||||
@@ -241,7 +203,7 @@ switch ($action) {
|
||||
echo $renderer->render_table($modellogstable);
|
||||
break;
|
||||
|
||||
case 'exportdata':
|
||||
case 'export':
|
||||
|
||||
if ($model->is_static() || !$model->is_trained()) {
|
||||
throw new moodle_exception('errornoexport', 'tool_analytics');
|
||||
@@ -249,7 +211,7 @@ switch ($action) {
|
||||
|
||||
$file = $model->get_training_data();
|
||||
if (!$file) {
|
||||
redirect($returnurl, get_string('errortrainingdataexport', 'tool_analytics'),
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'), get_string('errortrainingdataexport', 'tool_analytics'),
|
||||
null, \core\output\notification::NOTIFY_ERROR);
|
||||
}
|
||||
|
||||
@@ -257,20 +219,11 @@ switch ($action) {
|
||||
send_file($file, $filename, null, 0, false, true);
|
||||
break;
|
||||
|
||||
case 'exportmodel':
|
||||
|
||||
$includeweights = optional_param('includeweights', 1, PARAM_INT);
|
||||
|
||||
$zipfilename = 'model-' . $model->get_unique_id() . '-' . microtime(false) . '.zip';
|
||||
$zipfilepath = $model->export_model($zipfilename, $includeweights);
|
||||
send_temp_file($zipfilepath, $zipfilename);
|
||||
break;
|
||||
|
||||
case 'clear':
|
||||
confirm_sesskey();
|
||||
|
||||
$model->clear();
|
||||
redirect($returnurl);
|
||||
redirect(new \moodle_url('/admin/tool/analytics/index.php'));
|
||||
break;
|
||||
|
||||
case 'invalidanalysables':
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<?php
|
||||
// This file is part of Moodle - https://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/>.
|
||||
|
||||
/**
|
||||
* Check and create missing default prediction models.
|
||||
*
|
||||
* @package tool_analytics
|
||||
* @copyright 2019 David Mudrák <david@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
require_login();
|
||||
\core_analytics\manager::check_can_manage_models();
|
||||
|
||||
$confirmed = optional_param('confirmed', false, PARAM_BOOL);
|
||||
$restoreids = optional_param_array('restoreid', [], PARAM_ALPHANUM);
|
||||
|
||||
$returnurl = new \moodle_url('/admin/tool/analytics/index.php');
|
||||
$myurl = new \moodle_url('/admin/tool/analytics/restoredefault.php');
|
||||
|
||||
\tool_analytics\output\helper::set_navbar(get_string('restoredefault', 'tool_analytics'), $myurl);
|
||||
|
||||
if (data_submitted()) {
|
||||
require_sesskey();
|
||||
|
||||
if (empty($restoreids)) {
|
||||
$message = get_string('restoredefaultempty', 'tool_analytics');
|
||||
$type = \core\output\notification::NOTIFY_WARNING;
|
||||
redirect($myurl, $message, null, $type);
|
||||
}
|
||||
|
||||
$numcreated = 0;
|
||||
|
||||
foreach (\core_analytics\manager::load_default_models_for_all_components() as $componentname => $modelslist) {
|
||||
foreach ($modelslist as $definition) {
|
||||
if (!in_array(\core_analytics\manager::model_declaration_identifier($definition), $restoreids)) {
|
||||
// This model has not been selected by the user.
|
||||
continue;
|
||||
}
|
||||
|
||||
list($target, $indicators) = \core_analytics\manager::get_declared_target_and_indicators_instances($definition);
|
||||
|
||||
if (\core_analytics\model::exists($target, $indicators)) {
|
||||
// This model exists (normally this should not happen as we do not show such models in the UI to select).
|
||||
continue;
|
||||
}
|
||||
|
||||
\core_analytics\manager::create_declared_model($definition);
|
||||
$numcreated++;
|
||||
}
|
||||
}
|
||||
|
||||
$message = get_string('restoredefaultsome', 'tool_analytics', ['count' => $numcreated]);
|
||||
$type = \core\output\notification::NOTIFY_SUCCESS;
|
||||
|
||||
redirect($returnurl, $message, null, $type);
|
||||
}
|
||||
|
||||
$models = \core_analytics\manager::load_default_models_for_all_components();
|
||||
$ui = new \tool_analytics\output\restorable_models($models);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $PAGE->get_renderer('tool_analytics')->render($ui);
|
||||
echo $OUTPUT->footer();
|
||||
@@ -1,82 +0,0 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template tool_analytics/evaluation_options
|
||||
|
||||
Evaluation selector.
|
||||
|
||||
The purpose of this template is to render the evaluation mode options.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"trainedexternally": "1",
|
||||
"timesplittingmethods": [
|
||||
{
|
||||
"id": "ou",
|
||||
"name": "Quarters"
|
||||
}, {
|
||||
"id": "yeah",
|
||||
"name": "Tenths"
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
|
||||
{{#trainedexternally}}
|
||||
<div class="box mb-4">{{#str}} evaluationmodeinfo, tool_analytics {{/str}}</div>
|
||||
|
||||
<div class="custom-control custom-radio">
|
||||
<input class="custom-control-input" type="radio" name="evaluationmode" id="id-mode-trainedmodel" value="trainedmodel" checked>
|
||||
<label class="custom-control-label" for="id-mode-trainedmodel">{{#str}} evaluationmodetrainedmodel, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
|
||||
<div class="custom-control custom-radio">
|
||||
<input class="custom-control-input" type="radio" name="evaluationmode" id="id-mode-configuration" value="configuration">
|
||||
<label class="custom-control-label" for="id-mode-configuration">{{#str}} evaluationmodeconfiguration, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
{{/trainedexternally}}
|
||||
|
||||
{{! Hidden by default if #trainedexternally as the default option is trainedmodel in this case.}}
|
||||
<div id="id-evaluation-timesplitting-container" class="m-t-1 {{#trainedexternally}}hidden{{/trainedexternally}}">
|
||||
{{#str}} selecttimesplittingforevaluation, tool_analytics {{/str}}
|
||||
<div>
|
||||
<select id="id-evaluation-timesplitting" name="timesplitting" class="custom-select m-t-1">
|
||||
{{#timesplittingmethods}}
|
||||
<option value="{{id}}">{{text}}</option>
|
||||
{{/timesplittingmethods}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
$("input[name='evaluationmode']:radio").change(function() {
|
||||
if ($(this).val() == 'configuration') {
|
||||
$('#id-evaluation-timesplitting-container').show();
|
||||
} else {
|
||||
$('#id-evaluation-timesplitting-container').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
@@ -1,57 +0,0 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template tool_analytics/export_options
|
||||
|
||||
Export options.
|
||||
|
||||
The purpose of this template is to render the exporting options.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
}
|
||||
}}
|
||||
<div class="custom-control custom-radio">
|
||||
<input class="custom-control-input" type="radio" name="exportoption" id="id-mode-exportdata" value="exportdata">
|
||||
<label class="custom-control-label" for="id-mode-exportdata">{{#str}} exporttrainingdata, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
<div class="custom-control custom-radio">
|
||||
<input class="custom-control-input" type="radio" name="exportoption" id="id-mode-exportmodel" value="exportmodel" checked>
|
||||
<label class="custom-control-label" for="id-mode-exportmodel">{{#str}} exportmodel, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox m-l-2" id="id-includeweights-container">
|
||||
<input class="custom-control-input" type="checkbox" id="id-includeweights" value="1" checked>
|
||||
<label class="custom-control-label" for="id-includeweights">{{#str}} exportincludeweights, tool_analytics {{/str}}</label>
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
$("input[name='exportoption']:radio").change(function() {
|
||||
if ($(this).val() == 'exportdata') {
|
||||
$('#id-includeweights-container').hide();
|
||||
} else {
|
||||
$('#id-includeweights-container').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
@@ -48,38 +48,31 @@
|
||||
<div class="box">
|
||||
<h3>{{#str}}modelinvalidanalysables, tool_analytics, {{modelname}}{{/str}}</h3>
|
||||
<div>{{#str}}invalidanalysablesinfo, tool_analytics{{/str}}</div>
|
||||
{{#noanalysables}}
|
||||
<div class="mt-2 mb-1">
|
||||
{{> core/notification_info}}
|
||||
</div>
|
||||
{{/noanalysables}}
|
||||
{{^noanalysables}}
|
||||
<div class="mt-2 mb-1">
|
||||
<span>{{#prev}}{{> core/single_button}}{{/prev}}</span>
|
||||
<span>{{#next}}{{> core/single_button}}{{/next}}</span>
|
||||
</div>
|
||||
<table class="generaltable fullwidth">
|
||||
<caption class="accesshide">{{#str}}invalidanalysablestable, tool_analytics{{/str}}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}name{{/str}}</th>
|
||||
<th scope="col">{{#str}}invalidtraining, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}invalidprediction, tool_analytics{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#analysables}}
|
||||
<tr>
|
||||
<td>{{{url}}}</td>
|
||||
<td>{{validtraining}}</td>
|
||||
<td>{{validprediction}}</td>
|
||||
</tr>
|
||||
{{/analysables}}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mt-1 mb-2">
|
||||
<span>{{#prev}}{{> core/single_button}}{{/prev}}</span>
|
||||
<span>{{#next}}{{> core/single_button}}{{/next}}</span>
|
||||
</div>
|
||||
{{/noanalysables}}
|
||||
<div class="m-t-2 m-b-1">
|
||||
<span>{{#prev}}{{> core/single_button}}{{/prev}}</span>
|
||||
<span>{{#next}}{{> core/single_button}}{{/next}}</span>
|
||||
</div>
|
||||
<table class="generaltable fullwidth">
|
||||
<caption class="accesshide">{{#str}}invalidanalysablestable, tool_analytics{{/str}}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}name{{/str}}</th>
|
||||
<th scope="col">{{#str}}invalidtraining, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}invalidprediction, tool_analytics{{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#analysables}}
|
||||
<tr>
|
||||
<td>{{{url}}}</td>
|
||||
<td>{{validtraining}}</td>
|
||||
<td>{{validprediction}}</td>
|
||||
</tr>
|
||||
{{/analysables}}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="m-t-1 m-b-2">
|
||||
<span>{{#prev}}{{> core/single_button}}{{/prev}}</span>
|
||||
<span>{{#next}}{{> core/single_button}}{{/next}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,122 +20,85 @@
|
||||
Template for models list.
|
||||
|
||||
Classes required for JS:
|
||||
* The list od models wrapped within a id="predictionmodelslist" element.
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* [data-widget="toggle"] indicates the clickable element for expanding/collapsing
|
||||
the list of indicators used by the given model.
|
||||
* [data-model-name="..."] should be provided by an element wrapping the model's actions menu
|
||||
and contain the plain text name of the model.
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* models: array - list of models to display
|
||||
- id: int - model unique identifier
|
||||
- modelname: string - name of the model
|
||||
- name: object - data for the inplace editable element template
|
||||
- target: string - name of the target associated with the model
|
||||
- targetclass: string - fully qualified name of the target class
|
||||
- targethelp: object - data for the help tooltip template
|
||||
- enabled: bool - is the model enabled
|
||||
- indicatorsnum: int - number of indicators
|
||||
- indicators: array - list of indicators used by the model
|
||||
+ name: string - name of the indicator
|
||||
+ help: object - data for the help tooltip template
|
||||
- insights: object - data for the single select template
|
||||
- noinsights: string - text to display instead of insights
|
||||
* warnings: array - list of data for notification warning template
|
||||
* infos: array - list of data for notification info template
|
||||
* createmodelurl: string - URL to create a new model
|
||||
* importmodelurl: string - URL to import a model
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"id": 11,
|
||||
"modelname": "Prevent devs at risk",
|
||||
"name": {
|
||||
"component": "local_analyticsdemo",
|
||||
"itemtype": "modelname",
|
||||
"itemid": 42,
|
||||
"displayvalue": "Prevent devs at risk",
|
||||
"value": ""
|
||||
},
|
||||
"target": "Prevent devs at risk",
|
||||
"targetclass": "\\local_analyticsdemo\\analytics\\target\\dev_risk",
|
||||
"targethelp": {
|
||||
"title": "Help with Prevent devs at risk",
|
||||
"text": "This target blah blah ...",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon": {
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
},
|
||||
"enabled": 1,
|
||||
"indicatorsnum": 2,
|
||||
"indicators": [
|
||||
"targethelp": [
|
||||
{
|
||||
"name": "Indicator 1",
|
||||
"help": {
|
||||
"text": "This indicator blah blah ...",
|
||||
"title": "Help with Indicator 1",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon": {
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Indicator 2",
|
||||
"help": {
|
||||
"text": "This indicator blah blah ...",
|
||||
"title": "Help with Indicator 2",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon": {
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
"title": "Help with something",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon":{
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"enabled": 1,
|
||||
"indicators": [{
|
||||
"name": "Indicator 1",
|
||||
"help": [{
|
||||
"title": "Help with something",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon":{
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "Indicator 2",
|
||||
"help": [{
|
||||
"title": "Help with something",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon":{
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
}]
|
||||
}],
|
||||
"timesplitting": "Quarters",
|
||||
"timesplittinghelp": {
|
||||
"text": "This time splitting methof blah blah ...",
|
||||
"title": "Help with Quarters",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon": {
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
"timesplittinghelp": [
|
||||
{
|
||||
"title": "Help with something",
|
||||
"url": "http://example.org/help",
|
||||
"linktext": "",
|
||||
"icon":{
|
||||
"extraclasses": "iconhelp",
|
||||
"attributes": [
|
||||
{"name": "src", "value": "../../../pix/help.svg"},
|
||||
{"name": "alt", "value": "Help icon"}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
"noinsights": "No insights available yet"
|
||||
}
|
||||
],
|
||||
"warnings": [
|
||||
{
|
||||
"message": "Be ware, this is just an example!"
|
||||
}
|
||||
],
|
||||
"createmodelurl": "#",
|
||||
"importmodelurl": "#"
|
||||
"warnings": {
|
||||
"message": "Hey, this is a warning"
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -147,16 +110,11 @@
|
||||
{{/infos}}
|
||||
|
||||
<div class="box">
|
||||
<div class="top-nav d-flex">
|
||||
{{#newmodelmenu}}
|
||||
{{>core/action_menu}}
|
||||
{{/newmodelmenu}}
|
||||
</div>
|
||||
<table id="predictionmodelslist" class="generaltable fullwidth">
|
||||
<table class="generaltable fullwidth">
|
||||
<caption>{{#str}}analyticmodels, tool_analytics{{/str}}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{{#str}}modelname, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}target, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}enabled, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}indicators, tool_analytics{{/str}}</th>
|
||||
<th scope="col">{{#str}}modeltimesplitting, tool_analytics{{/str}}</th>
|
||||
@@ -166,17 +124,12 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#models}}
|
||||
<tr data-model-name="{{modelname}}">
|
||||
<tr>
|
||||
<td>
|
||||
{{#name}}
|
||||
<span class="model-name">{{>core/inplace_editable}}</span>
|
||||
{{/name}}
|
||||
<div>
|
||||
<small class="target-class">{{targetclass}}</small>
|
||||
{{#targethelp}}
|
||||
{{>core/help_icon}}
|
||||
{{/targethelp}}
|
||||
</div>
|
||||
<span class="target-name">{{target}}</span>
|
||||
{{#targethelp}}
|
||||
{{>core/help_icon}}
|
||||
{{/targethelp}}
|
||||
</td>
|
||||
<td>
|
||||
{{#enabled}}
|
||||
@@ -187,15 +140,7 @@
|
||||
{{/enabled}}
|
||||
</td>
|
||||
<td>
|
||||
<a data-widget="toggle"
|
||||
title="{{#str}} clicktohideshow {{/str}}"
|
||||
aria-expanded="false"
|
||||
aria-controls="indicators-{{id}}"
|
||||
role="button"
|
||||
href="">
|
||||
{{#str}} indicatorsnum, tool_analytics, {{indicatorsnum}} {{/str}}
|
||||
</a>
|
||||
<ul class="hidden" id="indicators-{{id}}">
|
||||
<ul>
|
||||
{{#indicators}}
|
||||
<li>
|
||||
{{name}}
|
||||
@@ -239,22 +184,3 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
|
||||
// Toggle the visibility of the indicators list.
|
||||
$('#predictionmodelslist').on('click', '[data-widget="toggle"]', function(e) {
|
||||
e.preventDefault();
|
||||
var toggle = $(e.currentTarget);
|
||||
var listid = toggle.attr('aria-controls');
|
||||
|
||||
$(document.getElementById(listid)).toggle();
|
||||
|
||||
if (toggle.attr('aria-expanded') == 'false') {
|
||||
toggle.attr('aria-expanded', 'true');
|
||||
} else {
|
||||
toggle.attr('aria-expanded', 'false');
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template tool_analytics/restorable_models
|
||||
|
||||
Displays the list of missing prediction models that can be restored.
|
||||
|
||||
Classes required for JS:
|
||||
* The list should be wrapped within a id="restorablemodelslist" element.
|
||||
|
||||
Data attributes required for JS:
|
||||
* [data-widget="toggle"] indicates the clickable element for expanding/collapsing
|
||||
the list of indicators used by the given model.
|
||||
* [data-select] indicates a clickable element used for selecting multiple checkboxes.
|
||||
* [data-component] should be set for checkboxes that select the particular model.
|
||||
|
||||
Context variables required for this template:
|
||||
* hasdata: boolean - do we have data to display
|
||||
* submiturl: string - URL where the form should be submitted
|
||||
* backurl: string - URL where the user should be sent without making any changes
|
||||
* sesskey: string
|
||||
* components: array - list of components to display
|
||||
- name: string - human readable name of the component
|
||||
- component: string - frankenstyle name of the component
|
||||
- models: array - list of restorable models provided by the component
|
||||
+ defid: string - model definition identifier
|
||||
+ targetname: string - human readable name of the target
|
||||
+ targetclass: string - fully qualified classname of the target
|
||||
+ indicatorsnum: int - number of indicators
|
||||
+ indicators: array - list of indicators
|
||||
~ name: string - human readable name of the indicator
|
||||
~ classname: string - fully qualified classname of the indicator
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"hasdata": true,
|
||||
"submiturl": "https://example.com/moodle/admin/tool/analytics/restoredefault.php",
|
||||
"backurl": "https://example.com/moodle/admin/tool/analytics/index.php",
|
||||
"sesskey": "abcdefg123456",
|
||||
"components": [
|
||||
{
|
||||
"name": "Core",
|
||||
"component": "core",
|
||||
"models": [
|
||||
{
|
||||
"defid": "id24680aceg",
|
||||
"targetname": "No teaching",
|
||||
"targetclass": "\\core\\analytics\\target\\no_teaching",
|
||||
"indicatorsnum": 2,
|
||||
"indicators": [
|
||||
{
|
||||
"name": "There are no teachers",
|
||||
"classname": "\\core\\analytics\\indicator\\no_teacher"
|
||||
},
|
||||
{
|
||||
"name": "There are no students",
|
||||
"classname": "\\core\\analytics\\indicator\\no_students"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"defid": "id13579bdfi",
|
||||
"targetname": "Students at risk of dropping out",
|
||||
"targetclass": "\\core\\analytics\\target\\course_dropout",
|
||||
"indicatorsnum": 1,
|
||||
"indicators": [
|
||||
{
|
||||
"name": "Read actions amount",
|
||||
"classname": "\\core\\analytics\\indicator\\read_actions"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Custom analytics plugin",
|
||||
"component": "tool_customanalytics",
|
||||
"models": [
|
||||
{
|
||||
"defid": "id566dsgffg655",
|
||||
"targetname": "Cheater",
|
||||
"targetclass": "\\tool_customanalytics\\analytics\\target\\cheater",
|
||||
"indicatorsnum": 1,
|
||||
"indicators": [
|
||||
{
|
||||
"name": "Copy-pasted submissions",
|
||||
"classname": "\\tool_customanalytics\\analytics\\indicator\\copy_paster_submissions"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
<div class="box">
|
||||
{{^hasdata}}
|
||||
<p>{{#str}} restoredefaultnone, tool_analytics {{/str}}</p>
|
||||
<div><a href="{{backurl}}" class="btn btn-secondary">{{#str}} back {{/str}}</a></div>
|
||||
{{/hasdata}}
|
||||
|
||||
{{#hasdata}}
|
||||
<p>{{#str}} restoredefaultinfo, tool_analytics {{/str}}</p>
|
||||
<form method="post" action="{{submiturl}}">
|
||||
<table id="restorablemodelslist" class="generaltable fullwidth">
|
||||
<colgroup>
|
||||
<col width="10%">
|
||||
<col width="45%">
|
||||
<col width="45%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><a href="" data-select="*">{{#str}} selectall {{/str}}</a></th>
|
||||
<th scope="col">{{#str}} target, tool_analytics {{/str}}</th>
|
||||
<th scope="col">{{#str}} indicators, tool_analytics {{/str}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#components}}
|
||||
<tr>
|
||||
<th scope="rowgroup" colspan="3">
|
||||
<span class="component-name">
|
||||
<a href=""
|
||||
title="{{#str}} componentselect, tool_analytics, {{name}} {{/str}}"
|
||||
data-select="{{component}}">
|
||||
{{name}}
|
||||
</a>
|
||||
</span>
|
||||
<div><small class="component-frankenstyle">{{component}}</small></div>
|
||||
</th>
|
||||
</tr>
|
||||
{{#models}}
|
||||
<tr>
|
||||
<td>
|
||||
<input data-component="{{component}}" type="checkbox" name="restoreid[]" value="{{defid}}">
|
||||
</td>
|
||||
<td>
|
||||
<span class="target-name">{{targetname}}</span>
|
||||
{{#targethelp}}
|
||||
{{>core/help_icon}}
|
||||
{{/targethelp}}
|
||||
<div><small class="target-class">{{targetclass}}</small></div>
|
||||
</td>
|
||||
<td>
|
||||
<a data-widget="toggle"
|
||||
title="{{#str}} clicktohideshow {{/str}}"
|
||||
aria-expanded="false"
|
||||
aria-controls="indicators-{{defid}}"
|
||||
role="button"
|
||||
href="">
|
||||
{{#str}} indicatorsnum, tool_analytics, {{indicatorsnum}} {{/str}}
|
||||
</a>
|
||||
<ul class="hidden listunstyled" id="indicators-{{defid}}">
|
||||
{{#indicators}}
|
||||
<li>
|
||||
{{name}}
|
||||
{{#indicatorhelp}}
|
||||
{{>core/help_icon}}
|
||||
{{/indicatorhelp}}
|
||||
<div><small>{{classname}}</small></div>
|
||||
</li>
|
||||
{{/indicators}}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{{/models}}
|
||||
{{/components}}
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<input class="btn btn-primary" type="submit" value="{{#str}} restoredefaultsubmit, tool_analytics {{/str}}">
|
||||
<input class="btn btn-secondary" type="reset" value="{{#str}} componentselectnone, tool_analytics {{/str}}">
|
||||
<a href="{{backurl}}" class="btn btn-secondary">{{#str}} back {{/str}}</a>
|
||||
<input type="hidden" name="sesskey" value="{{sesskey}}">
|
||||
</div>
|
||||
</form>
|
||||
{{/hasdata}}
|
||||
</div>
|
||||
|
||||
{{#js}}
|
||||
require(['jquery'], function($) {
|
||||
|
||||
// Toggle the visibility of the indicators list.
|
||||
$('#restorablemodelslist').on('click', '[data-widget="toggle"]', function(e) {
|
||||
e.preventDefault();
|
||||
var toggle = $(e.currentTarget);
|
||||
var listid = toggle.attr('aria-controls');
|
||||
|
||||
$(document.getElementById(listid)).toggle();
|
||||
|
||||
if (toggle.attr('aria-expanded') == 'false') {
|
||||
toggle.attr('aria-expanded', 'true');
|
||||
} else {
|
||||
toggle.attr('aria-expanded', 'false');
|
||||
}
|
||||
});
|
||||
|
||||
// Selecting all / all in component checkboxes.
|
||||
$('#restorablemodelslist').on('click', '[data-select]', function(e) {
|
||||
e.preventDefault();
|
||||
var handler = $(e.currentTarget);
|
||||
var component = handler.attr('data-select');
|
||||
|
||||
if (component == '*') {
|
||||
$('input[data-component]').prop('checked', true);
|
||||
} else {
|
||||
$('input[data-component="' + component + '"]').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
{{/js}}
|
||||
@@ -1,103 +0,0 @@
|
||||
@tool @tool_analytics
|
||||
Feature: Restoring default models
|
||||
In order to get prediction models into their initial state
|
||||
As a manager
|
||||
I need to be able to restore deleted default models
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| manager | Max | Manager | man@example.com |
|
||||
And the following "role assigns" exist:
|
||||
| user | role | contextlevel | reference |
|
||||
| manager | manager | System | |
|
||||
|
||||
Scenario: Restore a single deleted default model
|
||||
Given I log in as "manager"
|
||||
And I navigate to "Analytics > Analytics models" in site administration
|
||||
# Delete 'No teaching' model.
|
||||
And I click on "Delete" "link" in the "No teaching" "table_row"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "No teaching"
|
||||
# Delete 'Students at risk of dropping out' model.
|
||||
And I click on "Delete" "link" in the "Students at risk of dropping out" "table_row"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "Students at risk of dropping out"
|
||||
# Go to the page for restoring deleted models.
|
||||
When I click on "Restore default models" "link"
|
||||
And I should see "No teaching"
|
||||
And I should see "Students at risk of dropping out"
|
||||
# Select and restore the 'No teaching' model.
|
||||
And I set the field with xpath "//tr[contains(normalize-space(.), 'No teaching')]//input[@type='checkbox']" to "1"
|
||||
And I click on "Restore selected" "button"
|
||||
Then I should see "Succesfully re-created 1 new model(s)."
|
||||
And I should see "Analytics models"
|
||||
And I should see "No teaching"
|
||||
And I should not see "Students at risk of dropping out"
|
||||
|
||||
Scenario: Restore multiple deleted default models at once
|
||||
Given I log in as "manager"
|
||||
And I navigate to "Analytics > Analytics models" in site administration
|
||||
# Delete 'No teaching' model.
|
||||
And I click on "Delete" "link" in the "No teaching" "table_row"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "No teaching"
|
||||
# Delete 'Students at risk of dropping out' model.
|
||||
And I click on "Delete" "link" in the "Students at risk of dropping out" "table_row"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "Students at risk of dropping out"
|
||||
# Go to the page for restoring deleted models.
|
||||
When I click on "Restore default models" "link"
|
||||
And I should see "No teaching"
|
||||
And I should see "Students at risk of dropping out"
|
||||
# Select and restore both models.
|
||||
And I set the field with xpath "//tr[contains(normalize-space(.), 'No teaching')]//input[@type='checkbox']" to "1"
|
||||
And I set the field with xpath "//tr[contains(normalize-space(.), 'Students at risk of dropping out')]//input[@type='checkbox']" to "1"
|
||||
And I click on "Restore selected" "button"
|
||||
Then I should see "Succesfully re-created 2 new model(s)."
|
||||
And I should see "Analytics models"
|
||||
And I should see "No teaching"
|
||||
And I should see "Students at risk of dropping out"
|
||||
|
||||
Scenario: Going to the restore page while no models can be restored
|
||||
Given I log in as "manager"
|
||||
And I navigate to "Analytics > Analytics models" in site administration
|
||||
And I should see "Analytics models"
|
||||
And I should see "No teaching"
|
||||
When I click on "Restore default models" "link"
|
||||
Then I should see "All default models provided by core and installed plugins have been created. No new models were found; there is nothing to restore."
|
||||
And I click on "Back" "link"
|
||||
And I should see "Analytics models"
|
||||
|
||||
@javascript
|
||||
Scenario: User can select and restore all missing models
|
||||
Given I log in as "manager"
|
||||
And I navigate to "Analytics > Analytics models" in site administration
|
||||
# Delete 'No teaching' model.
|
||||
And I click on "Actions" "link" in the "No teaching" "table_row"
|
||||
And I click on "Delete" "link" in the "No teaching" "table_row"
|
||||
And I click on "Delete" "button" in the "Delete" "dialogue"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "No teaching"
|
||||
# Delete 'Students at risk of dropping out' model.
|
||||
And I click on "Actions" "link" in the "Students at risk of dropping out" "table_row"
|
||||
And I click on "Delete" "link" in the "Students at risk of dropping out" "table_row"
|
||||
And I click on "Delete" "button" in the "Delete" "dialogue"
|
||||
And I should see "Analytics models"
|
||||
And I should not see "No teaching"
|
||||
And I should not see "Students at risk of dropping out"
|
||||
# Go to the page for restoring deleted models.
|
||||
And I click on "New model" "link"
|
||||
And I click on "Restore default models" "link"
|
||||
And I should see "No teaching"
|
||||
And I should see "Students at risk of dropping out"
|
||||
# Attempt to submit the form without selecting any model.
|
||||
And I click on "Restore selected" "button"
|
||||
And I should see "Please select models to be restored."
|
||||
# Select all models.
|
||||
When I click on "Select all" "link"
|
||||
And I click on "Restore selected" "button"
|
||||
Then I should see "Succesfully re-created 2 new model(s)."
|
||||
And I should see "Analytics models"
|
||||
And I should see "No teaching"
|
||||
And I should see "Students at risk of dropping out"
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2019052000; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2019051100; // Requires this Moodle version.
|
||||
$plugin->version = 2018120300; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2018112800; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_analytics'; // Full name of the plugin (used for diagnostics).
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2019052000;
|
||||
$plugin->requires = 2019051100;
|
||||
$plugin->version = 2018120300;
|
||||
$plugin->requires = 2018112800;
|
||||
$plugin->component = 'tool_availabilityconditions';
|
||||
|
||||
@@ -109,17 +109,6 @@ require_once(__DIR__ . '/../../../../lib/behat/lib.php');
|
||||
require_once(__DIR__ . '/../../../../lib/behat/classes/behat_command.php');
|
||||
require_once(__DIR__ . '/../../../../lib/behat/classes/behat_config_manager.php');
|
||||
|
||||
// Remove error handling overrides done in config.php. This is consistent with admin/tool/behat/cli/util_single_run.php.
|
||||
$CFG->debug = (E_ALL | E_STRICT);
|
||||
$CFG->debugdisplay = 1;
|
||||
error_reporting($CFG->debug);
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('log_errors', '1');
|
||||
|
||||
// Import the necessary libraries.
|
||||
require_once($CFG->libdir . '/setuplib.php');
|
||||
require_once($CFG->libdir . '/behat/classes/util.php');
|
||||
|
||||
// For drop option check if parallel site.
|
||||
if ((empty($options['parallel'])) && ($options['drop']) || $options['updatesteps']) {
|
||||
$options['parallel'] = behat_config_manager::get_behat_run_config_value('parallel');
|
||||
|
||||
@@ -164,8 +164,6 @@ if ($options['install']) {
|
||||
mtrace("Acceptance tests site installed");
|
||||
}
|
||||
|
||||
// Note: Do not build the themes here. This is done during the 'enable' stage.
|
||||
|
||||
} else if ($options['drop']) {
|
||||
// Ensure no tests are running.
|
||||
test_lock::acquire('behat');
|
||||
@@ -184,10 +182,6 @@ if ($options['install']) {
|
||||
// Enable test mode.
|
||||
behat_util::start_test_mode($options['add-core-features-to-theme'], $options['optimize-runs'], $parallel, $run);
|
||||
|
||||
// Themes are only built in the 'enable' command.
|
||||
behat_util::build_themes();
|
||||
mtrace("Testing environment themes built");
|
||||
|
||||
// This is only displayed once for parallel install.
|
||||
if (empty($run)) {
|
||||
// Notify user that 2.5 profile has been converted to 3.5.
|
||||
@@ -224,7 +218,7 @@ if ($options['install']) {
|
||||
// Run behat command to get steps in feature files.
|
||||
$featurestepscmd = behat_command::get_behat_command(true);
|
||||
$featurestepscmd .= ' --config ' . behat_config_manager::get_behat_cli_config_filepath();
|
||||
$featurestepscmd .= ' --dry-run --format=moodle_stepcount';
|
||||
$featurestepscmd .= ' --dry-run --format=moodle_step_count';
|
||||
$processes = cli_execute_parallel(array($featurestepscmd), __DIR__ . "/../../../../");
|
||||
$status = print_update_step_output(array_pop($processes), $behatstepfile);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ require_once($CFG->libdir . '/behat/classes/behat_config_manager.php');
|
||||
// systems, but let's allow room for expansion.
|
||||
core_php_time_limit::raise(300);
|
||||
|
||||
$filter = optional_param('filter', '', PARAM_NOTAGS);
|
||||
$filter = optional_param('filter', '', PARAM_ALPHANUMEXT);
|
||||
$type = optional_param('type', false, PARAM_ALPHAEXT);
|
||||
$component = optional_param('component', '', PARAM_ALPHAEXT);
|
||||
|
||||
|
||||
@@ -24,14 +24,13 @@
|
||||
|
||||
$string['aim'] = 'This administration tool helps developers and test writers to create .feature files describing Moodle\'s functionalities and run them automatically. Step definitions available for use in .feature files are listed below.';
|
||||
$string['allavailablesteps'] = 'All available step definitions';
|
||||
$string['errorapproot'] = '$CFG->behat_ionic_dirroot is not pointing to a valid Moodle Mobile developer install.';
|
||||
$string['errorbehatcommand'] = 'Error running behat CLI command. Try running "{$a} --help" manually from CLI to find out more about the problem.';
|
||||
$string['errorcomposer'] = 'Composer dependencies are not installed.';
|
||||
$string['errordataroot'] = '$CFG->behat_dataroot is not set or is invalid.';
|
||||
$string['errorsetconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot need to be set in config.php.';
|
||||
$string['erroruniqueconfig'] = '$CFG->behat_dataroot, $CFG->behat_prefix and $CFG->behat_wwwroot values need to be different than $CFG->dataroot, $CFG->prefix, $CFG->wwwroot, $CFG->phpunit_dataroot and $CFG->phpunit_prefix values.';
|
||||
$string['fieldvalueargument'] = 'Field value arguments';
|
||||
$string['fieldvalueargument_help'] = 'This argument should be completed by a field value. There are many field types, including simple ones like checkboxes, selects or textareas, or complex ones like date selectors. See the dev documentation <a href="https://docs.moodle.org/dev/Acceptance_testing" target="_blank">Acceptance_testing</a> for details of expected field values.';
|
||||
$string['fieldvalueargument_help'] = 'This argument should be completed by a field value. There are many field types, including simple ones like checkboxes, selects or textareas, or complex ones like date selectors. See the dev documentation <a href="http://docs.moodle.org/dev/Acceptance_testing" target="_blank">Acceptance_testing</a> for details of expected field values.';
|
||||
$string['giveninfo'] = 'Given. Processes to set up the environment';
|
||||
$string['infoheading'] = 'Info';
|
||||
$string['installinfo'] = 'Read {$a} for installation and tests execution info';
|
||||
|
||||
@@ -55,13 +55,13 @@ class tool_behat {
|
||||
// The loaded steps depends on the component specified.
|
||||
behat_config_manager::update_config_file($component, false);
|
||||
|
||||
// The Moodle\BehatExtension\Definition\Printer\ConsoleDefinitionInformationPrinter will parse this search format.
|
||||
// The Moodle\BehatExtension\HelpPrinter\MoodleDefinitionsPrinter will parse this search format.
|
||||
if ($type) {
|
||||
$filter .= '&&' . $type;
|
||||
}
|
||||
|
||||
if ($filter) {
|
||||
$filteroption = ' -d ' . escapeshellarg($filter);
|
||||
$filteroption = ' -d "' . $filter . '"';
|
||||
} else {
|
||||
$filteroption = ' -di';
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user