},
'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',
// === 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',
+ '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',
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: {
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.
--- /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);
+}
$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) {
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);
};
/**
return self._render().then(function(html) {
self._find('[data-region="action-selector"]').replaceWith(html);
self._afterRender();
- }.bind(self));
+ });
};
/**
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 {
$.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' }
+ {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.
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;
});
},
children = this._tree.getChildren(this._competency.id),
context,
config = {
- base: { points: 2 },
+ base: {points: 2},
competencies: []
};
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' }
+ {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],
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' }
+ {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.
$.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' }
+ {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},
+ {key: 'move', component: 'tool_lp'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
var context = {
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) {
$.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({
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' }
+ {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.alert(
null,
}
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: confirmMessage, component: 'tool_lp', param: competency.shortname },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {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.
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);
};
/**
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);
Competencydialogue.prototype.triggerCompetencyViewedEvent = function(competencyId) {
ajax.call([{
methodname: 'core_competency_competency_viewed',
- args: { id: competencyId }
+ args: {id: competencyId}
}]);
};
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
}
// 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
}}
}
// 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);
};
/**
$.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));
+ });
};
/**
self._find('[data-action="chooseplan"]').change(function(e) {
self._planId = $(e.target).val();
self._loadCompetencies().then(self._refresh.bind(self));
- }.bind(self));
+ });
}
};
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;
$.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) {
$.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;
var currentValue = $(e.target).closest('a').data('pushratingstouserplans');
var context = {
courseid: courseid,
- settings: { pushratingstouserplans: currentValue }
+ settings: {pushratingstouserplans: currentValue}
};
e.preventDefault();
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);
// 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' },
+ {key: 'emptydragdropregion', component: 'moodle'},
+ {key: 'movecontent', component: 'moodle'},
+ {key: 'tocontent', component: 'moodle'},
]).done(function() {
Y.use('moodle-tool_lp-dragdrop-reorder', function() {
e.stopPropagation();
Str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'areyousure', component: 'moodle' },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'areyousure', component: 'moodle'},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
Notification.confirm(
strings[0], // Confirm.
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: {
if (success === false) {
var req = ajax.call([{
methodname: 'core_competency_read_competency_framework',
- args: { id: frameworkid }
+ args: {id: frameworkid}
}]);
req[0].done(function(framework) {
str.get_strings([
- { key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname },
- { key: 'cancel', component: 'moodle' }
+ {key: 'frameworkcannotbedeleted', component: 'tool_lp', param: framework.shortname},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.alert(
null,
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' }
+ {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.
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);
};
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);
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();
});
.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' }
+ {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[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' }
+ {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[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, 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: 'completeplanconfirm', component: 'tool_lp', param: plan.name },
- { key: 'completeplan', component: 'tool_lp' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'completeplanconfirm', component: 'tool_lp', param: plan.name},
+ {key: 'completeplan', component: 'tool_lp'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[3], // Cancel.
function() {
self._doCompletePlan(planData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
var self = this,
calls = [{
methodname: 'core_competency_unlink_plan_from_template',
- 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: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name },
- { key: 'unlinkplantemplate', component: 'tool_lp' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'unlinkplantemplateconfirm', component: 'tool_lp', param: plan.name},
+ {key: 'unlinkplantemplate', component: 'tool_lp'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[3], // Cancel.
function() {
self._doUnlinkPlan(planData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
var competencyid = $(e.target).data('id');
var requests = ajax.call([{
methodname: 'tool_lp_list_courses_using_competency',
- args: { id: competencyid }
+ args: {id: competencyid}
}]);
requests[0].done(function(courses) {
}.bind(this));
body.on('click', '[data-action="cancel"]', function() {
popup.close();
- }.bind(this));
+ });
};
/**
ScaleConfig.prototype.setScaleConfig = function() {
var body = $(this.popup.getContent());
// Get the data.
- var data = [{ scaleid: this.scaleid}];
+ var data = [{scaleid: this.scaleid}];
this.scalevalues.forEach(function(value) {
var scaledefault = 0;
var proficient = 0;
// We are chaining ajax requests here.
var requests = ajax.call([{
methodname: 'core_competency_delete_template',
- args: { id: templateid,
- deleteplans: deleteplans }
+ args: {id: templateid,
+ deleteplans: deleteplans}
}, {
methodname: 'tool_lp_data_for_templates_manage_page',
args: {
// We are chaining ajax requests here.
var requests = ajax.call([{
methodname: 'core_competency_duplicate_template',
- args: { id: templateid }
+ args: {id: templateid}
}, {
methodname: 'tool_lp_data_for_templates_manage_page',
args: {
var requests = ajax.call([{
methodname: 'core_competency_read_template',
- args: { id: templateid }
+ args: {id: templateid}
}, {
methodname: 'core_competency_template_has_related_data',
- args: { id: templateid }
+ args: {id: templateid}
}]);
requests[0].done(function(template) {
requests[1].done(function(templatehasrelateddata) {
if (templatehasrelateddata) {
str.get_strings([
- { key: 'deletetemplate', component: 'tool_lp', param: template.shortname },
- { key: 'deletetemplatewithplans', component: 'tool_lp' },
- { key: 'deleteplans', component: 'tool_lp' },
- { key: 'unlinkplanstemplate', component: 'tool_lp' },
- { key: 'confirm', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},
+ {key: 'deletetemplatewithplans', component: 'tool_lp'},
+ {key: 'deleteplans', component: 'tool_lp'},
+ {key: 'unlinkplanstemplate', component: 'tool_lp'},
+ {key: 'confirm', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
var actions = [{'text': strings[2], 'value': 'delete'},
{'text': strings[3], 'value': 'unlink'}];
}).fail(notification.exception);
} else {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'deletetemplate', component: 'tool_lp', param: template.shortname },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'deletetemplate', component: 'tool_lp', param: template.shortname},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
if (!this.multiSelect) {
allSelected = allSelected.first();
}
- this.treeRoot.trigger('selectionchanged', { selected: allSelected });
+ this.treeRoot.trigger('selectionchanged', {selected: allSelected});
};
/**
* @param {Event} e The event.
* @return {Boolean}
*/
+ // This function should be simplified. In the meantime..
+ // eslint-disable-next-line complexity
Tree.prototype.handleKeyDown = function(item, e) {
var currentIndex = this.visibleItems.index(item);
var newItem = null;
if (this._planId) {
this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';
- this._args = { competencyid: this._competencyId, planid: this._planId };
+ this._args = {competencyid: this._competencyId, planid: this._planId};
this._templateName = 'tool_lp/user_competency_summary_in_plan';
} else if (this._courseId) {
this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';
- this._args = { userid: this._userId, competencyid: this._competencyId, courseid: this._courseId };
+ this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};
this._templateName = 'tool_lp/user_competency_summary_in_course';
} else {
this._methodName = 'tool_lp_data_for_user_competency_summary';
- this._args = { userid: this._userId, competencyid: this._competencyId };
+ this._args = {userid: this._userId, competencyid: this._competencyId};
this._templateName = 'tool_lp/user_competency_summary';
}
};
var requests = ajax.call([{
methodname: 'tool_lp_data_for_user_competency_summary_in_plan',
- args: { competencyid: competencyId, planid: planId },
+ args: {competencyid: competencyId, planid: planId},
done: this._contextLoaded.bind(this),
fail: notification.exception
}]);
ajax.call([{
methodname: 'tool_lp_data_for_plan_page',
- args: { planid: planId},
+ args: {planid: planId},
done: this._pageContextLoaded.bind(this),
fail: notification.exception
}]);
templates.render(self._template, context)
.done(function(newhtml, newjs) {
templates.replaceNode($(self._region), newhtml, 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_user_evidence',
- args: { id: evidenceData.id }
+ args: {id: evidenceData.id}
}];
self._callAndRefresh(calls, evidenceData);
};
requests = ajax.call([{
methodname: 'core_competency_read_user_evidence',
- args: { id: evidenceData.id }
+ args: {id: evidenceData.id}
}]);
requests[0].done(function(evidence) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name },
- { key: 'delete', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'deleteuserevidence', component: 'tool_lp', param: evidence.name},
+ {key: 'delete', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[3], // Cancel.
function() {
self._doDelete(evidenceData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
picker.on('save', function(e, data) {
var competencyIds = data.competencyIds;
self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);
- }.bind(self));
+ });
picker.display();
};
var self = this,
calls = [{
methodname: 'core_competency_request_review_of_user_evidence_linked_competencies',
- args: { id: evidenceData.id }
+ args: {id: evidenceData.id}
}];
self._callAndRefresh(calls, evidenceData);
};
requests = ajax.call([{
methodname: 'core_competency_read_user_evidence',
- args: { id: evidenceData.id }
+ args: {id: evidenceData.id}
}]);
requests[0].done(function(evidence) {
str.get_strings([
- { key: 'confirm', component: 'moodle' },
- { key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name },
- { key: 'confirm', component: 'moodle' },
- { key: 'cancel', component: 'moodle' }
+ {key: 'confirm', component: 'moodle'},
+ {key: 'sendallcompetenciestoreview', component: 'tool_lp', param: evidence.name},
+ {key: 'confirm', component: 'moodle'},
+ {key: 'cancel', component: 'moodle'}
]).done(function(strings) {
notification.confirm(
strings[0], // Confirm.
strings[3], // Cancel.
function() {
self._doReviewUserEvidenceCompetencies(evidenceData);
- }.bind(self)
+ }
);
}).fail(notification.exception);
}).fail(notification.exception);
* @param {String[]} templateList List of template ids.
*/
var reloadListTemplate = function(templateList) {
- templates.render('tool_templatelibrary/search_results', { templates: templateList })
+ templates.render('tool_templatelibrary/search_results', {templates: templateList})
.done(function(result, js) {
templates.replaceNode($('[data-region="searchresults"]'), result, js);
}).fail(notification.exception);
// Trigger the search.
ajax.call([
- { methodname: 'tool_templatelibrary_list_templates',
- args: { component: componentStr, search: searchStr },
+ {methodname: 'tool_templatelibrary_list_templates',
+ args: {component: componentStr, search: searchStr},
done: reloadListTemplate,
- fail: notification.exception }
+ fail: notification.exception}
], true, false);
};
*/
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;
- return $DB->get_recordset_select('course', 'timemodified >= ?', array($modifiedfrom));
+ return $DB->get_recordset_select('course', 'timemodified >= ?', array($modifiedfrom), 'timemodified ASC');
}
/**
require_once($CFG->libdir.'/completionlib.php');
$id = optional_param('id', 0, PARAM_INT);
- $name = optional_param('name', '', PARAM_RAW);
+ $name = optional_param('name', '', PARAM_TEXT);
$edit = optional_param('edit', -1, PARAM_BOOL);
$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
+/* eslint-disable no-unused-vars */
/**
* Drag and Drop for course sections and course modules.
*
+/* global Item */
+
/**
* A managed category.
*
+/* global DragDrop, Category, Course */
+
/**
* Provides drop down menus for list of action links.
*
+/* global Item */
+
/**
* A managed course.
*
+/* global Console */
+
/**
* Drag and Drop handler
*
+/* global TOOLBOX, BODY, SELECTOR, INDENTLIMITS */
+
/**
* Resource and activity toolbox class.
*
+/* global SELECTOR, TOOLBOX */
+
/**
* Resource and activity toolbox class.
*
+/* eslint-disable no-unused-vars */
/**
* Resource and activity toolbox class.
*
}
}
);
-
}
if ($hasinline || $hasdisplay || $hasextra) {
$PAGE->requires->yui_module('moodle-filter_mathjaxloader-loader', 'M.filter_mathjaxloader.typeset');
- return '<span class="nolink"><span class="filter_mathjaxloader_equation">' . $text . '</span></span>';
+ if ($hasextra) {
+ // If custom dilimeters are used, wrap whole text to prevent autolinking.
+ $text = '<span class="nolink">' + $text + '</span>';
+ } else {
+ if ($hasinline) {
+ // If the default inline TeX delimiters \( \) are present, wrap each pair in nolink.
+ $text = preg_replace('/\\\\\\([\S\s]*?\\\\\\)/u',
+ '<span class="nolink">\0</span>', $text);
+ }
+ if ($hasdisplay) {
+ // If default display TeX is used, wrap $$ $$ or \[ \] individually.
+ $text = preg_replace('/\$\$[\S\s]*?\$\$|\\\\\\[[\S\s]*?\\\\\\]/u',
+ '<span class="nolink">\0</span>', $text);
+ }
+ }
+ return '<span class="filter_mathjaxloader_equation">' . $text . '</span>';
}
return $text;
}
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global SELECTORS */
/**
* @module moodle-gradereport_grader-gradereporttable
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* eslint-disable no-unused-vars */
/**
* Grader Report Functionality.
$string['authsettings'] = 'Manage authentication';
$string['autolang'] = 'Language autodetect';
$string['autologinguests'] = 'Auto-login guests';
-$string['availablesearchareas'] = 'Available areas for search';
+$string['searchareas'] = 'Search areas';
$string['availableto'] = 'Available to';
$string['availablelicenses'] = 'Available licences';
$string['backgroundcolour'] = 'Transparent colour';
$string['includemoduleuserdata'] = 'Include module user data';
$string['incompatibleblocks'] = 'Incompatible blocks';
$string['indexdata'] = 'Index data';
+$string['indexinginfo'] = 'The recommended way to index your site\'s contents is using "Global search indexing" scheduled task which runs automatically by Cron.';
$string['installhijacked'] = 'Installation must be finished from the original IP address, sorry.';
$string['installsessionerror'] = 'Can not initialise PHP session, please verify that your browser accepts cookies.';
$string['intlrecommended'] = 'Intl extension is used to improve internationalization support, such as locale aware sorting.';
$string['navsortmycoursessort'] = 'Sort my courses';
$string['navsortmycoursessort_help'] = 'This determines whether courses are listed under My courses according to the sort order (i.e. the order set in Site administration > Courses > Manage courses and categories) or alphabetically by course setting.';
$string['neverdeleteruns'] = 'Never delete runs';
+$string['newestdocindexed'] = 'Newest document indexed';
$string['nobookmarksforuser'] = 'You do not have any bookmarks.';
$string['nodatabase'] = 'No database';
$string['nohttpsformobilewarning'] = 'It is recommended to enable HTTPS with a valid certificate. The Moodle app will always try to use a secured connection first.';
$string['save'] = 'Save';
$string['savechanges'] = 'Save changes';
$string['search'] = 'Search';
+$string['searchalldeleted'] = 'All indexed contents have been deleted';
+$string['searchareaenabled'] = 'Search area enabled';
+$string['searchareadisabled'] = 'Search area disabled';
+$string['searchdeleteindex'] = 'Delete all indexed contents';
$string['searchengine'] = 'Search engine';
+$string['searchindexactions'] = 'Index actions';
+$string['searchindexdeleted'] = 'Index deleted';
+$string['searchindexupdated'] = 'Search engine contents have been updated';
$string['searchinsettings'] = 'Search in settings';
+$string['searchlastrun'] = 'Last run (time, # docs, # records, # ignores)';
+$string['searchnotavailable'] = 'Search is not available';
+$string['searchreindexed'] = 'All site\'s contents have been reindexed';
+$string['searchreindexindex'] = 'Reindex all site contents';
$string['searchresults'] = 'Search results';
$string['searchsetupinfo'] = 'Search setup';
+$string['searchupdateindex'] = 'Update indexed contents';
$string['sectionerror'] = 'Section error!';
$string['secureforms'] = 'Use additional form security';
$string['security'] = 'Security';
// Available areas.
$row = array();
- $url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
+ $url = new moodle_url('/admin/searchareas.php');
$row[0] = '2. ' . html_writer::tag('a', get_string('enablesearchareas', 'admin'),
array('href' => $url));
// Indexed data.
$row = array();
- $url = new moodle_url('/report/search/index.php#searchindexform');
+ $url = new moodle_url('/admin/searchareas.php');
$row[0] = '4. ' . html_writer::tag('a', get_string('indexdata', 'admin'), array('href' => $url));
if ($anyindexed) {
$status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
var yuiNodes = new Y.NodeList(nodes.get());
// And again for YUI.
- Y.fire(M.core.event.FILTER_CONTENT_UPDATED, { nodes: yuiNodes });
+ Y.fire(M.core.event.FILTER_CONTENT_UPDATED, {nodes: yuiNodes});
});
},
}
originalSelect.children('option').each(function(index, ele) {
if ($(ele).prop('selected')) {
- items.push({ label: $(ele).html(), value: $(ele).attr('value') });
+ items.push({label: $(ele).html(), value: $(ele).attr('value')});
}
});
- var context = $.extend({ items: items }, options, state);
+ var context = $.extend({items: items}, options, state);
// Render the template.
templates.render('core/form_autocomplete_selection', context).done(function(newHTML) {
var suggestions = [];
originalSelect.children('option').each(function(index, option) {
if ($(option).prop('selected') !== true) {
- suggestions[suggestions.length] = { label: option.innerHTML, value: $(option).attr('value') };
+ suggestions[suggestions.length] = {label: option.innerHTML, value: $(option).attr('value')};
}
});
// Re-render the list of suggestions.
var searchquery = state.caseSensitive ? query : query.toLocaleLowerCase();
- var context = $.extend({ options: suggestions}, options, state);
+ var context = $.extend({options: suggestions}, options, state);
templates.render(
'core/form_autocomplete_suggestions',
context
// Create the new markup and insert it after the select.
var suggestions = [];
originalSelect.children('option').each(function(index, option) {
- suggestions[index] = { label: option.innerHTML, value: $(option).attr('value') };
+ suggestions[index] = {label: option.innerHTML, value: $(option).attr('value')};
});
// Render all the parts of our UI.
// Public variables and functions.
processResults: function(selector, data) {
// Mangle the results into an array of objects.
- var results = [], i = 0;
+ var results = [];
+ var i = 0;
var excludelist = String($(selector).data('exclude')).split(',');
for (i = 0; i < data.courses.length; i++) {
if (excludelist.indexOf(String(data.courses[i].id)) === -1) {
- results.push({ value: data.courses[i].id, label: data.courses[i].displayname });
+ results.push({value: data.courses[i].id, label: data.courses[i].displayname});
}
}
return results;
allScript += ' ' + scriptNode.text();
}
}
- }.bind(this));
+ });
promise.resolve(data.html, allScript);
}).fail(function(ex) {
promise.reject(ex);
// From http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery.
/* jshint bitwise: false */
/* eslint no-bitwise: "off" */
- var hash = 0, i, chr, len;
+ var hash = 0;
+ var i, chr, len;
if (source.length === 0) {
return hash;
}
setupTargetRegion: function() {
var targetRegion = $('#' + notificationModule.fieldName);
if (targetRegion.length) {
- return;
+ return false;
}
var newRegion = $('<span>').attr('id', notificationModule.fieldName);
var promises = ajax.call([{
methodname: 'core_tag_get_tagindex',
- args: { tagindex: args }
+ args: {tagindex: args}
}], true);
$.when.apply($, promises)
var form = $(this).closest('form').get(0),
cnt = $(form).find("input[type=checkbox]:checked").length;
if (!cnt) {
- return false;
+ return;
}
var tempElement = $("<input type='hidden'/>").attr('name', this.name);
e.preventDefault();
notification.alert(s[0], s[1], s[2]);
}
);
- return false;
+ return;
}
var tempElement = $("<input type='hidden'/>").attr('name', this.name);
str.get_strings([
var href = $(this).attr('data-url') + '&sesskey=' + M.cfg.sesskey;
str.get_strings([
{key: 'delete'},
- {key: 'suredeletecoll', component: 'tag', param: $(this).attr('data-collname') },
+ {key: 'suredeletecoll', component: 'tag', param: $(this).attr('data-collname')},
{key: 'yes'},
{key: 'no'},
]).done(function(s) {
var templatecontext = {
attributes: [
- { name: 'src', value: url},
- { name: 'alt', value: helper(text)},
- { name: 'class', value: 'smallicon'}
+ {name: 'src', value: url},
+ {name: 'alt', value: helper(text)},
+ {name: 'class', value: 'smallicon'}
]
};
// We forced loading of this early, so it will be in the cache.
context.quote = function() {
return quoteHelper;
};
- context.globals = { config: config };
+ context.globals = {config: config};
context.currentTheme = themeName;
};
* @param {Event} e The event.
* @return {Boolean}
*/
+ // This function should be simplified. In the meantime..
+ // eslint-disable-next-line complexity
Tree.prototype.handleKeyDown = function(item, e) {
var currentIndex = this.getVisibleItems().index(item);
*
* @return external_function_parameters
* @since Moodle 2.7
+ * @deprecated Moodle 3.2 MDL-51373 - Please do not call this function any more.
+ * @see gradereport_user_external::get_grades_table for a similar function
*/
public static function get_grades_parameters() {
return new external_function_parameters(
* @param array $userids Array of user ids
* @return array Array of grades
* @since Moodle 2.7
+ * @deprecated Moodle 3.2 MDL-51373 - Please do not call this function any more.
+ * @see gradereport_user_external::get_grades_table for a similar function
*/
public static function get_grades($courseid, $component = null, $activityid = null, $userids = array()) {
global $CFG, $USER, $DB;
* @param int $iteminstance Item instance
* @param int $itemnumber Item number
* @return grade_item A grade_item instance
+ * @deprecated Moodle 3.2 MDL-51373 - Please do not call this function any more.
+ * @see gradereport_user_external::get_grades_table for a similar function
*/
private static function get_grade_item($courseid, $itemtype, $itemmodule = null, $iteminstance = null, $itemnumber = null) {
$gradeiteminstance = null;
*
* @return external_description
* @since Moodle 2.7
+ * @deprecated Moodle 3.2 MDL-51373 - Please do not call this function any more.
+ * @see gradereport_user_external::get_grades_table for a similar function
*/
public static function get_grades_returns() {
return new external_single_structure(
}
+ /**
+ * Marking the method as deprecated.
+ *
+ * @return bool
+ */
+ public static function get_grades_is_deprecated() {
+ return true;
+ }
+
/**
* Returns description of method parameters
*
$plugins = array(
'qformat' => array('blackboard', 'learnwise'),
'enrol' => array('authorize'),
+ 'report' => array('search'),
'tinymce' => array('dragmath'),
'tool' => array('bloglevelupgrade', 'qeupgradehelper', 'timezoneimport'),
'theme' => array('mymobile', 'afterburner', 'anomaly', 'arialist', 'binarius', 'boxxie', 'brick', 'formal_white',
'report' => array(
'backups', 'competency', 'completion', 'configlog', 'courseoverview', 'eventlist',
- 'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances', 'search',
+ 'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances',
'security', 'stats', 'performance', 'usersessions'
),
'core_grades_get_grades' => array(
'classname' => 'core_grades_external',
'methodname' => 'get_grades',
- 'description' => 'Returns student course total grade and grades for activities.
+ 'description' => '** DEPRECATED ** Please do not call this function any more.
+ Returns student course total grade and grades for activities.
This function does not return category or manual items.
This function is suitable for managers or teachers not students.',
'type' => 'read',
// Moodle v3.1.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2016070700.01) {
+
+ // If someone is emotionally attached to it let's leave the config (basically the version) there.
+ if (!file_exists($CFG->dirroot . '/report/search/classes/output/form.php')) {
+ unset_all_config_for_plugin('report_search');
+ }
+
+ // Savepoint reached.
+ upgrade_main_savepoint(true, 2016070700.01);
+ }
+
return true;
}
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global NOTIFY_WARNING, NOTIFY_INFO */
+/* eslint-disable no-unused-vars */
/**
* A autosave function for the Atto editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global LOGNAME */
/**
* @module moodle-editor_atto-editor
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global YUI */
/**
* @module moodle-editor_atto-plugin
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* eslint-disable no-unused-vars */
/**
* The Atto WYSIWG pluggable editor, written for Moodle.
+++ /dev/null
-/* globals rangy */
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global rangy */
/**
* @module moodle-editor_atto-editor
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global rangy */
/**
* @module moodle-editor_atto-editor
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global LOGNAME */
/**
* @module moodle-editor_atto-editor
* returned. Default false.
* allowid : If true then id attributes will not be removed, even when using htmlpurifier. Default (different from
* format_text) true. Default changed id attributes are commonly needed.
+ * blanktarget : If true all <a> tags will have target="_blank" added unless target is explicitly specified.
* </pre>
*
* @param string $text The content that may contain ULRs in need of rewriting.
+/* global CALENDAR, MOODLECALENDAR */
+
/**
* Add some custom methods to the node class to make our lives a little
* easier within this module.
$test = '$$ \pi $$';
$testformat = FORMAT_MARKDOWN;
- $correct = array('<span class="nolink"><span class="filter_mathjaxloader_equation"><p>$$ \pi $$</p>
-</span></span>', FORMAT_HTML);
+ $correct = array('<span class="filter_mathjaxloader_equation"><p><span class="nolink">$$ \pi $$</span></p>
+</span>', FORMAT_HTML);
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0), $correct);
// Filters can be opted out from by the developer.
- get_user_max_upload_file_size()
* The following functions have been removed and should not be used any more:
- file_modify_html_header() - See MDL-29738 for more information.
+* core_grades_external::get_grades has been deprecated. Please do not call this function any more.
+ External function gradereport_user_external::get_grades_table can be used for retrieving the course grades table.
+ Please note that the information returned from that WS is intended for displaying (not for data consumption).
=== 3.1 ===
+/* global MANAGER */
+
/**
* This file contains the Block Region class used by the drag and drop manager.
*
+/* global MANAGER */
+
/**
* Provides drag and drop functionality for blocks.
*
+/* global BLOCKREGION, SELECTOR, AJAXURL */
+
/**
* This file contains the drag and drop manager class.
*
+/* global BLOCK, LOGNS, DOCKEDITEM */
+
/**
* Dock JS.
*
* @module moodle-core-dock
*/
-
var LOGNS = 'moodle-core-dock',
BODY = Y.one(Y.config.doc.body),
CSS = {
DOCKPANEL,
TABHEIGHTMANAGER,
BLOCK,
- DOCKEDITEM;
+ DOCKEDITEM; // eslint-disable-line no-unused-vars
M.core = M.core || {};
M.core.dock = M.core.dock || {};
+/* global LOGNS, DOCKEDITEM */
+
/**
* Dock JS.
*
+/* global DOCKPANEL, LOGNS */
+
/**
* Dock JS.
*
+/* global TABHEIGHTMANAGER, LOGNS */
+
/**
* Dock JS.
*
+/* global NAME */
+
/**
* Home for a Confirmation class.
*
+/* global BASE, DIALOGUE_PREFIX */
+
/**
* A dialogue type designed to display an appropriate error when an error
* thrown in the Moodle codebase was reported during an AJAX request.
+/* global BASE, TITLE, CONFIRMYES, DIALOGUE_PREFIX */
+
/**
* A dialogue type designed to display an alert to the user.
*
+/* global CONFIRMYES, CONFIRMNO, QUESTION, BASE, TITLE, DIALOGUE_PREFIX */
+
/**
* A dialogue type designed to display a confirmation to the user.
*
+/* global DIALOGUE_PREFIX, BASE */
+
/**
* The generic dialogue class for use in Moodle.
*
+/* global BASE, DIALOGUE_PREFIX */
+
/**
* A dialogue type designed to display an appropriate error when a generic
* javascript error was thrown and caught.
+/* global DIALOGUE_PREFIX */
+
/**
* A dialogue type designed to display informative messages to users.
*
+/* eslint-disable no-unused-vars, no-unused-expressions */
var DIALOGUE_PREFIX,
BASE,
CONFIRMYES,
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* eslint-disable no-unused-vars */
/**
* Messenger constants.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global SELECTORS */
/**
* Messenger manager.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global CSSR, SELECTORS */
/**
* Send message dialog.
str.get_string('changeuser', 'mod_assign').done(function(s) {
autocomplete.enhance('[data-action=change-user]', false, 'mod_assign/participant_selector', s);
- }.bind(this)
+ }
).fail(notification.exception);
// We do not allow navigation while ajax requests are pending.
ajax.call([{
methodname: 'mod_assign_list_participants',
- args: { assignid: assignmentid, groupid: groupid, filter: '', onlyids: true },
+ args: {assignid: assignmentid, groupid: groupid, filter: '', onlyids: true},
done: this._usersLoaded.bind(this),
fail: notification.exception
}]);
if ($(ele).prop('checked')) {
filterlist[filterlist.length] = $(ele).closest('label').text();
}
- }.bind(this));
+ });
if (filterlist.length) {
this._region.find('[data-region="user-filters"] span').text(filterlist.join(', '));
} else {
show = false;
}
}
- }.bind(this));
+ });
if (show) {
this._filteredUsers[this._filteredUsers.length] = user;
if (checker.checkFormForChanges('[data-region="grade-panel"] .gradeform')) {
// Form has changes, so we need to confirm before switching users.
str.get_strings([
- { key: 'unsavedchanges', component: 'mod_assign' },
- { key: 'unsavedchangesquestion', component: 'mod_assign' },
- { key: 'saveandcontinue', component: 'mod_assign' },
- { key: 'cancel', component: 'core' },
+ {key: 'unsavedchanges', component: 'mod_assign'},
+ {key: 'unsavedchangesquestion', component: 'mod_assign'},
+ {key: 'saveandcontinue', component: 'mod_assign'},
+ {key: 'cancel', component: 'core'},
]).done(function(strs) {
notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
$(document).trigger('save-changes', -1);
});
- }.bind(this));
+ });
} else {
$(document).trigger('user-changed', -1);
}
if (checker.checkFormForChanges('[data-region="grade-panel"] .gradeform')) {
// Form has changes, so we need to confirm before switching users.
str.get_strings([
- { key: 'unsavedchanges', component: 'mod_assign' },
- { key: 'unsavedchangesquestion', component: 'mod_assign' },
- { key: 'saveandcontinue', component: 'mod_assign' },
- { key: 'cancel', component: 'core' },
+ {key: 'unsavedchanges', component: 'mod_assign'},
+ {key: 'unsavedchangesquestion', component: 'mod_assign'},
+ {key: 'saveandcontinue', component: 'mod_assign'},
+ {key: 'cancel', component: 'core'},
]).done(function(strs) {
notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
$(document).trigger('save-changes', useridnumber);
});
- }.bind(this));
+ });
} else {
select.attr('data-selected', userid);
e.preventDefault();
var select = this._region.find('[data-action=change-user]');
var currentUserId = select.attr('data-selected');
- var i = 0, currentIndex = 0;
+ var i = 0;
+ var currentIndex = 0;
for (i = 0; i < this._filteredUsers.length; i++) {
if (this._filteredUsers[i].id == currentUserId) {
e.preventDefault();
var select = this._region.find('[data-action=change-user]');
var currentUserId = select.attr('data-selected');
- var i = 0, currentIndex = 0;
+ var i = 0;
+ var currentIndex = 0;
for (i = 0; i < this._filteredUsers.length; i++) {
if (this._filteredUsers[i].id == currentUserId) {
if (count) {
currentIndex += 1;
}
- var param = { x: currentIndex, y: count };
+ var param = {x: currentIndex, y: count};
str.get_string('xofy', 'mod_assign', param).done(function(s) {
this._region.find('[data-region="user-count-summary"]').text(s);
if (checker.checkFormForChanges('[data-region="grade-panel"] .gradeform')) {
// Form has changes, so we need to confirm before switching users.
str.get_strings([
- { key: 'unsavedchanges', component: 'mod_assign' },
- { key: 'unsavedchangesquestion', component: 'mod_assign' },
- { key: 'saveandcontinue', component: 'mod_assign' },
- { key: 'cancel', component: 'core' },
+ {key: 'unsavedchanges', component: 'mod_assign'},
+ {key: 'unsavedchangesquestion', component: 'mod_assign'},
+ {key: 'saveandcontinue', component: 'mod_assign'},
+ {key: 'cancel', component: 'core'},
]).done(function(strs) {
notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
$(document).trigger('save-changes', userid);
});
- }.bind(this));
+ });
} else {
if (!isNaN(userid) && userid > 0) {
select.attr('data-selected', userid);
$(document).trigger('reset', [this._lastUserId, formdata]);
} else {
str.get_strings([
- { key: 'changessaved', component: 'core' },
- { key: 'gradechangessaveddetail', component: 'mod_assign' },
+ {key: 'changessaved', component: 'core'},
+ {key: 'gradechangessaveddetail', component: 'mod_assign'},
]).done(function(strs) {
notification.alert(strs[0], strs[1]);
}).fail(notification.exception);
var formhtml = formcopy.wrap($('<form/>')).html();
str.get_strings([
- { key: 'viewadifferentattempt', component: 'mod_assign' },
- { key: 'view', component: 'core' },
- { key: 'cancel', component: 'core' },
+ {key: 'viewadifferentattempt', component: 'mod_assign'},
+ {key: 'view', component: 'core'},
+ {key: 'cancel', component: 'core'},
]).done(function(strs) {
notification.confirm(strs[0], formhtml, strs[1], strs[2], function() {
var attemptnumber = $("input:radio[name='select-attemptnumber']:checked").val();
if (userid > 0) {
this._region.show();
// Reload the grading form "fragment" for this user.
- var params = { userid: userid, attemptnumber: attemptnumber, jsonformdata: JSON.stringify(submissiondata) };
+ var params = {userid: userid, attemptnumber: attemptnumber, jsonformdata: JSON.stringify(submissiondata)};
fragment.loadFragment('mod_assign', 'gradingpanel', contextid, params).done(function(html, js) {
this._niceReplaceNodeContents(this._region, html, js)
.done(function() {
* @return {Array}
*/
processResults: function(selector, data) {
- var results = [], i = 0;
+ var results = [];
+ var i = 0;
for (i = 0; i < data.length; i++) {
- results[i] = { value: data[i].id, label: data[i].label };
+ results[i] = {value: data[i].id, label: data[i].label};
}
return results;
},
});
var promise = ajax.call([{
- methodname: 'mod_assign_list_participants', args: { assignid: assignmentid, groupid: 0, filter: query, limit: 30 }
+ methodname: 'mod_assign_list_participants', args: {assignid: assignmentid, groupid: 0, filter: query, limit: 30}
}]);
promise[0].then(function(results) {
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global STROKEWEIGHT, SELECTOR, SELECTEDBORDERCOLOUR, SELECTEDFILLCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global ANNOTATIONCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global STROKEWEIGHT, ANNOTATIONCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global STROKEWEIGHT, ANNOTATIONCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global STROKEWEIGHT, ANNOTATIONCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global STROKEWEIGHT, ANNOTATIONCOLOUR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global SELECTOR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global SELECTOR, COMMENTCOLOUR, COMMENTTEXTCOLOUR */
/**
* Provides an in browser PDF editor.
+/* eslint-disable no-unused-vars */
+/* global SELECTOR */
var COMMENTSEARCHNAME = "commentsearch",
COMMENTSEARCH;
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global SELECTOR */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* eslint-disable no-unused-vars */
+/* global SELECTOR, TOOLSELECTOR, AJAXBASE, COMMENTCOLOUR, ANNOTATIONCOLOUR, AJAXBASEPROGRESS, CLICKTIMEOUT */
/**
* Provides an in browser PDF editor.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* eslint-disable no-unused-vars */
/**
* A list of globals used by this module.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/* global AJAXBASE */
/**
* Provides an in browser PDF editor.
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
- set_config($varname . '_enabled', false, $componentname);
+ set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
- set_config($varname . '_enabled', true, $componentname);
+ set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
+ ),
+
+ 'mod/choice:view' => array(
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array(
+ 'user' => CAP_ALLOW,
+ 'guest' => CAP_ALLOW
+ )
)
);
$string['choice:readresponses'] = 'View responses';
$string['choicesaved'] = 'Your choice has been saved';
$string['choicetext'] = 'Choice text';
+$string['choice:view'] = 'View choice activity';
$string['chooseaction'] = 'Choose an action ...';
$string['description'] = 'Description';
$string['includeinactive'] = 'Include responses from inactive/suspended users';
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2016052300; // The current module version (Date: YYYYMMDDXX)
+$plugin->version = 2016070700; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2016051900; // Requires this Moodle version
$plugin->component = 'mod_choice'; // Full name of the plugin (used for diagnostics)
$plugin->cron = 0;
if (!$data->approval) {
$replacement[] = '';
} else if ($record->approved) {
- $replacement[] = 'approved';
+ $replacement[] = get_string('approved', 'data');
} else {
- $replacement[] = 'notapproved';
+ $replacement[] = get_string('notapproved', 'data');
}
$patterns[]='##comments##';
$warnings = array();
// Request and permission validation.
- $forum = $DB->get_record('forum', array('id' => $params['forumid']), 'id', MUST_EXIST);
+ $forum = $DB->get_record('forum', array('id' => $params['forumid']), '*', MUST_EXIST);
list($course, $cm) = get_course_and_cm_from_instance($forum, 'forum');
$context = context_module::instance($cm->id);
}
echo $OUTPUT->heading(get_string('newforumposts', 'forum').':', 3);
- echo "\n<ul class='unlist'>\n";
+ $list = html_writer::start_tag('ul', ['class' => 'unlist']);
foreach ($printposts as $post) {
$subjectclass = empty($post->parent) ? ' bold' : '';
+ $authorhidden = forum_is_author_hidden($post, (object) ['type' => $post->forumtype]);
- echo '<li><div class="head">'.
- '<div class="date">'.userdate($post->modified, $strftimerecent).'</div>'.
- '<div class="name">'.fullname($post, $viewfullnames).'</div>'.
- '</div>';
- echo '<div class="info'.$subjectclass.'">';
- if (empty($post->parent)) {
- echo '"<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'">';
- } else {
- echo '"<a href="'.$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'&parent='.$post->parent.'#p'.$post->id.'">';
+ $list .= html_writer::start_tag('li');
+ $list .= html_writer::start_div('head');
+ $list .= html_writer::div(userdate($post->modified, $strftimerecent), 'date');
+ if (!$authorhidden) {
+ $list .= html_writer::div(fullname($post, $viewfullnames), 'name');
+ }
+ $list .= html_writer::end_div(); // Head.
+
+ $list .= html_writer::start_div('info' . $subjectclass);
+ $discussionurl = new moodle_url('/mod/forum/discuss.php', ['d' => $post->discussion]);
+ if (!empty($post->parent)) {
+ $discussionurl->param('parent', $post->parent);
+ $discussionurl->set_anchor('p'. $post->id);
}
$post->subject = break_up_long_words(format_string($post->subject, true));
- echo $post->subject;
- echo "</a>\"</div></li>\n";
+ $list .= html_writer::link($discussionurl, $post->subject);
+ $list .= html_writer::end_div(); // Info.
+ $list .= html_writer::end_tag('li');
}
- echo "</ul>\n";
+ $list .= html_writer::end_tag('ul');
+ echo $list;
return true;
}
$forumpostclass .= ' lastpost';
}
+ // Flag to indicate whether we should hide the author or not.
+ $authorhidden = forum_is_author_hidden($post, $forum);
$postbyuser = new stdClass;
$postbyuser->post = $post->subject;
$postbyuser->user = $postuser->fullname;
$discussionbyuser = get_string('postbyuser', 'forum', $postbyuser);
$output .= html_writer::tag('a', '', array('id'=>'p'.$post->id));
- $output .= html_writer::start_tag('div', array('class'=>'forumpost clearfix'.$forumpostclass.$topicclass,
- 'role' => 'region',
- 'aria-label' => $discussionbyuser));
- $output .= html_writer::start_tag('div', array('class'=>'row header clearfix'));
- $output .= html_writer::start_tag('div', array('class'=>'left picture'));
- $output .= $OUTPUT->user_picture($postuser, array('courseid'=>$course->id));
- $output .= html_writer::end_tag('div');
+ // Begin forum post.
+ $output .= html_writer::start_div('forumpost clearfix' . $forumpostclass . $topicclass,
+ ['role' => 'region', 'aria-label' => $discussionbyuser]);
+ // Begin header row.
+ $output .= html_writer::start_div('row header clearfix');
+ // User picture.
+ if (!$authorhidden) {
+ $picture = $OUTPUT->user_picture($postuser, ['courseid' => $course->id]);
+ $output .= html_writer::div($picture, 'left picture');
+ $topicclass = 'topic' . $topicclass;
+ }
- $output .= html_writer::start_tag('div', array('class'=>'topic'.$topicclass));
-
+ // Begin topic column.
+ $output .= html_writer::start_div($topicclass);
$postsubject = $post->subject;
if (empty($post->subjectnoformat)) {
$postsubject = format_string($postsubject);
}
- $output .= html_writer::tag('div', $postsubject, array('class'=>'subject',
- 'role' => 'heading',
- 'aria-level' => '2'));
+ $output .= html_writer::div($postsubject, 'subject', ['role' => 'heading', 'aria-level' => '2']);
- $by = new stdClass();
- $by->name = html_writer::link($postuser->profilelink, $postuser->fullname);
- $by->date = userdate($post->modified);
- $output .= html_writer::tag('div', get_string('bynameondate', 'forum', $by), array('class'=>'author',
- 'role' => 'heading',
- 'aria-level' => '2'));
-
- $output .= html_writer::end_tag('div'); //topic
- $output .= html_writer::end_tag('div'); //row
-
- $output .= html_writer::start_tag('div', array('class'=>'row maincontent clearfix'));
- $output .= html_writer::start_tag('div', array('class'=>'left'));
-
- $groupoutput = '';
- if ($groups) {
- $groupoutput = print_group_picture($groups, $course->id, false, true, true);
- }
- if (empty($groupoutput)) {
- $groupoutput = ' ';
+ if ($authorhidden) {
+ $bytext = userdate($post->modified);
+ } else {
+ $by = new stdClass();
+ $by->date = userdate($post->modified);
+ $by->name = html_writer::link($postuser->profilelink, $postuser->fullname);
+ $bytext = get_string('bynameondate', 'forum', $by);
+ }
+ $bytextoptions = [
+ 'role' => 'heading',
+ 'aria-level' => '2',
+ ];
+ $output .= html_writer::div($bytext, 'author', $bytextoptions);
+ // End topic column.
+ $output .= html_writer::end_div();
+
+ // End header row.
+ $output .= html_writer::end_div();
+
+ // Row with the forum post content.
+ $output .= html_writer::start_div('row maincontent clearfix');
+ // Show if author is not hidden or we have groups.
+ if (!$authorhidden || $groups) {
+ $output .= html_writer::start_div('left');
+ $groupoutput = '';
+ if ($groups) {
+ $groupoutput = print_group_picture($groups, $course->id, false, true, true);
+ }
+ if (empty($groupoutput)) {
+ $groupoutput = ' ';
+ }
+ $output .= html_writer::div($groupoutput, 'grouppictures');
+ $output .= html_writer::end_div(); // Left side.
}
- $output .= html_writer::tag('div', $groupoutput, array('class'=>'grouppictures'));
- $output .= html_writer::end_tag('div'); //left side
$output .= html_writer::start_tag('div', array('class'=>'no-overflow'));
$output .= html_writer::start_tag('div', array('class'=>'content'));
$tmpactivity->content->discussion = $post->discussion;
$tmpactivity->content->subject = format_string($post->subject);
$tmpactivity->content->parent = $post->parent;
+ $tmpactivity->content->forumtype = $post->forumtype;
$tmpactivity->user = new stdClass();
$additionalfields = array('id' => 'userid', 'picture', 'imagealt', 'email');
}
/**
- * @todo Document this function
- * @global object
+ * Outputs the forum post indicated by $activity.
+ *
+ * @param object $activity the activity object the forum resides in
+ * @param int $courseid the id of the course the forum resides in
+ * @param bool $detail not used, but required for compatibilty with other modules
+ * @param int $modnames not used, but required for compatibilty with other modules
+ * @param bool $viewfullnames not used, but required for compatibilty with other modules
*/
function forum_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames) {
- global $CFG, $OUTPUT;
+ global $OUTPUT;
- if ($activity->content->parent) {
+ $content = $activity->content;
+ if ($content->parent) {
$class = 'reply';
} else {
$class = 'discussion';
}
- echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
-
- echo "<tr><td class=\"userpicture\" valign=\"top\">";
- echo $OUTPUT->user_picture($activity->user, array('courseid'=>$courseid));
- echo "</td><td class=\"$class\">";
-
- if ($activity->content->parent) {
+ $tableoptions = [
+ 'border' => '0',
+ 'cellpadding' => '3',
+ 'cellspacing' => '0',
+ 'class' => 'forum-recent'
+ ];
+ $output = html_writer::start_tag('table', $tableoptions);
+ $output .= html_writer::start_tag('tr');
+
+ $post = (object) ['parent' => $content->parent];
+ $forum = (object) ['type' => $content->forumtype];
+ $authorhidden = forum_is_author_hidden($post, $forum);
+
+ // Show user picture if author should not be hidden.
+ if (!$authorhidden) {
+ $pictureoptions = [
+ 'courseid' => $courseid,
+ 'link' => $authorhidden,
+ 'alttext' => $authorhidden,
+ ];
+ $picture = $OUTPUT->user_picture($activity->user, $pictureoptions);
+ $output .= html_writer::tag('td', $picture, ['class' => 'userpicture', 'valign' => 'top']);
+ }
+
+ // Discussion title and author.
+ $output .= html_writer::start_tag('td', ['class' => $class]);
+ if ($content->parent) {
$class = 'title';
} else {
// Bold the title of new discussions so they stand out.
$class = 'title bold';
}
- echo "<div class=\"{$class}\">";
+
+ $output .= html_writer::start_div($class);
if ($detail) {
$aname = s($activity->name);
- echo "<img src=\"" . $OUTPUT->pix_url('icon', $activity->type) . "\" ".
- "class=\"icon\" alt=\"{$aname}\" />";
+ $output .= html_writer::img($OUTPUT->pix_url('icon', $activity->type), $aname, ['class' => 'icon']);
}
- echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d={$activity->content->discussion}"
- ."#p{$activity->content->id}\">{$activity->content->subject}</a>";
- echo '</div>';
+ $discussionurl = new moodle_url('/mod/forum/discuss.php', ['d' => $content->discussion]);
+ $discussionurl->set_anchor('p' . $activity->content->id);
+ $output .= html_writer::link($discussionurl, $content->subject);
+ $output .= html_writer::end_div();
- echo '<div class="user">';
- $fullname = fullname($activity->user, $viewfullnames);
- echo "<a href=\"$CFG->wwwroot/user/view.php?id={$activity->user->id}&course=$courseid\">"
- ."{$fullname}</a> - ".userdate($activity->timestamp);
- echo '</div>';
- echo "</td></tr></table>";
+ $timestamp = userdate($activity->timestamp);
+ if ($authorhidden) {
+ $authornamedate = $timestamp;
+ } else {
+ $fullname = fullname($activity->user, $viewfullnames);
+ $userurl = new moodle_url('/user/view.php');
+ $userurl->params(['id' => $activity->user->id, 'course' => $courseid]);
+ $by = new stdClass();
+ $by->name = html_writer::link($userurl, $fullname);
+ $by->date = $timestamp;
+ $authornamedate = get_string('bynameondate', 'forum', $by);
+ }
+ $output .= html_writer::div($authornamedate, 'user');
+ $output .= html_writer::end_tag('td');
+ $output .= html_writer::end_tag('tr');
+ $output .= html_writer::end_tag('table');
- return;
+ echo $output;
}
/**
return true;
}
+
+/**
+ * Checks whether the author's name and picture for a given post should be hidden or not.
+ *
+ * @param object $post The forum post.
+ * @param object $forum The forum object.
+ * @return bool
+ * @throws coding_exception
+ */
+function forum_is_author_hidden($post, $forum) {
+ if (!isset($post->parent)) {
+ throw new coding_exception('$post->parent must be set.');
+ }
+ if (!isset($forum->type)) {
+ throw new coding_exception('$forum->type must be set.');
+ }
+ if ($forum->type === 'single' && empty($post->parent)) {
+ return true;
+ }
+ return false;
+}
$this->assertCount($expectedreplycount, $unmailed);
}
+ /**
+ * Test for forum_is_author_hidden.
+ */
+ public function test_forum_is_author_hidden() {
+ // First post, different forum type.
+ $post = (object) ['parent' => 0];
+ $forum = (object) ['type' => 'standard'];
+ $this->assertFalse(forum_is_author_hidden($post, $forum));
+
+ // Child post, different forum type.
+ $post->parent = 1;
+ $this->assertFalse(forum_is_author_hidden($post, $forum));
+
+ // First post, single simple discussion forum type.
+ $post->parent = 0;
+ $forum->type = 'single';
+ $this->assertTrue(forum_is_author_hidden($post, $forum));
+
+ // Child post, single simple discussion forum type.
+ $post->parent = 1;
+ $this->assertFalse(forum_is_author_hidden($post, $forum));
+
+ // Incorrect parameters: $post.
+ $this->setExpectedException('coding_exception', '$post->parent must be set.');
+ unset($post->parent);
+ forum_is_author_hidden($post, $forum);
+
+ // Incorrect parameters: $forum.
+ $this->setExpectedException('coding_exception', '$forum->type must be set.');
+ unset($forum->type);
+ forum_is_author_hidden($post, $forum);
+ }
+
public function forum_get_unmailed_posts_provider() {
return [
'Untimed discussion; Single post; maxeditingtime not expired' => [
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
- set_config($varname . '_enabled', false, $componentname);
+ set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
- set_config($varname . '_enabled', true, $componentname);
+ set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}
$sql = "SELECT ge.*, g.course FROM {glossary_entries} ge
JOIN {glossary} g ON g.id = ge.glossaryid
- WHERE ge.timemodified >= ?";
+ WHERE ge.timemodified >= ? ORDER BY ge.timemodified ASC";
return $DB->get_recordset_sql($sql, array($modifiedfrom));
}
// Enabled by default once global search is enabled.
$this->assertTrue($searcharea->is_enabled());
- set_config($varname . '_enabled', false, $componentname);
+ set_config($varname . '_enabled', 0, $componentname);
$this->assertFalse($searcharea->is_enabled());
- set_config($varname . '_enabled', true, $componentname);
+ set_config($varname . '_enabled', 1, $componentname);
$this->assertTrue($searcharea->is_enabled());
}
$data = $mform->get_data();
require_sesskey();
+ $formattextdefoptions = new stdClass();
+ $formattextdefoptions->noclean = true;
+ $formattextdefoptions->para = false;
+
// set defaults
$result->response = '';
$result->newpageid = 0;
$result->studentanswer = $result->userresponse = $result->useranswer;
$answers = $this->get_answers();
foreach ($answers as $answer) {
+ $answer = parent::rewrite_answers_urls($answer);
if (strpos($answer->answer, ':')) {
// there's a pairs of values
list($min, $max) = explode(':', $answer->answer);
}
if (($result->useranswer >= $minimum) && ($result->useranswer <= $maximum)) {
$result->newpageid = $answer->jumpto;
- $result->response = trim($answer->response);
+ $result->response = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
if ($this->lesson->jumpto_is_correct($this->properties->id, $result->newpageid)) {
$result->correctanswer = true;
}
*/
var submitCartridgeURL = function() {
if (isLoading()) {
- return;
+ return false;
}
var url = getCartridgeURL();
// No URL? Do nothing.
if (url === "") {
- return;
+ return false;
}
startLoading();
* @param {Integer} id Tool proxy ID
* @return {Promise} jQuery Deferred object
*/
- delete: function(id) {
+ 'delete': function(id) {
var request = {
methodname: 'mod_lti_delete_tool_proxy',
args: {
* @param {Integer} id Tool type ID
* @return {Promise} jQuery Deferred object
*/
- delete: function(id) {
+ 'delete': function(id) {
var request = {
methodname: 'mod_lti_delete_tool_type',
args: {
+/* eslint-disable no-unused-vars */
/**
* Drag and Drop for Quiz sections and slots.
*
+/* global SELECTOR */
/**
* Resource drag and drop.
*
+/* global TOOLBOX, BODY, SELECTOR */
+
/**
* Resource and activity toolbox class.
*
instance.insert(editinstructions, 'before');
anchor.replace(editform);
- // Force the editing instruction to match the mod-indent position.
- var padside = 'left';
- if (window.right_to_left()) {
- padside = 'right';
- }
-
// We hide various components whilst editing:
activity.addClass(CSS.EDITINGMAXMARK);
+/* global TOOLBOX, BODY, SELECTOR */
+
/**
* Section toolbox class.
*
+/* eslint-disable no-unused-vars */
/**
* Resource and activity toolbox class.
*
+/* global YUI */
+
/**
* A collection of utility classes for use with pages.
*
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;
$select = 'course != ? AND ' . static::MODIFIED_FIELD_NAME . ' >= ?';
- return $DB->get_recordset_select($this->get_module_name(), $select, array(0, $modifiedfrom));
+ return $DB->get_recordset_select($this->get_module_name(), $select, array(0, $modifiedfrom),
+ static::MODIFIED_FIELD_NAME . ' ASC');
}
}