mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
Merge branch 'MDL-56553-master-2' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
8f5de6f268
@ -28,6 +28,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use tool_usertours\local\forms;
|
||||
use tool_usertours\local\table;
|
||||
use core\notification;
|
||||
|
||||
/**
|
||||
* Tour manager.
|
||||
@ -117,6 +118,21 @@ class manager {
|
||||
*/
|
||||
const ACTION_RESETFORALL = 'resetforall';
|
||||
|
||||
/**
|
||||
* @var CONFIG_SHIPPED_TOUR
|
||||
*/
|
||||
const CONFIG_SHIPPED_TOUR = 'shipped_tour';
|
||||
|
||||
/**
|
||||
* @var CONFIG_SHIPPED_FILENAME
|
||||
*/
|
||||
const CONFIG_SHIPPED_FILENAME = 'shipped_filename';
|
||||
|
||||
/**
|
||||
* @var CONFIG_SHIPPED_VERSION
|
||||
*/
|
||||
const CONFIG_SHIPPED_VERSION = 'shipped_version';
|
||||
|
||||
/**
|
||||
* This is the entry point for this controller class.
|
||||
*
|
||||
@ -349,6 +365,10 @@ class manager {
|
||||
if (empty($tour)) {
|
||||
$this->header('newtour');
|
||||
} else {
|
||||
if (!empty($tour->get_config(self::CONFIG_SHIPPED_TOUR))) {
|
||||
notification::add(get_string('modifyshippedtourwarning', 'tool_usertours'), notification::WARNING);
|
||||
}
|
||||
|
||||
$this->header($tour->get_name());
|
||||
$data = $tour->prepare_data_for_form();
|
||||
|
||||
@ -646,6 +666,11 @@ class manager {
|
||||
}
|
||||
|
||||
$tour = $step->get_tour();
|
||||
|
||||
if (!empty($tour->get_config(self::CONFIG_SHIPPED_TOUR))) {
|
||||
notification::add(get_string('modifyshippedtourwarning', 'tool_usertours'), notification::WARNING);
|
||||
}
|
||||
|
||||
$PAGE->navbar->add($tour->get_name(), $tour->get_view_link());
|
||||
if (isset($id)) {
|
||||
$PAGE->navbar->add($step->get_title(), $step->get_edit_link());
|
||||
@ -750,4 +775,68 @@ class manager {
|
||||
$step->remove();
|
||||
redirect($tour->get_view_link());
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure all of the default tours that are shipped with Moodle are created
|
||||
* and up to date with the latest version.
|
||||
*/
|
||||
public static function update_shipped_tours() {
|
||||
global $DB, $CFG;
|
||||
|
||||
// A list of tours that are shipped with Moodle. They are in
|
||||
// the format filename => version. The version value needs to
|
||||
// be increased if the tour has been updated.
|
||||
$shippedtours = [
|
||||
'boost_administrator.json' => 1,
|
||||
'boost_course_view.json' => 1,
|
||||
];
|
||||
|
||||
$existingtourrecords = $DB->get_recordset('tool_usertours_tours');
|
||||
|
||||
// Get all of the existing shipped tours and check if they need to be
|
||||
// updated.
|
||||
foreach ($existingtourrecords as $tourrecord) {
|
||||
$tour = tour::load_from_record($tourrecord);
|
||||
|
||||
if (!empty($tour->get_config(self::CONFIG_SHIPPED_TOUR))) {
|
||||
$filename = $tour->get_config(self::CONFIG_SHIPPED_FILENAME);
|
||||
$version = $tour->get_config(self::CONFIG_SHIPPED_VERSION);
|
||||
|
||||
// If we know about this tour (otherwise leave it as is).
|
||||
if (isset($shippedtours[$filename])) {
|
||||
// And the version in the DB is an older version.
|
||||
if ($version < $shippedtours[$filename]) {
|
||||
// Remove the old version because it's been updated
|
||||
// and needs to be recreated.
|
||||
$tour->remove();
|
||||
} else {
|
||||
// The tour has not been updated so we don't need to
|
||||
// do anything with it.
|
||||
unset($shippedtours[$filename]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$existingtourrecords->close();
|
||||
|
||||
foreach ($shippedtours as $filename => $version) {
|
||||
$filepath = $CFG->dirroot . '/admin/tool/usertours/tours/' . $filename;
|
||||
$tourjson = file_get_contents($filepath);
|
||||
$tour = self::import_tour_from_json($tourjson);
|
||||
|
||||
// Set some additional config data to record that this tour was
|
||||
// added as a shipped tour.
|
||||
$tour->set_config(self::CONFIG_SHIPPED_TOUR, true);
|
||||
$tour->set_config(self::CONFIG_SHIPPED_FILENAME, $filename);
|
||||
$tour->set_config(self::CONFIG_SHIPPED_VERSION, $version);
|
||||
|
||||
if (defined('BEHAT_SITE_RUNNING') || (defined('PHPUNIT_TEST') && PHPUNIT_TEST)) {
|
||||
// Disable this tour if this is behat or phpunit.
|
||||
$tour->set_enabled(false);
|
||||
}
|
||||
|
||||
$tour->persist();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
use tool_usertours\manager;
|
||||
|
||||
/**
|
||||
* Perform the post-install procedures.
|
||||
*/
|
||||
@ -71,4 +73,7 @@ function xmldb_tool_usertours_install() {
|
||||
$DB->delete_records('usertours_steps', null);
|
||||
$DB->delete_records('usertours_tours', null);
|
||||
}
|
||||
|
||||
// Update the tours shipped with Moodle.
|
||||
manager::update_shipped_tours();
|
||||
}
|
||||
|
46
admin/tool/usertours/db/upgrade.php
Normal file
46
admin/tool/usertours/db/upgrade.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Upgrade code for install
|
||||
*
|
||||
* @package tool_usertours
|
||||
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
use tool_usertours\manager;
|
||||
|
||||
/**
|
||||
* Upgrade the user tours plugin.
|
||||
*
|
||||
* @param int $oldversion The old version of the user tours plugin
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
if ($oldversion < 2016120501) {
|
||||
// Update the tours shipped with Moodle.
|
||||
manager::update_shipped_tours();
|
||||
|
||||
upgrade_plugin_savepoint(true, 2016120501, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -60,6 +60,7 @@ $string['filter_role'] = 'Role';
|
||||
$string['filter_role_help'] = 'A tour may be restricted to users with selected roles in the context where the tour is shown. For example, restricting a Dashboard tour to users with the role of student won\'t work if users have the role of student in a course (as is generally the case). A Dashboard tour can only be restricted to users with a system role.';
|
||||
$string['importtour'] = 'Import tour';
|
||||
$string['left'] = 'Left';
|
||||
$string['modifyshippedtourwarning'] = 'This is a user tour that has shipped with Moodle. Any modifications you make may be overridden during your next site upgrade.';
|
||||
$string['movestepdown'] = 'Move step down';
|
||||
$string['movestepup'] = 'Move step up';
|
||||
$string['movetourdown'] = 'Move tour down';
|
||||
@ -136,3 +137,35 @@ $string['target_selector_targetvalue_help'] = 'A CSS selector can be used to tar
|
||||
$string['viewtour_info'] = 'This is the \'{$a->tourname}\' tour. It applies to the path \'{$a->path}\'.';
|
||||
$string['viewtour_edit'] = 'You can <a href="{$a->editlink}">edit the tour defaults</a> and <a href="{$a->resetlink}">force the tour to be displayed</a> to all users again.';
|
||||
$string['tour_resetforall'] = 'The state of the tour has been reset. It will be displayed to all users again.';
|
||||
|
||||
// Boost - administrator tour.
|
||||
$string['tour1_title_welcome'] = 'Welcome';
|
||||
$string['tour1_content_welcome'] = 'Welcome to the Boost theme for Moodle 3.2. If you\'ve used Moodle before you might find some things look a bit different.';
|
||||
$string['tour1_title_navigation'] = 'Navigation';
|
||||
$string['tour1_content_navigation'] = 'Major navigation is now through this nav drawer. The contents update depending on where you are in the site. Use the button at the top to hide or show it.';
|
||||
$string['tour1_title_customisation'] = 'Customisation';
|
||||
$string['tour1_content_customisation'] = 'To customise the look of your site and the front page, use the settings menu in the corner of this header. Try turning editing on right now.';
|
||||
$string['tour1_title_blockregion'] = 'Block region';
|
||||
$string['tour1_content_blockregion'] = 'There is still a block region over here. We recommend removing the Navigation and Settings blocks completely, as all the functionality is elsewhere in the Boost theme.';
|
||||
$string['tour1_title_addingblocks'] = 'Adding blocks';
|
||||
$string['tour1_content_addingblocks'] = 'In fact, think carefully about including any blocks on your pages. Blocks are not shown on the Moodle mobile app, so as a general rule it\'s much better to make sure your site works well without any blocks.';
|
||||
$string['tour1_title_end'] = 'End of tour';
|
||||
$string['tour1_content_end'] = 'This has been a user tour, a new feature in Moodle 3.2. It won\'t show again unless you reset it using the link in the footer. As an admin you can also create your own tours like this!';
|
||||
|
||||
// Boost - course view tour.
|
||||
$string['tour2_title_welcome'] = 'Welcome';
|
||||
$string['tour2_content_welcome'] = 'Welcome to the Boost theme for Moodle 3.2. If you\'ve used Moodle before you might find things look a bit different here on the course page.';
|
||||
$string['tour2_title_customisation'] = 'Customisation';
|
||||
$string['tour2_content_customisation'] = 'To change any course settings, use the settings menu in the corner of this header. You will find a similar settings menu on the home page of every activity, too. Try turning editing on right now.';
|
||||
$string['tour2_title_navigation'] = 'Navigation';
|
||||
$string['tour2_content_navigation'] = 'Major navigation is now though this nav drawer. Use the button at the top to hide or show it. You will see that there are links for major sections of your course.';
|
||||
$string['tour2_title_opendrawer'] = 'Open the nav drawer';
|
||||
$string['tour2_content_opendrawer'] = 'Try opening the nav drawer now.';
|
||||
$string['tour2_title_participants'] = 'Course participants';
|
||||
$string['tour2_content_participants'] = 'View participants here. This is also where you go to add or remove students.';
|
||||
$string['tour2_title_addblock'] = 'Add a block';
|
||||
$string['tour2_content_addblock'] = 'If you enable editing mode you can add blocks from the nav drawer. However, think carefully about including any blocks on your pages. Blocks are not shown on Moodle mobile app, so for the best student experience it is much better to make sure your course works well without any blocks.';
|
||||
$string['tour2_title_addingblocks'] = 'Adding blocks';
|
||||
$string['tour2_content_addingblocks'] = 'You can add blocks to this page using this button. However, think carefully about including any blocks on your pages. Blocks are not shown on Moodle mobile app, so for the best student experience it is much better to make sure your course works well without any blocks.';
|
||||
$string['tour2_title_end'] = 'End of tour';
|
||||
$string['tour2_content_end'] = 'This has been a user tour, a new feature in Moodle 3.2. It won\'t show again unless you reset it using the link in the footer. The site admin can also create further tours for this site if required.';
|
||||
|
2
admin/tool/usertours/tours/boost_administrator.json
Normal file
2
admin/tool/usertours/tours/boost_administrator.json
Normal file
@ -0,0 +1,2 @@
|
||||
{"name":"Boost - administrator","description":"A tour for Administrator's new to the Boost theme","pathmatch":"FRONTPAGE","enabled":"1","sortorder":"0","configdata":"{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"role\":[\"-1\"],\"theme\":[\"boost\"]},\"majorupdatetime\":1479366244,\"default_tour\":true,\"filename\":\"boost_administrator.json\",\"version\":1}","version":"2016102001","steps":[{"title":"tour1_title_welcome,tool_usertours","content":"tour1_content_welcome,tool_usertours","targettype":"2","targetvalue":"","sortorder":"0","configdata":"{}"},{"title":"tour1_title_navigation,tool_usertours","content":"tour1_content_navigation,tool_usertours","targettype":"0","targetvalue":"[data-region=\"drawer-toggle\"] button[data-action=\"toggle-drawer\"]","sortorder":"1","configdata":"{}"},{"title":"tour1_title_customisation,tool_usertours","content":"tour1_content_customisation,tool_usertours","targettype":"0","targetvalue":"body:not(.editing) #page-header .card-block","sortorder":"2","configdata":"{\"placement\":\"bottom\"}"},{"title":"tour1_title_blockregion,tool_usertours","content":"tour1_content_blockregion,tool_usertours","targettype":"0","targetvalue":"body.editing [data-region=\"blocks-column\"]","sortorder":"3","configdata":"{}"},{"title":"tour1_title_addingblocks,tool_usertours","content":"tour1_content_addingblocks,tool_usertours","targettype":"0","targetvalue":"body.editing [data-region=\"blocks-column\"]","sortorder":"4","configdata":"{\"placement\":\"bottom\"}"},{"title":"tour1_title_end,tool_usertours","content":"tour1_content_end,tool_usertours","targettype":"2","targetvalue":"","sortorder":"5","configdata":"{}"}]}
|
||||
|
2
admin/tool/usertours/tours/boost_course_view.json
Normal file
2
admin/tool/usertours/tours/boost_course_view.json
Normal file
@ -0,0 +1,2 @@
|
||||
{"name":"Boost - course view","description":"A tour for introducing administrators and teachers to courses in the Boost theme","pathmatch":"\/course\/view.php%","enabled":"1","sortorder":"1","configdata":"{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"role\":[\"-1\",\"editingteacher\"],\"theme\":[\"boost\"]},\"majorupdatetime\":1480050104}","version":"2016102001","steps":[{"title":"tour2_title_welcome,tool_usertours","content":"tour2_content_welcome,tool_usertours","targettype":"2","targetvalue":"","sortorder":"0","configdata":"{}"},{"title":"tour2_title_customisation,tool_usertours","content":"tour2_content_customisation,tool_usertours","targettype":"0","targetvalue":"body:not(.editing) #page-header .card-block","sortorder":"1","configdata":"{}"},{"title":"tour2_title_navigation,tool_usertours","content":"tour2_content_navigation,tool_usertours","targettype":"0","targetvalue":"[data-region=\"drawer-toggle\"] button[data-action=\"toggle-drawer\"]","sortorder":"2","configdata":"{}"},{"title":"tour2_title_opendrawer,tool_usertours","content":"tour2_content_opendrawer,tool_usertours","targettype":"0","targetvalue":"body:not(.drawer-open-left) [data-region=\"drawer-toggle\"] button[data-action=\"toggle-drawer\"]","sortorder":"3","configdata":"{}"},{"title":"tour2_title_participants,tool_usertours","content":"tour2_content_participants,tool_usertours","targettype":"0","targetvalue":"body.drawer-open-left [data-region=\"drawer\"] [data-key=\"participants\"]","sortorder":"4","configdata":"{\"placement\":\"bottom\",\"backdrop\":\"0\"}"},{"title":"tour2_title_addblock,tool_usertours","content":"tour2_content_addblock,tool_usertours","targettype":"0","targetvalue":"body.drawer-open-left:not(.editing) [data-region=\"drawer\"]","sortorder":"5","configdata":"{\"placement\":\"top\",\"orphan\":\"0\",\"backdrop\":\"0\",\"reflex\":\"0\"}"},{"title":"tour2_title_addingblocks,tool_usertours","content":"tour2_content_addingblocks,tool_usertours","targettype":"0","targetvalue":"body.drawer-open-left.editing [data-region=\"drawer\"] [data-key=\"addblock\"]","sortorder":"6","configdata":"{\"backdrop\":\"0\",\"placement\":\"top\"}"},{"title":"tour2_title_end,tool_usertours","content":"tour2_content_end,tool_usertours","targettype":"2","targetvalue":"","sortorder":"7","configdata":"{}"}]}
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2016120500; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2016120501; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2016112900; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).
|
||||
|
@ -103,3 +103,10 @@ span[data-flexitour="container"] {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hack the bone! Hack the bone!
|
||||
[data-region="drawer"] [data-flexitour="container"] {
|
||||
/*rtl:ignore*/
|
||||
margin-left: -15px;
|
||||
width: $drawer-width - 10px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user