MDL-61514 Quiz: Display unavailable tags when editing random questions
When editing a random question, the form will display the tags that the random question is configured to get questions from even if those tags do not exist anymore.
This commit is contained in:
@@ -81,4 +81,20 @@ class randomquestion_form extends \moodleform {
|
||||
$mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
|
||||
$mform->closeHeaderBefore('buttonar');
|
||||
}
|
||||
|
||||
public function set_data($defaultvalues) {
|
||||
$mform = $this->_form;
|
||||
|
||||
if ($defaultvalues->fromtags) {
|
||||
$fromtagselement = $mform->getElement('fromtags');
|
||||
foreach ($defaultvalues->fromtags as $fromtag) {
|
||||
if (!$fromtagselement->optionExists($fromtag)) {
|
||||
$optionname = get_string('randomfromunavailabletag', 'mod_quiz', explode(',', $fromtag)[1]);
|
||||
$fromtagselement->addOption($optionname, $fromtag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::set_data($defaultvalues);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,6 +700,7 @@ $string['randomcreate'] = 'Create random questions';
|
||||
$string['randomediting'] = 'Editing a random question';
|
||||
$string['randomfromcategory'] = 'Random question from category:';
|
||||
$string['randomfromexistingcategory'] = 'Random question from an existing category';
|
||||
$string['randomfromunavailabletag'] = '{$a} (unavailable)';
|
||||
$string['randomnumber'] = 'Number of random questions';
|
||||
$string['randomnosubcat'] = 'Questions from this category only, not its subcategories.';
|
||||
$string['randomquestion'] = 'Random question';
|
||||
|
||||
Reference in New Issue
Block a user