Merge branch 'MDL-50710-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
David Monllao 2015-12-02 11:40:46 +08:00 committed by Eloy Lafuente (stronk7)
commit 76bcec2cb1

View File

@ -84,14 +84,13 @@ class block_glossary_random extends block_base {
$limitfrom = 0;
$limitnum = 1;
$BROWSE = 'timemodified';
$orderby = 'timemodified ASC';
switch ($this->config->type) {
case BGR_RANDOMLY:
$i = rand(1,$numberofentries);
$limitfrom = $i-1;
$SORT = 'ASC';
break;
case BGR_NEXTONE:
@ -104,11 +103,10 @@ class block_glossary_random extends block_base {
$i = 1;
}
$limitfrom = $i-1;
$SORT = 'ASC';
break;
case BGR_NEXTALPHA:
$BROWSE = 'concept';
$orderby = 'concept ASC';
if (isset($this->config->previous)) {
$i = $this->config->previous + 1;
} else {
@ -118,20 +116,19 @@ class block_glossary_random extends block_base {
$i = 1;
}
$limitfrom = $i-1;
$SORT = 'ASC';
break;
default: // BGR_LASTMODIFIED
$i = $numberofentries;
$limitfrom = 0;
$SORT = 'DESC';
$orderby = 'timemodified DESC, id DESC';
break;
}
if ($entry = $DB->get_records_sql("SELECT id, concept, definition, definitionformat, definitiontrust
FROM {glossary_entries}
WHERE glossaryid = ? AND approved = 1
ORDER BY $BROWSE $SORT", array($this->config->glossary), $limitfrom, $limitnum)) {
ORDER BY $orderby", array($this->config->glossary), $limitfrom, $limitnum)) {
$entry = reset($entry);