Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace tool_usertours;
18
 
19
/**
20
 * Tour class.
21
 *
22
 * @package    tool_usertours
23
 * @copyright  2016 Andrew Nicols <andrew@nicols.co.uk>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
class tour {
27
    /**
28
     * The tour is currently disabled
29
     *
30
     * @var DISABLED
31
     */
32
    const DISABLED = 0;
33
 
34
    /**
35
     * The tour is currently disabled
36
     *
37
     * @var DISABLED
38
     */
39
    const ENABLED = 1;
40
 
41
    /**
42
     * The user preference value to indicate the time of completion of the tour for a user.
43
     *
44
     * @var TOUR_LAST_COMPLETED_BY_USER
45
     */
46
    const TOUR_LAST_COMPLETED_BY_USER   = 'tool_usertours_tour_completion_time_';
47
 
48
    /**
49
     * The user preference value to indicate the time that a user last requested to see the tour.
50
     *
51
     * @var TOUR_REQUESTED_BY_USER
52
     */
53
    const TOUR_REQUESTED_BY_USER        = 'tool_usertours_tour_reset_time_';
54
 
55
    /** @var int Whether to show the tour only until it has been marked complete */
56
    const SHOW_TOUR_UNTIL_COMPLETE = 1;
57
 
58
    /** @var int Whether to show the tour every time a page matches */
59
    const SHOW_TOUR_ON_EACH_PAGE_VISIT = 2;
60
 
61
    /**
62
     * @var $id The tour ID.
63
     */
64
    protected $id;
65
 
66
    /**
67
     * @var $name The tour name.
68
     */
69
    protected $name;
70
 
71
    /**
72
     * @var $description The tour description.
73
     */
74
    protected $description;
75
 
76
    /**
77
     * @var $pathmatch The tour pathmatch.
78
     */
79
    protected $pathmatch;
80
 
81
    /**
82
     * @var $enabled The tour enabled state.
83
     */
84
    protected $enabled;
85
 
86
    /**
87
     * @var $endtourlabel The end tour label.
88
     */
89
    protected $endtourlabel;
90
 
91
    /**
92
     * @var $sortorder The sort order.
93
     */
94
    protected $sortorder;
95
 
96
    /**
97
     * @var $dirty Whether the current view of the tour has been modified.
98
     */
99
    protected $dirty = false;
100
 
101
    /**
102
     * @var $config The configuration object for the tour.
103
     */
104
    protected $config;
105
 
106
    /**
107
     * @var $filtervalues The filter configuration object for the tour.
108
     */
109
    protected $filtervalues;
110
 
111
    /**
112
     * @var $steps  The steps in this tour.
113
     */
114
    protected $steps = [];
115
 
116
    /**
117
     * @var bool $displaystepnumbers Display the step numbers in this tour.
118
     */
119
    protected $displaystepnumbers = true;
120
 
121
    /**
122
     * Create an instance of the specified tour.
123
     *
124
     * @param   int         $id         The ID of the tour to load.
125
     * @return  tour
126
     */
127
    public static function instance($id) {
128
        $tour = new self();
129
        return $tour->fetch($id);
130
    }
131
 
132
    /**
133
     * Create an instance of tour from its provided DB record.
134
     *
135
     * @param   stdClass    $record     The record of the tour to load.
136
     * @param   boolean     $clean      Clean the values.
137
     * @return  tour
138
     */
139
    public static function load_from_record($record, $clean = false) {
140
        $tour = new self();
141
        return $tour->reload_from_record($record, $clean);
142
    }
143
 
144
    /**
145
     * Fetch the specified tour into the current object.
146
     *
147
     * @param   int         $id         The ID of the tour to fetch.
148
     * @return  tour
149
     */
150
    protected function fetch($id) {
151
        global $DB;
152
 
153
        return $this->reload_from_record(
154
            $DB->get_record('tool_usertours_tours', ['id' => $id], '*', MUST_EXIST)
155
        );
156
    }
157
 
158
    /**
159
     * Reload the current tour from database.
160
     *
161
     * @return  tour
162
     */
163
    protected function reload() {
164
        return $this->fetch($this->id);
165
    }
166
 
167
    /**
168
     * Reload the tour into the current object.
169
     *
170
     * @param   stdClass    $record     The record to reload.
171
     * @param   boolean     $clean      Clean the values.
172
     * @return  tour
173
     */
174
    protected function reload_from_record($record, $clean = false) {
175
        $this->id           = $record->id;
176
        if (!property_exists($record, 'description')) {
177
            if (property_exists($record, 'comment')) {
178
                $record->description = $record->comment;
179
                unset($record->comment);
180
            }
181
        }
182
        if ($clean) {
183
            $this->name         = clean_param($record->name, PARAM_TEXT);
184
            $this->description  = clean_text($record->description);
185
        } else {
186
            $this->name         = $record->name;
187
            $this->description  = $record->description;
188
        }
189
        $this->pathmatch    = $record->pathmatch;
190
        $this->enabled      = $record->enabled;
191
        if (isset($record->sortorder)) {
192
            $this->sortorder = $record->sortorder;
193
        }
194
        $this->endtourlabel = $record->endtourlabel ?? null;
195
        $this->config       = json_decode($record->configdata);
196
        $this->dirty        = false;
197
        $this->steps        = [];
198
        $this->displaystepnumbers = !empty($record->displaystepnumbers);
199
 
200
        return $this;
201
    }
202
 
203
    /**
204
     * Fetch all steps in the tour.
205
     *
206
     * @return  step[]
207
     */
208
    public function get_steps() {
209
        if (empty($this->steps)) {
210
            $this->steps = helper::get_steps($this->id);
211
        }
212
 
213
        return $this->steps;
214
    }
215
 
216
    /**
217
     * Count the number of steps in the tour.
218
     *
219
     * @return  int
220
     */
221
    public function count_steps() {
222
        return count($this->get_steps());
223
    }
224
 
225
    /**
226
     * The ID of the tour.
227
     *
228
     * @return  int
229
     */
230
    public function get_id() {
231
        return $this->id;
232
    }
233
 
234
    /**
235
     * The name of the tour.
236
     *
237
     * @return  string
238
     */
239
    public function get_name() {
240
        return $this->name;
241
    }
242
 
243
    /**
244
     * Set the name of the tour to the specified value.
245
     *
246
     * @param   string      $value      The new name.
247
     * @return  $this
248
     */
249
    public function set_name($value) {
250
        $this->name = clean_param($value, PARAM_TEXT);
251
        $this->dirty = true;
252
 
253
        return $this;
254
    }
255
 
256
    /**
257
     * The description associated with the tour.
258
     *
259
     * @return  string
260
     */
261
    public function get_description() {
262
        return $this->description;
263
    }
264
 
265
    /**
266
     * Set the description of the tour to the specified value.
267
     *
268
     * @param   string      $value      The new description.
269
     * @return  $this
270
     */
271
    public function set_description($value) {
272
        $this->description = clean_text($value);
273
        $this->dirty = true;
274
 
275
        return $this;
276
    }
277
 
278
    /**
279
     * The path match for the tour.
280
     *
281
     * @return  string
282
     */
283
    public function get_pathmatch() {
284
        return $this->pathmatch;
285
    }
286
 
287
    /**
288
     * Set the patchmatch of the tour to the specified value.
289
     *
290
     * @param   string      $value      The new patchmatch.
291
     * @return  $this
292
     */
293
    public function set_pathmatch($value) {
294
        $this->pathmatch = $value;
295
        $this->dirty = true;
296
 
297
        return $this;
298
    }
299
 
300
    /**
301
     * The enabled state of the tour.
302
     *
303
     * @return  int
304
     */
305
    public function get_enabled() {
306
        return $this->enabled;
307
    }
308
 
309
    /**
310
     * Whether the tour is currently enabled.
311
     *
312
     * @return  boolean
313
     */
314
    public function is_enabled() {
315
        return ($this->enabled == self::ENABLED);
316
    }
317
 
318
    /**
319
     * Set the enabled state of the tour to the specified value.
320
     *
321
     * @param   boolean     $value      The new state.
322
     * @return  $this
323
     */
324
    public function set_enabled($value) {
325
        $this->enabled = $value;
326
        $this->dirty = true;
327
 
328
        return $this;
329
    }
330
 
331
    /**
332
     * The end tour label for the tour.
333
     *
334
     * @return string
335
     */
336
    public function get_endtourlabel(): string {
337
        if ($this->endtourlabel) {
338
            $label = helper::get_string_from_input($this->endtourlabel);
339
        } else if ($this->count_steps() == 1) {
340
            $label = get_string('endonesteptour', 'tool_usertours');
341
        } else {
342
            $label = get_string('endtour', 'tool_usertours');
343
        }
344
 
345
        return $label;
346
    }
347
 
348
    /**
349
     * Set the endtourlabel of the tour to the specified value.
350
     *
351
     * @param string $value
352
     * @return $this
353
     */
354
    public function set_endtourlabel(string $value): tour {
355
        $this->endtourlabel = $value;
356
        $this->dirty = true;
357
 
358
        return $this;
359
    }
360
 
361
    /**
362
     * The link to view this tour.
363
     *
364
     * @return  \moodle_url
365
     */
366
    public function get_view_link() {
367
        return helper::get_view_tour_link($this->id);
368
    }
369
 
370
    /**
371
     * The link to edit this tour.
372
     *
373
     * @return  \moodle_url
374
     */
375
    public function get_edit_link() {
376
        return helper::get_edit_tour_link($this->id);
377
    }
378
 
379
    /**
380
     * The link to reset the state of this tour for all users.
381
     *
382
     * @return  moodle_url
383
     */
384
    public function get_reset_link() {
385
        return helper::get_reset_tour_for_all_link($this->id);
386
    }
387
 
388
    /**
389
     * The link to export this tour.
390
     *
391
     * @return  moodle_url
392
     */
393
    public function get_export_link() {
394
        return helper::get_export_tour_link($this->id);
395
    }
396
 
397
    /**
398
     * The link to duplicate this tour.
399
     *
400
     * @return  moodle_url
401
     */
402
    public function get_duplicate_link() {
403
        return helper::get_duplicate_tour_link($this->id);
404
    }
405
 
406
    /**
407
     * The link to remove this tour.
408
     *
409
     * @return  moodle_url
410
     */
411
    public function get_delete_link() {
412
        return helper::get_delete_tour_link($this->id);
413
    }
414
 
415
    /**
416
     * Prepare this tour for saving to the database.
417
     *
418
     * @return  object
419
     */
420
    public function to_record() {
421
        return (object) [
422
            'id'            => $this->id,
423
            'name'          => $this->name,
424
            'description'   => $this->description,
425
            'pathmatch'     => $this->pathmatch,
426
            'enabled'       => $this->enabled,
427
            'sortorder'     => $this->sortorder,
428
            'endtourlabel'  => $this->endtourlabel,
429
            'configdata'    => json_encode($this->config),
430
            'displaystepnumbers' => $this->displaystepnumbers,
431
        ];
432
    }
433
 
434
    /**
435
     * Get the current sortorder for this tour.
436
     *
437
     * @return  int
438
     */
439
    public function get_sortorder() {
440
        return (int) $this->sortorder;
441
    }
442
 
443
    /**
444
     * Whether this tour is the first tour.
445
     *
446
     * @return  boolean
447
     */
448
    public function is_first_tour() {
449
        return ($this->get_sortorder() === 0);
450
    }
451
 
452
    /**
453
     * Whether this tour is the last tour.
454
     *
455
     * @param   int         $tourcount  The pre-fetched count of tours
456
     * @return  boolean
457
     */
458
    public function is_last_tour($tourcount = null) {
459
        if ($tourcount === null) {
460
            $tourcount = helper::count_tours();
461
        }
462
        return ($this->get_sortorder() === ($tourcount - 1));
463
    }
464
 
465
    /**
466
     * Set the sortorder for this tour.
467
     *
468
     * @param   int         $value      The new sortorder to use.
469
     * @return  $this
470
     */
471
    public function set_sortorder($value) {
472
        $this->sortorder = $value;
473
        $this->dirty = true;
474
 
475
        return $this;
476
    }
477
 
478
    /**
479
     * Calculate the next sort-order value.
480
     *
481
     * @return  int
482
     */
483
    protected function calculate_sortorder() {
484
        $this->sortorder = helper::count_tours();
485
 
486
        return $this;
487
    }
488
 
489
    /**
490
     * Get the link to move this tour up in the sortorder.
491
     *
492
     * @return  moodle_url
493
     */
494
    public function get_moveup_link() {
495
        return helper::get_move_tour_link($this->get_id(), helper::MOVE_UP);
496
    }
497
 
498
    /**
499
     * Get the link to move this tour down in the sortorder.
500
     *
501
     * @return  moodle_url
502
     */
503
    public function get_movedown_link() {
504
        return helper::get_move_tour_link($this->get_id(), helper::MOVE_DOWN);
505
    }
506
 
507
    /**
508
     * Get the value of the specified configuration item.
509
     *
510
     * @param   string      $key        The configuration key to set.
511
     * @param   mixed       $default    The default value to use if a value was not found.
512
     * @return  mixed
513
     */
514
    public function get_config($key = null, $default = null) {
515
        if ($this->config === null) {
516
            $this->config = (object) [];
517
        }
518
        if ($key === null) {
519
            return $this->config;
520
        }
521
 
522
        if (property_exists($this->config, $key)) {
523
            return $this->config->$key;
524
        }
525
 
526
        if ($default !== null) {
527
            return $default;
528
        }
529
 
530
        return configuration::get_default_value($key);
531
    }
532
 
533
    /**
534
     * Set the configuration item as specified.
535
     *
536
     * @param   string      $key        The configuration key to set.
537
     * @param   mixed       $value      The new value for the configuration item.
538
     * @return  $this
539
     */
540
    public function set_config($key, $value) {
541
        if ($this->config === null) {
542
            $this->config = (object) [];
543
        }
544
        $this->config->$key = $value;
545
        $this->dirty = true;
546
 
547
        return $this;
548
    }
549
 
550
    /**
551
     * Save the tour and it's configuration to the database.
552
     *
553
     * @param   boolean     $force      Whether to force writing to the database.
554
     * @return  $this
555
     */
556
    public function persist($force = false) {
557
        global $DB;
558
 
559
        if (!$this->dirty && !$force) {
560
            return $this;
561
        }
562
 
563
        if ($this->id) {
564
            $record = $this->to_record();
565
            $DB->update_record('tool_usertours_tours', $record);
566
        } else {
567
            $this->calculate_sortorder();
568
            $record = $this->to_record();
569
            unset($record->id);
570
            $this->id = $DB->insert_record('tool_usertours_tours', $record);
571
        }
572
 
573
        $this->reload();
574
 
575
        // Notify the cache that a tour has changed.
576
        cache::notify_tour_change();
577
 
578
        return $this;
579
    }
580
 
581
    /**
582
     * Remove this step.
583
     */
584
    public function remove() {
585
        global $DB;
586
 
587
        if ($this->id === null) {
588
            // Nothing to delete - this tour has not been persisted.
589
            return null;
590
        }
591
 
592
        // Delete all steps associated with this tour.
593
        // Note, although they are currently just DB records, there may be other components in the future.
594
        foreach ($this->get_steps() as $step) {
595
            $step->remove();
596
        }
597
 
598
        // Remove the configuration for the tour.
599
        $DB->delete_records('tool_usertours_tours', ['id' => $this->id]);
600
        helper::reset_tour_sortorder();
601
 
602
        $this->remove_user_preferences();
603
 
604
        return null;
605
    }
606
 
607
    /**
608
     * Reset the sortorder for all steps in the tour.
609
     *
610
     * @return  $this
611
     */
612
    public function reset_step_sortorder() {
613
        global $DB;
614
        $steps = $DB->get_records('tool_usertours_steps', ['tourid' => $this->id], 'sortorder ASC', 'id');
615
 
616
        $index = 0;
617
        foreach ($steps as $step) {
618
            $DB->set_field('tool_usertours_steps', 'sortorder', $index, ['id' => $step->id]);
619
            $index++;
620
        }
621
 
622
        // Notify of a change to the step configuration.
623
        // Note: Do not notify of a tour change here. This is only a step change for a tour.
624
        cache::notify_step_change($this->get_id());
625
 
626
        return $this;
627
    }
628
 
629
    /**
630
     * Remove stored user preferences for the tour
631
     */
632
    protected function remove_user_preferences(): void {
633
        global $DB;
634
 
635
        $DB->delete_records('user_preferences', ['name' => self::TOUR_LAST_COMPLETED_BY_USER . $this->get_id()]);
636
        $DB->delete_records('user_preferences', ['name' => self::TOUR_REQUESTED_BY_USER . $this->get_id()]);
637
    }
638
 
639
    /**
640
     * Whether this tour should be displayed to the user.
641
     *
642
     * @return  boolean
643
     */
644
    public function should_show_for_user() {
645
        if (!$this->is_enabled()) {
646
            // The tour is disabled - it should not be shown.
647
            return false;
648
        }
649
 
650
        if ($this->get_showtourwhen() === self::SHOW_TOUR_ON_EACH_PAGE_VISIT) {
651
            // The tour should be shown on every page visit.
652
            return true;
653
        }
654
 
655
        if ($tourcompletiondate = get_user_preferences(self::TOUR_LAST_COMPLETED_BY_USER . $this->get_id(), null)) {
656
            if ($tourresetdate = get_user_preferences(self::TOUR_REQUESTED_BY_USER . $this->get_id(), null)) {
657
                if ($tourresetdate >= $tourcompletiondate) {
658
                    return true;
659
                }
660
            }
661
            $lastmajorupdate = $this->get_config('majorupdatetime', time());
662
            if ($tourcompletiondate > $lastmajorupdate) {
663
                // The user has completed the tour since the last major update.
664
                return false;
665
            }
666
        }
667
 
668
        return true;
669
    }
670
 
671
    /**
672
     * Get the key for this tour.
673
     * This is used in the session cookie to determine whether the user has seen this tour before.
674
     */
675
    public function get_tour_key() {
676
        global $USER;
677
 
678
        $tourtime = $this->get_config('majorupdatetime', null);
679
 
680
        if ($tourtime === null) {
681
            // This tour has no majorupdate time.
682
            // Set one now to prevent repeated displays to the user.
683
            $this->set_config('majorupdatetime', time());
684
            $this->persist();
685
            $tourtime = $this->get_config('majorupdatetime', null);
686
        }
687
 
688
        if ($userresetdate = get_user_preferences(self::TOUR_REQUESTED_BY_USER . $this->get_id(), null)) {
689
            $tourtime = max($tourtime, $userresetdate);
690
        }
691
 
692
        return sprintf('tool_usertours_%d_%d_%s', $USER->id, $this->get_id(), $tourtime);
693
    }
694
 
695
    /**
696
     * Reset the requested by user date.
697
     *
698
     * @return  $this
699
     */
700
    public function request_user_reset() {
701
        set_user_preference(self::TOUR_REQUESTED_BY_USER . $this->get_id(), time());
702
 
703
        return $this;
704
    }
705
 
706
    /**
707
     * Mark this tour as completed for this user.
708
     *
709
     * @return  $this
710
     */
711
    public function mark_user_completed() {
712
        set_user_preference(self::TOUR_LAST_COMPLETED_BY_USER . $this->get_id(), time());
713
 
714
        return $this;
715
    }
716
 
717
    /**
718
     * Update a tour giving it a new major update time.
719
     * This will ensure that it is displayed to all users, even those who have already seen it.
720
     *
721
     * @return  $this
722
     */
723
    public function mark_major_change() {
724
        // Clear old reset and completion notes.
725
        $this->remove_user_preferences();
726
 
727
        $this->set_config('majorupdatetime', time());
728
        $this->persist();
729
 
730
        return $this;
731
    }
732
 
733
    /**
734
     * Add the step configuration to the form.
735
     *
736
     * @param   MoodleQuickForm $mform      The form to add configuration to.
737
     * @return  $this
738
     */
739
    public function add_config_to_form(\MoodleQuickForm &$mform) {
740
        $options = configuration::get_placement_options();
741
        $mform->addElement('select', 'placement', get_string('placement', 'tool_usertours'), $options);
742
        $mform->addHelpButton('placement', 'placement', 'tool_usertours');
743
 
744
        $this->add_config_field_to_form($mform, 'orphan');
745
        $this->add_config_field_to_form($mform, 'backdrop');
746
        $this->add_config_field_to_form($mform, 'reflex');
747
 
748
        return $this;
749
    }
750
 
751
    /**
752
     * Add the specified step field configuration to the form.
753
     *
754
     * @param   MoodleQuickForm $mform      The form to add configuration to.
755
     * @param   string          $key        The key to add.
756
     * @return  $this
757
     */
758
    protected function add_config_field_to_form(\MoodleQuickForm &$mform, $key) {
759
        $options = [
760
            true    => get_string('yes'),
761
            false   => get_string('no'),
762
        ];
763
        $mform->addElement('select', $key, get_string($key, 'tool_usertours'), $options);
764
        $mform->setDefault($key, configuration::get_default_value($key));
765
        $mform->addHelpButton($key, $key, 'tool_usertours');
766
 
767
        return $this;
768
    }
769
 
770
    /**
771
     * Prepare the configuration data for the moodle form.
772
     *
773
     * @return  object
774
     */
775
    public function prepare_data_for_form() {
776
        $data = $this->to_record();
777
        $data->showtourwhen = $this->get_showtourwhen();
778
        foreach (configuration::get_defaultable_keys() as $key) {
779
            $data->$key = $this->get_config($key, configuration::get_default_value($key));
780
        }
781
 
782
        return $data;
783
    }
784
 
785
    /**
786
     * Get the configured filter values.
787
     *
788
     * @param   string      $filter     The filter to retrieve values for.
789
     * @return  array
790
     */
791
    public function get_filter_values($filter) {
792
        if ($allvalues = (array) $this->get_config('filtervalues')) {
793
            if (isset($allvalues[$filter])) {
794
                return $allvalues[$filter];
795
            }
796
        }
797
 
798
        return [];
799
    }
800
 
801
    /**
802
     * Set the values for the specified filter.
803
     *
804
     * @param   string      $filter     The filter to set.
805
     * @param   array       $values     The values to set.
806
     * @return  $this
807
     */
808
    public function set_filter_values($filter, array $values = []) {
809
        $allvalues = (array) $this->get_config('filtervalues', []);
810
        $allvalues[$filter] = $values;
811
 
812
        return $this->set_config('filtervalues', $allvalues);
813
    }
814
 
815
    /**
816
     * Check whether this tour matches all filters.
817
     *
818
     * @param   \context     $context    The context to check.
819
     * @param   array|null   $filters    Optional array of filters.
820
     * @return  bool
821
     */
822
    public function matches_all_filters(\context $context, array $filters = null): bool {
823
        if (!$filters) {
824
            $filters = helper::get_all_filters();
825
        }
826
 
827
        // All filters must match.
828
        // If any one filter fails to match, we return false.
829
        foreach ($filters as $filterclass) {
830
            if (!$filterclass::filter_matches($this, $context)) {
831
                return false;
832
            }
833
        }
834
 
835
        return true;
836
    }
837
 
838
    /**
839
     * Gets all filter values for use in client side filters.
840
     *
841
     * @param   array     $filters    Array of clientside filters.
842
     * @return  array
843
     */
844
    public function get_client_filter_values(array $filters): array {
845
        $results = [];
846
 
847
        foreach ($filters as $filter) {
848
            $results[$filter::get_filter_name()] = $filter::get_client_side_values($this);
849
        }
850
 
851
        return $results;
852
    }
853
 
854
    /**
855
     * Set the value for the display step numbers setting.
856
     *
857
     * @param bool $value True for enable.
858
     * @return $this
859
     */
860
    public function set_display_step_numbers(bool $value): tour {
861
        $this->displaystepnumbers = $value;
862
        $this->dirty = true;
863
 
864
        return $this;
865
    }
866
 
867
    /**
868
     * Get the value of the display step numbers setting.
869
     *
870
     * @return bool
871
     */
872
    public function get_display_step_numbers(): bool {
873
        return $this->displaystepnumbers;
874
    }
875
 
876
    /**
877
     * Set the value for the when to show the tour.
878
     *
879
     * @see self::SHOW_TOUR_UNTIL_COMPLETE
880
     * @see self::SHOW_TOUR_ON_EACH_PAGE_VISIT
881
     *
882
     * @param int $value
883
     * @return self
884
     */
885
    public function set_showtourwhen(int $value): tour {
886
        return $this->set_config('showtourwhen', $value);
887
    }
888
 
889
    /**
890
     * When to show the tour.
891
     *
892
     * @see self::SHOW_TOUR_UNTIL_COMPLETE
893
     * @see self::SHOW_TOUR_ON_EACH_PAGE_VISIT
894
     *
895
     * @return int
896
     */
897
    public function get_showtourwhen(): int {
898
        return $this->get_config('showtourwhen', self::SHOW_TOUR_UNTIL_COMPLETE);
899
    }
900
}