Permalink
Browse files

MDL-35842 - Glossary, Blocks - Joseph Rézeau's patch for setting the …

…Random Glossary block to progress alphabetically
  • Loading branch information...
1 parent 2d7c5ee commit 9e7d097926fdf447aedb982c53f1554b898d9d59 @jsnfwlr jsnfwlr committed Nov 23, 2012
@@ -3,6 +3,7 @@
define('BGR_RANDOMLY', '0');
define('BGR_LASTMODIFIED', '1');
define('BGR_NEXTONE', '2');
+define('BGR_NEXTALPHA', '3');
class block_glossary_random extends block_base {
function init() {
@@ -50,6 +51,8 @@ function specialization() {
$limitfrom = 0;
$limitnum = 1;
+ $BROWSE = 'timemodified';
+
switch ($this->config->type) {
case BGR_RANDOMLY:
@@ -71,6 +74,20 @@ function specialization() {
$SORT = 'ASC';
break;
+ case BGR_NEXTALPHA:
+ $BROWSE = 'concept';
+ if (isset($this->config->previous)) {
+ $i = $this->config->previous + 1;
+ } else {
+ $i = 1;
+ }
+ if ($i > $numberofentries) { // Loop back to beginning
+ $i = 1;
+ }
+ $limitfrom = $i-1;
+ $SORT = 'ASC';
+ break;
+
default: // BGR_LASTMODIFIED
$i = $numberofentries;
$limitfrom = 0;
@@ -81,7 +98,7 @@ function specialization() {
if ($entry = $DB->get_records_sql("SELECT id, concept, definition, definitionformat, definitiontrust
FROM {glossary_entries}
WHERE glossaryid = ? AND approved = 1
- ORDER BY timemodified $SORT", array($this->config->glossary), $limitfrom, $limitnum)) {
+ ORDER BY $BROWSE $SORT", array($this->config->glossary), $limitfrom, $limitnum)) {
$entry = reset($entry);
@@ -55,7 +55,8 @@ protected function specific_definition($mform) {
$types = array(
0 => get_string('random','block_glossary_random'),
1 => get_string('lastmodified','block_glossary_random'),
- 2 => get_string('nextone','block_glossary_random')
+ 2 => get_string('nextone','block_glossary_random'),
+ 3 => get_string('nextalpha','block_glossary_random')
);
$mform->addElement('select', 'config_type', get_string('type', 'block_glossary_random'), $types);
@@ -32,6 +32,7 @@
$string['intro'] = 'Make sure you have at least one glossary with at least one entry added to this course. Then you can adjust the following settings';
$string['invisible'] = '(to be continued)';
$string['lastmodified'] = 'Last modified entry';
+$string['nextalpha'] = 'Alphabetical order';
$string['nextone'] = 'Next entry';
$string['noentriesyet'] = 'There are no entries yet in the chosen glossary.';
$string['notyetconfigured'] = 'Please configure this block using the edit icon.';

0 comments on commit 9e7d097

Please sign in to comment.