diff --git a/admin/tool/usertours/classes/local/forms/editstep.php b/admin/tool/usertours/classes/local/forms/editstep.php index 51173711a3f..b9418e75e22 100644 --- a/admin/tool/usertours/classes/local/forms/editstep.php +++ b/admin/tool/usertours/classes/local/forms/editstep.php @@ -214,7 +214,7 @@ class editstep extends \moodleform { if ($data->contenttype == static::CONTENTTYPE_LANGSTRING) { $data->content = [ 'text' => $data->contentlangstring, - 'format' => FORMAT_HTML, + 'format' => FORMAT_MOODLE, ]; } } diff --git a/admin/tool/usertours/classes/manager.php b/admin/tool/usertours/classes/manager.php index c4ecc9064e1..8867c052bdb 100644 --- a/admin/tool/usertours/classes/manager.php +++ b/admin/tool/usertours/classes/manager.php @@ -866,10 +866,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' => 2, - '40_tour_navigation_mycourse.json' => 2, - '40_tour_navigation_course_teacher.json' => 1, - '40_tour_navigation_course_student.json' => 1, + '40_tour_navigation_dashboard.json' => 4, + '40_tour_navigation_mycourse.json' => 4, + '40_tour_navigation_course_teacher.json' => 3, + '40_tour_navigation_course_student.json' => 3, ]; // 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 c62094bf586..8485acbc62c 100644 --- a/admin/tool/usertours/classes/output/step.php +++ b/admin/tool/usertours/classes/output/step.php @@ -88,8 +88,6 @@ class step implements \renderable { 'element' => $step->get_target()->convert_to_css(), ]; - $result->content = str_replace("\n", "
\n", $result->content); - foreach ($step->get_config_keys() as $key) { $result->$key = $step->get_config($key); } diff --git a/admin/tool/usertours/classes/step.php b/admin/tool/usertours/classes/step.php index 27c6517822e..0ba9de85c65 100644 --- a/admin/tool/usertours/classes/step.php +++ b/admin/tool/usertours/classes/step.php @@ -167,7 +167,7 @@ class step { $this->title = $record->title; $this->content = $record->content; } - $this->contentformat = isset($record->contentformat) ? $record->contentformat : 1; + $this->contentformat = isset($record->contentformat) ? $record->contentformat : FORMAT_MOODLE; $this->targettype = $record->targettype; $this->targetvalue = $record->targetvalue; $this->sortorder = $record->sortorder; diff --git a/admin/tool/usertours/db/install.xml b/admin/tool/usertours/db/install.xml index 25f2de6faa6..313ea2b5112 100644 --- a/admin/tool/usertours/db/install.xml +++ b/admin/tool/usertours/db/install.xml @@ -26,7 +26,7 @@ - + diff --git a/admin/tool/usertours/db/upgrade.php b/admin/tool/usertours/db/upgrade.php index 1c8bc1f6c0b..7540a87fb1f 100644 --- a/admin/tool/usertours/db/upgrade.php +++ b/admin/tool/usertours/db/upgrade.php @@ -100,26 +100,33 @@ function xmldb_tool_usertours_upgrade($oldversion) { upgrade_plugin_savepoint(true, 2021100700, 'tool', 'usertours'); } - if ($oldversion < 2021101300) { + if ($oldversion < 2022040601) { // Define field contentformat to be added to tool_usertours_steps. $table = new xmldb_table('tool_usertours_steps'); - $field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'content'); + $field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, FORMAT_MOODLE, 'content'); // Conditionally launch add field contentformat. if (!$dbman->field_exists($table, $field)) { $dbman->add_field($table, $field); + } else { + // Field was added by previous upgrade step with the default value is FORMAT_HTML. + // Need to drop the field and re-create with the new structure to make sure all the existing tours use FORMAT_MOODLE. + // FORMAT_MOODLE will force the external_format_text method to use nl2br to convert the new line to line break tag. + $dbman->drop_field($table, $field); + // Add the field again. + $dbman->add_field($table, $field); } // Usertours savepoint reached. - upgrade_plugin_savepoint(true, 2021101300, 'tool', 'usertours'); + upgrade_plugin_savepoint(true, 2022040601, 'tool', 'usertours'); } - if ($oldversion < 2021101303) { + if ($oldversion < 2022040602) { // 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, 2021101303, 'tool', 'usertours'); + upgrade_plugin_savepoint(true, 2022040602, 'tool', 'usertours'); } return true; diff --git a/admin/tool/usertours/version.php b/admin/tool/usertours/version.php index 6ac69048462..1e3c15778ef 100644 --- a/admin/tool/usertours/version.php +++ b/admin/tool/usertours/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021101303; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2022040602; // 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).