mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Merge branch 'MDL-73784-master' of https://github.com/HuongNV13/moodle
This commit is contained in:
commit
31a6f70ea1
@ -85,9 +85,20 @@ EOF;
|
||||
// This is a special case because the frontpage uses a shortened page path making it difficult to detect exactly.
|
||||
$isfrontpage = $targetmatch->compare(new \moodle_url('/'), URL_MATCH_BASE);
|
||||
$isdashboard = $targetmatch->compare(new \moodle_url('/my/'), URL_MATCH_BASE);
|
||||
$ismycourses = $targetmatch->compare(new \moodle_url('/my/courses.php'), URL_MATCH_BASE);
|
||||
|
||||
$possiblematches = [];
|
||||
if ($isfrontpage) {
|
||||
$possiblematches = ['FRONTPAGE', 'FRONTPAGE_MY', 'FRONTPAGE_MYCOURSES', 'FRONTPAGE_MY_MYCOURSES'];
|
||||
} else if ($isdashboard) {
|
||||
$possiblematches = ['MY', 'FRONTPAGE_MY', 'MY_MYCOURSES', 'FRONTPAGE_MY_MYCOURSES'];
|
||||
} else if ($ismycourses) {
|
||||
$possiblematches = ['MYCOURSES', 'FRONTPAGE_MYCOURSES', 'MY_MYCOURSES', 'FRONTPAGE_MY_MYCOURSES'];
|
||||
}
|
||||
|
||||
$target = $targetmatch->out_as_local_url();
|
||||
return array_filter($tours, function($tour) use ($isfrontpage, $isdashboard, $target) {
|
||||
if (($isfrontpage || $isdashboard) && $tour->pathmatch === 'FRONTPAGE') {
|
||||
return array_filter($tours, function($tour) use ($possiblematches, $target) {
|
||||
if (in_array($tour->pathmatch, $possiblematches)) {
|
||||
return true;
|
||||
}
|
||||
$pattern = preg_quote($tour->pathmatch, '@');
|
||||
|
@ -864,8 +864,8 @@ 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_dashboard.json' => 2,
|
||||
'40_tour_navigation_mycourse.json' => 2,
|
||||
'40_tour_navigation_course_teacher.json' => 1,
|
||||
'40_tour_navigation_course_student.json' => 1,
|
||||
];
|
||||
|
@ -803,19 +803,7 @@ class step {
|
||||
public static function get_string_from_input($string) {
|
||||
debugging('Use of ' . __FUNCTION__ .
|
||||
'() have been deprecated, please update your code to use helper::get_string_from_input()', DEBUG_DEVELOPER);
|
||||
$string = trim($string);
|
||||
|
||||
if (preg_match('|^([a-zA-Z][a-zA-Z0-9\.:/_-]*),([a-zA-Z][a-zA-Z0-9\.:/_-]*)$|', $string, $matches)) {
|
||||
if ($matches[2] === 'moodle') {
|
||||
$matches[2] = 'core';
|
||||
}
|
||||
|
||||
if (get_string_manager()->string_exists($matches[1], $matches[2])) {
|
||||
$string = get_string($matches[1], $matches[2]);
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
return helper::get_string_from_input($string);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -825,21 +813,23 @@ class step {
|
||||
* @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);
|
||||
if (strpos($content, '@@PIXICON') === false) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$content = preg_replace_callback('%@@PIXICON::(?P<identifier>([^::]*))::(?P<component>([^@@]*))@@%',
|
||||
function(array $matches) {
|
||||
global $OUTPUT;
|
||||
$component = $matches['component'];
|
||||
if ($component == 'moodle') {
|
||||
$component = 'core';
|
||||
}
|
||||
return \html_writer::img($OUTPUT->image_url($matches['identifier'], $component)->out(false), '',
|
||||
['class' => 'img-fluid']);
|
||||
},
|
||||
$content
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class tour {
|
||||
*/
|
||||
public function get_endtourlabel(): string {
|
||||
if ($this->endtourlabel) {
|
||||
$label = $this->endtourlabel;
|
||||
$label = helper::get_string_from_input($this->endtourlabel);
|
||||
} else if ($this->count_steps() == 1) {
|
||||
$label = get_string('endonesteptour', 'tool_usertours');
|
||||
} else {
|
||||
|
@ -114,12 +114,12 @@ function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2021101300, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
if ($oldversion < 2021101302) {
|
||||
if ($oldversion < 2021101303) {
|
||||
// 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, 2021101302, 'tool', 'usertours');
|
||||
upgrade_plugin_savepoint(true, 2021101303, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -60,7 +60,9 @@ $string['editstep'] = 'Editing "{$a}"';
|
||||
$string['tourisenabled'] = 'Tour is enabled';
|
||||
$string['enabled'] = 'Enabled';
|
||||
$string['endtourlabel'] = 'End tour button\'s label';
|
||||
$string['endtourlabel_help'] = 'You can optionally specify a custom label for the end tour button. The default label is "Got it" for single-step, and "End tour" for multiple-step tours.';
|
||||
$string['endtourlabel_help'] = 'You can optionally specify a custom label for the end tour button. The default label is "Got it" for single-step, and "End tour" for multiple-step tours..
|
||||
|
||||
Alternatively, a language string ID may be entered in the format identifier,component (with no brackets or space after the comma).';
|
||||
$string['event_tour_started'] = 'Tour started';
|
||||
$string['event_tour_reset'] = 'Tour reset';
|
||||
$string['event_tour_ended'] = 'Tour ended';
|
||||
@ -284,6 +286,7 @@ $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@@<br>Add, copy, delete and hide courses from this menu.';
|
||||
$string['tour_navigation_mycourses_endtourlabel'] = 'I understand';
|
||||
$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';
|
||||
|
@ -80,3 +80,21 @@ Feature: Steps can be navigated within a tour
|
||||
And I wait until the page is ready
|
||||
And I should see "This is the calendar block"
|
||||
Then I should see "CustomText"
|
||||
|
||||
@javascript
|
||||
Scenario: Customised 'end tour' button text for one step tours can be translatable
|
||||
Given I log in as "admin"
|
||||
And I add a new user tour with:
|
||||
| Name | Calendar tour |
|
||||
| Description | Calendar tour |
|
||||
| Apply to URL match | /my/% |
|
||||
| Tour is enabled | 1 |
|
||||
| End tour button's label | exporttour,tool_usertours |
|
||||
And I add steps to the "Calendar tour" tour:
|
||||
| targettype | Block | Title | id_content | Content type |
|
||||
| Block | Calendar | Calendar events | This is the calendar block | Enter manually |
|
||||
And I change window size to "large"
|
||||
And I follow "Dashboard"
|
||||
And I wait until the page is ready
|
||||
And I should see "This is the calendar block"
|
||||
Then I should see "Export tour"
|
||||
|
@ -164,7 +164,7 @@ class cache_testcase extends advanced_testcase {
|
||||
'Matches expected glob' => [
|
||||
$tourconfigs,
|
||||
'/my/index.php',
|
||||
['my_glob_1', 'my_glob_2', 'frontpage_match'],
|
||||
['my_glob_1', 'my_glob_2'],
|
||||
],
|
||||
'Matches expected glob and exact' => [
|
||||
$tourconfigs,
|
||||
|
@ -828,6 +828,7 @@ class step_testcase extends advanced_testcase {
|
||||
* 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() {
|
||||
// Test step content with single image.
|
||||
$stepcontent = '@@PIXICON::tour/tour_mycourses::tool_usertours@@<br>Test';
|
||||
$stepcontent = \tool_usertours\step::get_step_image_from_input($stepcontent);
|
||||
|
||||
@ -836,6 +837,16 @@ class step_testcase extends advanced_testcase {
|
||||
$this->assertStringEndsWith('Test', $stepcontent);
|
||||
$this->assertStringNotContainsString('PIXICON', $stepcontent);
|
||||
|
||||
// Test step content with multiple images.
|
||||
$stepcontent = '@@PIXICON::tour/tour_mycourses::tool_usertours@@<br>Test<br>@@PIXICON::tour/tour_myhomepage::tool_usertours@@';
|
||||
$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('<img', $stepcontent);
|
||||
// We should have 2 img tags here.
|
||||
$this->assertEquals(2, substr_count($stepcontent, '<img'));
|
||||
$this->assertStringNotContainsString('PIXICON', $stepcontent);
|
||||
|
||||
// Test step content with incorrect format.
|
||||
$stepcontent = '@@PIXICON::tour/tour_mycourses<br>Test';
|
||||
$stepcontent = \tool_usertours\step::get_step_image_from_input($stepcontent);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tour_navigation_dashboard_tour_name,tool_usertours",
|
||||
"description": "tour_navigation_dashboard_tour_des,tool_usertours",
|
||||
"pathmatch": "FRONTPAGE",
|
||||
"pathmatch": "FRONTPAGE_MY",
|
||||
"enabled": "1",
|
||||
"sortorder": "0",
|
||||
"endtourlabel": "",
|
||||
|
@ -4,7 +4,7 @@
|
||||
"pathmatch": "\/my\/courses.php",
|
||||
"enabled": "1",
|
||||
"sortorder": "1",
|
||||
"endtourlabel": "I understand",
|
||||
"endtourlabel": "tour_navigation_mycourses_endtourlabel,tool_usertours",
|
||||
"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",
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2021101302; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2021101303; // 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).
|
||||
|
Loading…
x
Reference in New Issue
Block a user