Merge branch 'wip-MDL-35842-master' of git://github.com/phalacee/moodle
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -55,6 +56,8 @@ class block_glossary_random extends block_base {
|
||||
$limitfrom = 0;
|
||||
$limitnum = 1;
|
||||
|
||||
$BROWSE = 'timemodified';
|
||||
|
||||
switch ($this->config->type) {
|
||||
|
||||
case BGR_RANDOMLY:
|
||||
@@ -76,6 +79,20 @@ class block_glossary_random extends block_base {
|
||||
$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;
|
||||
@@ -86,7 +103,7 @@ class block_glossary_random extends block_base {
|
||||
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 @@ class block_glossary_random_edit_form extends block_edit_form {
|
||||
$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);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ $string['glossary_random:addinstance'] = 'Add a new random glossary entry block'
|
||||
$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.';
|
||||
|
||||
Reference in New Issue
Block a user