mirror of
https://github.com/moodle/moodle.git
synced 2025-04-17 14:35:29 +02:00
MDL-74465 block_glossary_random: display config when adding
This commit is contained in:
parent
2909e91877
commit
2fdfc9c362
blocks/glossary_random
@ -40,7 +40,8 @@ class block_glossary_random_edit_form extends block_edit_form {
|
||||
$mform->setType('config_title', PARAM_TEXT);
|
||||
|
||||
// Select glossaries to put in dropdown box ...
|
||||
$glossaries = $DB->get_records_select_menu('glossary', 'course = ? OR globalglossary = ?', array($this->block->course->id, 1), 'name', 'id,name');
|
||||
$glossaries = $DB->get_records_select_menu('glossary', 'course = ? OR globalglossary = ?',
|
||||
[$this->get_course_id(), 1], 'name', 'id,name');
|
||||
foreach($glossaries as $key => $value) {
|
||||
$glossaries[$key] = strip_tags(format_string($value, true));
|
||||
}
|
||||
@ -76,4 +77,28 @@ class block_glossary_random_edit_form extends block_edit_form {
|
||||
$mform->setDefault('config_invisible', get_string('invisible', 'block_glossary_random'));
|
||||
$mform->setType('config_invisible', PARAM_NOTAGS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns id of the course where this block is located (or siteid for the dashboard or non-course page)
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function get_course_id(): int {
|
||||
if ($this->block->instance->id) {
|
||||
return $this->block->course->id;
|
||||
} else if ($parentcontext = $this->block->context->get_course_context(false)) {
|
||||
return $parentcontext->instanceid;
|
||||
} else {
|
||||
return get_site()->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the configuration form when block is being added to the page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function display_form_when_adding(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ Feature: Add the glossary random block when main feature is disabled
|
||||
|
||||
Scenario: The glossary random block is displayed even when glossary module is disabled
|
||||
Given I turn editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I add the "Random glossary entry" block to the default region with:
|
||||
| Title | Random glossary entry |
|
||||
When I navigate to "Plugins > Activity modules > Manage activities" in site administration
|
||||
And I click on "Disable the Glossary plugin" "icon" in the "Glossary" "table_row"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
@ -20,7 +21,8 @@ Feature: Add the glossary random block when main feature is disabled
|
||||
|
||||
Scenario: The glossary random block can be removed even when glossary module is disabled
|
||||
Given I turn editing mode on
|
||||
And I add the "Random glossary entry" block
|
||||
And I add the "Random glossary entry" block to the default region with:
|
||||
| Title | Random glossary entry |
|
||||
And I open the "Random glossary entry" blocks action menu
|
||||
And I click on "Delete Random glossary entry block" "link" in the "Random glossary entry" "block"
|
||||
And "Delete block?" "dialogue" should exist
|
||||
|
Loading…
x
Reference in New Issue
Block a user