--- /dev/null
+CONTRIBUTING TO MOODLE
+======================
+
+Moodle is made by people like you. We are members of a big worldwide community
+of developers, designers, teachers, testers, translators and other users. We
+work in universities, schools, companies and other places. You are very welcome
+to join us and contribute to the project.
+
+See <https://docs.moodle.org/dev/Contributing_to_Moodle> for the many ways you
+can help, not only with coding.
+
+Moodle is open to community contributions to core, though all code must go
+through peer-review, automated behaviour testing, continuous integration and
+human post-integration checks.
+
+Pull requests
+-------------
+
+Please do not open pull requests via Github. The repository there is just a
+mirror of the official repository at <https://git.moodle.org>. Issues are
+reported and patches provided via <https://tracker.moodle.org>. See below for
+more information.
+
+Moodle core bug fixes and new features
+--------------------------------------
+
+During the years of intensive development, a mature process of including
+submitted patches has evolved.
+
+* Every bug fix or new feature must have a tracker issue.
+* You publish the branch implementing the fix or new feature in your public
+ clone of the moodle.git repository (typically on Github).
+* Your patch is peer-reviewed, discussed, integrated, tested and then released
+ as a part of moodle.git.
+* New features are developed on the master branch. Bug fixes are also
+ backported to currently supported maintenance (stable) branches.
+
+For further details, see <https://docs.moodle.org/dev/Process>.
+
+Moodle plugins
+--------------
+
+Moodle has a framework for additional plugins to extend its functionality. We
+have a Moodle plugins directory <https://moodle.org/plugins/> where you can
+register and maintain your plugin. Plugins hosted in the plugins directory can
+be easily installed and updated via the Moodle administration interface.
+
+* You are expected to have a public source code repository with your plugin
+ code.
+* After registering your plugin in the plugins directory it is reviewed before
+ being published.
+* You are expected to continuously release updated versions of the plugin via
+ the plugins directory. We do not pull from your code repository; you must do
+ it explicitly.
+
+For further details, see <https://docs.moodle.org/dev/Plugin_contribution>.
--- /dev/null
+MOODLE INSTALLATION
+===================
+
+Here is a short summary of the installation process (which can take just a few
+minutes):
+
+1. Move the Moodle files into your web directory.
+
+2. Create a single database for Moodle to store all its tables in (or choose an
+ existing database).
+
+3. Visit your Moodle site with a browser. You should be taken to the
+ install.php script, which will lead you through creating a config.php file
+ and then setting up Moodle, creating an admin account etc.
+
+4. Set up a cron task to call the file admin/cron.php every minute.
+
+For more information, see <https://docs.moodle.org/en/Installing_Moodle>.
+
+Good luck and have fun!
--- /dev/null
+*** PLEASE DO NOT OPEN PULL REQUESTS VIA GITHUB ***
+
+The moodle.git repository at Github is just a mirror of the official repository. We do not accept pull requests at Github.
+
+See CONTRIBUTING.txt guidelines for how to contribute patches for Moodle. Thank you.
+
+--
-QUICK INSTALL
-=============
+ .-..-.
+ _____ | || |
+ /____/-.---_ .---. .---. .-.| || | .---.
+ | | _ _ |/ _ \/ _ \/ _ || |/ __ \
+ * | | | | | || |_| || |_| || |_| || || |___/
+ |_| |_| |_|\_____/\_____/\_____||_|\_____)
-For the impatient, here is a basic outline of the
-installation process, which normally takes me only
-a few minutes:
+Moodle - the world's open source learning platform
-1) Move the Moodle files into your web directory.
+Moodle <https://moodle.org> is a learning platform designed to provide
+educators, administrators and learners with a single robust, secure and
+integrated system to create personalised learning environments.
-2) Create a single database for Moodle to store all
- its tables in (or choose an existing database).
+You can download Moodle <https://download.moodle.org> and run it on your own
+web server, ask one of our Moodle Partners <https://moodle.com/partners/> to
+assist you, or have a MoodleCloud site <https://moodle.com/cloud/> set up for
+you.
-3) Visit your Moodle site with a browser, you should
- be taken to the install.php script, which will lead
- you through creating a config.php file and then
- setting up Moodle, creating an admin account etc.
+Moodle is widely used around the world by universities, schools, companies and
+all manner of organisations and individuals.
-4) Set up a cron task to call the file admin/cron.php
- every five minutes or so.
+Moodle is provided freely as open source software, under the GNU General Public
+License <https://docs.moodle.org/dev/License>.
+Moodle is written in PHP and JavaScript and uses an SQL database for storing
+the data.
-For more information, see the INSTALL DOCUMENTATION:
-
- http://docs.moodle.org/en/Installing_Moodle
-
-
-Good luck and have fun!
-Martin Dougiamas, Lead Developer
-
+See <https://docs.moodle.org> for details of Moodle's many features.
-------------------------
-Moodle Trademark License
-------------------------
-
-The name Moodleâ„¢ is a registered trademark of the Moodle Trust.
-
-A key part of the business model that allows us to produce and
-distribute Moodle as completely Free open source software is that
-we restrict the commercial use of the Moodle trademark to those
-who have contracted to support Moodle development (Moodle Partners).
-
-If you are intending to use the name (and/or logo) to advertise
-generic Moodleâ„¢ services (eg Moodle Hosting, Moodle Support,
-Moodle Certification, Moodle Training, Moodle Consulting,
-Moodle Customisation, Moodle Courseware Development, Moodle
-Theme design, Moodle Integrations, Moodle Installations, etc)
-or as the name of a software package, then you must seek
-direct permission in writing from the Moodle Trust via the
-moodle.com helpdesk, in accordance with normal trademark
-restrictions.
-
-There are no restrictions on how you use the name in other
-contexts (for example, if you use Moodle just to provide
-courses then you can use the name freely to refer to it.)
-
-If you aren't sure of a particular case, please ask us via
-http://moodle.com/helpdesk: we'll be happy to either provide
-you with official permission in writing or help you fix
-your wording.
-
-Martin Dougiamas
-Executive Director
-Moodle Trust
-http://moodle.com
+MOODLE TRADEMARKS POLICY
+========================
+
+The word "Moodle" is trademarked in many countries around the world. The word
+was originally an acronym: Modular Object-Oriented Dynamic Learning
+Environment. The trademark is owned by Martin Dougiamas, Founder and Director
+of Moodle.
+
+The law obligates trademark owners to police their marks and prevent the use of
+confusingly similar names by third parties. Through this policy we’d like to
+make it clear how Moodle-related projects, organisations, and people can use
+the Moodle trademark. We’d also like to be clear about how use of the word is
+restricted when used to promote commercial Moodle services. We do this to
+protect the very business model that allows us to continue developing Moodle
+for you.
+
+Allowed uses
+------------
+
+The following uses don’t require any permission at all:
+
+* Referring to the software or the Moodle project.
+* Describing your own Moodle implementation (including within corporate
+ settings).
+* Describing a Moodle-based community hub.
+* Describing some software you’ve made that integrates with Moodle
+ (eg a Moodle integration feature on another system).
+
+Restricted uses
+---------------
+
+The following uses are generally prohibited without explicit and direct
+permission being granted to you by Moodle Pty Ltd. We do this to protect the
+Moodle project from software and sites which could confuse people. Please
+contact us to ask for permission in writing.
+
+* You can’t use "Moodle" in the name of your software (including Mobile apps)
+* You can’t use "Moodle" in your company name
+* You can’t use "Moodle" in your domain name
+* You can’t use "Moodle" in advertising-related keywords (such as Adsense)
+* You can’t use "Moodle" to describe services around Moodle (such as hosting,
+ training, support, consulting, course creation services, theme development,
+ customisation, installation, integration and certification). This applies
+ even if you do not charge for the services. Note that usually only Moodle
+ Partners have this permission.
+
+For information about the Moodle Partner Certification Mark as well as for how
+to contact us, please see <https://moodle.com/trademarks/>.
$output .= $this->header();
$output .= $this->maturity_info($maturity);
+ $output .= $this->legacy_log_store_writing_error();
$output .= empty($CFG->disableupdatenotifications) ? $this->available_updates($availableupdates, $availableupdatesfetch) : '';
$output .= $this->insecure_dataroot_warning($insecuredataroot);
$output .= $this->display_errors_warning($errorsdisplayed);
return $output;
}
+
+ /**
+ * Check to see if writing to the deprecated legacy log store is enabled.
+ *
+ * @return string An error message if writing to the legacy log store is enabled.
+ */
+ protected function legacy_log_store_writing_error() {
+ $enabled = get_config('logstore_legacy', 'loglegacy');
+ $plugins = explode(',', get_config('tool_log', 'enabled_stores'));
+ $enabled = $enabled && in_array('logstore_legacy', $plugins);
+
+ if ($enabled) {
+ return $this->warning(get_string('legacylogginginuse'));
+ }
+ }
}
protected $allpermissions; // We don't need perms ourselves, but all our subclasses do.
protected $strperms; // Language string cache.
protected $risksurl; // URL in moodledocs about risks.
- protected $riskicons = array(); // Cache to avoid regenerating the HTML for each risk icon.
/** @var array The capabilities to highlight as default/inherited. */
protected $parentpermissions;
protected $displaypermissions;
*/
public function get_risk_icon($type) {
global $OUTPUT;
- if (!isset($this->riskicons[$type])) {
- $iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type));
- $text = '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />';
- $action = new popup_action('click', $this->risksurl, 'docspopup');
- $this->riskicons[$type] = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin')));
- }
- return $this->riskicons[$type];
+
+ $iconurl = $OUTPUT->pix_url('i/' . str_replace('risk', 'risk_', $type));
+ $text = '<img src="' . $iconurl . '" alt="' . get_string($type . 'short', 'admin') . '" />';
+ $action = new popup_action('click', $this->risksurl, 'docspopup');
+ $riskicon = $OUTPUT->action_link($this->risksurl, $text, $action, array('title'=>get_string($type, 'admin')));
+
+ return $riskicon;
}
}
$ADMIN->add('reportplugins', $page);
}
+if ($hassiteconfig) {
+ // Global Search engine plugins.
+ $ADMIN->add('modules', new admin_category('searchplugins', new lang_string('search', 'admin')));
+ $temp = new admin_settingpage('manageglobalsearch', new lang_string('globalsearchmanage', 'admin'));
+
+ $pages = array();
+ $engines = array();
+ foreach (core_component::get_plugin_list('search') as $engine => $plugindir) {
+ $engines[$engine] = new lang_string('pluginname', 'search_' . $engine);
+ $settingspath = "$plugindir/settings.php";
+ if (file_exists($settingspath)) {
+ $settings = new admin_settingpage('search' . $engine,
+ new lang_string('pluginname', 'search_' . $engine), 'moodle/site:config');
+ include($settingspath);
+ if ($settings) {
+ $pages[] = $settings;
+ }
+ }
+ }
+
+ // Setup status.
+ $temp->add(new admin_setting_searchsetupinfo());
+
+ // Search engine selection.
+ $temp->add(new admin_setting_heading('searchengineheading', new lang_string('searchengine', 'admin'), ''));
+ $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);
+
+ foreach ($pages as $page) {
+ $ADMIN->add('searchplugins', $page);
+ }
+}
+
/// Add all admin tools
if ($hassiteconfig) {
$ADMIN->add('modules', new admin_category('tools', new lang_string('tools', 'admin')));
$optionalsubsystems->add(new admin_setting_configcheckbox('enableplagiarism', new lang_string('enableplagiarism','plagiarism'), new lang_string('configenableplagiarism','plagiarism'), 0));
$optionalsubsystems->add(new admin_setting_configcheckbox('enablebadges', new lang_string('enablebadges', 'badges'), new lang_string('configenablebadges', 'badges'), 1));
+
+ $optionalsubsystems->add(new admin_setting_configcheckbox('enableglobalsearch', new lang_string('enableglobalsearch', 'admin'),
+ new lang_string('enableglobalsearch_desc', 'admin'), 0, 1, 0));
}
/**
* Legacy add_to_log() code.
+ * @deprecated since Moodle 3.1 MDL-45104 - Please use supported log stores such as "standard" or "external" instead.
+ * @todo MDL-52805 This will be removed in Moodle 3.3
*
* @param int $courseid The course id
* @param string $module The module name e.g. forum, journal, resource, course, user etc
try {
\core\task\manager::configure_scheduled_task($task);
- $url = $PAGE->url;
- $url->params(array('success'=>get_string('changessaved')));
- redirect($url);
+ redirect($PAGE->url, get_string('changessaved'), null, \core\output\notification::NOTIFY_SUCCESS);
} catch (Exception $e) {
- $url = $PAGE->url;
- $url->params(array('error'=>$e->getMessage()));
- redirect($url);
+ redirect($PAGE->url, $e->getMessage(), null, \core\output\notification::NOTIFY_ERROR);
}
} else {
echo $OUTPUT->header();
} else {
echo $OUTPUT->header();
- $error = optional_param('error', '', PARAM_NOTAGS);
- if ($error) {
- echo $OUTPUT->notification($error, 'notifyerror');
- }
- $success = optional_param('success', '', PARAM_NOTAGS);
- if ($success) {
- echo $OUTPUT->notification($success, 'notifysuccess');
- }
$tasks = core\task\manager::get_all_scheduled_tasks();
echo $renderer->scheduled_tasks_table($tasks);
echo $OUTPUT->footer();
}
-
-
-
-
// Change the theme to 'base' because it overrides these templates.
$CFG->theme = 'base';
- $template = external::load_canonical_template('core', 'notification_problem');
+ $template = external::load_canonical_template('core', 'notification_error');
// Only the base template should contain the docs.
- $this->assertContains('@template core/notification_problem', $template);
+ $this->assertContains('@template core/notification_error', $template);
// Restore the original theme.
$CFG->theme = $originaltheme;
unset($allcohorts);
if (count($cohorts) < 2) {
- echo $OUTPUT->header();
- echo $OUTPUT->heading(get_string('bulkadd', 'core_cohort'));
- echo $OUTPUT->notification(get_string('bulknocohort', 'core_cohort'));
- echo $OUTPUT->continue_button(new moodle_url('/admin/user/user_bulk.php'));
- echo $OUTPUT->footer();
- die;
+ redirect(new moodle_url('/admin/user/user_bulk.php'), get_string('bulknocohort', 'core_cohort'));
}
$countries = get_string_manager()->get_list_of_countries(true);
$url = new moodle_url('/badges/action.php', $params);
if (!$badge->has_criteria()) {
- echo $OUTPUT->notification(get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'));
- echo $OUTPUT->continue_button($returnurl);
+ redirect($returnurl, get_string('error:cannotact', 'badges') . get_string('nocriteria', 'badges'), null, \core\output\notification::NOTIFY_ERROR);
} else {
$message = get_string('reviewconfirm', 'badges', $badge->name);
echo $OUTPUT->confirm($message, $url, $returnurl);
--- /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/>.
+
+/**
+ * Global search block.
+ *
+ * @package block_globalsearch
+ * @copyright Prateek Sachan {@link http://prateeksachan.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Global search block.
+ *
+ * @package block_globalsearch
+ * @copyright Prateek Sachan {@link http://prateeksachan.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_globalsearch extends block_base {
+
+ /**
+ * Initialises the block.
+ *
+ * @return void
+ */
+ public function init() {
+ $this->title = get_string('pluginname', 'block_globalsearch');
+ }
+
+ /**
+ * Gets the block contents.
+ *
+ * If we can avoid it better not check the server status here as connecting
+ * to the server will slow down the whole page load.
+ *
+ * @return string The block HTML.
+ */
+ public function get_content() {
+ global $OUTPUT;
+ if ($this->content !== null) {
+ return $this->content;
+ }
+
+ $this->content = new stdClass();
+ $this->content->footer = '';
+
+ if (\core_search\manager::is_global_search_enabled() === false) {
+ $this->content->text = get_string('globalsearchdisabled', 'search');
+ return $this->content;
+ }
+
+ $url = new moodle_url('/search/index.php');
+ $this->content->footer .= html_writer::link($url, get_string('advancedsearch', 'search'));
+
+ $this->content->text = html_writer::start_tag('div', array('class' => 'searchform'));
+ $this->content->text .= html_writer::start_tag('form', array('action' => $url->out()));
+ $this->content->text .= html_writer::start_tag('fieldset', array('action' => 'invisiblefieldset'));
+
+ // Input.
+ $this->content->text .= html_writer::tag('label', get_string('search', 'search'),
+ array('for' => 'searchform_search', 'class' => 'accesshide'));
+ $inputoptions = array('id' => 'searchform_search', 'name' => 'q', 'type' => 'text', 'size' => '15');
+ $this->content->text .= html_writer::empty_tag('input', $inputoptions);
+
+ // Search button.
+ $this->content->text .= html_writer::tag('button', get_string('search', 'search'),
+ array('id' => 'searchform_button', 'type' => 'submit', 'title' => 'globalsearch'));
+ $this->content->text .= html_writer::end_tag('fieldset');
+ $this->content->text .= html_writer::end_tag('form');
+ $this->content->text .= html_writer::end_tag('div');
+
+ return $this->content;
+ }
+}
--- /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/>.
+
+/**
+ * Global search Block caps.
+ *
+ * @package block_globalsearch
+ * @copyright Prateek Sachan {@link http://prateeksachan.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+ 'block/globalsearch:myaddinstance' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'archetypes' => array(
+ 'user' => CAP_ALLOW
+ ),
+
+ 'clonepermissionsfrom' => 'moodle/my:manageblocks'
+ ),
+
+ 'block/globalsearch:addinstance' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_BLOCK,
+ 'archetypes' => array(
+ 'manager' => CAP_ALLOW
+ ),
+
+ 'clonepermissionsfrom' => 'moodle/site:manageblocks'
+ ),
+);
--- /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/>.
+
+/**
+ * Strings for component 'block_globalsearch'.
+ *
+ * @package block_globalsearch
+ * @copyright Prateek Sachan {@link http://prateeksachan.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['globalsearch:addinstance'] = 'Add a new global search block';
+$string['globalsearch:myaddinstance'] = 'Add a new global search block to Dashboard';
+$string['pluginname'] = 'Global search';
--- /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/>.
+
+/**
+ * Global Search version details.
+ *
+ * @package block_globalsearch
+ * @copyright Prateek Sachan {@link http://prateeksachan.com}
+ * @copyright Daniel Neis
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die;
+
+$plugin->version = 2016012000;
+$plugin->requires = 2015111000;
+$plugin->component = 'block_globalsearch';
// Turn our navigation items into list items.
$lis = array();
- $number = 0;
+ // Set the number to be static for unique id's.
+ static $number = 0;
foreach ($items as $item) {
$number++;
if (!$item->display && !$item->contains_active_node()) {
* Sets the identifiers for this definition, or updates them if they have already been set.
*
* @param array $identifiers
+ * @return bool false if no identifiers where changed, true otherwise.
* @throws coding_exception
*/
public function set_identifiers(array $identifiers = array()) {
// If we are setting the exact same identifiers then just return as nothing really changed.
// We don't care about order as cache::make will use the same definition order all the time.
if ($identifiers === $this->identifiers) {
- return;
+ return false;
}
foreach ($this->requireidentifiers as $identifier) {
// Reset the key prefix's they need updating now.
$this->keyprefixsingle = null;
$this->keyprefixmulti = null;
+
+ return true;
}
/**
foreach ($keyvaluearray as $pair) {
$this->store[$pair['key']] = $pair['value'];
}
- return count($keyvaluearray);
+
}
- return 0;
+ return count($keyvaluearray);
}
/**
* @param array $identifiers
*/
public function set_identifiers(array $identifiers) {
- $this->definition->set_identifiers($identifiers);
+ if ($this->definition->set_identifiers($identifiers)) {
+ // As static acceleration uses input keys and not parsed keys
+ // it much be cleared when the identifier set is changed.
+ $this->staticaccelerationarray = array();
+ if ($this->staticaccelerationsize !== false) {
+ $this->staticaccelerationkeys = array();
+ $this->staticaccelerationcount = 0;
+ }
+ }
}
/**
* @throws coding_exception
*/
public function get($key, $strictness = IGNORE_MISSING) {
- // 1. Parse the key.
- $parsedkey = $this->parse_key($key);
- // 2. Get it from the static acceleration array if we can (only when it is enabled and it has already been requested/set).
- $result = false;
- if ($this->use_static_acceleration()) {
- $result = $this->static_acceleration_get($parsedkey);
- }
- if ($result !== false) {
- if (!is_scalar($result)) {
- // If data is an object it will be a reference.
- // If data is an array if may contain references.
- // We want to break references so that the cache cannot be modified outside of itself.
- // Call the function to unreference it (in the best way possible).
- $result = $this->unref($result);
+ // 1. Get it from the static acceleration array if we can (only when it is enabled and it has already been requested/set).
+ $usesstaticacceleration = $this->use_static_acceleration();
+
+ if ($usesstaticacceleration) {
+ $result = $this->static_acceleration_get($key);
+ if ($result !== false) {
+ return $result;
}
- return $result;
}
+
+ // 2. Parse the key.
+ $parsedkey = $this->parse_key($key);
+
// 3. Get it from the store. Obviously wasn't in the static acceleration array.
$result = $this->store->get($parsedkey);
if ($result !== false) {
if ($result instanceof cache_cached_object) {
$result = $result->restore_object();
}
- if ($this->use_static_acceleration()) {
- $this->static_acceleration_set($parsedkey, $result);
+ if ($usesstaticacceleration) {
+ $this->static_acceleration_set($key, $result);
}
}
+
// 4. Load if from the loader/datasource if we don't already have it.
$setaftervalidation = false;
if ($result === false) {
}
// 7. Make sure we don't pass back anything that could be a reference.
// We don't want people modifying the data in the cache.
- if (!is_scalar($result)) {
+ if (!$this->store->supports_dereferencing_objects() && !is_scalar($result)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
$parsedkeys[$pkey] = $key;
$keystofind[$pkey] = $key;
if ($isusingpersist) {
- $value = $this->static_acceleration_get($pkey);
+ $value = $this->static_acceleration_get($key);
if ($value !== false) {
$resultpersist[$pkey] = $value;
unset($keystofind[$pkey]);
$value = $value->restore_object();
}
if ($value !== false && $this->use_static_acceleration()) {
- $this->static_acceleration_set($key, $value);
+ $this->static_acceleration_set($keystofind[$key], $value);
}
$resultstore[$key] = $value;
}
// Create an array with the original keys and the found values. This will be what we return.
$fullresult = array();
foreach ($result as $key => $value) {
+ if (!is_scalar($value)) {
+ // If data is an object it will be a reference.
+ // If data is an array if may contain references.
+ // We want to break references so that the cache cannot be modified outside of itself.
+ // Call the function to unreference it (in the best way possible).
+ $value = $this->unref($value);
+ }
$fullresult[$parsedkeys[$key]] = $value;
}
unset($result);
// We have to let the loader do its own parsing of data as it may be unique.
$this->loader->set($key, $data);
}
+ $usestaticacceleration = $this->use_static_acceleration();
+
if (is_object($data) && $data instanceof cacheable_object) {
$data = new cache_cached_object($data);
- } else if (!is_scalar($data)) {
+ } else if (!$this->store->supports_dereferencing_objects() && !is_scalar($data)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
// Call the function to unreference it (in the best way possible).
$data = $this->unref($data);
}
+
+ if ($usestaticacceleration) {
+ $this->static_acceleration_set($key, $data);
+ }
+
if ($this->has_a_ttl() && !$this->store_supports_native_ttl()) {
$data = new cache_ttl_wrapper($data, $this->definition->get_ttl());
}
$parsedkey = $this->parse_key($key);
- if ($this->use_static_acceleration()) {
- $this->static_acceleration_set($parsedkey, $data);
- }
+
return $this->store->set($parsedkey, $data);
}
$data = array();
$simulatettl = $this->has_a_ttl() && !$this->store_supports_native_ttl();
$usestaticaccelerationarray = $this->use_static_acceleration();
+ $needsdereferencing = !$this->store->supports_dereferencing_objects();
foreach ($keyvaluearray as $key => $value) {
if (is_object($value) && $value instanceof cacheable_object) {
$value = new cache_cached_object($value);
- } else if (!is_scalar($value)) {
+ } else if ($needsdereferencing && !is_scalar($value)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
// Call the function to unreference it (in the best way possible).
$value = $this->unref($value);
}
+ if ($usestaticaccelerationarray) {
+ $this->static_acceleration_set($key, $value);
+ }
if ($simulatettl) {
$value = new cache_ttl_wrapper($value, $this->definition->get_ttl());
}
'key' => $this->parse_key($key),
'value' => $value
);
- if ($usestaticaccelerationarray) {
- $this->static_acceleration_set($data[$key]['key'], $value);
- }
}
$successfullyset = $this->store->set_many($data);
if ($this->perfdebug && $successfullyset) {
* @return bool True if the cache has the requested key, false otherwise.
*/
public function has($key, $tryloadifpossible = false) {
- $parsedkey = $this->parse_key($key);
- if ($this->static_acceleration_has($parsedkey)) {
+ if ($this->static_acceleration_has($key)) {
// Hoorah, that was easy. It exists in the static acceleration array so we definitely have it.
return true;
}
+ $parsedkey = $this->parse_key($key);
+
if ($this->has_a_ttl() && !$this->store_supports_native_ttl()) {
// The data has a TTL and the store doesn't support it natively.
// We must fetch the data and expect a ttl wrapper.
}
if ($this->use_static_acceleration()) {
- $parsedkeys = array();
foreach ($keys as $id => $key) {
- $parsedkey = $this->parse_key($key);
- if ($this->static_acceleration_has($parsedkey)) {
+ if ($this->static_acceleration_has($key)) {
return true;
}
- $parsedkeys[] = $parsedkey;
}
- } else {
- $parsedkeys = array_map(array($this, 'parse_key'), $keys);
}
+ $parsedkeys = array_map(array($this, 'parse_key'), $keys);
return $this->store->has_any($parsedkeys);
}
* @return bool True of success, false otherwise.
*/
public function delete($key, $recurse = true) {
- $parsedkey = $this->parse_key($key);
- $this->static_acceleration_delete($parsedkey);
+ $this->static_acceleration_delete($key);
if ($recurse && $this->loader !== false) {
// Delete from the bottom of the stack first.
$this->loader->delete($key, $recurse);
}
+ $parsedkey = $this->parse_key($key);
return $this->store->delete($parsedkey);
}
* @return int The number of items successfully deleted.
*/
public function delete_many(array $keys, $recurse = true) {
- $parsedkeys = array_map(array($this, 'parse_key'), $keys);
if ($this->use_static_acceleration()) {
- foreach ($parsedkeys as $parsedkey) {
- $this->static_acceleration_delete($parsedkey);
+ foreach ($keys as $key) {
+ $this->static_acceleration_delete($key);
}
}
if ($recurse && $this->loader !== false) {
// Delete from the bottom of the stack first.
$this->loader->delete_many($keys, $recurse);
}
+ $parsedkeys = array_map(array($this, 'parse_key'), $keys);
return $this->store->delete_many($parsedkeys);
}
* @return bool
*/
protected function static_acceleration_has($key) {
- // This method of checking if an array was supplied is faster than is_array.
- if ($key === (array)$key) {
- $key = $key['key'];
- }
// This could be written as a single line, however it has been split because the ttl check is faster than the instanceof
// and has_expired calls.
- if (!$this->staticacceleration || !array_key_exists($key, $this->staticaccelerationarray)) {
+ if (!$this->staticacceleration || !isset($this->staticaccelerationarray[$key])) {
return false;
}
- if ($this->has_a_ttl() && $this->store_supports_native_ttl()) {
- return !($this->staticaccelerationarray[$key] instanceof cache_ttl_wrapper &&
- $this->staticaccelerationarray[$key]->has_expired());
- }
return true;
}
* Returns the item from the static acceleration array if it exists there.
*
* @param string $key The parsed key
- * @return mixed|false The data from the static acceleration array or false if it wasn't there.
+ * @return mixed|false Dereferenced data from the static acceleration array or false if it wasn't there.
*/
protected function static_acceleration_get($key) {
- // This method of checking if an array was supplied is faster than is_array.
- if ($key === (array)$key) {
- $key = $key['key'];
- }
- // This isset check is faster than array_key_exists but will return false
- // for null values, meaning null values will come from backing store not
- // the static acceleration array. We think this okay because null usage should be
- // very rare (see comment in MDL-39472).
if (!$this->staticacceleration || !isset($this->staticaccelerationarray[$key])) {
$result = false;
} else {
- $data = $this->staticaccelerationarray[$key];
- if (!$this->has_a_ttl() || !$data instanceof cache_ttl_wrapper) {
- if ($data instanceof cache_cached_object) {
- $data = $data->restore_object();
- }
- $result = $data;
- } else if ($data->has_expired()) {
- $this->static_acceleration_delete($key);
- $result = false;
+ $data = $this->staticaccelerationarray[$key]['data'];
+
+ if ($data instanceof cache_cached_object) {
+ $result = $data->restore_object();
+ } else if ($this->staticaccelerationarray[$key]['serialized']) {
+ $result = unserialize($data);
} else {
- if ($data instanceof cache_cached_object) {
- $data = $data->restore_object();
- }
- $result = $data->data;
+ $result = $data;
}
}
if ($result) {
* @return bool
*/
protected function static_acceleration_set($key, $data) {
- // This method of checking if an array was supplied is faster than is_array.
- if ($key === (array)$key) {
- $key = $key['key'];
- }
if ($this->staticaccelerationsize !== false && isset($this->staticaccelerationkeys[$key])) {
$this->staticaccelerationcount--;
unset($this->staticaccelerationkeys[$key]);
}
- $this->staticaccelerationarray[$key] = $data;
+
+ // We serialize anything that's not;
+ // 1. A known scalar safe value.
+ // 2. A definition that says it's simpledata. We trust it that it doesn't contain dangerous references.
+ // 3. An object that handles dereferencing by itself.
+ if (is_scalar($data) || $this->definition->uses_simple_data()
+ || $data instanceof cache_cached_object) {
+ $this->staticaccelerationarray[$key]['data'] = $data;
+ $this->staticaccelerationarray[$key]['serialized'] = false;
+ } else {
+ $this->staticaccelerationarray[$key]['data'] = serialize($data);
+ $this->staticaccelerationarray[$key]['serialized'] = true;
+ }
if ($this->staticaccelerationsize !== false) {
$this->staticaccelerationcount++;
$this->staticaccelerationkeys[$key] = $key;
*/
protected function static_acceleration_delete($key) {
unset($this->staticaccelerationarray[$key]);
- if ($this->staticaccelerationsize !== false) {
- $dropkey = array_search($key, $this->staticaccelerationkeys);
- if ($dropkey) {
- unset($this->staticaccelerationkeys[$dropkey]);
- $this->staticaccelerationcount--;
- }
+ if ($this->staticaccelerationsize !== false && isset($this->staticaccelerationkeys[$key])) {
+ unset($this->staticaccelerationkeys[$key]);
+ $this->staticaccelerationcount--;
}
return true;
}
}
// 6. Make sure we don't pass back anything that could be a reference.
// We don't want people modifying the data in the cache.
- if (!is_scalar($result)) {
+ if (!$this->get_store()->supports_dereferencing_objects() && !is_scalar($result)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
}
if (is_object($data) && $data instanceof cacheable_object) {
$data = new cache_cached_object($data);
- } else if (!is_scalar($data)) {
+ } else if (!$this->get_store()->supports_dereferencing_objects() && !is_scalar($data)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
if ($value instanceof cache_cached_object) {
/* @var cache_cached_object $value */
$value = $value->restore_object();
+ } else if (!$this->get_store()->supports_dereferencing_objects() && !is_scalar($value)) {
+ // If data is an object it will be a reference.
+ // If data is an array if may contain references.
+ // We want to break references so that the cache cannot be modified outside of itself.
+ // Call the function to unreference it (in the best way possible).
+ $value = $this->unref($value);
}
$return[$key] = $value;
if ($value === false) {
foreach ($keyvaluearray as $key => $value) {
if (is_object($value) && $value instanceof cacheable_object) {
$value = new cache_cached_object($value);
- } else if (!is_scalar($value)) {
+ } else if (!$this->get_store()->supports_dereferencing_objects() && !is_scalar($value)) {
// If data is an object it will be a reference.
// If data is an array if may contain references.
// We want to break references so that the cache cannot be modified outside of itself.
*/
const IS_SEARCHABLE = 8;
+ /**
+ * The cache store dereferences objects.
+ *
+ * When set, loaders will assume that all data coming from this store has already had all references
+ * resolved. So even for complex object structures it will not try to remove references again.
+ */
+ const DEREFERENCES_OBJECTS = 16;
+
// Constants for the modes of a cache store
/**
return in_array('cache_is_searchable', class_implements($this));
}
+ /**
+ * Returns true if the store automatically dereferences objects.
+ *
+ * @return bool
+ */
+ public function supports_dereferencing_objects() {
+ return $this::get_supported_features() & self::DEREFERENCES_OBJECTS;
+ }
+
/**
* Creates a clone of this store instance ready to be initialised.
*
public static function get_supported_features(array $configuration = array()) {
$supported = self::SUPPORTS_DATA_GUARANTEE +
self::SUPPORTS_NATIVE_TTL +
- self::IS_SEARCHABLE;
+ self::IS_SEARCHABLE +
+ self::DEREFERENCES_OBJECTS;
return $supported;
}
* @return int
*/
public static function get_supported_features(array $configuration = array()) {
- return self::SUPPORTS_NATIVE_TTL;
+ return self::SUPPORTS_NATIVE_TTL + self::DEREFERENCES_OBJECTS;
}
/**
* @return int
*/
public static function get_supported_features(array $configuration = array()) {
- return self::SUPPORTS_NATIVE_TTL;
+ return self::SUPPORTS_NATIVE_TTL + self::DEREFERENCES_OBJECTS;
}
/**
* @return int
*/
public static function get_supported_features(array $configuration = array()) {
- $supports = self::SUPPORTS_DATA_GUARANTEE;
+ $supports = self::SUPPORTS_DATA_GUARANTEE + self::DEREFERENCES_OBJECTS;
if (array_key_exists('extendedmode', $configuration) && $configuration['extendedmode']) {
$supports += self::SUPPORTS_MULTIPLE_IDENTIFIERS;
}
$this->assertEquals('pork', $var->subobj->subobj->key);
$this->assertTrue($cache->delete('obj'));
- // Death reference test... basicaly we don't want this to die.
+ // Death reference test... basically we don't want this to die.
$obj = new stdClass;
$obj->key = 'value';
$obj->self =& $obj;
$this->assertTrue($cache->delete('obj'));
+ // Death reference test on get_many... basically we don't want this to die.
+ $obj = new stdClass;
+ $obj->key = 'value';
+ $obj->self =& $obj;
+ $this->assertEquals(1, $cache->set_many(array('obj' => $obj)));
+ $var = $cache->get_many(array('obj'));
+ $this->assertInstanceOf('stdClass', $var['obj']);
+ $this->assertEquals('value', $var['obj']->key);
+
+ // Reference test after retrieve.
+ $obj = new stdClass;
+ $obj->key = 'value';
+ $this->assertEquals(1, $cache->set_many(array('obj' => $obj)));
+
+ $var1 = $cache->get_many(array('obj'));
+ $this->assertInstanceOf('stdClass', $var1['obj']);
+ $this->assertEquals('value', $var1['obj']->key);
+ $var1['obj']->key = 'eulav';
+ $this->assertEquals('eulav', $var1['obj']->key);
+
+ $var2 = $cache->get_many(array('obj'));
+ $this->assertInstanceOf('stdClass', $var2['obj']);
+ $this->assertEquals('value', $var2['obj']->key);
+
+ $this->assertTrue($cache->delete('obj'));
+
// Test strictness exceptions.
try {
$cache->get('exception', MUST_EXIST);
* @return false|mixed
*/
public function phpunit_static_acceleration_get($key) {
- $key = $this->parse_key($key);
return $this->static_acceleration_get($key);
}
}
This files describes API changes in /cache/stores/* - cache store plugins.
Information provided here is intended especially for developers.
+=== 3.1 ===
+* Cache stores has a new feature DEREFERENCES_OBJECTS.
+ This allows the cache loader to decide if it needs to handle dereferencing or whether the data
+ coming directly to it has already had references resolved.
+ - see supports_dereferencing_objects in store.php.
+
=== 2.9 ===
* Cache data source aggregation functionality has been removed. This functionality was found to be broken and unused.
It was decided that rather than fixing it it should be removed.
echo $OUTPUT->header();
echo $OUTPUT->heading($strdeletingcourse);
+ // This might take a while. Raise the execution time limit.
+ core_php_time_limit::raise();
// We do this here because it spits out feedback as it goes.
delete_course($course);
echo $OUTPUT->heading( get_string("deletedcourse", "", $courseshortname) );
$mform->addGroup($elementgroup, 'name_group', get_string('sectionname'), ' ', false);
$mform->addGroupRule('name_group', array('name' => array(array(get_string('maximumchars', '', 255), 'maxlength', 255))));
- // Add rule for name_group to make sure that the section name is not blank if 'Use default section name'
- // checkbox is unchecked.
- $mform->addRule('name_group', get_string('required'), 'required', null, 'client');
-
$mform->setDefault('usedefaultname', true);
$mform->setType('name', PARAM_TEXT);
$mform->disabledIf('name','usedefaultname','checked');
$editoroptions = $this->_customdata['editoroptions'];
$default_values = file_prepare_standard_editor($default_values, 'summary', $editoroptions,
$editoroptions['context'], 'course', 'section', $default_values->id);
- $default_values->usedefaultname = (is_null($default_values->name));
+ $default_values->usedefaultname = (strval($default_values->name) === '');
parent::set_data($default_values);
}
$data = parent::get_data();
if ($data !== null) {
$editoroptions = $this->_customdata['editoroptions'];
+ // Set name as an empty string if use default section name is checked.
if (!empty($data->usedefaultname)) {
- $data->name = null;
+ $data->name = '';
}
$data = file_postupdate_standard_editor($data, 'summary', $editoroptions,
$editoroptions['context'], 'course', 'section', $data->id);
\core_availability\frontend::report_validation_errors($data, $errors);
}
- // Validate section name if 'Use default section name' is unchecked.
- if (empty($data['usedefaultname'])) {
- // Make sure the trimmed value of section name is not empty.
- $trimmedname = trim($data['name']);
- if (empty($trimmedname)) {
- $errors['name_group'] = get_string('required');
- }
- }
-
return $errors;
}
}
return array(
new Given('I add a "' . $this->escape($activity) . '" to section "' . $this->escape($section) . '"'),
+ new Given('I wait to be redirected'),
new Given('I set the following fields to these values:', $data),
new Given('I press "' . get_string('savechangesandreturntocourse') . '"')
);
$courseid = required_param('id', PARAM_INT);
$action = optional_param('action', 0, PARAM_ALPHA);
$eid = optional_param('eid', 0, PARAM_ALPHANUM);
-$category = optional_param('category', null, PARAM_INT);
-$aggregationtype = optional_param('aggregationtype', null, PARAM_INT);
+$weightsadjusted = optional_param('weightsadjusted', 0, PARAM_INT);
$url = new moodle_url('/grade/edit/tree/index.php', array('id' => $courseid));
$PAGE->set_url($url);
$gpr = new grade_plugin_return(array('type'=>'edit', 'plugin'=>'tree', 'courseid'=>$courseid));
$returnurl = $gpr->get_return_url(null);
-// Change category aggregation if requested
-if (!is_null($category) && !is_null($aggregationtype) && confirm_sesskey()) {
- if (!$grade_category = grade_category::fetch(array('id'=>$category, 'courseid'=>$courseid))) {
- print_error('invalidcategoryid');
- }
-
- $data = new stdClass();
- $data->aggregation = $aggregationtype;
- grade_category::set_properties($grade_category, $data);
- $grade_category->update();
-
- grade_regrade_final_grades($courseid);
-}
-
-//first make sure we have proper final grades - we need it for locking changes
-$normalisationmessage = null;
-
-$originalweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
-
-grade_regrade_final_grades($courseid);
-
-$alteredweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
-
-if (array_diff($originalweights, $alteredweights)) {
- $normalisationmessage = get_string('weightsadjusted', 'grades');
-}
-
// get the grading tree object
// note: total must be first for moving to work correctly, if you want it last moving code must be rewritten!
$gtree = new grade_tree($courseid, false, false);
$recreatetree = true;
}
}
+}
- $originalweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
+$originalweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
- grade_regrade_final_grades($courseid);
+/**
+ * Callback function to adjust the URL if weights changed after the
+ * regrade.
+ *
+ * @param int $courseid The course ID
+ * @param array $originalweights The weights before the regrade
+ * @param int $weightsadjusted Whether weights have been adjusted
+ * @return moodle_url A URL to redirect to after regrading when a progress bar is displayed.
+ */
+$grade_edit_tree_index_checkweights = function() use ($courseid, $originalweights, &$weightsadjusted) {
+ global $PAGE;
$alteredweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
if (array_diff($originalweights, $alteredweights)) {
- $normalisationmessage = get_string('weightsadjusted', 'grades');
+ $weightsadjusted = 1;
+ return new moodle_url($PAGE->url, array('weightsadjusted' => $weightsadjusted));
}
+ return $PAGE->url;
+};
+
+if (grade_regrade_final_grades_if_required($course, $grade_edit_tree_index_checkweights)) {
+ $recreatetree = true;
}
print_grade_page_head($courseid, 'settings', 'setup', get_string('gradebooksetup', 'grades'));
if ($recreatetree) {
$grade_edit_tree = new grade_edit_tree($gtree, $movingeid, $gpr);
}
+
// Check to see if we have a normalisation message to send.
-if (!empty($normalisationmessage)) {
- echo $OUTPUT->notification($normalisationmessage, 'notifymessage');
+if ($weightsadjusted) {
+ echo $OUTPUT->notification(get_string('weightsadjusted', 'grades'), 'notifymessage');
}
echo html_writer::table($grade_edit_tree->table);
* @param $courseid int The course being exported
*/
function export_verify_grades($courseid) {
- $regraderesult = grade_regrade_final_grades($courseid);
- if (is_array($regraderesult)) {
- throw new moodle_exception('gradecantregrade', 'error', '', implode(', ', array_unique($regraderesult)));
+ if (grade_needs_regrade_final_grades($courseid)) {
+ throw new moodle_exception('gradesneedregrading', 'grades');
}
}
if (!strlen(trim($criterion['maxscore']))) {
$errors['err_nomaxscore'] = 1;
$criterion['error_description'] = true;
- } else if (!is_numeric($criterion['maxscore']) || $criterion['maxscore'] < 0) {
+ } else if (!is_numeric($criterion['maxscore'])) {
$errors['err_maxscorenotnumeric'] = 1;
$criterion['error_description'] = true;
+ } else if ($criterion['maxscore'] < 0) {
+ $errors['err_maxscoreisnegative'] = 1;
+ $criterion['error_description'] = true;
}
}
if (array_key_exists('moveup', $criterion) || $lastaction == 'movedown') {
$string['description'] = 'Description';
$string['descriptionmarkers'] = 'Description for Markers';
$string['descriptionstudents'] = 'Description for Students';
+$string['err_maxscoreisnegative'] = 'The max score is not valid, negative values are not allowed';
$string['err_maxscorenotnumeric'] = 'Criterion max score must be numeric';
$string['err_nocomment'] = 'Comment can not be empty';
$string['err_nodescription'] = 'Student description can not be empty';
$string['err_nomaxscore'] = 'Criterion max score can not be empty';
$string['err_noshortname'] = 'Criterion name can not be empty';
$string['err_shortnametoolong'] = 'Criterion name must be less than 256 characters';
-$string['err_scoreinvalid'] = 'The score given to {$a->criterianame} is not valid, the max score is: {$a->maxscore}';
+$string['err_scoreinvalid'] = 'The score given to \'{$a->criterianame}\' is not valid, the max score is: {$a->maxscore}';
+$string['err_scoreisnegative'] = 'The score given to \'{$a->criterianame}\' is not valid, negative values are not allowed';
$string['gradingof'] = '{$a} grading';
$string['guide'] = 'Marking guide';
$string['guidemappingexplained'] = 'WARNING: Your marking guide has a maximum grade of <b>{$a->maxscore} points</b>Â but the maximum grade set in your activity is {$a->modulegrade} The maximum score set in your marking guide will be scaled to the maximum grade in the module.<br />
|| $criterion['maxscore'] < $elementvalue['criteria'][$id]['score']
|| !is_numeric($elementvalue['criteria'][$id]['score'])
|| $elementvalue['criteria'][$id]['score'] < 0) {
- $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score'];
+ $this->validationerrors[$id]['score'] = $elementvalue['criteria'][$id]['score'];
}
}
if (!empty($this->validationerrors)) {
$a = new stdClass();
$a->criterianame = s($criteria[$id]['shortname']);
$a->maxscore = $criteria[$id]['maxscore'];
- $html .= html_writer::tag('div', get_string('err_scoreinvalid', 'gradingform_guide', $a),
+ if ($this->validationerrors[$id]['score'] < 0) {
+ $html .= html_writer::tag('div', get_string('err_scoreisnegative', 'gradingform_guide', $a),
array('class' => 'gradingform_guide-error'));
+ } else {
+ $html .= html_writer::tag('div', get_string('err_scoreinvalid', 'gradingform_guide', $a),
+ array('class' => 'gradingform_guide-error'));
+ }
}
}
}
break;
default:
if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FROZEN && $value) {
+ // Id should be different then the actual input added later.
+ $attrs['id'] .= '_hidden';
$html .= html_writer::empty_tag('input', $attrs + array('type' => 'hidden', 'value' => $value));
}
// Display option as checkbox
if ($mode == gradingform_rubric_controller::DISPLAY_EDIT_FROZEN || $mode == gradingform_rubric_controller::DISPLAY_PREVIEW) {
$attrs['disabled'] = 'disabled';
unset($attrs['name']);
+ // Id should be different then the actual input added later.
+ $attrs['id'] .= '_disabled';
}
$html .= html_writer::empty_tag('input', $attrs);
$html .= html_writer::tag('label', get_string($option, 'gradingform_rubric'), array('for' => $attrs['id']));
grade_extend_settings($plugin_info, $courseid);
}
+ // Set the current report as active in the breadcrumbs.
+ if ($active_plugin !== null && $reportnav = $PAGE->settingsnav->find($active_plugin, navigation_node::TYPE_SETTING)) {
+ $reportnav->make_active();
+ }
+
$returnval = $OUTPUT->header();
if (!$return) {
set_user_preferences(array('grade_report_show'.$toggle_type => $toggle));
}
-//first make sure we have proper final grades - this must be done before constructing of the grade tree
-grade_regrade_final_grades($courseid);
-
// Perform actions
if (!empty($target) && !empty($action) && confirm_sesskey()) {
grade_report_grader::do_process_action($target, $action, $courseid);
$reportname = get_string('pluginname', 'gradereport_grader');
+// Do this check just before printing the grade header (and only do it once).
+grade_regrade_final_grades_if_required($course);
+
// Print header
print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons);
}
$name = shorten_text($element['object']->get_name());
- $courseheader = html_writer::tag('span', $name, array('id' => 'courseheader'));
- $courseheader .= html_writer::label($showing, 'courseheader', false, array('class' => 'accesshide'));
+ $courseheaderid = 'courseheader_' . clean_param($name, PARAM_ALPHANUMEXT);
+ $courseheader = html_writer::tag('span', $name, array('id' => $courseheaderid));
+ $courseheader .= html_writer::label($showing, $courseheaderid, false, array('class' => 'accesshide'));
$courseheader .= $icon;
return $courseheader;
var userCells = Y.all(SELECTORS.USERCELL);
this.userColumnHeader.one('.cell').setStyle('width', userWidth);
this.userColumn.all('.cell').each(function(cell, idx) {
+ var height = userCells.item(idx).getComputedStyle(HEIGHT);
+ // Nasty hack to account for Internet Explorer
+ if(Y.UA.ie !== 0) {
+ var node = userCells.item(idx);
+ var allHeight = node.getDOMNode ?
+ node.getDOMNode().getBoundingClientRect().height :
+ node.get('offsetHeight');
+ var marginHeight = parseInt(node.getComputedStyle('marginTop'),10) +
+ parseInt(node.getComputedStyle('marginBottom'),10);
+ var paddingHeight = parseInt(node.getComputedStyle('paddingTop'),10) +
+ parseInt(node.getComputedStyle('paddingBottom'),10);
+ var borderHeight = parseInt(node.getComputedStyle('borderTopWidth'),10) +
+ parseInt(node.getComputedStyle('borderBottomWidth'),10);
+ height = allHeight - marginHeight - paddingHeight - borderHeight;
+ }
cell.setStyles({
width: userWidth,
- height: userCells.item(idx).getComputedStyle(HEIGHT)
+ height: height
});
}, this);
require_capability('gradereport/outcomes:view', $context);
// First make sure we have proper final grades.
-grade_regrade_final_grades($courseid);
+grade_regrade_final_grades_if_required($course);
// Grab all outcomes used in course.
$report_info = array();
}
$USER->grade_last_report[$course->id] = 'overview';
-//first make sure we have proper final grades - this must be done before constructing of the grade tree
-grade_regrade_final_grades($courseid);
+// First make sure we have proper final grades.
+grade_regrade_final_grades_if_required($course);
if (has_capability('moodle/grade:viewall', $context) && $courseid != SITEID) {
// Please note this would be extremely slow if we wanted to implement this properly for all teachers.
}
$courseparams = array('id' => $courseid);
-$PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $courseparams));
+$pageparams = array(
+ 'id' => $courseid,
+ 'group' => $groupid,
+ 'userid' => $userid,
+ 'itemid' => $itemid,
+ 'item' => $itemtype,
+ 'page' => $page,
+ 'perpage' => $perpage,
+ );
+$PAGE->set_url(new moodle_url('/grade/report/singleview/index.php', $pageparams));
$PAGE->set_pagelayout('incourse');
if (!$course = $DB->get_record('course', $courseparams)) {
}
$USER->grade_last_report[$course->id] = 'singleview';
-// First make sure we have proper final grades -
-// this must be done before constructing of the grade tree.
-grade_regrade_final_grades($courseid);
+// First make sure we have proper final grades.
+grade_regrade_final_grades_if_required($course);
$report = new gradereport_singleview($courseid, $gpr, $context, $itemtype, $itemid);
| assign | C1 | a3 | Test assignment three | Submit something! |
| assign | C1 | a4 | Test assignment four | Submit nothing! |
- @javascript
Scenario: I can bulk insert grades and check their override flags for grade view.
Given I log in as "teacher1"
And I follow "Course 1"
And I follow "Single view for Test assignment one"
Then the field "Grade for james (Student) 1" matches value "50.00"
And the field "Override for james (Student) 1" matches value "0"
- And I click on "Perform bulk insert" "checkbox"
+ And I set the field "Perform bulk insert" to "1"
And I set the field "Insert value" to "1.0"
And I press "Save"
And I press "Continue"
And the field "Override for anna (Student) 3" matches value "1"
And the field "Grade for zac (Student) 4" matches value "1.00"
And the field "Override for zac (Student) 4" matches value "1"
- And I click on "All grades" "option"
- And I click on "Perform bulk insert" "checkbox"
+ And I set the field "For" to "All grades"
+ And I set the field "Perform bulk insert" to "1"
And I set the field "Insert value" to "2.0"
And I press "Save"
And I press "Continue"
And the field "Grade for zac (Student) 4" matches value "2.00"
And the field "Override for zac (Student) 4" matches value "1"
- @javascript
Scenario: I can bulk insert grades and check their override flags for user view.
Given I log in as "teacher1"
And I follow "Course 1"
And I press "Continue"
And I follow "View gradebook"
And I follow "Single view for Test assignment two"
- And I click on "Student 1" "option"
+ And I select "Student 1" from the "Select user..." singleselect
Then the field "Grade for Test assignment two" matches value "50.00"
And the field "Override for Test assignment two" matches value "0"
- And I click on "Perform bulk insert" "checkbox"
- And I click on "Empty grades" "option"
+ And I set the field "For" to "Empty grades"
+ And I set the field "Perform bulk insert" to "1"
And I set the field "Insert value" to "1.0"
And I press "Save"
And I press "Continue"
@javascript
Scenario: I can update grades, add feedback and exclude grades.
- Given I click on "Single view" "option"
- And I click on "Student 4" "option"
- And I click on "Override for Test assignment one" "checkbox"
+ Given I select "Single view" from the "Grade report" singleselect
+ And I select "Student 4" from the "Select user..." singleselect
+ And I set the field "Override for Test assignment one" to "1"
When I set the following fields to these values:
| Grade for Test assignment one | 10.00 |
| Feedback for Test assignment one | test data |
- And I click on "Exclude for Test assignment four" "checkbox"
+ And I set the field "Exclude for Test assignment four" to "1"
And I press "Save"
Then I should see "Grades were set for 2 items"
And I press "Continue"
And I set the following fields to these values:
| Grade for james (Student) 1 | 12.05 |
| Feedback for james (Student) 1 | test data2 |
- And I click on "Exclude for holly (Student) 2" "checkbox"
+ And I set the field "Exclude for holly (Student) 2" to "1"
And I press "Save"
Then I should see "Grades were set for 2 items"
And I press "Continue"
And the field "Grade for james (Student) 1" matches value "12.05"
And the field "Exclude for holly (Student) 2" matches value "1"
- And I click on "Single view" "link"
- And I click on "new grade item 1" "option"
+ And I select "new grade item 1" from the "Select grade item..." singleselect
And I click on "Very good" "option"
And I press "Save"
Then I should see "Grades were set for 1 items"
And I follow "Single view for Student 1"
Then I should see "Student 1"
- @javascript
Scenario: I can bulk update grades.
Given I follow "Single view for Student 1"
Then I should see "Student 1"
- When I click on "All grades" "option"
+ When I set the field "For" to "All grades"
And I set the field "Insert value" to "1.0"
- And I click on "Perform bulk insert" "checkbox"
+ And I set the field "Perform bulk insert" to "1"
And I press "Save"
Then I should see "Grades were set for 8 items"
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-
+global $CFG;
require_once(__DIR__ . '/fixtures/screen.php');
+require_once($CFG->libdir . '/gradelib.php');
defined('MOODLE_INTERNAL') || die();
/**
$this->getDataGenerator()->create_group_member(array('groupid' => $group->id, 'userid' => $user1->id));
$this->getDataGenerator()->create_group_member(array('groupid' => $group->id, 'userid' => $user2->id));
+ // Perform a regrade before creating the report.
+ grade_regrade_final_grades($course->id);
$screentest = new gradereport_singleview_screen_testable($course->id, 0, $group->id);
$groupusers = $screentest->test_load_users();
$this->assertCount(2, $groupusers);
$users = $screentest->test_load_users();
$this->assertCount(2, $users);
}
-}
\ No newline at end of file
+}
}
$USER->grade_last_report[$course->id] = 'user';
-
-//first make sure we have proper final grades - this must be done before constructing of the grade tree
-grade_regrade_final_grades($courseid);
+// First make sure we have proper final grades.
+grade_regrade_final_grades_if_required($course);
if (has_capability('moodle/grade:viewall', $context)) { //Teachers will see all student reports
$groupmode = groups_get_course_groupmode($course); // Groups are being used
$context = context_course::instance($course->id);
- //first make sure we have proper final grades - this must be done before constructing of the grade tree
- grade_regrade_final_grades($course->id);
-
/// return tracking object
$gpr = new grade_plugin_return(array('type'=>'report', 'plugin'=>'user', 'courseid'=>$course->id, 'userid'=>$user->id));
// Create a report instance
And I follow "Course 1"
And I navigate to "Grades" node in "Course administration"
And I select "User report" from the "Grade report" singleselect
- And I press "Go"
And I select "All users (0)" from the "Select all or one user" singleselect
- And I click on "Go" "button" in the "#choosegradeuser" "css_element"
Then I should see "No students enrolled in this course yet"
When I click on "Edit assign Assignment1" "link"
And I should see "Minimum grade"
Then I navigate to "General settings" node in "Site administration > Grades"
- And I click on "Show minimum grade" "checkbox"
+ And I set the field "Show minimum grade" to "0"
And I press "Save changes"
And I am on site homepage
And I follow "Course 1"
Scenario: Hide calculation icons
And "Edit calculation for Course total" "link" should exist
When I navigate to "Grader report" node in "Site administration > Grades > Report settings"
- And I click on "Show calculations" "checkbox"
+ And I set the field "Show calculations" to "0"
And I press "Save changes"
And I am on site homepage
And I follow "Course 1"
Scenario: Disable category overriding
And "tr .course input[type='text']" "css_element" should exist
Then I navigate to "Grade category settings" node in "Site administration > Grades"
- And I click on "Allow category grades to be manually overridden" "checkbox"
+ And I set the field "Allow category grades to be manually overridden" to "0"
And I press "Save changes"
And I am on site homepage
And I follow "Course 1"
| 89.99 % | 85.00 % | β |
| 84.99 % | 70.00 % | γ |
| 69.99 % | 55.00 % | δ |
- | 54.99 % | 0.00 % | Ω |
\ No newline at end of file
+ | 54.99 % | 0.00 % | Ω |
And the "Maximum grade" "field" should be disabled
And I press "Save and return to course"
- @javascript
Scenario: Create an activity with a maximum grade point value higher than the system maximum
When I follow "Test Assignment 1"
And I follow "Edit settings"
Then I should see "Invalid grade value. This must be an integer between 1 and 900"
And I press "Cancel"
- @javascript
Scenario: Create an activity with a valid maximum grade point and then change the system maximum to be lower
When I follow "Test Assignment 1"
And I follow "Edit settings"
| grade_includescalesinaggregation | 0 |
And I log out
- @javascript
Scenario Outline: Scales can be excluded from aggregation
Given I log in as "teacher1"
And I follow "Course 1"
And I set the following settings for grade item "Course 1":
| Aggregation | <aggregation> |
And I follow "User report"
- And I set the field "Select all or one user" to "Student 1"
+ And I select "Student 1" from the "Select all or one user" singleselect
Then the following should exist in the "user-grade" table:
| Grade item | Grade | Percentage | Contribution to course total |
| Grade me | 10.00 | 10.00 % | <gradecontrib> |
And I follow "Course 1"
And I navigate to "Grades" node in "Course administration"
And I follow "User report"
- And I set the field "Select all or one user" to "Student 1"
+ And I select "Student 1" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Grade | Percentage | Contribution to course total |
| Grade me | 10.00 | 10.00 % | <gradecontrib2> |
And I follow "Grader report"
And I turn editing mode on
- @javascript
Scenario: Test displaying single item scales in gradebook in aggregation method Natural
When I turn editing mode off
Then the following should exist in the "user-grades" table:
| Range | Ace!–Ace! | 0.00–1.00 | 0.00–1.00 |
| Overall average | Ace! | 1.00 | 1.00 |
And I follow "User report"
- And I set the field "Select all or one user" to "Student 1"
+ And I select "Student 1" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Grade | Range | Contribution to course total |
| Test assignment one | Ace! | Ace!–Ace! | 100.00 % |
| Sub category 1 total| 1.00 | 0–1 | - |
| Course total | 1.00 | 0–1 | - |
- And I set the field "Select all or one user" to "Student 2"
+ And I select "Student 2" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Grade | Range | Contribution to course total |
| Test assignment one | - | Ace!–Ace! | - |
| Sub category 1 total| - | 0–1 | - |
| Course total | - | 0–1 | - |
- And I set the field "jump" to "Gradebook setup"
+ And I select "Gradebook setup" from the "jump" singleselect
And the following should exist in the "grade_edit_tree_table" table:
| Name | Max grade |
| Test assignment one | 1.00 |
| Sub category 1 total| 1.00 |
| Course total | 1.00 |
- @javascript
Scenario Outline: Test displaying single item scales in gradebook in all other aggregation methods
When I follow "Edit Course 1"
And I set the field "Aggregation" to "<aggregation>"
And I press "Save changes"
And I follow "Edit Sub category 1"
- And I expand all fieldsets
- And I set the field "Aggregation" to "<aggregation>"
- And I set the field "Category name" to "Sub category (<aggregation>)"
- # And I set the field "Maximum grade" to "5"
- # And I set the field "Minimum grade" to "1"
+ And I set the following fields to these values:
+ | Aggregation | <aggregation> |
+ | Category name | Sub category (<aggregation>) |
And I press "Save changes"
And I turn editing mode off
Then the following should exist in the "user-grades" table:
| Range | Ace!–Ace! | 0.00–100.0 | 0.00–100.00 |
| Overall average | Ace! | <catavg> | <overallavg> |
And I follow "User report"
- And I set the field "Select all or one user" to "Student 1"
- And I click on "Select all or one user" "select"
+ And I select "Student 1" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Grade | Range | Contribution to course total |
| Test assignment one | Ace! | Ace!–Ace! | <contrib1> |
| Sub category (<aggregation>) total<aggregation>. | <cattotal1> | 0–100 | - |
| Course total<aggregation>. | <coursetotal1> | 0–100 | - |
- And I set the field "jump" to "Gradebook setup"
+ And I select "Gradebook setup" from the "jump" singleselect
And the following should exist in the "grade_edit_tree_table" table:
- | Name | Max grade |
- | Test assignment one | Ace! (1) |
+ | Name | Max grade |
+ | Test assignment one | Ace! (1) |
| Sub category (<aggregation>) total<aggregation>. | 100.00 |
- | Course total<aggregation>. | 100.00 |
+ | Course total<aggregation>. | 100.00 |
Examples:
| aggregation | contrib1 | cattotal1 | coursetotal1 | catavg | overallavg |
Then I should see "The grade to pass can not be greater than the maximum possible grade 50"
And I press "Cancel"
- @javascript
Scenario: Set a valid grade to pass for an assignment activity using points
When I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
And I click on "Edit assign Test Assignment 1" "link"
And the field "Grade to pass" matches value "30"
- @javascript
Scenario: Set a valid grade to pass for an assignment activity using scales
When I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit assign Test Assignment 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "3"
And I set the field "Grade to pass" to "4"
And I press "Save changes"
And I follow "Edit settings"
And the field "Grade to pass" matches value "4"
- @javascript
Scenario: Set a invalid grade to pass for an assignment activity using scales
When I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Grade to pass | 10 |
Then I should see "The grade to pass can not be greater than the maximum possible grade 4"
- @javascript
Scenario: Set a valid grade to pass for workshop activity
When I turn editing mode on
And I add a "Workshop" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit workshop Test Workshop 1 (submission)" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "40"
And I set the field "Grade to pass" to "45"
And I press "Save changes"
And I click on "Edit workshop Test Workshop 1 (assessment)" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
And the field "Grade to pass" matches value "10"
And I set the field "Grade to pass" to "15"
And I press "Save changes"
And the field "Submission grade to pass" matches value "45"
And the field "Assessment grade to pass" matches value "15"
- @javascript
Scenario: Set an invalid grade to pass for workshop activity
When I turn editing mode on
And I add a "Workshop" to section "1" and I fill the form with:
Then "The grade to pass can not be greater than the maximum possible grade 80" "text" should exist in the "#fitem_id_submissiongradepass .error" "css_element"
Then "The grade to pass can not be greater than the maximum possible grade 20" "text" should exist in the "#fitem_id_gradinggradepass .error" "css_element"
- @javascript
Scenario: Set a valid grade to pass for quiz activity
When I turn editing mode on
And I add a "Quiz" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit quiz Test Quiz 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "9.5"
And I set the field "Grade to pass" to "8"
And I press "Save changes"
And I follow "Edit settings"
And the field "Grade to pass" matches value "8.00"
- @javascript
Scenario: Set a valid grade to pass for lesson activity
When I turn editing mode on
And I add a "Lesson" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit lesson Test Lesson 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
And I set the field "Grade to pass" to "80"
And I press "Save changes"
And I follow "Edit settings"
And the field "Grade to pass" matches value "80"
- @javascript
Scenario: Set a valid grade to pass for database activity
When I turn editing mode on
And I add a "Database" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit data Test Database 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
And I set the field "Grade to pass" to "80"
And I press "Save changes"
And I follow "Edit settings"
And the field "Grade to pass" matches value "80"
- @javascript
Scenario: Set an invalid grade to pass for forum activity
When I turn editing mode on
And I add a "Forum" to section "1" and I fill the form with:
| scale[modgrade_point] | 60 |
Then I should see "The grade to pass can not be greater than the maximum possible grade 60"
- @javascript
Scenario: Set a valid grade to pass for forum activity
When I turn editing mode on
And I add a "Forum" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit forum Test Forum 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
And I set the field "Grade to pass" to "80"
And I press "Save changes"
And I follow "Edit settings"
And the field "Grade to pass" matches value "80"
- @javascript
Scenario: Set a valid grade to pass for glossary activity
When I turn editing mode on
And I add a "Glossary" to section "1" and I fill the form with:
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I click on "Edit glossary Test Glossary 1" "link"
- And I follow "Show more..."
+ And I expand all fieldsets
Then the field "Grade to pass" matches value "90"
And I set the field "Grade to pass" to "80"
And I press "Save changes"
$string['cliincorrectvalueerror'] = 'Error, valor incorrecte "{$a->value}" per a "{$a->option}"';
$string['cliincorrectvalueretry'] = 'Valor incorrecte, si us plau, torneu-ho a provar.';
$string['clitypevalue'] = 'Valor de tipus';
-$string['clitypevaluedefault'] = 'valor de tipus, premeu Intro per fer servir un valor per defecte ({$a})';
+$string['clitypevaluedefault'] = 'valor de tipus, premeu la tecla de retorn (<em>Enter</em>) per fer servir un valor per defecte ({$a})';
$string['cliunknowoption'] = 'Opcions invà lides:
{$a}
L\'opció --help us orientarà .';
$string['pathshead'] = 'Confirmar caminhos';
$string['pathsrodataroot'] = 'A pasta de dados não tem permissões de escrita.';
$string['pathsroparentdataroot'] = 'A pasta pai <b>{$a->parent}</b> não tem permissões de escrita. O programa de instalação não conseguiu criar a pasta <b>{$a->dataroot}</b>.';
-$string['pathssubadmindir'] = 'Alguns servidores Web utilizam a pasta <strong>admin</strong> em URLs especiais de acesso a funcionalidades especiais, como é o caso de painéis de controlo. Algumas situações podem criar conflitos com a localização normal das páginas de administração do Moodle. Estes problemas podem ser resolvidos renomeando a pasta <strong>admin</strong> na instalação do Moodle e indicando aqui o novo nome a utilizar. Por exemplo:<br /><br /><b>moodleadmin</b><br /><br />Esta ação resolverá os problemas de acesso dos links para as funcionalidades de administração do Moodle.';
+$string['pathssubadmindir'] = 'Alguns servidores Web utilizam a pasta <strong>admin</strong> em URLs especiais de acesso a funcionalidades especiais, como é o caso de painéis de controlo. Algumas situações podem criar conflitos com a localização normal das páginas de administração do Moodle. Estes problemas podem ser resolvidos renomeando a pasta <strong>admin</strong> na instalação do Moodle e indicando aqui o novo nome a utilizar. Por exemplo:<br /><br /><b>moodleadmin</b><br /><br />Esta ação resolverá os problemas de acesso das hiperligações para as funcionalidades de administração do Moodle.';
$string['pathssubdataroot'] = '<p>Uma diretoria em que o Moodle irá armazenar todo o conteúdo de ficheiros enviados pelos utilizadores.</p>
<p>Esta diretoria deve ser legÃvel e gravável pelo utilizador do servidor web (geralmente \'www-data\', \'nobody\', ou \'apache\').</p>
<p>Não deve ser diretamente acessÃvel através da web.</p>
$string['authsettings'] = 'Manage authentication';
$string['autolang'] = 'Language autodetect';
$string['autologinguests'] = 'Auto-login guests';
+$string['availablesearchareas'] = 'Available areas for search';
$string['availableto'] = 'Available to';
$string['availablelicenses'] = 'Available licences';
$string['backgroundcolour'] = 'Transparent colour';
$string['enablecssoptimiser_desc'] = 'When enabled CSS will be run through an optimisation process before being cached. The optimiser processes the CSS removing duplicate rules and styles, as well as white space removable and reformatting. Please note turning this on at the same time as theme designer mode is awful for performance but will help theme designers create optimised CSS.';
$string['enabled'] = 'Enabled';
$string['enabledevicedetection'] = 'Enable device detection';
+$string['enableglobalsearch'] = 'Enable global search';
+$string['enableglobalsearch_desc'] = 'If enabled, data will be indexed and syncronised by a scheduled task.';
$string['enablegravatar'] = 'Enable Gravatar';
$string['enablegravatar_help'] = 'When enabled Moodle will attempt to fetch a user profile picture from Gravatar if the user has not uploaded an image.';
$string['enablemobilewebservice'] = 'Enable web services for mobile devices';
$string['enablerecordcache'] = 'Enable record cache';
$string['enablerssfeeds'] = 'Enable RSS feeds';
$string['enablesafebrowserintegration'] = 'Enable Safe Exam Browser integration';
+$string['enablesearchareas'] = 'Enable search areas';
$string['enablestats'] = 'Enable statistics';
$string['enabletrusttext'] = 'Enable trusted content';
$string['enablewebservices'] = 'Enable web services';
$string['generalsettings'] = 'General settings';
$string['geoipfile'] = 'GeoIP city data file';
$string['getremoteaddrconf'] = 'Logged IP address source';
+$string['globalsearch'] = 'Global search';
+$string['globalsearchmanage'] = 'Manage global search';
$string['groupenrolmentkeypolicy'] = 'Group enrolment key policy';
$string['groupenrolmentkeypolicy_desc'] = 'Turning this on will make Moodle check group enrolment keys against a valid password policy.';
$string['googlemapkey3'] = 'Google Maps API V3 key';
$string['ignore'] = 'Ignore';
$string['includemoduleuserdata'] = 'Include module user data';
$string['incompatibleblocks'] = 'Incompatible blocks';
+$string['indexdata'] = 'Index data';
$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['save'] = 'Save';
$string['savechanges'] = 'Save changes';
$string['search'] = 'Search';
+$string['searchengine'] = 'Search engine';
$string['searchinsettings'] = 'Search in settings';
$string['searchresults'] = 'Search results';
+$string['searchsetupinfo'] = 'Search setup';
$string['sectionerror'] = 'Section error!';
$string['secureforms'] = 'Use additional form security';
$string['security'] = 'Security';
$string['selectdevice'] = 'Select device';
+$string['selectsearchengine'] = 'Select search engine';
$string['selecttheme'] = 'Select theme for {$a} device';
$string['server'] = 'Server';
$string['serverchecks'] = 'Server checks';
$string['settingfileuploads'] = 'File uploading is required for normal operation, please enable it in PHP configuration.';
$string['settingmemorylimit'] = 'Insufficient memory detected, please set higher memory limit in PHP settings.';
$string['settingsafemode'] = 'Moodle is not fully compatible with safe mode, please ask server administrator to turn it off. Running Moodle under safe mode is not supported, please expect various problems if you do so.';
+$string['setupsearchengine'] = 'Setup search engine';
$string['showcommentscount'] = 'Show comments count';
$string['showdetails'] = 'Show details';
$string['showuseridentity'] = 'Show user identity';
$string['taskdeleteunconfirmedusers'] = 'Delete unconfirmed users';
$string['taskeventscron'] = 'Background processing for events';
$string['taskfiletrashcleanup'] = 'Cleanup files in trash';
+$string['taskglobalsearch'] = 'Global search indexing';
$string['taskgradecron'] = 'Background processing for gradebook';
$string['tasklegacycron'] = 'Legacy cron processing for plugins';
$string['taskmessagingcleanup'] = 'Background processing for messaging';
$string['cachedef_plugin_manager'] = 'Plugin info manager';
$string['cachedef_questiondata'] = 'Question definitions';
$string['cachedef_repositories'] = 'Repositories instances data';
+$string['cachedef_search_results'] = 'Search results user data';
$string['cachedef_string'] = 'Language string cache';
$string['cachedef_tags'] = 'Tags collections and areas';
$string['cachedef_userselections'] = 'Data used to persist user selections throughout Moodle';
$string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum';
$string['generalexceptionmessage'] = 'Exception - {$a}';
$string['gradepubdisable'] = 'Grade publishing disabled';
+$string['gradesneedregrading'] = 'The course grades need to be recalculated';
$string['gradecantregrade'] = 'An error occurred during grade calculation: {$a}';
$string['groupalready'] = 'User already belongs to group {$a}';
$string['groupexistforcourse'] = 'Group "{$a}" already exists for this course';
$string['real'] = 'Real';
$string['realletter'] = 'Real (letter)';
$string['realpercentage'] = 'Real (percentage)';
+$string['recalculatinggrades'] = 'Recalculating grades';
$string['recovergradesdefault'] = 'Recover grades default';
$string['recovergradesdefault_help'] = 'By default recover old grades when re-enrolling a user in a course.';
$string['refreshpreview'] = 'Refresh preview';
$string['eventemailfailed'] = 'Email failed to send';
$string['eventname'] = 'Event name';
$string['eventrecentactivityviewed'] = 'Recent activity viewed';
+$string['eventsearchindexed'] = 'Search data indexed';
$string['eventunknownlogged'] = 'Unknown event';
$string['eventusercreated'] = 'User created';
$string['eventuserdeleted'] = 'User deleted';
$string['latestlanguagepack'] = 'Check for latest language pack on moodle.org';
$string['layouttable'] = 'Layout table';
$string['leavetokeep'] = 'Leave blank to keep current password';
+$string['legacylogginginuse'] = 'This site currently has writing to the legacy log store enabled. Writing to this log store is deprecated. Please write to a supported log store such as "standard" or "external".';
$string['legacythemeinuse'] = 'This site is being displayed to you in compatibility mode because your browser is too old.';
$string['license'] = 'Licence';
$string['licenses'] = 'Licences';
$string['roletoassign'] = 'Role to assign';
$string['roletooverride'] = 'Role to override';
$string['safeoverridenotice'] = 'Note: Capabilities with higher risks are locked because you are only allowed to override safe capabilities.';
+$string['search:query'] = 'Perform site-wide searches';
$string['selectanotheruser'] = 'Select another user';
$string['selectauser'] = 'Select a user';
$string['selectrole'] = 'Select a role';
$string['advancedsearch'] = 'Advanced search';
$string['all'] = 'All';
+$string['allareas'] = 'All areas';
$string['author'] = 'Author';
$string['authorname'] = 'Author name';
$string['back'] = 'Back';
$string['databasestate'] = 'Indexing database state';
$string['datadirectory'] = 'Data directory';
$string['deletionsinindex'] = 'Deletions in index';
+$string['docmodifiedon'] = 'Last modified on {$a}';
$string['doctype'] = 'Doctype';
+$string['doctypenotsupported'] = 'The specified doc type is not yet supported';
$string['documents'] = 'documents';
$string['documentsfor'] = 'Documents for';
$string['documentsindatabase'] = 'Documents in database';
$string['documentsinindex'] = 'Documents in index';
$string['duration'] = 'Duration';
$string['emptydatabaseerror'] = 'Database table is not present, or contains no index records.';
+$string['enginenotfound'] = 'Engine {$a} not found.';
+$string['enginenotinstalled'] = '{$a} not installed.';
+$string['engineserverstatus'] = 'The search engine is not available. Please contact your administrator.';
$string['enteryoursearchquery'] = 'Enter your search query';
$string['errors'] = 'Errors';
+$string['errorareanotavailable'] = '{$a} search area is not available.';
$string['filesinindexdirectory'] = 'Files in index directory';
+$string['filterheader'] = 'Filter';
+$string['fromtime'] = 'Modified after';
+$string['globalsearch'] = 'Global search';
$string['globalsearchdisabled'] = 'Global searching is not enabled.';
$string['checkdb'] = 'Check database';
$string['checkdbadvice'] = 'Check your database for any problems.';
$string['checkdir'] = 'Check dir';
$string['checkdiradvice'] = 'Ensure the data directory exists and is writable.';
+$string['incourse'] = 'in course {$a}';
+$string['index'] = 'Index';
$string['invalidindexerror'] = 'Index directory either contains an invalid index, or nothing at all.';
$string['ittook'] = 'It took';
$string['next'] = 'Next';
$string['noindexmessage'] = 'Admin: There appears to be no search index. Please';
+$string['noresults'] = 'No results';
$string['normalsearch'] = 'Normal search';
$string['openedon'] = 'opened on';
+$string['optimize'] = 'Optimize';
+$string['queryerror'] = 'The query you provided could not be parsed by the search engine: {$a}';
$string['resultsreturnedfor'] = 'results returned for';
$string['runindexer'] = 'Run indexer (real)';
$string['runindexertest'] = 'Run indexer test';
$string['score'] = 'Score';
$string['search'] = 'Search';
+$string['searcharea'] = 'Search area';
$string['searching'] = 'Searching in ...';
$string['searchnotpermitted'] = 'You are not allowed to do a search';
+$string['searchsetupdescription'] = 'The following steps help you to set up Moodle global search.';
$string['seconds'] = 'seconds';
$string['solutions'] = 'Solutions';
$string['statistics'] = 'Statistics';
+$string['step'] = 'Step';
$string['thesewordshelpimproverank'] = 'These words help improve rank';
$string['thesewordsmustappear'] = 'These words must appear';
$string['thesewordsmustnotappear'] = 'These words must not appear';
$string['title'] = 'Title';
$string['tofetchtheseresults'] = 'to fetch these results';
$string['totalsize'] = 'Total size';
+$string['totime'] = 'Modified before';
$string['type'] = 'Type';
$string['uncompleteindexingerror'] = 'Indexing was not successfully completed, please restart it.';
$string['versiontoolow'] = 'Sorry, global search requires PHP 5.0.0 or later';
+$string['viewresultincontext'] = 'View this result in context';
$string['whichmodulestosearch?'] = 'Which modules to search?';
$string['wordsintitle'] = 'Words in title';
return false;
}
- $this->settings->{$setting->name} = $setting;
+ $name = $setting->name;
+ if ($setting->plugin) {
+ $name = $setting->plugin . $name;
+ }
+ $this->settings->{$name} = $setting;
return true;
}
return true;
}
}
+
+
+/**
+ * Search setup steps info.
+ *
+ * @package core
+ * @copyright 2016 David Monllao {@link http://www.davidmonllao.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class admin_setting_searchsetupinfo extends admin_setting {
+
+ /**
+ * Calls parent::__construct with specific arguments
+ */
+ public function __construct() {
+ $this->nosave = true;
+ parent::__construct('searchsetupinfo', '', '', '');
+ }
+
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
+ public function get_setting() {
+ return true;
+ }
+
+ /**
+ * Always returns true, does nothing
+ *
+ * @return true
+ */
+ public function get_defaultsetting() {
+ return true;
+ }
+
+ /**
+ * Always returns '', does not write anything
+ *
+ * @param array $data
+ * @return string Always returns ''
+ */
+ public function write_setting($data) {
+ // Do not write any setting.
+ return '';
+ }
+
+ /**
+ * Builds the HTML to display the control
+ *
+ * @param string $data Unused
+ * @param string $query
+ * @return string
+ */
+ public function output_html($data, $query='') {
+ global $CFG, $OUTPUT;
+
+ $return = '';
+ $brtag = html_writer::empty_tag('br');
+
+ // Available search areas.
+ $searchareas = \core_search\manager::get_search_areas_list();
+ $anyenabled = false;
+ $anyindexed = false;
+ foreach ($searchareas as $areaid => $searcharea) {
+ list($componentname, $varname) = $searcharea->get_config_var_name();
+ if (!$anyenabled) {
+ $anyenabled = get_config($componentname, $varname . '_enabled');
+ }
+ if (!$anyindexed) {
+ $anyindexed = get_config($componentname, $varname . '_indexingstart');
+ }
+ if ($anyenabled && $anyindexed) {
+ break;
+ }
+ }
+
+ $return .= $OUTPUT->heading(get_string('searchsetupinfo', 'admin'), 3, 'main');
+
+ $table = new html_table();
+ $table->head = array(get_string('step', 'search'), get_string('status'));
+ $table->colclasses = array('leftalign step', 'leftalign status');
+ $table->id = 'searchsetup';
+ $table->attributes['class'] = 'admintable generaltable';
+ $table->data = array();
+
+ $return .= $brtag . get_string('searchsetupdescription', 'search') . $brtag . $brtag;
+
+ // Enable global search.
+ $row = array();
+ $url = new moodle_url("/admin/search.php?query=enableglobalsearch");
+ $row[0] = '1. ' . html_writer::tag('a', get_string('enableglobalsearch', 'admin'),
+ array('href' => $url));
+ $status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
+ if (\core_search\manager::is_global_search_enabled()) {
+ $status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
+ }
+ $row[1] = $status;
+ $table->data[] = $row;
+
+ // Select a search engine.
+ $row = array();
+ $url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
+ $row[0] = '2. ' . html_writer::tag('a', get_string('selectsearchengine', 'admin'),
+ array('href' => $url));
+
+ $status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
+ if (!empty($CFG->searchengine)) {
+ $status = html_writer::tag('span', get_string('pluginname', 'search_' . $CFG->searchengine),
+ array('class' => 'statusok'));
+
+ }
+ $row[1] = $status;
+ $table->data[] = $row;
+
+ // Available areas.
+ $row = array();
+ $url = new moodle_url('/admin/settings.php?section=manageglobalsearch#admin-searchengine');
+ $row[0] = '3. ' . html_writer::tag('a', get_string('enablesearchareas', 'admin'),
+ array('href' => $url));
+
+ $status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
+ if ($anyenabled) {
+ $status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
+
+ }
+ $row[1] = $status;
+ $table->data[] = $row;
+
+ // Setup search engine.
+ $row = array();
+ if (empty($CFG->searchengine)) {
+ $row[0] = '4. ' . get_string('setupsearchengine', 'admin');
+ $row[1] = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
+ } else {
+ $url = new moodle_url('/admin/settings.php?section=search' . $CFG->searchengine);
+ $row[0] = '4. ' . html_writer::tag('a', get_string('setupsearchengine', 'admin'),
+ array('href' => $url));
+ // Check the engine status.
+ $searchengine = \core_search\manager::search_engine_instance();
+ $serverstatus = $searchengine->is_server_ready();
+ if ($serverstatus === true) {
+ $status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
+ } else {
+ $status = html_writer::tag('span', $serverstatus, array('class' => 'statuscritical'));
+ }
+ $row[1] = $status;
+ }
+ $table->data[] = $row;
+
+ // Indexed data.
+ $row = array();
+ $url = new moodle_url('/report/search/index.php#searchindexform');
+ $row[0] = '5. ' . html_writer::tag('a', get_string('indexdata', 'admin'), array('href' => $url));
+ if ($anyindexed) {
+ $status = html_writer::tag('span', get_string('yes'), array('class' => 'statusok'));
+ } else {
+ $status = html_writer::tag('span', get_string('no'), array('class' => 'statuscritical'));
+ }
+ $row[1] = $status;
+ $table->data[] = $row;
+
+ $return .= html_writer::table($table);
+
+ return highlight($query, $return);
+ }
+
+}
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
+ * A system for displaying notifications to users from the session.
+ *
* Wrapper for the YUI M.core.notification class. Allows us to
* use the YUI version in AMD code until it is replaced.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/
-define(['core/yui'], function(Y) {
+define(['core/yui', 'jquery', 'theme_bootstrapbase/bootstrap', 'core/templates', 'core/ajax', 'core/log'],
+function(Y, $, bootstrap, templates, ajax, log) {
+ var notificationModule = {
+ types: {
+ 'success': 'core/notification_success',
+ 'info': 'core/notification_info',
+ 'warning': 'core/notification_warning',
+ 'error': 'core/notification_error',
+ },
- // Private variables and functions.
+ fieldName: 'user-notifications',
+
+ fetchNotifications: function() {
+ var promises = ajax.call([{
+ methodname: 'core_fetch_notifications',
+ args: {
+ contextid: notificationModule.contextid
+ }
+ }]);
+
+ promises[0]
+ .done(notificationModule.addNotifications)
+ ;
+
+ },
+
+ addNotifications: function(notifications) {
+ if (!notifications) {
+ notifications = [];
+ }
+
+ $.each(notifications, function(i, notification) {
+ notificationModule.renderNotification(notification.template, notification.variables);
+ });
+ },
+
+ setupTargetRegion: function() {
+ var targetRegion = $('#' + notificationModule.fieldName);
+ if (targetRegion.length) {
+ return;
+ }
+
+ var newRegion = $('<span>').attr('id', notificationModule.fieldName);
+
+ targetRegion = $('#region-main');
+ if (targetRegion.length) {
+ return targetRegion.prepend(newRegion);
+ }
+
+ targetRegion = $('[role="main"]');
+ if (targetRegion.length) {
+ return targetRegion.prepend(newRegion);
+ }
+
+ targetRegion = $('body');
+ return targetRegion.prepend(newRegion);
+ },
+
+ addNotification: function(notification) {
+ var template = notificationModule.types.error;
+
+ notification = $.extend({
+ closebutton: true,
+ announce: true,
+ type: 'error'
+ }, notification);
+
+ if (notification.template) {
+ template = notification.template;
+ delete notification.template;
+ } else if (notification.type){
+ if (typeof notificationModule.types[notification.type] !== 'undefined') {
+ template = notificationModule.types[notification.type];
+ }
+ delete notification.type;
+ }
+
+ return notificationModule.renderNotification(template, notification);
+ },
+
+ renderNotification: function(template, variables) {
+ if (typeof variables.message === 'undefined' || !variables.message) {
+ log.debug('Notification received without content. Skipping.');
+ return;
+ }
+ templates.render(template, variables)
+ .done(function(html) {
+ $('#' + notificationModule.fieldName).prepend(html);
+ })
+ .fail(notificationModule.exception)
+ ;
+ },
- return /** @alias module:core/notification */ {
- // Public variables and functions.
- /**
- * Wrap M.core.alert.
- *
- * @method alert
- * @param {string} title
- * @param {string} message
- * @param {string} yesLabel
- */
alert: function(title, message, yesLabel) {
// Here we are wrapping YUI. This allows us to start transitioning, but
// wait for a good alternative without having inconsistent dialogues.
});
},
- /**
- * Wrap M.core.confirm.
- *
- * @method confirm
- * @param {string} title
- * @param {string} question
- * @param {string} yesLabel
- * @param {string} noLabel
- * @param {function} callback
- */
confirm: function(title, question, yesLabel, noLabel, callback) {
// Here we are wrapping YUI. This allows us to start transitioning, but
// wait for a good alternative without having inconsistent dialogues.
});
},
- /**
- * Wrap M.core.exception.
- *
- * @method exception
- * @param {Error} ex
- */
exception: function(ex) {
// Fudge some parameters.
if (ex.backtrace) {
});
}
};
+
+ return /** @alias module:core/notification */{
+ init: function(contextid, notifications) {
+ notificationModule.contextid = contextid;
+
+ // Setup the message target region if it isn't setup already
+ notificationModule.setupTargetRegion();
+
+ // Setup closing of bootstrap alerts.
+ $().alert();
+
+ // Add provided notifications.
+ notificationModule.addNotifications(notifications);
+
+ // Poll for any new notifications.
+ notificationModule.fetchNotifications();
+ },
+
+ /**
+ * Poll the server for any new notifications.
+ *
+ * @method fetchNotifications
+ */
+ fetchNotifications: notificationModule.fetchNotifications,
+
+ /**
+ * Add a notification to the page.
+ *
+ * Note: This does not cause the notification to be added to the session.
+ *
+ * @method addNotification
+ * @param {Object} notification The notification to add.
+ * @param {string} notification.message The body of the notification
+ * @param {string} notification.type The type of notification to add (error, warning, info, success).
+ * @param {Boolean} notification.closebutton Whether to show the close button.
+ * @param {Boolean} notification.announce Whether to announce to screen readers.
+ */
+ addNotification: notificationModule.addNotification,
+
+ /**
+ * Wrap M.core.alert.
+ *
+ * @method alert
+ * @param {string} title
+ * @param {string} message
+ * @param {string} yesLabel
+ */
+ alert: notificationModule.alert,
+
+ /**
+ * Wrap M.core.confirm.
+ *
+ * @method confirm
+ * @param {string} title
+ * @param {string} question
+ * @param {string} yesLabel
+ * @param {string} noLabel
+ * @param {function} callback
+ */
+ confirm: notificationModule.confirm,
+
+ /**
+ * Wrap M.core.exception.
+ *
+ * @method exception
+ * @param {Error} ex
+ */
+ exception: notificationModule.exception
+ };
});
--- /dev/null
+// 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/>.
+
+/**
+ * Search box.
+ *
+ * @module core/search-input
+ * @class search-input
+ * @package core
+ * @copyright 2016 David Monllao {@link http://www.davidmonllao.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @since Moodle 3.1
+ */
+define(['jquery'], function($) {
+
+ /**
+ * This search box div node.
+ *
+ * @private
+ */
+ var wrapper = null;
+
+ /**
+ * Toggles the form visibility.
+ *
+ * @param {Event} ev
+ * @method toggleForm
+ * @private
+ */
+ var toggleForm = function(ev) {
+
+ if (wrapper.hasClass('expanded')) {
+ hideForm();
+ } else {
+ showForm(ev);
+ }
+ };
+
+ /**
+ * Shows the form or submits it depending on the window size.
+ *
+ * @param {Event} ev
+ * @method showForm
+ * @private
+ */
+ var showForm = function(ev) {
+
+ var windowWidth = $(document).width();
+
+ // We are only interested in enter and space keys (accessibility).
+ if (ev.type === 'keydown' && ev.keyCode !== 13 && ev.keyCode !== 32) {
+ return;
+ }
+
+ if (windowWidth <= 767 && (ev.type === 'click' || ev.type === 'keydown')) {
+ // Move to the search page when using small window sizes as the input requires too much space.
+ submitForm();
+ return;
+ } else if (windowWidth <= 767) {
+ // Ignore mousedown events in while using small window sizes.
+ return;
+ }
+
+ if (ev.type === 'keydown') {
+ // We don't want to submit the form unless the user hits enter.
+ ev.preventDefault();
+ }
+
+ wrapper.addClass('expanded');
+ wrapper.find('form').addClass('expanded');
+ wrapper.find('input').focus();
+ };
+
+ /**
+ * Hides the form.
+ *
+ * @method hideForm
+ * @private
+ */
+ var hideForm = function() {
+ wrapper.removeClass('expanded');
+ wrapper.find('form').removeClass('expanded');
+ };
+
+ /**
+ * Submits the form.
+ *
+ * @param {Event} ev
+ * @method submitForm
+ * @private
+ */
+ var submitForm = function() {
+ wrapper.find('form').submit();
+ };
+
+ return /** @alias module:core/search-input */ {
+ // Public variables and functions.
+
+ /**
+ * Assigns listeners to the requested select box.
+ *
+ * @method init
+ * @param {Number} id The search wrapper div id
+ */
+ init: function(id) {
+ wrapper = $('#' + id);
+ wrapper.on('click mouseover keydown', 'div', toggleForm);
+ }
+ };
+});
$afterfirstoption = true;
}
} else {
- // This is a single select, let's pass the last one specified.
- $this->field->selectOption(end($options));
+ // If value is already set then don't set it again.
+ if ($this->field->getValue() == $value) {
+ return;
+ } else {
+ $opt = $this->field->find('named', array(
+ 'option', $this->field->getSession()->getSelectorsHandler()->xpathLiteral($value)
+ ));
+ if ($opt && ($this->field->getValue() == $opt->getValue())) {
+ return;
+ }
+ }
+
+ // If not running JS or not a singleselect then use selectOption.
+ // For singleselect only click event is enough.
+ if (!$this->running_javascript() ||
+ !($this->field->hasClass('singleselect') || $this->field->hasClass('urlselect'))) {
+
+ // This is a single select, let's pass the last one specified.
+ $this->field->selectOption(end($options));
+ }
}
// With JS disabled this is enough and we finish here.
'repository' => $CFG->dirroot.'/repository',
'rss' => $CFG->dirroot.'/rss',
'role' => $CFG->dirroot.'/'.$CFG->admin.'/roles',
- 'search' => null,
+ 'search' => $CFG->dirroot.'/search',
'table' => null,
'tag' => $CFG->dirroot.'/tag',
'timezones' => null,
'webservice' => $CFG->dirroot.'/webservice',
'repository' => $CFG->dirroot.'/repository',
'portfolio' => $CFG->dirroot.'/portfolio',
+ 'search' => $CFG->dirroot.'/search/engine',
'qbehaviour' => $CFG->dirroot.'/question/behaviour',
'qformat' => $CFG->dirroot.'/question/format',
'plagiarism' => $CFG->dirroot.'/plagiarism',
return $pluginfiles;
}
+ /**
+ * Returns all classes in a component matching the provided namespace.
+ *
+ * It checks that the class exists.
+ *
+ * e.g. get_component_classes_in_namespace('mod_forum', 'event')
+ *
+ * @param string $component A valid moodle component (frankenstyle)
+ * @param string $namespace Namespace from the component name.
+ * @return array The full class name as key and the class path as value.
+ */
+ public static function get_component_classes_in_namespace($component, $namespace = '') {
+
+ // We will add them later.
+ $namespace = ltrim($namespace, '\\');
+
+ // We need add double backslashes as it is how classes are stored into self::$classmap.
+ $namespace = implode('\\\\', explode('\\', $namespace));
+
+ $regex = '/^' . $component . '\\\\' . $namespace . '/';
+ $it = new RegexIterator(new ArrayIterator(self::$classmap), $regex, RegexIterator::GET_MATCH, RegexIterator::USE_KEY);
+
+ // We want to be sure that they exist.
+ $classes = array();
+ foreach ($it as $classname => $classpath) {
+ if (class_exists($classname)) {
+ $classes[$classname] = $classpath;
+ }
+ }
+
+ return $classes;
+ }
+
/**
* Returns the exact absolute path to plugin directory.
*
--- /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/>.
+
+/**
+ * Data indexed event.
+ *
+ * @package core
+ * @copyright 2015 David Monllao - http://www.davidmonllao.com
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace core\event;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Event when new data has been indexed.
+ *
+ * @package core
+ * @since Moodle 3.1
+ * @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class search_indexed extends base {
+
+ /**
+ * Initialise required event data properties.
+ */
+ protected function init() {
+ $this->data['crud'] = 'c';
+ $this->data['edulevel'] = self::LEVEL_OTHER;
+ }
+
+ /**
+ * Returns localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('eventsearchindexed');
+ }
+
+ /**
+ * Returns non-localised event description.
+ *
+ * @return string
+ */
+ public function get_description() {
+ if (!empty($this->userid)) {
+ return "The user with id '{$this->userid}' updated the search engine data";
+ } else {
+ return 'The search engine data has been updated';
+ }
+ }
+
+ /**
+ * Returns relevant URL.
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/search/admin.php');
+ }
+}
--- /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/>.
+
+namespace core;
+
+/**
+ * User Alert notifications.
+ *
+ * @package core
+ * @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+class notification {
+ /**
+ * A notification of level 'success'.
+ */
+ const SUCCESS = 'success';
+
+ /**
+ * A notification of level 'warning'.
+ */
+ const WARNING = 'warning';
+
+ /**
+ * A notification of level 'info'.
+ */
+ const INFO = 'info';
+
+ /**
+ * A notification of level 'error'.
+ */
+ const ERROR = 'error';
+
+ /**
+ * Add a message to the session notification stack.
+ *
+ * @param string $message The message to add to the stack
+ * @param string $level The type of message to add to the stack
+ */
+ public static function add($message, $level = null) {
+ global $PAGE, $SESSION;
+
+ if ($PAGE && $PAGE->state === \moodle_page::STATE_IN_BODY) {
+ // Currently in the page body - just render and exit immediately.
+ // We insert some code to immediately insert this into the user-notifications created by the header.
+ $id = uniqid();
+ echo \html_writer::span(
+ $PAGE->get_renderer('core')->render(new \core\output\notification($message, $level)),
+ '', array('id' => $id));
+
+ // Insert this JS here using a script directly rather than waiting for the page footer to load to avoid
+ // ensure that the message is added to the user-notifications section as soon as possible after it is created.
+ echo \html_writer::script(
+ "(function() {" .
+ "var notificationHolder = document.getElementById('user-notifications');" .
+ "if (!notificationHolder) { return; }" .
+ "var thisNotification = document.getElementById('{$id}');" .
+ "if (!thisNotification) { return; }" .
+ "notificationHolder.appendChild(thisNotification.firstChild);" .
+ "thisNotification.remove();" .
+ "})();"
+ );
+ return;
+ }
+
+ // Add the notification directly to the session.
+ // This will either be fetched in the header, or by JS in the footer.
+ $SESSION->notifications[] = (object) array(
+ 'message' => $message,
+ 'type' => $level,
+ );
+ }
+
+ /**
+ * Fetch all of the notifications in the stack and clear the stack.
+ *
+ * @return array All of the notifications in the stack
+ */
+ public static function fetch() {
+ global $SESSION;
+
+ if (!isset($SESSION) || !isset($SESSION->notifications)) {
+ return [];
+ }
+
+ $notifications = $SESSION->notifications;
+ $SESSION->notifications = [];
+
+ $renderables = [];
+ foreach ($notifications as $notification) {
+ $renderable = new \core\output\notification($notification->message, $notification->type);
+ $renderables[] = $renderable;
+ }
+
+ return $renderables;
+ }
+
+ /**
+ * Fetch all of the notifications in the stack and clear the stack.
+ *
+ * @return array All of the notifications in the stack
+ */
+ public static function fetch_as_array(\renderer_base $renderer) {
+ $notifications = [];
+ foreach (self::fetch() as $notification) {
+ $notifications[] = [
+ 'template' => $notification->get_template_name(),
+ 'variables' => $notification->export_for_template($renderer),
+ ];
+ }
+ return $notifications;
+ }
+
+ /**
+ * Add a success message to the notification stack.
+ *
+ * @param string $message The message to add to the stack
+ */
+ public static function success($message) {
+ return self::add($message, self::SUCCESS);
+ }
+
+ /**
+ * Add a info message to the notification stack.
+ *
+ * @param string $message The message to add to the stack
+ */
+ public static function info($message) {
+ return self::add($message, self::INFO);
+ }
+
+ /**
+ * Add a warning message to the notification stack.
+ *
+ * @param string $message The message to add to the stack
+ */
+ public static function warning($message) {
+ return self::add($message, self::WARNING);
+ }
+
+ /**
+ * Add a error message to the notification stack.
+ *
+ * @param string $message The message to add to the stack
+ */
+ public static function error($message) {
+ return self::add($message, self::ERROR);
+ }
+}
*/
namespace core\output;
-use stdClass;
/**
* Data structure representing a notification.
class notification implements \renderable, \templatable {
/**
- * A generic message.
+ * A notification of level 'success'.
*/
- const NOTIFY_MESSAGE = 'message';
+ const NOTIFY_SUCCESS = 'success';
+
/**
- * A message notifying the user of a successful operation.
+ * A notification of level 'warning'.
*/
- const NOTIFY_SUCCESS = 'success';
+ const NOTIFY_WARNING = 'warning';
+
+ /**
+ * A notification of level 'info'.
+ */
+ const NOTIFY_INFO = 'info';
+
+ /**
+ * A notification of level 'error'.
+ */
+ const NOTIFY_ERROR = 'error';
+
/**
+ * @deprecated
+ * A generic message.
+ */
+ const NOTIFY_MESSAGE = 'message';
+
+ /**
+ * @deprecated
* A message notifying the user that a problem occurred.
*/
const NOTIFY_PROBLEM = 'problem';
+
/**
- * A message to display during a redirect..
+ * @deprecated
+ * A notification of level 'redirect'.
*/
const NOTIFY_REDIRECT = 'redirect';
/**
* @var string Message payload.
*/
- private $message = '';
+ protected $message = '';
/**
* @var string Message type.
*/
- private $messagetype = self::NOTIFY_PROBLEM;
+ protected $messagetype = self::NOTIFY_WARNING;
+
+ /**
+ * @var bool $announce Whether this notification should be announced assertively to screen readers.
+ */
+ protected $announce = true;
+
+ /**
+ * @var bool $closebutton Whether this notification should inlcude a button to dismiss itself.
+ */
+ protected $closebutton = true;
+
+ /**
+ * @var array $extraclasses A list of any extra classes that may be required.
+ */
+ protected $extraclasses = array();
/**
* Notification constructor.
* @param string $message the message to print out
* @param string $messagetype normally NOTIFY_PROBLEM or NOTIFY_SUCCESS.
*/
- public function __construct($message, $messagetype = self::NOTIFY_PROBLEM) {
+ public function __construct($message, $messagetype = null) {
+ $this->message = $message;
+
+ if (empty($messagetype)) {
+ $messagetype = self::NOTIFY_ERROR;
+ }
- $this->message = clean_text($message);
$this->messagetype = $messagetype;
+ switch ($messagetype) {
+ case self::NOTIFY_PROBLEM:
+ case self::NOTIFY_REDIRECT:
+ case self::NOTIFY_MESSAGE:
+ debugging('Use of ' . $messagetype . ' has been deprecated. Please switch to an alternative type.');
+ }
+ }
+
+ /**
+ * Set whether this notification should be announced assertively to screen readers.
+ *
+ * @param bool $announce
+ * @return $this
+ */
+ public function set_announce($announce = false) {
+ $this->announce = (bool) $announce;
+
+ return $this;
+ }
+
+ /**
+ * Set whether this notification should include a button to disiss itself.
+ *
+ * @param bool $button
+ * @return $this
+ */
+ public function set_show_closebutton($button = false) {
+ $this->closebutton = (bool) $button;
+
+ return $this;
+ }
+
+ /**
+ * Add any extra classes that this notification requires.
+ *
+ * @param array $classes
+ * @return $this
+ */
+ public function set_extra_classes($classes = array()) {
+ $this->extraclasses = $classes;
+
+ return $this;
}
/**
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output) {
+ return array(
+ 'message' => clean_text($this->message),
+ 'extraclasses' => implode(' ', $this->extraclasses),
+ 'announce' => $this->announce,
+ 'closebutton' => $this->closebutton,
+ );
+ }
- $data = new stdClass();
-
- $data->type = $this->messagetype;
- $data->message = $this->message;
+ public function get_template_name() {
+ $templatemappings = [
+ // Current types mapped to template names.
+ 'success' => 'core/notification_success',
+ 'info' => 'core/notification_info',
+ 'warning' => 'core/notification_warning',
+ 'error' => 'core/notification_error',
+ ];
- return $data;
+ if (isset($templatemappings[$this->messagetype])) {
+ return $templatemappings[$this->messagetype];
+ }
+ return $templatemappings['error'];
}
}
'blog_menu', 'blog_recent', 'blog_tags', 'calendar_month',
'calendar_upcoming', 'comments', 'community',
'completionstatus', 'course_list', 'course_overview',
- 'course_summary', 'feedback', 'glossary_random', 'html',
+ 'course_summary', 'feedback', 'globalsearch', 'glossary_random', 'html',
'login', 'mentees', 'messages', 'mnet_hosts', 'myprofile',
'navigation', 'news_items', 'online_users', 'participants',
'private_files', 'quiz_results', 'recent_activity',
'report' => array(
'backups', 'completion', 'configlog', 'courseoverview', 'eventlist',
- 'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances', 'security', 'stats', 'performance',
- 'usersessions',
+ 'log', 'loglive', 'outline', 'participation', 'progress', 'questioninstances', 'search',
+ 'security', 'stats', 'performance', 'usersessions'
),
'repository' => array(
'wikimedia', 'youtube'
),
+ 'search' => array(
+ 'solr'
+ ),
+
'scormreport' => array(
'basic',
'interactions',
--- /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/>.
+
+/**
+ * Defines classes used for plugin info.
+ *
+ * @package core
+ * @copyright 2015 Daniel Neis
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace core\plugininfo;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Class for search plugins
+ *
+ * @package core
+ * @copyright 2015 Daniel Neis
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class search extends base {
+
+ /**
+ * Is uninstall allowed or not.
+ *
+ * @return bool
+ */
+ public function is_uninstall_allowed() {
+ return true;
+ }
+
+ /**
+ * Returns the node name used in admin settings menu for this plugin settings (if applicable).
+ *
+ * @return null|string node name or null if plugin does not create settings node (default)
+ */
+ public function get_settings_section_name() {
+ return 'searchsetting' . $this->name;
+ }
+}
$this->direction = -$this->direction;
$this->currentstate += 2 * $this->direction;
}
+ $buffersize = ini_get('output_buffering');
+ if ($buffersize) {
+ // Force the buffer full.
+ echo str_pad('', $buffersize);
+ }
}
// Get progress.
public static function init_empty_session() {
global $CFG;
+ // Backup notifications. These should be preserved across session changes until the user fetches and clears them.
+ $notifications = [];
+ if (isset($GLOBALS['SESSION']->notifications)) {
+ $notifications = $GLOBALS['SESSION']->notifications;
+ }
$GLOBALS['SESSION'] = new \stdClass();
$GLOBALS['USER'] = new \stdClass();
$GLOBALS['USER']->id = 0;
+
+ // Restore notifications.
+ $GLOBALS['SESSION']->notifications = $notifications;
if (isset($CFG->mnet_localhost_id)) {
$GLOBALS['USER']->mnethostid = $CFG->mnet_localhost_id;
} else {
--- /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/>.
+
+/**
+ * A scheduled task for global search.
+ *
+ * @package core
+ * @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace core\task;
+
+/**
+ * Runs global search indexing.
+ *
+ * @package core
+ * @copyright 2015 David Monllao {@link http://www.davidmonllao.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class search_task extends scheduled_task {
+
+ /**
+ * Get a descriptive name for this task (shown to admins).
+ *
+ * @return string
+ */
+ public function get_name() {
+ return get_string('taskglobalsearch', 'admin');
+ }
+
+ /**
+ * Do the job.
+ * Throw exceptions on errors (the job will be retried).
+ */
+ public function execute() {
+ if (!\core_search\manager::is_global_search_enabled()) {
+ return;
+ }
+ $globalsearch = \core_search\manager::instance();
+
+ // Indexing database records for modules + rich documents of forum.
+ $globalsearch->index();
+
+ // Optimize index at last.
+ $globalsearch->optimize_index();
+ }
+}
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
)
+ ),
+
+ // Perform site-wide search queries through the search API.
+ 'moodle/search:query' => array(
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_SYSTEM,
+ 'archetypes' => array(
+ 'guest' => CAP_ALLOW,
+ 'user' => CAP_ALLOW,
+ 'student' => CAP_ALLOW,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ )
)
+
);
'tags' => array(
'mode' => cache_store::MODE_REQUEST,
'simplekeys' => true,
- )
+ ),
+
+ // Caches search results.
+ 'search_results' => array(
+ 'mode' => cache_store::MODE_SESSION,
+ 'simplekeys' => true,
+ 'staticacceleration' => true,
+ 'staticaccelerationsize' => 3
+ ),
);
array(
'eventname' => '\core\event\user_updated',
'callback' => 'core_badges_observer::profile_criteria_review',
- )
-
+ ),
+ array(
+ 'eventname' => '\core\event\search_indexed',
+ 'callback' => 'core_search_observer::invalidate_caches',
+ ),
);
// List of all events triggered by Moodle can be found using Events list report.
'description' => 'Generic service to update title',
'type' => 'write',
'loginrequired' => true,
- 'ajax' => true
+ 'ajax' => true,
+ ),
+
+ 'core_fetch_notifications' => array(
+ 'classname' => 'core_external',
+ 'methodname' => 'fetch_notifications',
+ 'classpath' => 'lib/external/externallib.php',
+ 'description' => 'Return a list of notifications for the current session',
+ 'type' => 'read',
+ 'loginrequired' => false,
+ 'ajax' => true,
),
// === Calendar related functions ===
'dayofweek' => '*',
'month' => '*'
),
+ array(
+ 'classname' => 'core\task\search_task',
+ 'blocking' => 0,
+ 'minute' => '*/30',
+ 'hour' => '*',
+ 'day' => '*',
+ 'dayofweek' => '*',
+ 'month' => '*'
+ ),
array(
'classname' => 'core\task\stats_cron_task',
'blocking' => 0,
* @param bool $return whether to return an output string or echo now
* @return string|bool Depending on $result
*/
-function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
+function notify($message, $classes = 'error', $align = 'center', $return = false) {
global $OUTPUT;
debugging('notify() is deprecated, please use $OUTPUT->notification() instead', DEBUG_DEVELOPER);
if ($classes == 'green') {
- debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER);
- $classes = 'notifysuccess'; // Backward compatible with old color system
+ debugging('Use of deprecated class name "green" in notify. Please change to "success".', DEBUG_DEVELOPER);
+ $classes = 'success'; // Backward compatible with old color system.
}
$output = $OUTPUT->notification($message, $classes);
/**
* Use this editor for given element.
*
+ * Available Atto-specific options:
+ * atto:toolbar - set to a string to override the system config editor_atto/toolbar
+ *
+ * Available general options:
+ * context - set to the current context object
+ * enable_filemanagement - set false to get rid of the managefiles plugin
+ * autosave - true/false to control autosave
+ *
+ * Options are also passed through to the plugins.
+ *
* @param string $elementid
* @param array $options
* @param null $fpoptions
public function use_editor($elementid, array $options=null, $fpoptions=null) {
global $PAGE;
- $configstr = get_config('editor_atto', 'toolbar');
+ if (array_key_exists('atto:toolbar', $options)) {
+ $configstr = $options['atto:toolbar'];
+ } else {
+ $configstr = get_config('editor_atto', 'toolbar');
+ }
$grouplines = explode("\n", $configstr);
And the field "Width" matches value "204"
And the field "Height" matches value "61"
And I set the field "Auto size" to "1"
+ And I wait until the page is ready
And I set the field "Width" to "2040"
# Trigger blur on the width field.
And I take focus off "Width" "field"
And I take focus off "Height" "field"
And the field "Width" matches value "204"
And I set the field "Auto size" to "0"
+ And I wait until the page is ready
And I set the field "Width" to "123"
And I set the field "Height" to "456"
# Trigger blur on the height field.
--- /dev/null
+@editor @editor_atto @atto
+Feature: Atto editor with customised toolbar
+ In order to develop plugins that use Atto for specialised purposes
+ As a developer
+ I need to be able to configure Atto toolbar per-instance to include different plugins
+
+ Background:
+ # Get to the fixture page.
+ Given the following "courses" exist:
+ | fullname | shortname | format |
+ | Course 1 | C1 | topics |
+ And the following "activities" exist:
+ | activity | name | intro | course | idnumber |
+ | label | L1 | <a href="../lib/editor/atto/tests/fixtures/custom_toolbar_example.php">FixtureLink</a> | C1 | label1 |
+ When I log in as "admin"
+ And I am on site homepage
+ And I follow "Course 1"
+ And I follow "FixtureLink"
+
+ @javascript
+ Scenario: Confirm that both editors have different toolbars but still function
+ Then ".atto_link_button" "css_element" should exist in the ".normaldiv" "css_element"
+ And ".atto_link_button" "css_element" should not exist in the ".specialdiv" "css_element"
+ And ".atto_bold_button_bold" "css_element" should exist in the ".normaldiv" "css_element"
+ And ".atto_italic_button_italic" "css_element" should exist in the ".normaldiv" "css_element"
+ And ".atto_bold_button_bold" "css_element" should exist in the ".specialdiv" "css_element"
+ And ".atto_italic_button_italic" "css_element" should exist in the ".specialdiv" "css_element"
--- /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/>.
+
+/**
+ * Demonstrates use of Atto editor with overridden toolbar setting.
+ *
+ * This fixture is only used by the Behat test.
+ *
+ * @package editor_atto
+ * @copyright 2016 The Open University
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require(__DIR__ . '/../../../../../config.php');
+require_once($CFG->dirroot . '/lib/editor/atto/lib.php');
+
+// Behat test fixture only.
+defined('BEHAT_SITE_RUNNING') || die('Only available on Behat test server');
+
+$PAGE->set_url('/lib/editor/atto/tests/fixtures/override_plugins_example.php');
+$PAGE->set_context(context_system::instance());
+
+echo $OUTPUT->header();
+
+// If this was sending some input, display it.
+$normal = optional_param('normaleditor', '', PARAM_RAW);
+$special = optional_param('specialeditor', '', PARAM_RAW);
+if ($normal !== '' || $special !== '') {
+ echo html_writer::start_div('normalresult');
+ echo s($normal);
+ echo html_writer::end_div();
+ echo html_writer::start_div('specialresult');
+ echo s($special);
+ echo html_writer::end_div();
+} else {
+ // Create a form.
+ echo html_writer::start_tag('form', array('method' => 'post', 'action' => 'custom_toolbar_example.php'));
+ echo html_writer::start_div();
+
+ // Basic editor options.
+ $options = array();
+ $atto = new atto_texteditor();
+
+ // Normal Atto.
+ echo html_writer::start_div('normaldiv');
+ echo $OUTPUT->heading('Normal Atto');
+ echo html_writer::div(html_writer::tag('textarea', '',
+ array('id' => 'normaleditor', 'name' => 'normaleditor', 'rows' => 10)));
+ $atto->use_editor('normaleditor', $options);
+ echo html_writer::end_div();
+
+ // Second Atto with custom options.
+ echo html_writer::start_div('specialdiv');
+ $options['atto:toolbar'] = <<<EOT
+style1 = bold, italic
+list = unorderedlist, orderedlist
+EOT;
+ echo $OUTPUT->heading('Special Atto');
+ echo html_writer::div(html_writer::tag('textarea', '',
+ array('id' => 'specialeditor', 'name' => 'specialeditor', 'rows' => 10)));
+ $atto->use_editor('specialeditor', $options);
+ echo html_writer::end_div();
+
+ // Button to submit form.
+ echo html_writer::start_div('', array('style' => 'margin-top: 20px'));
+ echo html_writer::tag('button', 'Submit and see the HTML');
+ echo html_writer::end_div();
+
+ echo html_writer::end_div();
+ echo html_writer::end_tag('form');
+}
+
+echo $OUTPUT->footer();
/**
* Add required JS needed for editor
+ *
+ * Valid options may vary by editor. See the individual editor
+ * implementations of this function for documentation.
+ *
* @param string $elementid id of text area to be converted to editor
- * @param array $options
+ * @param array $options Editor options
* @param obejct $fpoptions file picker options
* @return void
*/
)
);
}
+
+ /**
+ * Returns description of fetch_notifications() parameters.
+ *
+ * @return external_function_parameters
+ * @since Moodle 3.1
+ */
+ public static function fetch_notifications_parameters() {
+ return new external_function_parameters(
+ array(
+ 'contextid' => new external_value(PARAM_INT, 'Context ID', VALUE_REQUIRED),
+ ));
+ }
+
+ /**
+ * Returns description of fetch_notifications() result value.
+ *
+ * @return external_description
+ * @since Moodle 3.1
+ */
+ public static function fetch_notifications_returns() {
+ return new external_multiple_structure(
+ new external_single_structure(
+ array(
+ 'template' => new external_value(PARAM_RAW, 'Name of the template'),
+ 'variables' => new external_single_structure(array(
+ 'message' => new external_value(PARAM_RAW, 'HTML content of the Notification'),
+ 'extraclasses' => new external_value(PARAM_RAW, 'Extra classes to provide to the tmeplate'),
+ 'announce' => new external_value(PARAM_RAW, 'Whether to announce'),
+ 'closebutton' => new external_value(PARAM_RAW, 'Whether to close'),
+ )),
+ )
+ )
+ );
+ }
+
+ /**
+ * Returns the list of notifications against the current session.
+ *
+ * @return array
+ * @since Moodle 3.1
+ */
+ public static function fetch_notifications($contextid) {
+ global $PAGE;
+
+ self::validate_parameters(self::fetch_notifications_parameters(), [
+ 'contextid' => $contextid,
+ ]);
+
+ $context = \context::instance_by_id($contextid);
+ $PAGE->set_context($context);
+
+ return \core\notification::fetch_as_array($PAGE->get_renderer('core'));
+ }
}
--- /dev/null
+The Flowplayer Free version is released under the
+GNU GENERAL PUBLIC LICENSE Version 3 (GPL).
+
+The GPL requires that you not remove the Flowplayer copyright notices
+from the user interface. See section 5.d below.
+
+Commercial licenses are available. The commercial player version
+does not require any Flowplayer notices or texts and also provides
+some additional features.
+
+========================================================================
+
+ADDITIONAL TERM per GPL Section 7
+If you convey this program (or any modifications of it) and assume
+contractual liability for the program to recipients of it, you agree
+to indemnify Flowplayer, Ltd. for any liability that those contractual
+assumptions impose on Flowplayer, Ltd.
+
+Except as expressly provided herein, no trademark rights are granted in
+any trademarks of Flowplayer, Ltd. Licensees are granted a limited,
+non-exclusive right to use the mark Flowplayer and the Flowplayer logos
+in connection with unmodified copies of the Program and the copyright
+notices required by section 5.d of the GPL license. For the purposes
+of this limited trademark license grant, customizing the Flowplayer
+by skinning, scripting, or including PlugIns provided by Flowplayer, Ltd.
+is not considered modifying the Program.
+
+Licensees that do modify the Program, taking advantage of the open-source
+license, may not use the Flowplayer mark or Flowplayer logos and must
+change the fullscreen notice (and the non-fullscreen notice, if that
+option is enabled), the copyright notice in the dialog box, and the
+notice on the Canvas as follows:
+
+the full screen (and non-fullscreen equivalent, if activated) notice
+should read: "Based on Flowplayer source code"; in the context menu
+(right-click menu), the link to "About Flowplayer free version #.#.#"
+can remain. The copyright notice can remain, but must be supplemented with
+an additional notice, stating that the licensee modified the Flowplayer.
+A suitable notice might read "Flowplayer Source code modified by ModOrg 2009";
+for the canvas, the notice should read "Based on Flowplayer source code".
+In addition, licensees that modify the Program must give the modified
+Program a new name that is not confusingly similar to Flowplayer and
+may not distribute it under the name Flowplayer.
+
+========================================================================
+
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program 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.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
\ No newline at end of file
Description of FlowPlayer import
+Source code available at: https://github.com/flowplayer/flash
+
Our changes:
* the handling of flash content now it's done by PHP, checking url parameter to avoid security issues.
* we do not load the flow player if flash not present - this is much better
for accessibility and flash incompatible devices - they may play mp3 or flv directly
* no splashscreens
-TODO:
-* switch to git repo once flowplayer decides to use better version control system
-
skodak
\ No newline at end of file
function getHelpButton(){
return $this->_helpbutton;
}
-
}
if (count($options->repositories) > 0) {
$straddlink = get_string('choosealink', 'repository');
$str .= <<<EOD
-<button id="filepicker-button-{$client_id}" class="visibleifjs">
+<button id="filepicker-button-js-{$client_id}" class="visibleifjs">
$straddlink
</button>
EOD;
'actionbuttons'=>"\n\t\t".'<div id="{id}" class="fitem fitem_actionbuttons fitem_{type}"><div class="felement {type}">{element}</div></div>',
- 'fieldset'=>"\n\t\t".'<div id="{id}" class="fitem {advanced}<!-- BEGIN required --> required<!-- END required --> fitem_{type} {emptylabel}"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div></div><fieldset class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</fieldset></div>',
+ 'fieldset'=>"\n\t\t".'<div id="{id}" class="fitem {advanced} {class}<!-- BEGIN required --> required<!-- END required --> fitem_{type} {emptylabel}"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div></div><fieldset class="felement {type}<!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</fieldset></div>',
'static'=>"\n\t\t".'<div class="fitem {advanced} {emptylabel}"><div class="fitemtitle"><div class="fstaticlabel">{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</div></div><div class="felement fstatic <!-- BEGIN error --> error<!-- END error -->"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</div></div>',
$html =str_replace('{id}', 'fgroup_' . $group->getAttribute('id'), $html);
$html =str_replace('{name}', $group->getName(), $html);
$html =str_replace('{type}', 'fgroup', $html);
+ $html =str_replace('{class}', $group->getAttribute('class'), $html);
$emptylabel = '';
if ($group->getLabel() == '') {
$emptylabel = 'femptylabel';
return false; //grade items not found
}
+/**
+ * Return true if the course needs regrading.
+ *
+ * @param int $courseid The course ID
+ * @return bool true if course grades need updating.
+ */
+function grade_needs_regrade_final_grades($courseid) {
+ $course_item = grade_item::fetch_course_item($courseid);
+ return $course_item->needsupdate;
+}
+
+/**
+ * Return true if the regrade process is likely to be time consuming and
+ * will therefore require the progress bar.
+ *
+ * @param int $courseid The course ID
+ * @return bool Whether the regrade process is likely to be time consuming
+ */
+function grade_needs_regrade_progress_bar($courseid) {
+ global $DB;
+ $grade_items = grade_item::fetch_all(array('courseid' => $courseid));
+
+ list($sql, $params) = $DB->get_in_or_equal(array_keys($grade_items), SQL_PARAMS_NAMED, 'gi');
+ $gradecount = $DB->count_records_select('grade_grades', 'itemid ' . $sql, $params);
+
+ // This figure may seem arbitrary, but after analysis it seems that 100 grade_grades can be calculated in ~= 0.5 seconds.
+ // Any longer than this and we want to show the progress bar.
+ return $gradecount > 100;
+}
+
+/**
+ * Check whether regarding of final grades is required and, if so, perform the regrade.
+ *
+ * If the regrade is expected to be time consuming (see grade_needs_regrade_progress_bar), then this
+ * function will output the progress bar, and redirect to the current PAGE->url after regrading
+ * completes. Otherwise the regrading will happen immediately and the page will be loaded as per
+ * normal.
+ *
+ * A callback may be specified, which is called if regrading has taken place.
+ * The callback may optionally return a URL which will be redirected to when the progress bar is present.
+ *
+ * @param stdClass $course The course to regrade
+ * @param callable $callback A function to call if regrading took place
+ * @return moodle_url The URL to redirect to if redirecting
+ */
+function grade_regrade_final_grades_if_required($course, callable $callback = null) {
+ global $PAGE, $OUTPUT;
+
+ if (!grade_needs_regrade_final_grades($course->id)) {
+ return false;
+ }
+
+ if (grade_needs_regrade_progress_bar($course->id)) {
+ $PAGE->set_heading($course->fullname);
+ echo $OUTPUT->header();
+ echo $OUTPUT->heading(get_string('recalculatinggrades', 'grades'));
+ $progress = new \core\progress\display(true);
+ grade_regrade_final_grades($course->id, null, null, $progress);
+
+ if ($callback) {
+ //
+ $url = call_user_func($callback);
+ }
+
+ if (empty($url)) {
+ $url = $PAGE->url;
+ }
+
+ echo $OUTPUT->continue_button($url);
+ echo $OUTPUT->footer();
+ die();
+ } else {
+ $result = grade_regrade_final_grades($course->id);
+ if ($callback) {
+ call_user_func($callback);
+ }
+ return $result;
+ }
+}
+
/**
* Returns grading information for given activity, optionally with user grades
* Manual, course or category items can not be queried.
* @param int $courseid The course ID
* @param int $userid If specified try to do a quick regrading of the grades of this user only
* @param object $updated_item Optional grade item to be marked for regrading
+ * @param \core\progress\base $progress If provided, will be used to update progress on this long operation.
* @return bool true if ok, array of errors if problems found. Grade item id => error message
*/
-function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null) {
+function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null, $progress=null) {
// This may take a very long time.
\core_php_time_limit::raise();
$course_item = grade_item::fetch_course_item($courseid);
+ if ($progress == null) {
+ $progress = new \core\progress\none();
+ }
+
if ($userid) {
// one raw grade updated for one user
if (empty($updated_item)) {
$depends_on[$gid] = $grade_items[$gid]->depends_on();
}
+ $progresstotal = 0;
+ $progresscurrent = 0;
+
+ // This progress total might not be 100% accurate, because more things might get marked as needsupdate
+ // during the process.
+ foreach ($grade_items as $item) {
+ if ($item->needsupdate) {
+ $progresstotal++;
+ }
+ }
+ $progress->start_progress('regrade_course', $progresstotal);
+
$errors = array();
$finalids = array();
$gids = array_keys($grade_items);
$finalids[] = $gid; // we can make it final - does not need update
continue;
}
+ $thisprogress = $progresstotal;
+ foreach ($grade_items as $item) {
+ if ($item->needsupdate) {
+ $thisprogress--;
+ }
+ }
+ // Clip between $progresscurrent and $progresstotal.
+ $thisprogress = max(min($thisprogress, $progresstotal), $progresscurrent);
+ $progress->progress($thisprogress);
+ $progresscurrent = $thisprogress;
$doupdate = true;
foreach ($depends_on[$gid] as $did) {
break; // Found error.
}
}
+ $progress->end_progress();
if (count($errors) == 0) {
if (empty($userid)) {
$output = <<<OET
<span class="mediaplugin mediaplugin_vimeo">
<iframe title="$info" src="https://player.vimeo.com/video/$videoid"
- width="$width" height="$height" frameborder="0"></iframe>
+ width="$width" height="$height" frameborder="0"
+ webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
</span>
OET;
self::TYPE_SETTING, null, 'tags');
}
+ // Search.
+ if (!empty($CFG->enableglobalsearch) && has_capability('moodle/search:query', $sitecontext)) {
+ $node = $coursenode->add(get_string('search', 'search'), new moodle_url('/search/index.php'),
+ self::TYPE_SETTING, null, 'search');
+ }
+
if (isloggedin()) {
// Calendar
$calendarurl = new moodle_url('/calendar/view.php', array('view' => 'month'));
* @param boolean $debugdisableredirect this redirect has been disabled for
* debugging purposes. Display a message that explains, and don't
* trigger the redirect.
+ * @param string $messagetype The type of notification to show the message in.
+ * See constants on \core\output\notification.
* @return string The HTML to display to the user before dying, may contain
* meta refresh, javascript refresh, and may have set header redirects
*/
- public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect) {
+ public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect,
+ $messagetype = \core\output\notification::NOTIFY_INFO) {
global $CFG;
$url = str_replace('&', '&', $encodedurl);
throw new coding_exception('You cannot redirect after the entire page has been generated');
break;
}
- $output .= $this->notification($message, 'redirectmessage');
+ $output .= $this->notification($message, $messagetype);
$output .= '<div class="continuebutton">(<a href="'. $encodedurl .'">'. get_string('continue') .'</a>)</div>';
if ($debugdisableredirect) {
$output .= '<p><strong>'.get_string('erroroutput', 'error').'</strong></p>';
* @return string HTML fragment
*/
public function footer() {
- global $CFG, $DB;
+ global $CFG, $DB, $PAGE;
$output = $this->container_end_all(true);
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
+ $this->page->requires->js_call_amd('core/notification', 'init', array($PAGE->context->id, \core\notification::fetch_as_array($this)));
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
*/
public function course_content_header($onlyifnotcalledbefore = false) {
global $CFG;
- if ($this->page->course->id == SITEID) {
- // return immediately and do not include /course/lib.php if not necessary
- return '';
- }
static $functioncalled = false;
if ($functioncalled && $onlyifnotcalledbefore) {
// we have already output the content header
return '';
}
+
+ // Output any session notification.
+ $notifications = \core\notification::fetch();
+
+ $bodynotifications = '';
+ foreach ($notifications as $notification) {
+ $bodynotifications .= $this->render_from_template(
+ $notification->get_template_name(),
+ $notification->export_for_template($this)
+ );
+ }
+
+ $output = html_writer::span($bodynotifications, 'notifications', array('id' => 'user-notifications'));
+
+ if ($this->page->course->id == SITEID) {
+ // return immediately and do not include /course/lib.php if not necessary
+ return $output;
+ }
+
require_once($CFG->dirroot.'/course/lib.php');
$functioncalled = true;
$courseformat = course_get_format($this->page->course);
if (($obj = $courseformat->course_content_header()) !== null) {
- return html_writer::div($courseformat->get_renderer($this->page)->render($obj), 'course-content-header');
+ $output .= html_writer::div($courseformat->get_renderer($this->page)->render($obj), 'course-content-header');
}
- return '';
+ return $output;
}
/**
}
/**
- * Output a notification (that is, a status message about something that has
- * just happened).
+ * Output a notification (that is, a status message about something that has just happened).
*
- * @param string $message the message to print out
- * @param string $classes normally 'notifyproblem' or 'notifysuccess'.
+ * Note: \core\notification::add() may be more suitable for your usage.
+ *
+ * @param string $message The message to print out.
+ * @param string $type The type of notification. See constants on \core\output\notification.
* @return string the HTML to output.
*/
- public function notification($message, $classes = 'notifyproblem') {
-
- $classmappings = array(
- 'notifyproblem' => \core\output\notification::NOTIFY_PROBLEM,
- 'notifytiny' => \core\output\notification::NOTIFY_PROBLEM,
- 'notifysuccess' => \core\output\notification::NOTIFY_SUCCESS,
- 'notifymessage' => \core\output\notification::NOTIFY_MESSAGE,
- 'redirectmessage' => \core\output\notification::NOTIFY_REDIRECT
- );
-
- // Identify what type of notification this is.
- $type = \core\output\notification::NOTIFY_PROBLEM;
- $classarray = explode(' ', self::prepare_classes($classes));
- if (count($classarray) > 0) {
- foreach ($classarray as $class) {
- if (isset($classmappings[$class])) {
- $type = $classmappings[$class];
- break;
+ public function notification($message, $type = null)&nbs