--errors=errors,duplicate-properties
--warnings=known-properties,display-property-grouping,empty-rules,important
---exclude-list=vendor/,lib/editor/tinymce/,lib/yuilib/,theme/bootstrapbase/style/
+--exclude-list=vendor/,node_modules/,lib/editor/tinymce/,lib/yuilib/,theme/bootstrapbase/style/,lib/jquery/,lib/htmlpurifier,theme/clean/style/custom.css,theme/more/style/custom.css,
},
'rules': {
// See http://eslint.org/docs/rules/ for all rules and explanations of all
- // rules. Commented out rules with 'DEFINE POLICY' are rules Dan P has flagged
- // for discussion and possible enable soon.
+ // rules.
+
// === Possible Errors ===
- // DEFINE POLICY: 'comma-dangle': ['off', 'always'],
+ 'comma-dangle': 'off',
'no-cond-assign': 'error',
'no-console': 'error',
'no-constant-condition': 'error',
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
- // Disabled for YUI rollups, enabled by grunt for AMD: 'no-empty': 'error',
+ 'no-empty': 'warn',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-unreachable': 'warn',
'no-unsafe-finally': 'error',
'use-isnan': 'error',
- 'valid-jsdoc': ['warn', { 'requireReturn': false }],
+ 'valid-jsdoc': ['warn', { 'requireReturn': false, 'requireParamDescription': false, 'requireReturnDescription': false }],
'valid-typeof': 'error',
// === Best Practices ===
// (these mostly match our jshint config)
+ 'array-callback-return': 'warn',
+ 'block-scoped-var': 'warn',
+ 'complexity': 'warn',
+ 'consistent-return': 'warn',
'curly': 'error',
'dot-notation': 'warn',
'no-alert': 'warn',
'no-caller': 'error',
'no-case-declarations': 'error',
+ 'no-div-regex': 'error',
'no-empty-pattern': 'error',
'no-empty-function': 'warn',
- //DEFINE POLICY: 'no-eq-null': 'warn',
+ 'no-eq-null': 'error',
'no-eval': 'error',
- //DEFINE POLICY: 'no-extra-bind': 'warn',
+ 'no-extend-native': 'error',
+ 'no-extra-bind': 'warn',
'no-fallthrough': 'error',
- //DEFINE POLICY: 'no-implicit-globals': 'warn',
+ 'no-floating-decimal': 'warn',
+ // Enabled by grunt for AMD modules: 'no-implicit-globals': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-iterator': 'error',
'no-native-reassign': 'warn',
'no-new-func': 'error',
'no-new-wrappers': 'error',
- // DEFINE POLICY: no-octal: "error"
- // DEFINE POLICY: no-octal-escape: "error"
+ 'no-octal': 'error',
+ 'no-octal-escape': 'error',
'no-proto': 'error',
'no-redeclare': 'warn',
'no-return-assign': 'error',
'no-script-url': 'error',
'no-self-assign': 'error',
'no-self-compare': 'error',
+ 'no-sequences': 'warn',
+ 'no-throw-literal': 'warn',
'no-unmodified-loop-condition': 'error',
- // Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-expressions': 'error',
+ 'no-unused-expressions': 'error',
'no-unused-labels': 'error',
- //DEFINE POLICY: 'no-useless-call': 'error',
+ 'no-useless-call': 'warn',
'no-useless-escape': 'warn',
- //DEFINE POLICY: 'no-with': 'error',
+ 'no-with': 'error',
'wrap-iife': ['error', 'any'],
// === Variables ===
'no-delete-var': 'error',
- // Disabled for YUI rollups, enabled by grunt for AMD: 'no-undef': 'off',
- //DEFINE POLICY: 'no-undef-init': 'error',
- // Disabled for YUI rollups, enabled by grunt for AMD: 'no-unused-vars': 'error',
+ 'no-undef': 'error',
+ 'no-undef-init': 'error',
+ 'no-unused-vars': ['error', { 'caughtErrors': 'none', 'argsIgnorePattern': "(e|event)" }],
// === Stylistic Issues ===
'array-bracket-spacing': 'warn',
'lines-around-comment': 'off',
'max-len': ['error', 132],
'max-lines': 'off',
- // DEFINE POLICY: turn on some of these max values?
- 'max-depth': 'off',
- 'max-nested-callbacks': 'off',
+ 'max-depth': 'warn',
+ 'max-nested-callbacks': ['warn', 5],
'max-params': 'off',
'max-statements': 'off',
- 'max-statements-per-line': 'off',
- 'new-cap': 'warn',
+ 'max-statements-per-line': ['warn', { max: 2 }],
+ 'new-cap': ['warn', { 'properties': false }],
'new-parens': 'warn',
'newline-after-var': 'off',
'newline-before-return': 'off',
- // REVIST POLICY: 'newline-per-chained-call': 'warn',
+ 'newline-per-chained-call': 'off',
'no-array-constructor': 'off',
'no-bitwise': 'error',
'no-continue': 'off',
'no-ternary': 'off',
'no-trailing-spaces': 'error',
'no-underscore-dangle': 'off',
- // DEFINE POLICY: 'no-unneeded-ternary': 'off',
+ 'no-unneeded-ternary': 'off',
'no-whitespace-before-property': 'warn',
- // DEFINE POLICY: 'object-curly-newline': 'off,
- // DEFINE POLICY: 'object-curly-spacing': 'off',
- // DEFINE POLICY: 'object-property-newline': 'off',
+ 'object-curly-newline': 'off',
+ 'object-curly-spacing': 'warn',
+ 'object-property-newline': 'off',
'one-var': 'off',
- // DEFINE POLICY: 'one-var-declaration-per-line': 'off',
+ 'one-var-declaration-per-line': ['warn', 'initializations'],
'operator-assignment': 'off',
'operator-linebreak': 'off',
'padded-blocks': 'off',
- // DEFINE POLICY: 'quote-props': 'off',
+ 'quote-props': ['warn', 'as-needed', {'unnecessary': false, 'keywords': true, 'numbers': true}],
'quotes': 'off',
'require-jsdoc': 'warn',
'semi': 'error',
+// NOTE: We use eslint now. This file is used only by shifter. We keep the configuration
+// here because shifter uses jshint after modules have been concating. Eslint can't
+// currently do this.
{
"asi": false,
"bitwise": true,
php:
# We only run the highest and lowest supported versions to reduce the load on travis-ci.org.
- 7.0
- # - 5.6
- # - 5.5
- - 5.4
+ - 5.6
env:
# Although we want to run these jobs and see failures as quickly as possible, we also want to get the slowest job to
# start first so that the total run time is not too high.
#
- # We only run MySQL on PHP 5.6, so run that first.
+ # We only run MySQL on PHP 7.0, so run that first.
# 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.
# Perform an upgrade test too.
- DB=pgsql TASK=UPGRADE
- # Run a check for unbuilt files with Grunt.
- - DB=none TASK=GRUNT
-
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 grunt/npm install on lowest supported npm version
+ - php: 7
+ env: DB=none TASK=GRUNT NVM_VERSION='4'
+ # Run grunt/npm install on highest version ('node' is an alias for the latest node.js version.)
+ - php: 7
+ env: DB=none TASK=GRUNT NVM_VERSION='node'
+
exclude:
# MySQL - it's just too slow.
# Exclude it on all versions except for 7.0
- # - env: DB=mysqli TASK=PHPUNIT
- # php: 5.6
- #
- # - env: DB=mysqli TASK=PHPUNIT
- # php: 5.5
- env: DB=mysqli TASK=PHPUNIT
- php: 5.4
-
- - env: DB=none TASK=GRUNT
- php: 5.4
+ php: 5.6
# Moodle 2.7 is not compatible with PHP 7 for the upgrade test.
- env: DB=pgsql TASK=UPGRADE
# Disable xdebug. We aren't generating code coverage, and it has a huge impact upon test performance.
- rm /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- # Set the encrypted GITHUB_TOKEN if it's available to raise the API limit.
- - if [ -n "$GITHUB_APITOKEN" ]; then composer config github-oauth.github.com $GITHUB_APITOKEN; fi
- - echo 'auth.json' >> .git/info/exclude
+ - >
+ if [ "$TASK" = 'PHPUNIT' ];
+ then
+ if [ -n "$GITHUB_APITOKEN" ]; then
+ composer config github-oauth.github.com $GITHUB_APITOKEN;
+ echo 'auth.json' >> .git/info/exclude
+ fi
+
+ # 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.
+ # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
+ travis_retry composer install --prefer-dist --no-interaction;
+ fi
- # 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.
- # Typically it should be able to use the Composer cache if any other job has already completed before we started here.
- - travis_retry composer install --prefer-dist --no-interaction
+ - >
+ if [ "$TASK" = 'GRUNT' ];
+ then
+ nvm install $NVM_VERSION ;
+ nvm use $NVM_VERSION ;
+ fi
before_script:
- >
- >
if [ "$TASK" = 'GRUNT' ];
then
- npm install ;
- npm install -g grunt ;
- grunt ;
+ npm install --no-spin;
+ npm install --no-spin -g grunt ;
fi
########################################################################
- >
if [ "$TASK" = 'GRUNT' ];
then
+ grunt ;
# Add all files to the git index and then run diff --cached to see all changes.
# This ensures that we get the status of all files, including new files.
git add . ;
// Project configuration.
grunt.initConfig({
- jshint: {
- options: {jshintrc: '.jshintrc'},
- amd: { src: amdSrc }
- },
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.
- options: { quiet: !grunt.option('show-lint-warnings') },
- // Check AMD files. We add some stricter rules which we can't apply to the default configuration due
- // to YUI rollups.
+ options: {quiet: !grunt.option('show-lint-warnings')},
amd: {
src: amdSrc,
- options: {
- rules: {'no-undef': 'error', 'no-unused-vars': 'error', 'no-empty': 'error', 'no-unused-expressions': 'error'}
+ // Check AMD with some slightly stricter rules.
+ rules: {
+ 'no-unused-vars': 'error',
+ 'no-implicit-globals': 'error'
}
},
// Check YUI module source files.
yui: {
src: ['**/yui/src/**/*.js', '!*/**/yui/src/*/meta/*.js'],
+ options: {
+ // Disable some rules which we can't safely define for YUI rollups.
+ rules: {
+ 'no-undef': 'off',
+ 'no-unused-vars': 'off',
+ 'no-unused-expressions': 'off'
+ }
+ }
}
},
uglify: {
expand: true,
src: amdSrc,
rename: uglifyRename
- }]
+ }],
+ options: {report: 'none'}
}
},
less: {
var changedFiles = Object.create(null);
var onChange = grunt.util._.debounce(function() {
var files = Object.keys(changedFiles);
- grunt.config('jshint.amd.src', files);
+ grunt.config('eslint.amd.src', files);
+ grunt.config('eslint.yui.src', files);
grunt.config('uglify.amd.files', [{ expand: true, src: files, rename: uglifyRename }]);
grunt.config('shifter.options.paths', files);
changedFiles = Object.create(null);
// Register NPM tasks.
grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('shifter', 'Run Shifter against the current directory', tasks.shifter);
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', tasks.ignorefiles);
grunt.registerTask('yui', ['eslint:yui', 'shifter']);
- grunt.registerTask('amd', ['eslint:amd', 'jshint', 'uglify']);
+ grunt.registerTask('amd', ['eslint:amd', 'uglify']);
grunt.registerTask('js', ['amd', 'yui']);
// Register CSS taks.
define('IGNORE_COMPONENT_CACHE', true);
// Check that PHP is of a sufficient version
-if (version_compare(phpversion(), "5.4.4") < 0) {
+if (version_compare(phpversion(), "5.6.5") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
- fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
+ fwrite(STDERR, "Moodle 3.2 or later requires at least PHP 5.6.5 (currently using version $phpversion).\n");
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
exit(1);
}
";
// Check that PHP is of a sufficient version
-if (version_compare(phpversion(), "5.4.4") < 0) {
+if (version_compare(phpversion(), "5.6.5") < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it after installib
- fwrite(STDERR, "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).\n");
+ fwrite(STDERR, "Moodle 3.2 or later requires at least PHP 5.6.5 (currently using version $phpversion).\n");
fwrite(STDERR, "Please upgrade your server software or install older Moodle version.\n");
exit(1);
}
require(__DIR__.'/../../config.php');
require_once($CFG->libdir.'/clilib.php'); // cli only functions
+// Define the input options.
+$longparams = array(
+ 'help' => false,
+ 'username' => '',
+ 'password' => '',
+ 'ignore-password-policy' => false
+);
+
+$shortparams = array(
+ 'h' => 'help',
+ 'u' => 'username',
+ 'p' => 'password',
+ 'i' => 'ignore-password-policy'
+);
// now get cli options
-list($options, $unrecognized) = cli_get_params(array('help'=>false),
- array('h'=>'help'));
+list($options, $unrecognized) = cli_get_params($longparams, $shortparams);
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
execute this file may execute any PHP too.
Options:
--h, --help Print out this help
+-h, --help Print out this help
+-u, --username=username Specify username to change
+-p, --password=newpassword Specify new password
+--ignore-password-policy Ignore password policy when setting password
Example:
\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php
+\$sudo -u www-data /usr/bin/php admin/cli/reset_password.php --username=rosaura --password=jiu3jiu --ignore-password-policy
"; //TODO: localize - to be translated later when everything is finished
echo $help;
die;
}
-cli_heading('Password reset'); // TODO: localize
-$prompt = "enter username (manual authentication only)"; // TODO: localize
-$username = cli_input($prompt);
+if ($options['username'] == '' ) {
+ cli_heading('Password reset'); // TODO: localize.
+ $prompt = "enter username (manual authentication only)"; // TODO: localize.
+ $username = cli_input($prompt);
+} else {
+ $username = $options['username'];
+}
if (!$user = $DB->get_record('user', array('auth'=>'manual', 'username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
cli_error("Can not find user '$username'");
}
-$prompt = "Enter new password"; // TODO: localize
-$password = cli_input($prompt);
+if ($options['password'] == '' ) {
+ $prompt = "Enter new password"; // TODO: localize.
+ $password = cli_input($prompt);
+} else {
+ $password = $options['password'];
+}
$errmsg = '';//prevent eclipse warning
-if (!check_password_policy($password, $errmsg)) {
- cli_error($errmsg);
+if (!$options['ignore-password-policy'] ) {
+ if (!check_password_policy($password, $errmsg)) {
+ cli_error($errmsg);
+ }
}
$hashedpassword = hash_internal_user_password($password);
echo "Password changed\n";
-exit(0); // 0 means success
\ No newline at end of file
+exit(0); // 0 means success.
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>
+ <MOODLE version="3.2" requires="2.7">
+ <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.5.31" />
+ <VENDOR name="postgres" version="9.1" />
+ <VENDOR name="mssql" version="10.0" />
+ <VENDOR name="oracle" version="10.2" />
+ </DATABASE>
+ <PHP version="5.6.5" 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="optional">
+ <FEEDBACK>
+ <ON_CHECK message="opensslrecommended" />
+ </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="optional">
+ <FEEDBACK>
+ <ON_CHECK message="intlrecommended" />
+ </FEEDBACK>
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="json" level="required">
+ </PHP_EXTENSION>
+ <PHP_EXTENSION name="hash" 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_CHECKS>
+ </MOODLE>
</COMPATIBILITY_MATRIX>
}
// Check that PHP is of a sufficient version as soon as possible
-if (version_compare(phpversion(), '5.4.4') < 0) {
+if (version_compare(phpversion(), '5.6.5') < 0) {
$phpversion = phpversion();
// do NOT localise - lang strings would not work here and we CAN NOT move it to later place
- echo "Moodle 2.7 or later requires at least PHP 5.4.4 (currently using version $phpversion).<br />";
+ echo "Moodle 3.2 or later requires at least PHP 5.6.5 (currently using version $phpversion).<br />";
echo "Please upgrade your server software or install older Moodle version.";
die();
}
require_capability('moodle/role:review', $context);
require_sesskey();
+$OUTPUT->header();
+
list($overridableroles, $overridecounts, $nameswithcounts) = get_overridable_roles($context,
ROLENAME_BOTH, true);
--- /dev/null
+<?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/>.
+
+/**
+ * Manage global search areas.
+ *
+ * @package core_search
+ * @copyright 2016 Dan Poltawski <dan@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+require_once(__DIR__ . '/../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+
+admin_externalpage_setup('searchareas');
+
+$areaid = optional_param('areaid', null, PARAM_ALPHAEXT);
+$action = optional_param('action', null, PARAM_ALPHA);
+
+try {
+ $searchmanager = \core_search\manager::instance();
+} catch (core_search\engine_exception $searchmanagererror) {
+ // Continue, we return an error later depending on the requested action.
+}
+
+echo $OUTPUT->header();
+
+if ($action) {
+ require_sesskey();
+
+ if ($areaid) {
+ // We need to check that the area exists.
+ $area = \core_search\manager::get_search_area($areaid);
+ if ($area === false) {
+ throw new moodle_exception('invalidrequest');
+ }
+ }
+
+ // All actions but enable/disable need the search engine to be ready.
+ if ($action !== 'enable' && $action !== 'disable') {
+ if (!empty($searchmanagererror)) {
+ throw $searchmanagererror;
+ }
+ }
+
+ switch ($action) {
+ case 'enable':
+ $area->set_enabled(true);
+ echo $OUTPUT->notification(get_string('searchareaenabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ case 'disable':
+ $area->set_enabled(false);
+ echo $OUTPUT->notification(get_string('searchareadisabled', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ case 'delete':
+ $search = \core_search\manager::instance();
+ $search->delete_index($areaid);
+ echo $OUTPUT->notification(get_string('searchindexdeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ case 'indexall':
+ $searchmanager->index();
+ echo $OUTPUT->notification(get_string('searchindexupdated', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ case 'reindexall':
+ $searchmanager->index(true);
+ echo $OUTPUT->notification(get_string('searchreindexed', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ case 'deleteall':
+ $searchmanager->delete_index();
+ echo $OUTPUT->notification(get_string('searchalldeleted', 'admin'), \core\output\notification::NOTIFY_SUCCESS);
+ break;
+ default:
+ throw new moodle_exception('invalidaction');
+ break;
+ }
+}
+
+$searchareas = \core_search\manager::get_search_areas_list();
+if (empty($searchmanagererror)) {
+ $areasconfig = $searchmanager->get_areas_config($searchareas);
+} else {
+ $areasconfig = false;
+}
+
+if (!empty($searchmanagererror)) {
+ $errorstr = get_string($searchmanagererror->errorcode, $searchmanagererror->module);
+ echo $OUTPUT->notification($errorstr, \core\output\notification::NOTIFY_ERROR);
+} else {
+ echo $OUTPUT->notification(get_string('indexinginfo', 'admin'), \core\output\notification::NOTIFY_INFO);
+}
+
+$table = new html_table();
+$table->id = 'core-search-areas';
+
+$table->head = array(get_string('searcharea', 'search'), get_string('enable'), get_string('newestdocindexed', 'admin'),
+ get_string('searchlastrun', 'admin'), get_string('searchindexactions', 'admin'));
+
+foreach ($searchareas as $area) {
+ $areaid = $area->get_area_id();
+ $columns = array(new html_table_cell($area->get_visible_name()));
+
+ 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')),
+ null, array('title' => get_string('disable')));
+
+ if ($areasconfig) {
+ $columns[] = $areasconfig[$areaid]->lastindexrun;
+
+ if ($areasconfig[$areaid]->indexingstart) {
+ $timediff = $areasconfig[$areaid]->indexingend - $areasconfig[$areaid]->indexingstart;
+ $laststatus = $timediff . ' , ' .
+ $areasconfig[$areaid]->docsprocessed . ' , ' .
+ $areasconfig[$areaid]->recordsprocessed . ' , ' .
+ $areasconfig[$areaid]->docsignored;
+ } else {
+ $laststatus = '';
+ }
+ $columns[] = $laststatus;
+ $columns[] = html_writer::link(admin_searcharea_action_url('delete', $areaid), 'Delete index');
+
+ } else {
+ $blankrow = new html_table_cell(get_string('searchnotavailable', 'admin'));
+ $blankrow->colspan = 3;
+ $columns[] = $blankrow;
+ }
+
+ } else {
+ $columns[] = $OUTPUT->action_icon(admin_searcharea_action_url('enable', $areaid),
+ new pix_icon('t/show', get_string('enable'), 'moodle', array('title' => '', 'class' => 'iconsmall')),
+ null, array('title' => get_string('enable')));
+
+ $blankrow = new html_table_cell(get_string('searchareadisabled', 'admin'));
+ $blankrow->colspan = 3;
+ $columns[] = $blankrow;
+ }
+ $row = new html_table_row($columns);
+ $table->data[] = $row;
+}
+
+// Cross-search area tasks.
+$options = array();
+if (!empty($searchmanagererror)) {
+ $options['disabled'] = true;
+}
+echo $OUTPUT->box_start('search-areas-actions');
+echo $OUTPUT->single_button(admin_searcharea_action_url('indexall'), get_string('searchupdateindex', 'admin'), 'get', $options);
+echo $OUTPUT->single_button(admin_searcharea_action_url('reindexall'), get_string('searchreindexindex', 'admin'), 'get', $options);
+echo $OUTPUT->single_button(admin_searcharea_action_url('deleteall'), get_string('searchdeleteindex', 'admin'), 'get', $options);
+echo $OUTPUT->box_end();
+
+echo html_writer::table($table);
+echo $OUTPUT->footer();
+
+/**
+ * Helper for generating url for management actions.
+ *
+ * @param string $action
+ * @param string $areaid
+ * @return moodle_url
+ */
+function admin_searcharea_action_url($action, $areaid = false) {
+ $params = array('action' => $action, 'sesskey' => sesskey());
+ if ($areaid) {
+ $params['areaid'] = $areaid;
+ }
+ return new moodle_url('/admin/searchareas.php', $params);
+}
get_string('requiremodintro', 'admin'), get_string('requiremodintro_desc', 'admin'), 0));
$ADMIN->add('modsettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('mod');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\mod $plugin */
$plugin->load_settings($ADMIN, 'modsettings', $hassiteconfig);
}
$temp = new admin_settingpage('manageformats', new lang_string('manageformats', 'core_admin'));
$temp->add(new admin_setting_manageformats());
$ADMIN->add('formatsettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('format') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('format');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\format $plugin */
$plugin->load_settings($ADMIN, 'formatsettings', $hassiteconfig);
}
// blocks
$ADMIN->add('modules', new admin_category('blocksettings', new lang_string('blocks')));
$ADMIN->add('blocksettings', new admin_page_manageblocks());
- foreach (core_plugin_manager::instance()->get_plugins_of_type('block') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('block');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\block $plugin */
$plugin->load_settings($ADMIN, 'blocksettings', $hassiteconfig);
}
$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());
- foreach (core_plugin_manager::instance()->get_plugins_of_type('message') as $plugin) {
+ $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);
}
$temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true);
$ADMIN->add('authsettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('auth') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('auth');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\auth $plugin */
$plugin->load_settings($ADMIN, 'authsettings', $hassiteconfig);
}
$temp = new admin_externalpage('enroltestsettings', get_string('testsettings', 'core_enrol'), new moodle_url("/enrol/test_settings.php"), 'moodle/site:config', true);
$ADMIN->add('enrolments', $temp);
- foreach(core_plugin_manager::instance()->get_plugins_of_type('enrol') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('enrol');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\enrol $plugin */
$plugin->load_settings($ADMIN, 'enrolments', $hassiteconfig);
}
$temp = new admin_settingpage('manageeditors', new lang_string('editorsettings', 'editor'));
$temp->add(new admin_setting_manageeditors());
$ADMIN->add('editorsettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('editor') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('editor');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\editor $plugin */
$plugin->load_settings($ADMIN, 'editorsettings', $hassiteconfig);
}
$temp = new admin_settingpage('manageantiviruses', new lang_string('antivirussettings', 'antivirus'));
$temp->add(new admin_setting_manageantiviruses());
$ADMIN->add('antivirussettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('antivirus') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('antivirus');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/* @var \core\plugininfo\antivirus $plugin */
$plugin->load_settings($ADMIN, 'antivirussettings', $hassiteconfig);
}
}
$ADMIN->add('filtersettings', $temp);
- foreach (core_plugin_manager::instance()->get_plugins_of_type('filter') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('filter');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\filter $plugin */
$plugin->load_settings($ADMIN, 'filtersettings', $hassiteconfig);
}
new lang_string('createrepository', 'repository'), $url, 'moodle/site:config', true));
$ADMIN->add('repositorysettings', new admin_externalpage('repositoryinstanceedit',
new lang_string('editrepositoryinstance', 'repository'), $url, 'moodle/site:config', true));
- foreach (core_plugin_manager::instance()->get_plugins_of_type('repository') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('repository');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\repository $plugin */
$plugin->load_settings($ADMIN, 'repositorysettings', $hassiteconfig);
}
'admin'), new lang_string('configenablewsdocumentation', 'admin', $wsdoclink), false));
$ADMIN->add('webservicesettings', $temp);
/// links to protocol pages
- foreach (core_plugin_manager::instance()->get_plugins_of_type('webservice') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('webservice');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\webservice $plugin */
$plugin->load_settings($ADMIN, 'webservicesettings', $hassiteconfig);
}
get_string('responsehistory', 'question'), '', 0, $hiddenofvisible));
// Settings for particular question types.
- foreach (core_plugin_manager::instance()->get_plugins_of_type('qtype') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('qtype');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\qtype $plugin */
$plugin->load_settings($ADMIN, 'qtypesettings', $hassiteconfig);
}
$ADMIN->add('plagiarism', new admin_externalpage('manageplagiarismplugins', new lang_string('manageplagiarism', 'plagiarism'),
$CFG->wwwroot . '/' . $CFG->admin . '/plagiarism.php'));
- foreach (core_plugin_manager::instance()->get_plugins_of_type('plagiarism') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('plagiarism');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\plagiarism $plugin */
$plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
}
}
if (!empty($pages)) {
$ADMIN->add('modules', new admin_category('coursereports', new lang_string('coursereports')));
+ core_collator::asort_objects_by_property($pages, 'visiblename');
foreach ($pages as $page) {
$ADMIN->add('coursereports', $page);
}
$ADMIN->add('modules', new admin_category('reportplugins', new lang_string('reports')));
$ADMIN->add('reportplugins', new admin_externalpage('managereports', new lang_string('reportsmanage', 'admin'),
$CFG->wwwroot . '/' . $CFG->admin . '/reports.php'));
+core_collator::asort_objects_by_property($pages, 'visiblename');
foreach ($pages as $page) {
$ADMIN->add('reportplugins', $page);
}
$temp->add(new admin_setting_configselect('searchengine',
new lang_string('selectsearchengine', 'admin'), '', 'solr', $engines));
- // Enable search areas.
- $temp->add(new admin_setting_heading('searchareasheading', new lang_string('availablesearchareas', 'admin'), ''));
- $searchareas = \core_search\manager::get_search_areas_list();
- foreach ($searchareas as $areaid => $searcharea) {
- list($componentname, $varname) = $searcharea->get_config_var_name();
- $temp->add(new admin_setting_configcheckbox($componentname . '/' . $varname . '_enabled', $searcharea->get_visible_name(true),
- '', 1, 1, 0));
- }
$ADMIN->add('searchplugins', $temp);
+ $ADMIN->add('searchplugins', new admin_externalpage('searchareas', new lang_string('searchareas', 'admin'),
+ new moodle_url('/admin/searchareas.php')));
+ core_collator::asort_objects_by_property($pages, 'visiblename');
foreach ($pages as $page) {
$ADMIN->add('searchplugins', $page);
}
}
// Now add various admin tools.
-foreach (core_plugin_manager::instance()->get_plugins_of_type('tool') as $plugin) {
+$plugins = core_plugin_manager::instance()->get_plugins_of_type('tool');
+core_collator::asort_objects_by_property($plugins, 'displayname');
+foreach ($plugins as $plugin) {
/** @var \core\plugininfo\tool $plugin */
$plugin->load_settings($ADMIN, null, $hassiteconfig);
}
$ADMIN->add('cache', new admin_externalpage('cacheconfig', new lang_string('cacheconfig', 'cache'), $CFG->wwwroot .'/cache/admin.php'));
$ADMIN->add('cache', new admin_externalpage('cachetestperformance', new lang_string('testperformance', 'cache'), $CFG->wwwroot . '/cache/testperformance.php'));
$ADMIN->add('cache', new admin_category('cachestores', new lang_string('cachestores', 'cache')));
+ $ADMIN->locate('cachestores')->set_sorting(true);
foreach (core_component::get_plugin_list('cachestore') as $plugin => $path) {
$settingspath = $path.'/settings.php';
if (file_exists($settingspath)) {
// Add Calendar type settings.
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('calendartype', new lang_string('calendartypes', 'calendar')));
- foreach (core_plugin_manager::instance()->get_plugins_of_type('calendartype') as $plugin) {
+ $plugins = core_plugin_manager::instance()->get_plugins_of_type('calendartype');
+ core_collator::asort_objects_by_property($plugins, 'displayname');
+ foreach ($plugins as $plugin) {
/** @var \core\plugininfo\calendartype $plugin */
$plugin->load_settings($ADMIN, 'calendartype', $hassiteconfig);
}
// Extend settings for each local plugin. Note that their settings may be in any part of the
// settings tree and may be visible not only for administrators.
-foreach (core_plugin_manager::instance()->get_plugins_of_type('local') as $plugin) {
+$plugins = core_plugin_manager::instance()->get_plugins_of_type('local');
+core_collator::asort_objects_by_property($plugins, 'displayname');
+foreach ($plugins as $plugin) {
/** @var \core\plugininfo\local $plugin */
$plugin->load_settings($ADMIN, null, $hassiteconfig);
}
if (extension_loaded('pcntl')) {
$disabled = explode(',', ini_get('disable_functions'));
if (!in_array('pcntl_signal', $disabled)) {
+ // Handle interrupts on PHP7.
+ declare(ticks = 1);
+
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
}
.path-admin-tool-health dl.notice dd {
background-color: #e5db36;
}
-.path-admin-tool-health dt.solution,
-.path-admin-tool-health dd.solution,
+.path-admin-tool-health dl dt.solution,
+.path-admin-tool-health dl dd.solution,
.path-admin-tool-health div#healthnoproblemsfound {
- background-color: #5BB83E !important;
+ background-color: #5BB83E;
}
.path-admin-tool-health dl.healthissues dt,
.path-admin-tool-health dl.healthissues dd {
self._selectedValue = $("input[type='radio']:checked").val();
self._find('[data-action="action-selector-confirm"]').removeAttr('disabled');
self._refresh.bind(self);
- }.bind(self));
+ });
// Add listener for cancel.
self._find('[data-action="action-selector-cancel"]').click(function(e) {
e.preventDefault();
self.close();
- }.bind(self));
+ });
// Add listener for confirm.
self._find('[data-action="action-selector-confirm"]').click(function(e) {
if (!self._selectedValue.length) {
return;
}
- self._trigger('save', { action: self._selectedValue });
+ self._trigger('save', {action: self._selectedValue});
self.close();
- }.bind(self));
+ });
};
/**
html,
self._afterRender.bind(self)
);
- }.bind(self)).fail(Notification.exception);
+ }).fail(Notification.exception);
};
/**
* Find a node in the dialogue.
*
* @param {String} selector
+ * @return {JQuery} The node
* @method _find
*/
ActionSelector.prototype._find = function(selector) {
return self._render().then(function(html) {
self._find('[data-region="action-selector"]').replaceWith(html);
self._afterRender();
- }.bind(self));
+ });
};
/**
for (var i in self._actions) {
choices.push(self._actions[i]);
}
- var content = {'message': self._message, 'choices' : choices,
- 'confirm' : self._confirm, 'cancel' : self._cancel};
+ var content = {'message': self._message, 'choices': choices,
+ 'confirm': self._confirm, 'cancel': self._cancel};
return Templates.render('tool_lp/action_selector', content);
};
*
* @param {Number} itemid
* @param {String} itemtype
+ * @param {Number} pagectxid
*/
var competencies = function(itemid, itemtype, pagectxid) {
this.itemid = itemid;
function(movestring) {
dragdrop.dragdrop('movecompetency',
movestring,
- { identifier: 'movecompetency', component: 'tool_lp'},
- { identifier: 'movecompetencyafter', component: 'tool_lp'},
+ {identifier: 'movecompetency', component: 'tool_lp'},
+ {identifier: 'movecompetencyafter', component: 'tool_lp'},
'drag-samenode',
'drag-parentnode',
'drag-handlecontainer',
function(drag, drop) {
- localthis.handleDrop.call(localthis, drag, drop);
+ localthis.handleDrop(drag, drop);
});
}
).fail(notification.exception);
requests = ajax.call([
{
methodname: 'core_competency_reorder_course_competency',
- args: { courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid }
+ args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}
}
]);
} else if (localthis.itemtype == 'template') {
requests = ajax.call([
{
methodname: 'core_competency_reorder_template_competency',
- args: { templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid }
+ args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}
}
]);
} else if (localthis.itemtype == 'plan') {
requests = ajax.call([
{
methodname: 'core_competency_reorder_plan_competency',
- args: { planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid }
+ args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}
}
]);
} else {
- return null;
+ return;
}
requests[0].fail(notification.exception);
$.each(compIds, function(index, compId) {
requests.push({
methodname: 'core_competency_add_competency_to_course',
- args: { courseid: self.itemid, competencyid: compId }
+ args: {courseid: self.itemid, competencyid: compId}
});
});
requests.push({
methodname: 'tool_lp_data_for_course_competencies_page',
- args: { courseid: self.itemid }
+ args: {courseid: self.itemid}
});
pagerender = 'tool_lp/course_competencies_page';
$.each(compIds, function(index, compId) {
requests.push({
methodname: 'core_competency_add_competency_to_template',
- args: { templateid: self.itemid, competencyid: compId }
+ args: {templateid: self.itemid, competencyid: compId}
});
});
requests.push({
methodname: 'tool_lp_data_for_template_competencies_page',
- args: { templateid: self.itemid, pagecontext: { contextid: self.pageContextId }}
+ args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}
});
pagerender = 'tool_lp/template_competencies_page';
pageregion = 'templatecompetenciespage';
$.each(compIds, function(index, compId) {
requests.push({
methodname: 'core_competency_add_competency_to_plan',
- args: { planid: self.itemid, competencyid: compId }
+ args: {planid: self.itemid, competencyid: compId}
});
});
requests.push({
methodname: 'tool_lp_data_for_plan_page',
- args: { planid: self.itemid}
+ args: {planid: self.itemid}
});
pagerender = 'tool_lp/plan_page';
pageregion = 'plan-page';
// Delete the link and reload the page template.
if (localthis.itemtype == 'course') {
requests = ajax.call([
- { methodname: 'core_competency_remove_competency_from_course',
- args: { courseid: localthis.itemid, competencyid: deleteid } },
- { methodname: 'tool_lp_data_for_course_competencies_page',
- args: { courseid: localthis.itemid } }
+ {methodname: 'core_competency_remove_competency_from_course',
+ args: {courseid: localthis.itemid, competencyid: deleteid}},
+ {methodname: 'tool_lp_data_for_course_competencies_page',
+ args: {courseid: localthis.itemid}}
]);
pagerender = 'tool_lp/course_competencies_page';
pageregion = 'coursecompetenciespage';
} else if (localthis.itemtype == 'template') {
requests = ajax.call([
- { methodname: 'core_competency_remove_competency_from_template',
- args: { templateid: localthis.itemid, competencyid: deleteid } },
- { methodname: 'tool_lp_data_for_template_competencies_page',
- args: { templateid: localthis.itemid, pagecontext: { contextid: localthis.pageContextId } } }
+ {methodname: 'core_competency_remove_competency_from_template',
+ args: {templateid: localthis.itemid, competencyid: deleteid}},
+ {methodname: 'tool_lp_data_for_template_competencies_page',
+ args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}
]);
pagerender = 'tool_lp/template_competencies_page';
pageregion = 'templatecompetenciespage';
} else if (localthis.itemtype == 'plan') {
requests = ajax.call([
- { methodname: 'core_competency_remove_competency_from_plan',
- args: { planid: localthis.itemid, competencyid: deleteid } },
- { methodname: 'tool_lp_data_for_plan_page',
- args: { planid: localthis.itemid } }
+ {methodname: 'core_competency_remove_competency_from_plan',
+ args: {planid: localthis.itemid, competencyid: deleteid}},
+ {methodname: 'tool_lp_data_for_plan_page',
+ args: {planid: localthis.itemid}}
]);
pagerender = 'tool_lp/plan_page';
pageregion = 'plan-page';
requests = ajax.call([{
methodname: 'core_competency_read_competency',
- args: { id: deleteid }
+ args: {id: deleteid}
}]);
requests[0].done(function(competency) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: message, component: 'tool_lp', param: competency.shortname },
- { key: 'confirm', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: message, component: 'tool_lp', param: competency.shortname},
+ {key: 'confirm', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Unlink the competency X from the course?
if (localthis.itemtype == 'course') {
// Course completion rule handling.
- $('[data-region="coursecompetenciespage"]').on('change', 'select[data-field="ruleoutcome"]', function(e){
+ $('[data-region="coursecompetenciespage"]').on('change', 'select[data-field="ruleoutcome"]', function(e) {
var requests = [];
var pagerender = 'tool_lp/course_competencies_page';
var pageregion = 'coursecompetenciespage';
var coursecompetencyid = $(e.target).data('id');
var ruleoutcome = $(e.target).val();
requests = ajax.call([
- { methodname: 'core_competency_set_course_competency_ruleoutcome',
- args: { coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome } },
- { methodname: 'tool_lp_data_for_course_competencies_page',
- args: { courseid: localthis.itemid } }
+ {methodname: 'core_competency_set_course_competency_ruleoutcome',
+ args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},
+ {methodname: 'tool_lp_data_for_course_competencies_page',
+ args: {courseid: localthis.itemid}}
]);
requests[1].done(function(context) {
getAll: function() {
var self = this;
return Str.get_strings([
- { key: 'competencyoutcome_none', component: 'tool_lp' },
- { key: 'competencyoutcome_evidence', component: 'tool_lp' },
- { key: 'competencyoutcome_recommend', component: 'tool_lp' },
- { key: 'competencyoutcome_complete', component: 'tool_lp' },
+ {key: 'competencyoutcome_none', component: 'tool_lp'},
+ {key: 'competencyoutcome_evidence', component: 'tool_lp'},
+ {key: 'competencyoutcome_recommend', component: 'tool_lp'},
+ {key: 'competencyoutcome_complete', component: 'tool_lp'},
]).then(function(strings) {
var outcomes = {};
- outcomes[self.NONE] = { code: self.NONE, name: strings[0] };
- outcomes[self.EVIDENCE] = { code: self.EVIDENCE, name: strings[1] };
- outcomes[self.RECOMMEND] = { code: self.RECOMMEND, name: strings[2] };
- outcomes[self.COMPLETE] = { code: self.COMPLETE, name: strings[3] };
+ outcomes[self.NONE] = {code: self.NONE, name: strings[0]};
+ outcomes[self.EVIDENCE] = {code: self.EVIDENCE, name: strings[1]};
+ outcomes[self.RECOMMEND] = {code: self.RECOMMEND, name: strings[2]};
+ outcomes[self.COMPLETE] = {code: self.COMPLETE, name: strings[3]};
return outcomes;
});
},
* Get the string for an outcome.
*
* @param {Number} id The outcome code.
- * @return {Promise Resolved with the string.
+ * @return {Promise} Resolved with the string.
* @method getString
*/
getString: function(id) {
/**
* CompetencyPlanNavigation
*
- * @param {String} The selector of the competency element.
- * @param {String} The base url for the page (no params).
- * @param {Number} The user id
- * @param {Number} The competency id
- * @param {Number} The plan id
+ * @param {String} competencySelector The selector of the competency element.
+ * @param {String} baseUrl The base url for the page (no params).
+ * @param {Number} userId The user id
+ * @param {Number} competencyId The competency id
+ * @param {Number} planId The plan id
*/
var CompetencyPlanNavigation = function(competencySelector, baseUrl, userId, competencyId, planId) {
this._baseUrl = baseUrl;
return null;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Return the type of the module.
*
* Trigger an event.
*
* @param {String} type The type of event.
- * @param {Object} The data to pass to the listeners.
+ * @param {Object} data The data to pass to the listeners.
* @method _trigger
* @protected
*/
children = this._tree.getChildren(this._competency.id),
context,
config = {
- base: { points: 2 },
+ base: {points: 2},
competencies: []
};
var parent = $('[data-region="competencyactions"]').data('competency');
var params = {
- competencyframeworkid : treeModel.getCompetencyFrameworkId(),
+ competencyframeworkid: treeModel.getCompetencyFrameworkId(),
pagecontextid: pageContextId
};
if (parent !== null && treeModel.hasRule(parent.id)) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname },
- { key: 'yes', component: 'core' },
- { key: 'no', component: 'core' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},
+ {key: 'yes', component: 'core'},
+ {key: 'no', component: 'core'}
+ ]).done(function(strings) {
notification.confirm(
strings[0],
strings[1],
var frameworkid = $('[data-region="filtercompetencies"]').data('frameworkid');
var requests = ajax.call([{
methodname: 'core_competency_set_parent_competency',
- args: { competencyid: moveSource, parentid: moveTarget }
+ args: {competencyid: moveSource, parentid: moveTarget}
}, {
methodname: 'tool_lp_data_for_competencies_manage_page',
- args: { competencyframeworkid: frameworkid,
- search: $('[data-region="filtercompetencies"] input').val() }
+ args: {competencyframeworkid: frameworkid,
+ search: $('[data-region="filtercompetencies"] input').val()}
}]);
requests[1].done(reloadPage).fail(notification.exception);
};
// Show confirm, and/or do the things.
if (showConfirm) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: confirmMessage, component: 'tool_lp' },
- { key: 'yes', component: 'moodle' },
- { key: 'no', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: confirmMessage, component: 'tool_lp'},
+ {key: 'yes', component: 'moodle'},
+ {key: 'no', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Delete competency X?
});
treeRoot.show();
- body.on('click', '[data-action="move"]', function() { popup.close(); confirmMove(); });
- body.on('click', '[data-action="cancel"]', function() { popup.close(); });
+ body.on('click', '[data-action="move"]', function() {
+ popup.close();
+ confirmMove();
+ });
+ body.on('click', '[data-action="cancel"]', function() {
+ popup.close();
+ });
};
/**
/**
* A node was chosen and "Move" was selected from the menu. Open a popup to select the target.
+ * @param {Event} e
* @method moveHandler
*/
var moveHandler = function(e) {
competencyframeworkid: competency.competencyframeworkid,
searchtext: ''
}
- },{
+ }, {
methodname: 'core_competency_read_competency_framework',
args: {
id: competency.competencyframeworkid
$.when.apply(null, requests).done(function(competencies, framework) {
// Expand the list of competencies into a tree.
- var i, competenciestree = [];
+ var i;
+ var competenciestree = [];
for (i = 0; i < competencies.length; i++) {
var onecompetency = competencies[i];
if (onecompetency.parentid == "0") {
}
str.get_strings([
- { key: 'movecompetency', component: 'tool_lp', param: competency.shortname },
- { key: 'move', component: 'tool_lp' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},
+ {key: 'move', component: 'tool_lp'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
var context = {
framework: framework,
var competency = $('[data-region="competencyactions"]').data('competency');
var params = {
- competencyframeworkid : treeModel.getCompetencyFrameworkId(),
- id : competency.id,
+ competencyframeworkid: treeModel.getCompetencyFrameworkId(),
+ id: competency.id,
parentid: competency.parentid,
pagecontextid: pageContextId
};
/**
* Re-render the page with the latest data.
+ * @param {Object} context
* @method reloadPage
*/
var reloadPage = function(context) {
/**
* Perform a search and render the page with the new search results.
+ * @param {Event} e
* @method updateSearchHandler
*/
var updateSearchHandler = function(e) {
var requests = ajax.call([{
methodname: 'tool_lp_data_for_competencies_manage_page',
- args: { competencyframeworkid: frameworkid,
- search: $('[data-region="filtercompetencies"] input').val() }
+ args: {competencyframeworkid: frameworkid,
+ search: $('[data-region="filtercompetencies"] input').val()}
}]);
requests[0].done(reloadPage).fail(notification.exception);
};
var competency = $('[data-region="competencyactions"]').data('competency');
var requests = ajax.call([{
methodname: 'core_competency_move_up_competency',
- args: { id: competency.id }
+ args: {id: competency.id}
}, {
methodname: 'tool_lp_data_for_competencies_manage_page',
- args: { competencyframeworkid: competency.competencyframeworkid,
- search: $('[data-region="filtercompetencies"] input').val() }
+ args: {competencyframeworkid: competency.competencyframeworkid,
+ search: $('[data-region="filtercompetencies"] input').val()}
}]);
requests[1].done(reloadPage).fail(notification.exception);
};
var competency = $('[data-region="competencyactions"]').data('competency');
var requests = ajax.call([{
methodname: 'core_competency_move_down_competency',
- args: { id: competency.id }
+ args: {id: competency.id}
}, {
methodname: 'tool_lp_data_for_competencies_manage_page',
- args: { competencyframeworkid: competency.competencyframeworkid,
- search: $('[data-region="filtercompetencies"] input').val() }
+ args: {competencyframeworkid: competency.competencyframeworkid,
+ search: $('[data-region="filtercompetencies"] input').val()}
}]);
requests[1].done(reloadPage).fail(notification.exception);
};
var requests = ajax.call([{
methodname: 'tool_lp_list_courses_using_competency',
- args: { id: competency.id }
+ args: {id: competency.id}
}]);
requests[0].done(function(courses) {
courses: courses
};
templates.render('tool_lp/linked_courses_summary', context).done(function(html) {
- str.get_string('linkedcourses', 'tool_lp').done(function (linkedcourses) {
+ str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {
new Dialogue(
linkedcourses, // Title.
html, // The linked courses.
$.each(compIds, function(index, value) {
calls.push({
methodname: 'core_competency_add_related_competency',
- args: { competencyid: value, relatedcompetencyid: relatedTarget.id }
+ args: {competencyid: value, relatedcompetencyid: relatedTarget.id}
});
});
- calls.push( {
+ calls.push({
methodname: 'tool_lp_data_for_related_competencies_section',
- args: { competencyid: relatedTarget.id }
+ args: {competencyid: relatedTarget.id}
});
var promises = ajax.call(calls);
};
var promise = ajax.call([{
methodname: 'core_competency_update_competency',
- args: { competency: update }
+ args: {competency: update}
}]);
promise[0].then(function(result) {
if (result) {
var competency = $('[data-region="competencyactions"]').data('competency');
var requests = ajax.call([{
methodname: 'core_competency_delete_competency',
- args: { id: competency.id }
+ args: {id: competency.id}
}, {
methodname: 'tool_lp_data_for_competencies_manage_page',
- args: { competencyframeworkid: competency.competencyframeworkid,
- search: $('[data-region="filtercompetencies"] input').val() }
+ args: {competencyframeworkid: competency.competencyframeworkid,
+ search: $('[data-region="filtercompetencies"] input').val()}
}]);
requests[0].done(function(success) {
if (success === false) {
str.get_strings([
- { key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.alert(
null,
strings[0]
}
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: confirmMessage, component: 'tool_lp', param: competency.shortname },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: confirmMessage, component: 'tool_lp', param: competency.shortname},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Delete competency X?
/**
* HTML5 implementation of drag/drop (there is an accesible alternative in the menus).
* @method dragStart
+ * @param {Event} e
*/
var dragStart = function(e) {
e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));
/**
* HTML5 implementation of drag/drop (there is an accesible alternative in the menus).
* @method allowDrop
+ * @param {Event} e
*/
var allowDrop = function(e) {
e.originalEvent.dataTransfer.dropEffect = 'move';
/**
* HTML5 implementation of drag/drop (there is an accesible alternative in the menus).
* @method dragEnter
+ * @param {Event} e
*/
var dragEnter = function(e) {
e.preventDefault();
/**
* HTML5 implementation of drag/drop (there is an accesible alternative in the menus).
* @method dragLeave
+ * @param {Event} e
*/
var dragLeave = function(e) {
e.preventDefault();
/**
* HTML5 implementation of drag/drop (there is an accesible alternative in the menus).
* @method dropOver
+ * @param {Event} e
*/
var dropOver = function(e) {
e.preventDefault();
var relatedid = this.id.substr(11);
var competency = $('[data-region="competencyactions"]').data('competency');
var removeRelated = ajax.call([
- { methodname: 'core_competency_remove_related_competency',
- args: { relatedcompetencyid: relatedid, competencyid: competency.id } },
- { methodname: 'tool_lp_data_for_related_competencies_section',
- args: { competencyid: competency.id } }
+ {methodname: 'core_competency_remove_related_competency',
+ args: {relatedcompetencyid: relatedid, competencyid: competency.id}},
+ {methodname: 'tool_lp_data_for_related_competencies_section',
+ args: {competencyid: competency.id}}
]);
removeRelated[1].done(function(context) {
templates.render('tool_lp/related_competencies', context).done(function(html) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
updatedRelatedCompetencies();
- }.bind(this)).fail(notification.exception);
- }.bind(this)).fail(notification.exception);
+ }).fail(notification.exception);
+ }).fail(notification.exception);
};
/**
/**
* Log the competency viewed event.
*
- * @param {Object} The competency.
+ * @param {Object} competency The competency.
* @method triggerCompetencyViewedEvent
*/
var triggerCompetencyViewedEvent = function(competency) {
selectedCompetencyId = competency.id;
ajax.call([{
methodname: 'core_competency_competency_viewed',
- args: { id: competency.id }
+ args: {id: competency.id}
}]);
}
};
}).done(function() {
ajax.call([{
methodname: 'tool_lp_data_for_related_competencies_section',
- args: { competencyid: competency.id },
+ args: {competencyid: competency.id},
done: function(context) {
return templates.render('tool_lp/related_competencies', context).done(function(html, js) {
$('[data-region="relatedcompetencies"]').replaceWith(html);
* @method selectionChanged
* @param {Event} evt The event that triggered the selection change.
* @param {Object} params The parameters for the event. Contains a list of selected nodes.
+ * @return {Boolean}
*/
var selectionChanged = function(evt, params) {
var node = params.selected,
* Return the string "Selected <taxonomy>".
*
* @function parseTaxonomies
- * @param {String} Comma separated list of taxonomies.
+ * @param {String} taxonomiesstr Comma separated list of taxonomies.
* @return {Array} of level => taxonomystr
*/
var parseTaxonomies = function(taxonomiesstr) {
*
*/
var Competencydialogue = function() {
+ // Intentionally left empty.
};
/**
* Log the competency viewed event.
*
- * @param {Number} The competency ID.
+ * @param {Number} competencyId The competency ID.
* @method triggerCompetencyViewedEvent
*/
Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {
ajax.call([{
methodname: 'core_competency_competency_viewed',
- args: { id: competencyId }
+ args: {id: competencyId}
}]);
};
/**
* The action on the click event.
*
- * @param {Event} event click
+ * @param {Event} e event click
* @method clickEventHandler
*/
Competencydialogue.prototype.clickEventHandler = function(e) {
* Get a promise on data competency.
*
* @param {Number} competencyid
+ * @param {Object} options
* @return {Promise} return promise on data request
* @method getCompetencyDataPromise
*/
Competencydialogue.prototype.getCompetencyDataPromise = function(competencyid, options) {
var requests = ajax.call([
- { methodname: 'tool_lp_data_for_competency_summary',
- args: { competencyid: competencyid,
+ {methodname: 'tool_lp_data_for_competency_summary',
+ args: {competencyid: competencyid,
includerelated: options.includerelated || false,
includecourses: options.includecourses || false
}
* Initialise the competency dialogue module.
*
* Only the first call matters.
- *
- * @return {Void}
*/
init: function() {
if (typeof instance !== 'undefined') {
// Instantiate the one instance and delegate event on the body.
instance = new Competencydialogue();
- $('body').delegate('[data-action="competency-dialogue"]', 'click', { compdialogue: instance },
+ $('body').delegate('[data-action="competency-dialogue"]', 'click', {compdialogue: instance},
instance.clickEventHandler.bind(instance));
}
};
if (valid) {
validIds.push(compId);
}
- }.bind(self));
+ });
self._selectedCompetencies = validIds;
} else {
self._find('[data-region="competencylinktree"] [data-action="add"]').removeAttr('disabled');
}
- }.bind(self));
+ });
// Add listener for framework change.
if (!self._singleFramework) {
self._find('[data-action="chooseframework"]').change(function(e) {
self._frameworkId = $(e.target).val();
self._loadCompetencies().then(self._refresh.bind(self));
- }.bind(self));
+ });
}
// Add listener for search.
return self._refresh().always(function() {
$(e.target).removeAttr('disabled');
});
- }.bind(self));
+ });
// Add listener for cancel.
self._find('[data-region="competencylinktree"] [data-action="cancel"]').click(function(e) {
e.preventDefault();
self.close();
- }.bind(self));
+ });
// Add listener for add.
self._find('[data-region="competencylinktree"] [data-action="add"]').click(function(e) {
}
if (self._multiSelect) {
- self._trigger('save', { competencyIds: self._selectedCompetencies });
+ self._trigger('save', {competencyIds: self._selectedCompetencies});
} else {
// We checked above that the array has at least one value.
- self._trigger('save', { competencyId: self._selectedCompetencies[0] });
+ self._trigger('save', {competencyId: self._selectedCompetencies[0]});
}
self.close();
- }.bind(self));
+ });
// The list of selected competencies will be modified while looping (because of the listeners above).
var currentItems = self._selectedCompetencies.slice(0);
tree.toggleItem(node);
tree.updateFocus(node);
}
- }.bind(self));
+ });
};
html,
self._afterRender.bind(self)
);
- }.bind(self));
- }.bind(self)).fail(Notification.exception);
+ });
+ }).fail(Notification.exception);
};
/**
var self = this;
return Ajax.call([
- { methodname: 'core_competency_search_competencies', args: {
+ {methodname: 'core_competency_search_competencies', args: {
searchtext: searchText,
competencyframeworkid: frameworkId
}}
])[0].done(function(competencies) {
-
+ /**
+ * @param {Object} parent
+ * @param {Array} competencies
+ */
function addCompetencyChildren(parent, competencies) {
for (var i = 0; i < competencies.length; i++) {
if (competencies[i].parentid == parent.id) {
}
// Expand the list of competencies into a tree.
- var i, tree = [], comp;
+ var i, comp;
+ var tree = [];
for (i = 0; i < competencies.length; i++) {
comp = competencies[i];
if (comp.parentid == "0") { // Loose check for now, because WS returns a string.
self._competencies = tree;
- }.bind(self)).fail(Notification.exception);
+ }).fail(Notification.exception);
};
/**
* Find a node in the dialogue.
*
* @param {String} selector
+ * @return {JQuery}
* @method _find
*/
Picker.prototype._find = function(selector) {
* Convenience method to get a framework object.
*
* @param {Number} fid The framework ID.
+ * @return {Object}
* @method _getFramework
*/
Picker.prototype._getFramework = function(fid) {
$.each(this._frameworks, function(i, f) {
if (f.id == fid) {
frm = f;
- return false;
+ return;
}
});
return frm;
if (self._singleFramework) {
promise = Ajax.call([
- { methodname: 'core_competency_read_competency_framework', args: {
+ {methodname: 'core_competency_read_competency_framework', args: {
id: this._frameworkId
}}
])[0].then(function(framework) {
});
} else {
promise = Ajax.call([
- { methodname: 'core_competency_list_competency_frameworks', args: {
+ {methodname: 'core_competency_list_competency_frameworks', args: {
sort: 'shortname',
- context: { contextid: self._pageContextId },
+ context: {contextid: self._pageContextId},
includes: self._pageContextIncludes,
onlyvisible: self._onlyVisible
}}
}
return self._loadCompetencies();
- }.bind(self));
+ });
};
/**
return self._render().then(function(html) {
self._find('[data-region="competencylinktree"]').replaceWith(html);
self._afterRender();
- }.bind(self));
+ });
};
/**
};
return Templates.render('tool_lp/competency_picker', context);
- }.bind(self));
+ });
};
/**
*
* This needs to be set after reset/close.
*
- * @params {Number[]} The IDs.
+ * @param {Number[]} ids The IDs.
* @method _setDisallowedCompetencyIDs
*/
Picker.prototype.setDisallowedCompetencyIDs = function(ids) {
* Trigger an event.
*
* @param {String} type The type of event.
- * @param {Object} The data to pass to the listeners.
+ * @param {Object} data The data to pass to the listeners.
* @method _reset
*/
Picker.prototype._trigger = function(type, data) {
/**
* Competency picker in plan class.
*
+ * @param {Number} userId
* @param {Number|false} singlePlan The ID of the plan when limited to one.
- * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.
* @param {Boolean} multiSelect Support multi-select in the tree.
*/
var Picker = function(userId, singlePlan, multiSelect) {
self._find('[data-action="chooseplan"]').change(function(e) {
self._planId = $(e.target).val();
self._loadCompetencies().then(self._refresh.bind(self));
- }.bind(self));
+ });
}
};
* @param {Number} planId The planId.
* @param {String} searchText Limit the competencies to those matching the text.
* @method _fetchCompetencies
- * @return {Promise}
+ * @return {Promise} The promise object.
*/
Picker.prototype._fetchCompetencies = function(planId, searchText) {
var self = this;
return Ajax.call([
- { methodname: 'core_competency_list_plan_competencies', args: {
+ {methodname: 'core_competency_list_plan_competencies', args: {
id: planId
}}
])[0].done(function(competencies) {
// Expand the list of competencies into a fake tree.
- var i, tree = [], comp;
+ var i, comp;
+ var tree = [];
for (i = 0; i < competencies.length; i++) {
comp = competencies[i].competency;
if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {
$.each(this._plans, function(i, f) {
if (f.id == id) {
plan = f;
- return false;
+ return;
}
});
return plan;
if (self._singlePlan) {
promise = Ajax.call([
- { methodname: 'core_competency_read_plan', args: {
+ {methodname: 'core_competency_read_plan', args: {
id: this._planId
}}
])[0].then(function(plan) {
});
} else {
promise = Ajax.call([
- { methodname: 'core_competency_list_user_plans', args: {
+ {methodname: 'core_competency_list_user_plans', args: {
userid: self._userId
}}
])[0];
}
return self._loadCompetencies();
- }.bind(self));
+ });
};
/**
};
return Templates.render('tool_lp/competency_picker_user_plans', context);
- }.bind(self));
+ });
};
return /** @alias module:tool_lp/competencypicker_user_plans */ Picker;
*
* Triggered when a change occured.
*
- * @return {Void}
* @method _afterChange
* @protected
*/
*
* Triggered when a change occured in a specific rule config.
*
- * @return {Void}
* @method _afterRuleConfigChange
* @protected
+ * @param {Event} e
+ * @param {Rule} rule
*/
RuleConfig.prototype._afterRuleConfigChange = function(e, rule) {
if (rule != this._getRule()) {
/**
* After render hook.
*
- * @return {Promise}
* @method _afterRender
* @protected
*/
$.each(this._rules, function(index, rule) {
if (rule.canConfig()) {
can = true;
- return false;
+ return;
}
});
return can;
RuleConfig.prototype.display = function() {
var self = this;
if (!self._competency) {
- return;
+ return false;
}
return self._render().then(function(html) {
return Str.get_string('competencyrule', 'tool_lp').then(function(title) {
* Find a node in the dialogue.
*
* @param {String} selector
+ * @return {JQuery}
* @method _find
* @protected
*/
$.each(this._rules, function(index, rule) {
if (rule.getType() == type) {
result = rule;
- return false;
+ return;
}
});
$.each(self._rulesModules, function(index, modInfo) {
if (modInfo.type == type) {
name = modInfo.name;
- return false;
+ return;
}
});
return name;
/**
* Set up the instance.
*
- * @return {Void}
* @method _setUp
* @protected
*/
/**
* Called when the user switches outcome.
*
- * @return {Void}
* @method _switchedOutcome
* @protected
*/
/**
* Called when the user switches rule.
*
- * @return {Void}
* @method _switchedRule
* @protected
*/
* Trigger an event.
*
* @param {String} type The type of event.
- * @param {Object} The data to pass to the listeners.
+ * @param {Object} data The data to pass to the listeners.
* @method _trigger
* @protected
*/
var currentValue = $(e.target).closest('a').data('pushratingstouserplans');
var context = {
courseid: courseid,
- settings: { pushratingstouserplans: currentValue }
+ settings: {pushratingstouserplans: currentValue}
};
e.preventDefault();
templates.render('tool_lp/course_competency_settings', context).done(function(html) {
- str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function (title) {
+ str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function(title) {
this._dialogue = new Dialogue(
title,
html,
var newValue = this._find('input[name="pushratingstouserplans"]:checked').val();
var courseId = this._find('input[name="courseid"]').val();
- var settings = { pushratingstouserplans: newValue };
+ var settings = {pushratingstouserplans: newValue};
ajax.call([
- { methodname: 'core_competency_update_course_competency_settings',
- args: { courseid: courseId, settings: settings } }
+ {methodname: 'core_competency_update_course_competency_settings',
+ args: {courseid: courseId, settings: settings}}
])[0].done(function() {
this.refreshCourseCompetenciesPage();
}.bind(this)).fail(notification.exception);
var courseId = this._find('input[name="courseid"]').val();
ajax.call([
- { methodname: 'tool_lp_data_for_course_competencies_page',
- args: { courseid: courseId } }
+ {methodname: 'tool_lp_data_for_course_competencies_page',
+ args: {courseid: courseId}}
])[0].done(function(context) {
templates.render('tool_lp/course_competencies_page', context).done(function(html, js) {
$('[data-region="coursecompetenciespage"]').replaceWith(html);
wide = false;
}
- Y.use('moodle-core-notification', 'timers', function () {
+ Y.use('moodle-core-notification', 'timers', function() {
var width = '480px';
if (wide) {
width = '800px';
/**
* Get content.
+ * @return {node}
*/
dialogue.prototype.getContent = function() {
return this.yuiDialogue.bodyNode.getDOMNode();
// Here we are wrapping YUI. This allows us to start transitioning, but
// wait for a good alternative without having inconsistent UIs.
str.get_strings([
- { key: 'emptydragdropregion', component: 'moodle' },
- { key: 'movecontent', component: 'moodle' },
- { key: 'tocontent', component: 'moodle' },
- ]).done( function () {
- Y.use('moodle-tool_lp-dragdrop-reorder', function () {
+ {key: 'emptydragdropregion', component: 'moodle'},
+ {key: 'movecontent', component: 'moodle'},
+ {key: 'tocontent', component: 'moodle'},
+ ]).done(function() {
+ Y.use('moodle-tool_lp-dragdrop-reorder', function() {
var context = {
callback: callback
* Trigger an event.
*
* @param {String} type The type of event.
- * @param {Object} The data to pass to the listeners.
+ * @param {Object} data The data to pass to the listeners.
* @method _trigger
*/
Base.prototype._trigger = function(type, data) {
*
* @param {String} triggerSelector The node on which the click will happen.
* @param {String} containerSelector The parent node that will be removed and contains the evidence ID.
- * @return {Void}
*/
var register = function(triggerSelector, containerSelector) {
if (typeof selectors[triggerSelector] !== 'undefined') {
e.stopPropagation();
Str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'areyousure', component: 'moodle' },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: 'areyousure', component: 'moodle'},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
Notification.confirm(
strings[0], // Confirm.
strings[1], // Are you sure?
methodname: 'tool_lp_search_cohorts',
args: {
query: query,
- context: { contextid: contextid },
+ context: {contextid: contextid},
includes: includes
}
}]);
// We are chaining ajax requests here.
var requests = ajax.call([{
methodname: 'core_competency_duplicate_competency_framework',
- args: { id: frameworkid }
+ args: {id: frameworkid}
}, {
methodname: 'tool_lp_data_for_competency_frameworks_manage_page',
args: {
// We are chaining ajax requests here.
var requests = ajax.call([{
methodname: 'core_competency_delete_competency_framework',
- args: { id: frameworkid }
+ args: {id: frameworkid}
}, {
methodname: 'tool_lp_data_for_competency_frameworks_manage_page',
args: {
}
}
}]);
- requests[0].done(function (success) {
+ requests[0].done(function(success) {
if (success === false) {
var req = ajax.call([{
methodname: 'core_competency_read_competency_framework',
- args: { id: frameworkid }
+ args: {id: frameworkid}
}]);
- req[0].done(function (framework) {
+ req[0].done(function(framework) {
str.get_strings([
- { key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.alert(
null,
strings[0]
var requests = ajax.call([{
methodname: 'core_competency_read_competency_framework',
- args: { id: frameworkid }
+ args: {id: frameworkid}
}]);
requests[0].done(function(framework) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: 'deletecompetencyframework', component: 'tool_lp', param: framework.shortname},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Delete competency framework X?
* @param {String} selector The selector of the auto complete element.
* @param {String} query The query string.
* @param {Function} callback A callback function receiving an array of results.
- * @return {Void}
*/
transport: function(selector, query, callback) {
var el = $(selector),
/**
* Grade dialogue class.
+ * @param {Array} ratingOptions
*/
var Grade = function(ratingOptions) {
EventBase.prototype.constructor.apply(this, []);
/**
* After render hook.
*
- * @return {Promise}
* @method _afterRender
* @protected
*/
*
* @param {String} selector
* @method _find
+ * @returns {node} The node
* @protected
*/
Grade.prototype._find = function(selector) {
* InlineEditor
*
* @param {String} selector The selector to trigger the grading.
- * @param {Number} The id of the scale for this competency.
- * @param {Number} The id of the competency.
- * @param {Number} The id of the user.
- * @param {Number} The id of the plan.
- * @param {Number} The id of the course.
- * @param {String} Language string for choose a rating.
+ * @param {Number} scaleId The id of the scale for this competency.
+ * @param {Number} competencyId The id of the competency.
+ * @param {Number} userId The id of the user.
+ * @param {Number} planId The id of the plan.
+ * @param {Number} courseId The id of the course.
+ * @param {String} chooseStr Language string for choose a rating.
*/
var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {
EventBase.prototype.constructor.apply(this, []);
methodname: self._methodName,
args: args,
done: function(evidence) {
- self._trigger('competencyupdated', { args: args, evidence: evidence });
- }.bind(self),
+ self._trigger('competencyupdated', {args: args, evidence: evidence});
+ },
fail: notification.exception
}]);
- }.bind(self));
+ });
}).fail(notification.exception);
};
/**
* Constructor
*
- * @param {$} Jquery collection matching the root of the menu.
+ * @param {$} menuRoot Jquery collection matching the root of the menu.
* @param {Function[]} handlers, called when a menu item is chosen.
*/
var Menubar = function(menuRoot, handlers) {
* @method handleClick
* @param {Object} item is the jquery object of the item firing the event
* @param {Event} e is the associated event object
- * @return boolean Returns false
+ * @return {boolean} Returns false
*/
Menubar.prototype.handleClick = function(item, e) {
e.stopPropagation();
this.activeItem = null;
// Close the menu.
- this.menuRoot.find('ul').not('.root-level').attr('aria-hidden','true');
+ this.menuRoot.find('ul').not('.root-level').attr('aria-hidden', 'true');
// Follow any link, or call the click handlers.
var anchor = item.find('a').first();
var clickEvent = new $.Event('click');
if (this.handlers) {
$.each(this.handlers, function(selector, handler) {
if (eventHandled) {
- return false;
+ return;
}
if (item.find(selector).length > 0) {
var callable = $.proxy(handler, anchor);
subMenuContainer.css('margin-right', '-' + marginright + 'px');
}
} else {
- if ( pos.left + menuRealWidth > $(window).width()) {
+ if (pos.left + menuRealWidth > $(window).width()) {
marginleft = menuRealWidth - widthmenuRoot;
subMenuContainer.css('margin-left', '-' + marginleft + 'px');
}
return true;
}
- switch(e.keyCode) {
+ switch (e.keyCode) {
case this.keys.tab: {
// Hide all menu items and update their aria attributes.
// This is the root level move to next sibling. This will require closing
// the current child menu and opening the new one.
- if (menuIndex < menuNum-1) {
+ if (menuIndex < menuNum - 1) {
// Not the last root menu.
newItem = item.next();
} else { // Wrap to first item.
menuIndex = this.rootMenus.index(rootItem);
// If this is not the last root menu item, move to the next one.
- if (menuIndex < this.rootMenus.length-1) {
+ if (menuIndex < this.rootMenus.length - 1) {
newItem = rootItem.next();
} else {
// Loop.
// to the next item with a title that begins with that character.
if (startChr) {
var match = false;
- var curNdx = menuIndex+1;
+ var curNdx = menuIndex + 1;
// Check if the active item was the last one on the list.
if (curNdx == menuNum) {
// Iterate through the menu items (starting from the current item and wrapping) until a match is found
// or the loop returns to the current menu item.
- while (curNdx != menuIndex) {
+ while (curNdx != menuIndex) {
var titleChr = menuItems.eq(curNdx).html().charAt(0);
break;
}
- curNdx = curNdx+1;
+ curNdx = curNdx + 1;
if (curNdx == menuNum) {
// Reached the end of the list, start again at the beginning.
return item;
}
} else {
- if (menuIndex < menuNum-1) {
- newItem = menuItems.eq(menuIndex+1);
+ if (menuIndex < menuNum - 1) {
+ newItem = menuItems.eq(menuIndex + 1);
} else {
newItem = menuItems.first();
}
// If item is not the first item in its menu, move to the previous item.
if (menuIndex > 0) {
- newItem = menuItems.eq(menuIndex-1);
+ newItem = menuItems.eq(menuIndex - 1);
} else {
// Loop to top of menu.
newItem = menuItems.last();
* { "[data-action='add']" : callAddFunction }
*/
enhance: function(selector, handler) {
- $(selector).each(function (index, element) {
+ $(selector).each(function(index, element) {
var menuRoot = $(element);
// Don't enhance the same menu twice.
if (menuRoot.data("menubarEnhanced") !== true) {
/**
* Set the parent competency in the competency form.
*
- * @param {Object} Data containing selected cmpetency.
+ * @param {Object} data Data containing selected competency.
* @method setParent
*/
ParentCompetencyForm.prototype.setParent = function(data) {
if (data.competencyId !== 0) {
ajax.call([
- { methodname: 'core_competency_read_competency', args: {
+ {methodname: 'core_competency_read_competency', args: {
id: data.competencyId
}}
])[0].done(function(competency) {
};
return Templates.render('tool_lp/competency_picker_competencyform', context);
- }.bind(self));
+ });
};
// On selected competency.
picker.on('save', function(e, data) {
self.setParent(data);
- }.bind(self));
+ });
picker.display();
});
/**
* Main initialisation.
* @param {String} buttonSelector The parent competency button selector.
- * @param {String} inputHiddenSelector The hidden input field selector.
+ * @param {String} inputSelector The hidden input field selector.
* @param {String} staticElementSelector The static element displaying the parent competency.
* @param {Number} frameworkId The competency framework ID.
* @param {Number} pageContextId The page context ID.
.done(function(newhtml, newjs) {
$(self._region).replaceWith(newhtml);
templates.runTemplateJS(newjs);
- }.bind(self))
+ })
.fail(notification.exception);
};
// Apply all the promises, and refresh when the last one is resolved.
return $.when.apply($.when, ajax.call(calls))
.then(function() {
- self._renderView.call(self, arguments[arguments.length - 1]);
+ self._renderView(arguments[arguments.length - 1]);
})
.fail(notification.exception);
};
var self = this,
calls = [{
methodname: 'core_competency_delete_plan',
- args: { id: planData.id }
+ args: {id: planData.id}
}];
self._callAndRefresh(calls, planData);
};
requests = ajax.call([{
methodname: 'core_competency_read_plan',
- args: { id: planData.id }
+ args: {id: planData.id}
}]);
requests[0].done(function(plan) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'deleteplan', component: 'tool_lp', param: plan.name },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: 'deleteplan', component: 'tool_lp', param: plan.name},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Delete plan X?
strings[3], // Cancel.
function() {
self._doDelete(planData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
var self = this,
calls = [{
methodname: 'core_competency_reopen_plan',
- args: { planid: planData.id}
+ args: {planid: planData.id}
}];
self._callAndRefresh(calls, planData);
};
var self = this,
requests = ajax.call([{
methodname: 'core_competency_read_plan',
- args: { id: planData.id }
+ args: {id: planData.id}
}]);
requests[0].done(function(plan) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name },
- { key: 'reopenplan', component: 'tool_lp' },
- { key: 'cancel', component: 'moodle' }
- ]).done(function (strings) {
+ {key: 'confirm', component: 'moodle'},
+ {key: 'reopenplanconfirm', component: 'tool_lp', param: plan.name},
+ {key: 'reopenplan', component: 'tool_lp'},
+ {key: 'cancel', component: 'moodle'}
+ ]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[1], // Reopen plan X?
strings[3], // Cancel.
function() {
self._doReopenPlan(planData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
var self = this,
calls = [{
methodname: 'core_competency_complete_plan',
- args: { planid: planData.id}
+ args: {planid: planData.id}
}];
self._callAndRefresh(calls, planDa