Merge branch 'MDL-66032-MOODLE_36_STABLE_awarded_badges_criteria' of https://github.com/andrewmadden/moodle into MOODLE_36_STABLE

This commit is contained in:
Eloy Lafuente (stronk7)
2019-07-17 01:32:05 +02:00
+5 -3
View File
@@ -112,7 +112,7 @@ class award_criteria_badge extends award_criteria {
if ($this->id !== 0) {
$selected = array_keys($this->params);
}
$settings = array('multiple' => 'multiple', 'size' => 20, 'class' => 'selectbadge');
$settings = array('multiple' => 'multiple', 'size' => 20, 'class' => 'selectbadge', 'required' => 'required');
$mform->addElement('select', 'badge_badges', get_string('addbadge', 'badges'), $select, $settings);
$mform->addRule('badge_badges', get_string('requiredbadge', 'badges'), 'required');
$mform->addHelpButton('badge_badges', 'addbadge', 'badges');
@@ -243,7 +243,6 @@ class award_criteria_badge extends award_criteria {
if ($this->method == BADGE_CRITERIA_AGGREGATION_ANY) {
// User has received ANY of the required badges.
$join = " LEFT JOIN {badge_issued} bi2 ON bi2.userid = u.id";
$where = "AND (";
$i = 0;
foreach ($this->params as $param) {
if ($i == 0) {
@@ -254,7 +253,10 @@ class award_criteria_badge extends award_criteria {
$params['badgeid'.$i] = $param['badge'];
$i++;
}
$where .= ") ";
// MDL-66032 Do not create expression if there are no badges in criteria.
if (!empty($where)) {
$where = ' AND (' . $where . ') ';
}
return array($join, $where, $params);
} else {
// User has received ALL of the required badges.