1+ /**
2+ * Collapsed Topics Information
3+ *
4+ * A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics
5+ * except zero have a toggle that displays that topic. One or more topics can be displayed at any given time.
6+ * Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small
7+ * code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file.
8+ *
9+ * @package course/format
10+ * @subpackage topcoll
11+ * @version See the value of '$plugin->version' in version.php.
12+ * @copyright © 2014-onwards G J Barnard in respect to modifications of standard topics format.
13+ * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195}
14+ * @link http://docs.moodle.org/en/Collapsed_Topics_course_format
15+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
16+ *
17+ * This program is free software: you can redistribute it and/or modify
18+ * it under the terms of the GNU General Public License as published by
19+ * the Free Software Foundation, either version 3 of the License, or
20+ * (at your option) any later version.
21+
22+ * This program is distributed in the hope that it will be useful,
23+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
24+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+ * GNU General Public License for more details.
26+
27+ * You should have received a copy of the GNU General Public License
28+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
29+ */
30+
31+ M . format_topcoll . test_all_states = function ( ) {
32+ "use strict" ;
33+ // Reset for this course.
34+ console . log ( 'test_all_states: togglestate:' + this . togglestate ) ;
35+ console . log ( 'test_all_states: reset course.' ) ;
36+ M . format_topcoll . resetState ( M . format_topcoll . get_min_digit ( ) ) ;
37+ M . format_topcoll . save_toggles ( ) ;
38+ console . log ( 'test_all_states: togglestate:' + this . togglestate ) ;
39+
40+ // Loop through all possible states, this involves the first twelve toggles.
41+ console . log ( 'test_all_states: start loop.' ) ;
42+ var state = 0 ;
43+
44+ for ( state = 0 ; state < 64 ; state ++ ) {
45+ var newchar = this . encode_value_to_character ( state ) ;
46+ console . log ( 'test_all_states: newchar: ' + newchar + ' - togglestate:' + this . togglestate ) ;
47+
48+ //M.util.set_user_preference('topcoll_toggle_' + state + '_' + this.courseid, this.togglestate);
49+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_a' + state + '_' + this . courseid , newchar ) ;
50+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_b' + state + '_' + this . courseid , newchar + ':' ) ;
51+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_c' + state + '_' + this . courseid , ':' + newchar ) ;
52+ }
53+ console . log ( 'test_all_states: end loop.' ) ;
54+ console . log ( 'test_all_states: start invalid data.' ) ;
55+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_bf_' + this . courseid , '9' ) ;
56+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_af_' + this . courseid , 'z' ) ;
57+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_bf2_' + this . courseid , '9:' ) ;
58+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_af2_' + this . courseid , 'z:' ) ;
59+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_bf3_' + this . courseid , ':9' ) ;
60+ M . format_topcoll . set_user_preference ( 'topcoll_toggle_af3_' + this . courseid , ':z' ) ;
61+ console . log ( 'test_all_states: end invalid data.' ) ;
62+ } ;
0 commit comments