diff --git a/admin/tool/usertours/classes/local/table/step_list.php b/admin/tool/usertours/classes/local/table/step_list.php
index b4a80e083b7..c774c6e63f6 100644
--- a/admin/tool/usertours/classes/local/table/step_list.php
+++ b/admin/tool/usertours/classes/local/table/step_list.php
@@ -101,7 +101,10 @@ class step_list extends \flexible_table {
$content = file_rewrite_pluginfile_urls($content, 'pluginfile.php', $systemcontext->id,
'tool_usertours', 'stepcontent', $step->get_id());
- return format_text(helper::get_string_from_input($content), $step->get_contentformat());
+ $content = helper::get_string_from_input($content);
+ $content = step::get_step_image_from_input($content);
+
+ return format_text($content, $step->get_contentformat());
}
/**
diff --git a/admin/tool/usertours/classes/manager.php b/admin/tool/usertours/classes/manager.php
index 33dfffea827..13f6cad6e63 100644
--- a/admin/tool/usertours/classes/manager.php
+++ b/admin/tool/usertours/classes/manager.php
@@ -864,6 +864,10 @@ class manager {
// the format filename => version. The version value needs to
// be increased if the tour has been updated.
$shippedtours = [
+ '40_tour_navigation_dashboard.json' => 1,
+ '40_tour_navigation_mycourse.json' => 1,
+ '40_tour_navigation_course_teacher.json' => 1,
+ '40_tour_navigation_course_student.json' => 1,
];
// These are tours that we used to ship but don't ship any longer.
diff --git a/admin/tool/usertours/classes/output/step.php b/admin/tool/usertours/classes/output/step.php
index cffc90c6251..c62094bf586 100644
--- a/admin/tool/usertours/classes/output/step.php
+++ b/admin/tool/usertours/classes/output/step.php
@@ -68,6 +68,9 @@ class step implements \renderable {
$content = file_rewrite_pluginfile_urls($content, 'pluginfile.php', $systemcontext->id,
'tool_usertours', 'stepcontent', $step->get_id());
+ $content = helper::get_string_from_input($content);
+ $content = $step::get_step_image_from_input($content);
+
$result = (object) [
'stepid' => $step->get_id(),
'title' => external_format_text(
@@ -77,7 +80,7 @@ class step implements \renderable {
'tool_usertours'
)[0],
'content' => external_format_text(
- helper::get_string_from_input($content),
+ $content,
$step->get_contentformat(),
$PAGE->context->id,
'tool_usertours'
diff --git a/admin/tool/usertours/classes/step.php b/admin/tool/usertours/classes/step.php
index 41e968eeda4..0fe9b6999a3 100644
--- a/admin/tool/usertours/classes/step.php
+++ b/admin/tool/usertours/classes/step.php
@@ -817,4 +817,29 @@ class step {
return $string;
}
+
+ /**
+ * Attempt to replace PIXICON placeholder with the correct images for tour step content.
+ *
+ * @param string $content Tour content
+ * @return string Processed tour content
+ */
+ public static function get_step_image_from_input(string $content): string {
+ global $OUTPUT;
+
+ if (preg_match('/(?<=@@PIXICON::).*?(?=@@)/', $content, $matches)) {
+ $bits = explode('::', $matches[0]);
+ $identifier = $bits[0];
+ $component = $bits[1];
+ if ($component == 'moodle') {
+ $component = 'core';
+ }
+ $image = \html_writer::img($OUTPUT->image_url($identifier, $component)->out(false),
+ '', ['class' => 'img-fluid']);
+ $contenttoreplace = '@@PIXICON::' . $matches[0] . '@@';
+ $content = str_replace($contenttoreplace, $image, $content);
+ }
+
+ return $content;
+ }
}
diff --git a/admin/tool/usertours/db/upgrade.php b/admin/tool/usertours/db/upgrade.php
index b299b85f1be..487cb65190a 100644
--- a/admin/tool/usertours/db/upgrade.php
+++ b/admin/tool/usertours/db/upgrade.php
@@ -114,11 +114,12 @@ function xmldb_tool_usertours_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2021101300, 'tool', 'usertours');
}
- if ($oldversion < 2021101301) {
+ if ($oldversion < 2021101302) {
// Update shipped tours.
+ // Normally, we just bump the version numbers because we need to call update_shipped_tours only once.
manager::update_shipped_tours();
- upgrade_plugin_savepoint(true, 2021101301, 'tool', 'usertours');
+ upgrade_plugin_savepoint(true, 2021101302, 'tool', 'usertours');
}
return true;
diff --git a/admin/tool/usertours/lang/en/tool_usertours.php b/admin/tool/usertours/lang/en/tool_usertours.php
index 710ca43ef46..03dfbc6fb2e 100644
--- a/admin/tool/usertours/lang/en/tool_usertours.php
+++ b/admin/tool/usertours/lang/en/tool_usertours.php
@@ -266,6 +266,28 @@ $string['tour_activityinfo_course_student_content'] = 'Activity dates and/or wha
$string['tour_activityinfo_course_teacher_title'] = 'New: Activity information';
$string['tour_activityinfo_course_teacher_content'] = 'New course settings \'Show completion conditions\' and \'Show activity dates\' enable you to choose whether activity completion conditions (if set) and/or dates are displayed for students on the course page.';
+// 4.0 New navigation tour.
+$string['tour_navigation_course_announcements_teacher_content'] = '@@PIXICON::tour/tour_course_admin_3::tool_usertours@@
Post important news here.';
+$string['tour_navigation_course_announcements_teacher_title'] = 'Something to tell everyone?';
+$string['tour_navigation_course_edit_teacher_content'] = '@@PIXICON::tour/tour_course_admin_1::tool_usertours@@
Add new content or edit existing content.';
+$string['tour_navigation_course_edit_teacher_title'] = 'Activate edit mode';
+$string['tour_navigation_course_index_student_content'] = '@@PIXICON::tour/tour_course_student::tool_usertours@@
Browse through activities and track your progress.';
+$string['tour_navigation_course_index_student_title'] = 'Find your way around';
+$string['tour_navigation_course_index_teacher_content'] = '@@PIXICON::tour/tour_course_admin_2::tool_usertours@@
Drag and drop activities to re-order course content.';
+$string['tour_navigation_course_index_teacher_title'] = 'Course index';
+$string['tour_navigation_course_student_tour_des'] = 'Where to browse through activities in a course';
+$string['tour_navigation_course_student_tour_name'] = 'Course index';
+$string['tour_navigation_course_teacher_tour_des'] = 'Edit mode, drag and drop of activities and posting announcements in a course';
+$string['tour_navigation_course_teacher_tour_name'] = 'Course editing';
+$string['tour_navigation_dashboard_content'] = '@@PIXICON::tour/tour_dashboard::tool_usertours@@
This side panel can contain more features.';
+$string['tour_navigation_dashboard_title'] = 'Expand to explore!';
+$string['tour_navigation_dashboard_tour_des'] = 'Where blocks can be found on the Dashboard';
+$string['tour_navigation_dashboard_tour_name'] = 'Block drawer';
+$string['tour_navigation_mycourses_content'] = '@@PIXICON::tour/tour_mycourses::tool_usertours@@
Add, copy, delete and hide courses from this menu.';
+$string['tour_navigation_mycourses_title'] = 'Courses and categories';
+$string['tour_navigation_mycourses_tour_des'] = 'Course management options on the My courses page';
+$string['tour_navigation_mycourses_tour_name'] = 'Course management';
+
$string['tour_final_step_title'] = 'End of tour';
$string['tour_final_step_content'] = 'This is the end of your user tour. It won\'t show again unless you reset it using the link in the footer.';
diff --git a/admin/tool/usertours/pix/tour/tour_course_admin_1.png b/admin/tool/usertours/pix/tour/tour_course_admin_1.png
new file mode 100644
index 00000000000..29e6f8493f9
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_course_admin_1.png differ
diff --git a/admin/tool/usertours/pix/tour/tour_course_admin_2.png b/admin/tool/usertours/pix/tour/tour_course_admin_2.png
new file mode 100644
index 00000000000..a460a816fea
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_course_admin_2.png differ
diff --git a/admin/tool/usertours/pix/tour/tour_course_admin_3.png b/admin/tool/usertours/pix/tour/tour_course_admin_3.png
new file mode 100644
index 00000000000..5f37de859a9
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_course_admin_3.png differ
diff --git a/admin/tool/usertours/pix/tour/tour_course_student.png b/admin/tool/usertours/pix/tour/tour_course_student.png
new file mode 100644
index 00000000000..d066c9292f9
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_course_student.png differ
diff --git a/admin/tool/usertours/pix/tour/tour_dashboard.png b/admin/tool/usertours/pix/tour/tour_dashboard.png
new file mode 100644
index 00000000000..51709c9ad6d
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_dashboard.png differ
diff --git a/admin/tool/usertours/pix/tour/tour_mycourses.png b/admin/tool/usertours/pix/tour/tour_mycourses.png
new file mode 100644
index 00000000000..ff241937604
Binary files /dev/null and b/admin/tool/usertours/pix/tour/tour_mycourses.png differ
diff --git a/admin/tool/usertours/tests/step_test.php b/admin/tool/usertours/tests/step_test.php
index 6937b776d69..d6c78d0dea5 100644
--- a/admin/tool/usertours/tests/step_test.php
+++ b/admin/tool/usertours/tests/step_test.php
@@ -823,4 +823,26 @@ class step_testcase extends advanced_testcase {
$this->assertEquals($value, $step->$getter());
}
+
+ /**
+ * Ensure that the get_step_image_from_input function replace PIXICON placeholder with the correct images correctly.
+ */
+ public function test_get_step_image_from_input() {
+ $stepcontent = '@@PIXICON::tour/tour_mycourses::tool_usertours@@
Test';
+ $stepcontent = \tool_usertours\step::get_step_image_from_input($stepcontent);
+
+ // If the format is correct, PIXICON placeholder will be replaced with the img tag.
+ $this->assertStringStartsWith('
assertStringEndsWith('Test', $stepcontent);
+ $this->assertStringNotContainsString('PIXICON', $stepcontent);
+
+ $stepcontent = '@@PIXICON::tour/tour_mycourses
Test';
+ $stepcontent = \tool_usertours\step::get_step_image_from_input($stepcontent);
+
+ // If the format is not correct, PIXICON placeholder will not be replaced with the img tag.
+ $this->assertStringStartsNotWith('
assertStringStartsWith('@@PIXICON', $stepcontent);
+ $this->assertStringEndsWith('Test', $stepcontent);
+ $this->assertStringContainsString('PIXICON', $stepcontent);
+ }
}
diff --git a/admin/tool/usertours/tours/40_tour_navigation_course_student.json b/admin/tool/usertours/tours/40_tour_navigation_course_student.json
new file mode 100644
index 00000000000..c44950e7d61
--- /dev/null
+++ b/admin/tool/usertours/tours/40_tour_navigation_course_student.json
@@ -0,0 +1,22 @@
+{
+ "name": "tour_navigation_course_student_tour_name,tool_usertours",
+ "description": "tour_navigation_course_student_tour_des,tool_usertours",
+ "pathmatch": "\/course\/view.php%",
+ "enabled": "1",
+ "sortorder": "3",
+ "endtourlabel": "",
+ "configdata": "{\"placement\":\"right\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[\"student\"],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972472,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_course_student.json\",\"shipped_version\":1}",
+ "displaystepnumbers": true,
+ "version": "2021101301",
+ "steps": [
+ {
+ "title": "tour_navigation_course_index_student_title,tool_usertours",
+ "content": "tour_navigation_course_index_student_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": "#theme_boost-drawers-courseindex .drawercontent",
+ "sortorder": "0",
+ "configdata": "{}"
+ }
+ ]
+}
diff --git a/admin/tool/usertours/tours/40_tour_navigation_course_teacher.json b/admin/tool/usertours/tours/40_tour_navigation_course_teacher.json
new file mode 100644
index 00000000000..30791351dd7
--- /dev/null
+++ b/admin/tool/usertours/tours/40_tour_navigation_course_teacher.json
@@ -0,0 +1,40 @@
+{
+ "name": "tour_navigation_course_teacher_tour_name,tool_usertours",
+ "description": "tour_navigation_course_teacher_tour_des,tool_usertours",
+ "pathmatch": "\/course\/view.php%",
+ "enabled": "1",
+ "sortorder": "2",
+ "endtourlabel": "",
+ "configdata": "{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[\"-1\",\"coursecreator\",\"manager\",\"teacher\",\"editingteacher\"],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972470,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_course_teacher.json\",\"shipped_version\":1}",
+ "displaystepnumbers": true,
+ "version": "2021101301",
+ "steps": [
+ {
+ "title": "tour_navigation_course_edit_teacher_title,tool_usertours",
+ "content": "tour_navigation_course_edit_teacher_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": "form.editmode-switch-form",
+ "sortorder": "0",
+ "configdata": "{}"
+ },
+ {
+ "title": "tour_navigation_course_index_teacher_title,tool_usertours",
+ "content": "tour_navigation_course_index_teacher_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": "#theme_boost-drawers-courseindex .drawercontent",
+ "sortorder": "1",
+ "configdata": "{\"placement\":\"right\"}"
+ },
+ {
+ "title": "tour_navigation_course_announcements_teacher_title,tool_usertours",
+ "content": "tour_navigation_course_announcements_teacher_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": ".course-content .course-content-item-content .activity-item[data-activityname=\"Announcements\"]",
+ "sortorder": "2",
+ "configdata": "{\"placement\":\"left\"}"
+ }
+ ]
+}
diff --git a/admin/tool/usertours/tours/40_tour_navigation_dashboard.json b/admin/tool/usertours/tours/40_tour_navigation_dashboard.json
new file mode 100644
index 00000000000..671e1012aee
--- /dev/null
+++ b/admin/tool/usertours/tours/40_tour_navigation_dashboard.json
@@ -0,0 +1,22 @@
+{
+ "name": "tour_navigation_dashboard_tour_name,tool_usertours",
+ "description": "tour_navigation_dashboard_tour_des,tool_usertours",
+ "pathmatch": "FRONTPAGE",
+ "enabled": "1",
+ "sortorder": "0",
+ "endtourlabel": "",
+ "configdata": "{\"placement\":\"left\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972465,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_dashboard.json\",\"shipped_version\":1}",
+ "displaystepnumbers": true,
+ "version": "2021101301",
+ "steps": [
+ {
+ "title": "tour_navigation_dashboard_title,tool_usertours",
+ "content": "tour_navigation_dashboard_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": ".drawer-toggles .drawer-toggler.drawer-right-toggle",
+ "sortorder": "0",
+ "configdata": "{\"placement\":\"left\"}"
+ }
+ ]
+}
diff --git a/admin/tool/usertours/tours/40_tour_navigation_mycourse.json b/admin/tool/usertours/tours/40_tour_navigation_mycourse.json
new file mode 100644
index 00000000000..48c091014e3
--- /dev/null
+++ b/admin/tool/usertours/tours/40_tour_navigation_mycourse.json
@@ -0,0 +1,22 @@
+{
+ "name": "tour_navigation_mycourses_tour_name,tool_usertours",
+ "description": "tour_navigation_mycourses_tour_des,tool_usertours",
+ "pathmatch": "\/my\/courses.php",
+ "enabled": "1",
+ "sortorder": "1",
+ "endtourlabel": "I understand",
+ "configdata": "{\"placement\":\"bottom\",\"orphan\":\"0\",\"backdrop\":\"1\",\"reflex\":\"0\",\"filtervalues\":{\"accessdate\":{\"filter_accessdate\":\"tool_usertours_accountcreation\",\"filter_accessdate_range\":0,\"filter_accessdate_enabled\":\"0\"},\"category\":[],\"course\":[],\"courseformat\":[],\"role\":[],\"theme\":[\"boost\"],\"cssselector\":[]},\"majorupdatetime\":1641972468,\"shipped_tour\":true,\"shipped_filename\":\"40_tour_navigation_mycourse.json\",\"shipped_version\":1}",
+ "displaystepnumbers": true,
+ "version": "2021101301",
+ "steps": [
+ {
+ "title": "tour_navigation_mycourses_title,tool_usertours",
+ "content": "tour_navigation_mycourses_content,tool_usertours",
+ "contentformat": "1",
+ "targettype": "0",
+ "targetvalue": ".header-actions-container .btn-group",
+ "sortorder": "0",
+ "configdata": "{}"
+ }
+ ]
+}
diff --git a/admin/tool/usertours/version.php b/admin/tool/usertours/version.php
index 05c0e8108c4..80ad9e0976e 100644
--- a/admin/tool/usertours/version.php
+++ b/admin/tool/usertours/version.php
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2021101301; // The current module version (Date: YYYYMMDDXX).
+$plugin->version = 2021101302; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).