-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
306 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Code to update a user preference in response to an ajax call. | ||
* | ||
* You should not send requests to this script directly. Instead use the set_user_preference | ||
* function in /course/format/topcol/module.js. | ||
* | ||
* @package course/format | ||
* @subpackage topcoll | ||
* @version See the value of '$plugin->version' in below. | ||
* @copyright © 2014-onwards G J Barnard based upon code originally written by Tim Hunt. | ||
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} | ||
* @link http://docs.moodle.org/en/Collapsed_Topics_course_format | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once(dirname(__FILE__) . '/../../../config.php'); | ||
require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); | ||
|
||
// Check access. | ||
if (!confirm_sesskey()) { | ||
print_error('invalidsesskey'); | ||
} | ||
|
||
// Get the name of the preference to update, and check that it is allowed. | ||
$name = required_param('pref', PARAM_RAW); | ||
if (!isset($USER->ajax_updatable_user_prefs[$name])) { | ||
print_error('notallowedtoupdateprefremotely'); | ||
} | ||
|
||
// Get and set the value. | ||
$value = required_topcoll_param('value', $USER->ajax_updatable_user_prefs[$name]); | ||
error_log($name.' is before: '.$USER->ajax_updatable_user_prefs[$name].' after: '.$value); | ||
// Update | ||
if (!set_user_preference($name, $value)) { | ||
print_error('errorsettinguserpref'); | ||
} | ||
|
||
echo 'OK'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Collapsed Topics Information | ||
* | ||
* A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics | ||
* except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. | ||
* Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small | ||
* code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. | ||
* | ||
* @package course/format | ||
* @subpackage topcoll | ||
* @version See the value of '$plugin->version' in below. | ||
* @copyright © 2014-onwards G J Barnard in respect to modifications of standard topics format. | ||
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} | ||
* @link http://docs.moodle.org/en/Collapsed_Topics_course_format | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
*/ | ||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once($CFG->dirroot . '/course/format/topcoll/togglelib.php'); | ||
|
||
$run = false; | ||
if ($run) { | ||
// TEST CODE. | ||
for ($i = 0; $i < 64; $i++) { | ||
user_preference_allow_ajax_update('topcoll_toggle_a'.$i.'_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_b'.$i.'_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_c'.$i.'_' . $course->id, PARAM_TOPCOLL); | ||
} | ||
user_preference_allow_ajax_update('topcoll_toggle_bf_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_bf2_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_bf3_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_af_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_af2_' . $course->id, PARAM_TOPCOLL); | ||
user_preference_allow_ajax_update('topcoll_toggle_af3_' . $course->id, PARAM_TOPCOLL); | ||
// Test clean_param to see if it accepts '<' and '>' for PARAM_TEXT as stated in moodlelib.php. | ||
echo '<h3>PARAM_TEXT < : '.clean_param('<',PARAM_TEXT).'</h3>'; | ||
echo '<h3>PARAM_TEXT > : '.clean_param('>',PARAM_TEXT).'</h3>'; | ||
echo '<h3>PARAM_RAW < : '.clean_param('<',PARAM_RAW).'</h3>'; | ||
echo '<h3>PARAM_RAW > : '.clean_param('>',PARAM_RAW).'</h3>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Collapsed Topics Information | ||
* | ||
* A topic based format that solves the issue of the 'Scroll of Death' when a course has many topics. All topics | ||
* except zero have a toggle that displays that topic. One or more topics can be displayed at any given time. | ||
* Toggles are persistent on a per browser session per course basis but can be made to persist longer by a small | ||
* code change. Full installation instructions, code adaptions and credits are included in the 'Readme.txt' file. | ||
* | ||
* @package course/format | ||
* @subpackage topcoll | ||
* @version See the value of '$plugin->version' in version.php. | ||
* @copyright © 2014-onwards G J Barnard in respect to modifications of standard topics format. | ||
* @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} | ||
* @link http://docs.moodle.org/en/Collapsed_Topics_course_format | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
M.format_topcoll.test_all_states = function() { | ||
"use strict"; | ||
// Reset for this course. | ||
console.log('test_all_states: togglestate:' + this.togglestate); | ||
console.log('test_all_states: reset course.'); | ||
M.format_topcoll.resetState(M.format_topcoll.get_min_digit()); | ||
M.format_topcoll.save_toggles(); | ||
console.log('test_all_states: togglestate:' + this.togglestate); | ||
|
||
// Loop through all possible states, this involves the first twelve toggles. | ||
console.log('test_all_states: start loop.'); | ||
var state = 0; | ||
|
||
for (state = 0; state < 64; state++) { | ||
var newchar = this.encode_value_to_character(state); | ||
console.log('test_all_states: newchar: ' + newchar + ' - togglestate:' + this.togglestate); | ||
|
||
//M.util.set_user_preference('topcoll_toggle_' + state + '_' + this.courseid, this.togglestate); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_a' + state + '_' + this.courseid, newchar); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_b' + state + '_' + this.courseid, newchar + ':'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_c' + state + '_' + this.courseid, ':' + newchar); | ||
} | ||
console.log('test_all_states: end loop.'); | ||
console.log('test_all_states: start invalid data.'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_bf_' + this.courseid, '9'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_af_' + this.courseid, 'z'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_bf2_' + this.courseid, '9:'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_af2_' + this.courseid, 'z:'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_bf3_' + this.courseid, ':9'); | ||
M.format_topcoll.set_user_preference('topcoll_toggle_af3_' + this.courseid, ':z'); | ||
console.log('test_all_states: end invalid data.'); | ||
}; |
Oops, something went wrong.