Merge branch 'MDL-72557-master' of git://github.com/rezaies/moodle
This commit is contained in:
+1
-1
@@ -104,7 +104,7 @@ class tour extends external_api {
|
||||
'tourconfig' => new external_single_structure([
|
||||
'name' => new external_value(PARAM_RAW, 'Tour Name'),
|
||||
'steps' => new external_multiple_structure(self::step_structure_returns()),
|
||||
'onesteptour' => new external_value(PARAM_BOOL, 'Is a one step tour', VALUE_DEFAULT, false),
|
||||
'endtourlabel' => new external_value(PARAM_RAW, 'Label of the end tour button'),
|
||||
], 'Tour config', VALUE_OPTIONAL)
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ class edittour extends \moodleform {
|
||||
|
||||
$mform->addElement('checkbox', 'enabled', get_string('tourisenabled', 'tool_usertours'));
|
||||
|
||||
$mform->addElement('text', 'endtourlabel', get_string('endtourlabel', 'tool_usertours'));
|
||||
$mform->setType('endtourlabel', PARAM_TEXT);
|
||||
$mform->addHelpButton('endtourlabel', 'endtourlabel', 'tool_usertours');
|
||||
|
||||
// Configuration.
|
||||
$this->tour->add_config_to_form($mform);
|
||||
|
||||
|
||||
@@ -370,6 +370,7 @@ class manager {
|
||||
$tour->set_description($data->description);
|
||||
$tour->set_pathmatch($data->pathmatch);
|
||||
$tour->set_enabled(!empty($data->enabled));
|
||||
$tour->set_endtourlabel($data->endtourlabel);
|
||||
|
||||
foreach (configuration::get_defaultable_keys() as $key) {
|
||||
$tour->set_config($key, $data->$key);
|
||||
|
||||
@@ -60,18 +60,13 @@ class tour implements \renderable {
|
||||
$result = (object) [
|
||||
'name' => $this->tour->get_tour_key(),
|
||||
'steps' => [],
|
||||
'onesteptour' => false,
|
||||
'endtourlabel' => $this->tour->get_endtourlabel(),
|
||||
];
|
||||
|
||||
foreach ($this->tour->get_steps() as $step) {
|
||||
$result->steps[] = (new step($step))->export_for_template($output);
|
||||
}
|
||||
|
||||
// Check if its a only one step tour.
|
||||
if (count($result->steps) == 1) {
|
||||
$result->onesteptour = true;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,11 @@ class tour {
|
||||
*/
|
||||
protected $enabled;
|
||||
|
||||
/**
|
||||
* @var $endtourlabel The end tour label.
|
||||
*/
|
||||
protected $endtourlabel;
|
||||
|
||||
/**
|
||||
* @var $sortorder The sort order.
|
||||
*/
|
||||
@@ -187,6 +192,7 @@ class tour {
|
||||
if (isset($record->sortorder)) {
|
||||
$this->sortorder = $record->sortorder;
|
||||
}
|
||||
$this->endtourlabel = $record->endtourlabel ?? null;
|
||||
$this->config = json_decode($record->configdata);
|
||||
$this->dirty = false;
|
||||
$this->steps = [];
|
||||
@@ -322,6 +328,36 @@ class tour {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The end tour label for the tour.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_endtourlabel(): string {
|
||||
if ($this->endtourlabel) {
|
||||
$label = $this->endtourlabel;
|
||||
} else if ($this->count_steps() == 1) {
|
||||
$label = get_string('endonesteptour', 'tool_usertours');
|
||||
} else {
|
||||
$label = get_string('endtour', 'tool_usertours');
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the endtourlabel of the tour to the specified value.
|
||||
*
|
||||
* @param string $value
|
||||
* @return $this
|
||||
*/
|
||||
public function set_endtourlabel(string $value): tour {
|
||||
$this->endtourlabel = $value;
|
||||
$this->dirty = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The link to view this tour.
|
||||
*
|
||||
@@ -389,6 +425,7 @@ class tour {
|
||||
'pathmatch' => $this->pathmatch,
|
||||
'enabled' => $this->enabled,
|
||||
'sortorder' => $this->sortorder,
|
||||
'endtourlabel' => $this->endtourlabel,
|
||||
'configdata' => json_encode($this->config),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="admin/tool/usertours/db" VERSION="20160830" COMMENT="XMLDB file for Moodle tool/usertours"
|
||||
<XMLDB PATH="admin/tool/usertours/db" VERSION="20210923" COMMENT="XMLDB file for Moodle tool/usertours"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -12,6 +12,7 @@
|
||||
<FIELD NAME="pathmatch" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false"/>
|
||||
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="endtourlabel" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" COMMENT="Custom label for the end tour button"/>
|
||||
<FIELD NAME="configdata" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
|
||||
@@ -36,6 +36,8 @@ use tool_usertours\tour;
|
||||
function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$dbman = $DB->get_manager();
|
||||
|
||||
// Automatically generated Moodle v3.6.0 release upgrade line.
|
||||
// Put any upgrade step following this.
|
||||
|
||||
@@ -83,5 +85,19 @@ function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2021052508, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
if ($oldversion < 2021092300) {
|
||||
// Define field endtourlabel to be added to tool_usertours_tours.
|
||||
$table = new xmldb_table('tool_usertours_tours');
|
||||
$field = new xmldb_field('endtourlabel', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'sortorder');
|
||||
|
||||
// Conditionally launch add field endtourlabel.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Usertours savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2021092300, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ $string['duplicatetour_name'] = '{$a} (copy)';
|
||||
$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['event_tour_started'] = 'Tour started';
|
||||
$string['event_tour_reset'] = 'Tour reset';
|
||||
$string['event_tour_ended'] = 'Tour ended';
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
Example context (json):
|
||||
{
|
||||
"name" : "tour_activity_completion",
|
||||
"onesteptour" : true,
|
||||
"endtourlabel" : "Got it!",
|
||||
"steps": [
|
||||
{
|
||||
"stepid": 10,
|
||||
@@ -68,12 +68,7 @@
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-role="previous">{{# str }} previousstep, tool_usertours {{/ str }}</button>
|
||||
<button type="button" class="btn btn-primary" data-role="next">{{# str }} nextstep, tool_usertours {{/ str }}</button>
|
||||
{{#onesteptour}}
|
||||
<button class="btn btn-secondary" data-role="end"> {{# str }} endonesteptour, tool_usertours {{/ str }} </button>
|
||||
{{/onesteptour}}
|
||||
{{^onesteptour}}
|
||||
<button class="btn btn-secondary" data-role="end"> {{# str }} endtour, tool_usertours {{/ str }} </button>
|
||||
{{/onesteptour}}
|
||||
<button class="btn btn-secondary" data-role="end"> {{endtourlabel}} </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -60,3 +60,21 @@ Feature: Steps can be navigated within a tour
|
||||
And I should see "Next"
|
||||
And I click on "Next" "button"
|
||||
And I should see "End tour"
|
||||
|
||||
@javascript
|
||||
Scenario: Customised 'end tour' button text for one step tours
|
||||
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 | CustomText |
|
||||
And I add steps to the "Calendar tour" tour:
|
||||
| targettype | Block | Title | Content |
|
||||
| Block | Calendar | Calendar events | This is the calendar block |
|
||||
And I change window size to "large"
|
||||
And I follow "Dashboard" in the user menu
|
||||
And I wait until the page is ready
|
||||
And I should see "This is the calendar block"
|
||||
Then I should see "CustomText"
|
||||
|
||||
@@ -2,8 +2,8 @@ This files describes API changes in the tool_usertours code.
|
||||
|
||||
=== 4.0 ===
|
||||
* The `tourconfig` property returned by the `tool_usertours_fetch_and_start_tour`
|
||||
external method has also a `onsteptour` property to differentiate between
|
||||
one step tours and multiple step tours.
|
||||
external method has also an `endtourlabel` property that contains the label to be used
|
||||
for the end tour button.
|
||||
|
||||
=== 3.9 ===
|
||||
* The `tourconfig` property returned by the `tool_usertours_fetch_and_start_tour`
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2021052508; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2021092300; // 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).
|
||||
|
||||
Reference in New Issue
Block a user