mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
Merge branch 'MDL-81050-main' of https://github.com/roland04/moodle
This commit is contained in:
commit
45750b413e
15 changed files with 96 additions and 14 deletions
2
course/amd/build/actions.min.js
vendored
2
course/amd/build/actions.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -994,7 +994,7 @@ define(
|
||||||
|
|
||||||
// The section and activity names are edited using inplace editable.
|
// The section and activity names are edited using inplace editable.
|
||||||
// The "update" jQuery event must be captured in order to update the course state.
|
// The "update" jQuery event must be captured in order to update the course state.
|
||||||
$('body').on('updated', `${SELECTOR.SECTIONLI} ${SELECTOR.SECTIONITEM} [data-inplaceeditable]`, function(e) {
|
$('body').on('updated', `${SELECTOR.SECTIONITEM} [data-inplaceeditable]`, function(e) {
|
||||||
if (e.ajaxreturn && e.ajaxreturn.itemid) {
|
if (e.ajaxreturn && e.ajaxreturn.itemid) {
|
||||||
const state = courseeditor.state;
|
const state = courseeditor.state;
|
||||||
const section = state.section.get(e.ajaxreturn.itemid);
|
const section = state.section.get(e.ajaxreturn.itemid);
|
||||||
|
|
2
course/format/amd/build/local/content.min.js
vendored
2
course/format/amd/build/local/content.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -63,6 +63,7 @@ export default class Component extends BaseComponent {
|
||||||
};
|
};
|
||||||
this.selectorGenerators = {
|
this.selectorGenerators = {
|
||||||
cmNameFor: (id) => `[data-cm-name-for='${id}']`,
|
cmNameFor: (id) => `[data-cm-name-for='${id}']`,
|
||||||
|
sectionNameFor: (id) => `[data-section-name-for='${id}']`,
|
||||||
};
|
};
|
||||||
// Default classes to toggle on refresh.
|
// Default classes to toggle on refresh.
|
||||||
this.classes = {
|
this.classes = {
|
||||||
|
@ -236,6 +237,7 @@ export default class Component extends BaseComponent {
|
||||||
{watch: `cm.name:updated`, handler: this._refreshCmName},
|
{watch: `cm.name:updated`, handler: this._refreshCmName},
|
||||||
// Update section number and title.
|
// Update section number and title.
|
||||||
{watch: `section.number:updated`, handler: this._refreshSectionNumber},
|
{watch: `section.number:updated`, handler: this._refreshSectionNumber},
|
||||||
|
{watch: `section.title:updated`, handler: this._refreshSectionTitle},
|
||||||
// Collapse and expand sections.
|
// Collapse and expand sections.
|
||||||
{watch: `section.contentcollapsed:updated`, handler: this._refreshSectionCollapsed},
|
{watch: `section.contentcollapsed:updated`, handler: this._refreshSectionCollapsed},
|
||||||
// Sections and cm sorting.
|
// Sections and cm sorting.
|
||||||
|
@ -429,6 +431,22 @@ export default class Component extends BaseComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a course section name on the whole page.
|
||||||
|
*
|
||||||
|
* @param {object} param
|
||||||
|
* @param {Object} param.element details the update details.
|
||||||
|
*/
|
||||||
|
_refreshSectionTitle({element}) {
|
||||||
|
// Replace the text content of the section name in the whole page.
|
||||||
|
const allSectionNamesFor = document.querySelectorAll(
|
||||||
|
this.selectorGenerators.sectionNameFor(element.id)
|
||||||
|
);
|
||||||
|
allSectionNamesFor.forEach((sectionNameFor) => {
|
||||||
|
sectionNameFor.textContent = element.title;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh a section cm list.
|
* Refresh a section cm list.
|
||||||
*
|
*
|
||||||
|
|
|
@ -374,3 +374,10 @@ Feature: Course index depending on role
|
||||||
And I should see "Activity sample 5" in the "courseindex-content" "region"
|
And I should see "Activity sample 5" in the "courseindex-content" "region"
|
||||||
# Label intro text should be displayed if label name is not set.
|
# Label intro text should be displayed if label name is not set.
|
||||||
And I should see "Test label 2" in the "courseindex-content" "region"
|
And I should see "Test label 2" in the "courseindex-content" "region"
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Change the section name inline in section page
|
||||||
|
When I am on the "Course 1 > Section 2" "course > section" page logged in as "teacher1"
|
||||||
|
And I turn editing mode on
|
||||||
|
When I set the field "Edit section name" in the "page-header" "region" to "Custom section name"
|
||||||
|
Then I should see "Custom section name" in the "courseindex-content" "region"
|
||||||
|
|
|
@ -90,3 +90,13 @@ Feature: Single section course page
|
||||||
Given I turn editing mode on
|
Given I turn editing mode on
|
||||||
When I click on "View" "link" in the "Section 1" "section"
|
When I click on "View" "link" in the "Section 1" "section"
|
||||||
Then "Add section" "link" should not exist in the "region-main" "region"
|
Then "Add section" "link" should not exist in the "region-main" "region"
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Change the section name inline
|
||||||
|
# The course index is hidden by default in small devices.
|
||||||
|
Given I change window size to "large"
|
||||||
|
And I turn editing mode on
|
||||||
|
And I open section "1" edit menu
|
||||||
|
And I click on "View" "link" in the "Section 1" "section"
|
||||||
|
When I set the field "Edit section name" in the "page-header" "region" to "Custom section name"
|
||||||
|
Then "Custom section name" "text" should exist in the ".breadcrumb" "css_element"
|
||||||
|
|
|
@ -148,7 +148,10 @@ if ($format->show_editor()) {
|
||||||
$renderable = $sectionclass->export_for_template($renderer);
|
$renderable = $sectionclass->export_for_template($renderer);
|
||||||
$controlmenuhtml = $renderable->controlmenu->menu;
|
$controlmenuhtml = $renderable->controlmenu->menu;
|
||||||
$PAGE->add_header_action($controlmenuhtml);
|
$PAGE->add_header_action($controlmenuhtml);
|
||||||
$sectionheading = $OUTPUT->render($format->inplace_editable_render_section_name($sectioninfo, false));
|
$sectionheading = $OUTPUT->container(
|
||||||
|
$OUTPUT->render($format->inplace_editable_render_section_name($sectioninfo, false)),
|
||||||
|
attributes: ['data-for' => 'section_title'],
|
||||||
|
);
|
||||||
$PAGE->set_heading($sectionheading, false, false);
|
$PAGE->set_heading($sectionheading, false, false);
|
||||||
} else {
|
} else {
|
||||||
$PAGE->set_heading($sectiontitle);
|
$PAGE->set_heading($sectiontitle);
|
||||||
|
|
|
@ -116,6 +116,8 @@ class navigation_node implements renderable {
|
||||||
public $forceopen = false;
|
public $forceopen = false;
|
||||||
/** @var array An array of CSS classes for the node */
|
/** @var array An array of CSS classes for the node */
|
||||||
public $classes = array();
|
public $classes = array();
|
||||||
|
/** @var array An array of HTML attributes for the node */
|
||||||
|
public $attributes = [];
|
||||||
/** @var navigation_node_collection An array of child nodes */
|
/** @var navigation_node_collection An array of child nodes */
|
||||||
public $children = array();
|
public $children = array();
|
||||||
/** @var bool If set to true the node will be recognised as active */
|
/** @var bool If set to true the node will be recognised as active */
|
||||||
|
@ -559,6 +561,16 @@ class navigation_node implements renderable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an HTML attribute to this node.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $value
|
||||||
|
*/
|
||||||
|
public function add_attribute(string $name, string $value): void {
|
||||||
|
$this->attributes[] = ['name' => $name, 'value' => $value];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a CSS class from this node.
|
* Removes a CSS class from this node.
|
||||||
*
|
*
|
||||||
|
@ -2290,6 +2302,7 @@ class global_navigation extends navigation_node {
|
||||||
null, $section->id, new pix_icon('i/section', ''));
|
null, $section->id, new pix_icon('i/section', ''));
|
||||||
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
|
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
|
||||||
$sectionnode->hidden = (!$section->visible || !$section->available);
|
$sectionnode->hidden = (!$section->visible || !$section->available);
|
||||||
|
$sectionnode->add_attribute('data-section-name-for', $section->id);
|
||||||
if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) {
|
if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) {
|
||||||
$this->load_section_activities($sectionnode, $section->section, $activities);
|
$this->load_section_activities($sectionnode, $section->section, $activities);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3410,10 +3410,11 @@ EOD;
|
||||||
* @param string $contents The contents of the box
|
* @param string $contents The contents of the box
|
||||||
* @param string $classes A space-separated list of CSS classes
|
* @param string $classes A space-separated list of CSS classes
|
||||||
* @param string $id An optional ID
|
* @param string $id An optional ID
|
||||||
|
* @param array $attributes Optional other attributes as array
|
||||||
* @return string the HTML to output.
|
* @return string the HTML to output.
|
||||||
*/
|
*/
|
||||||
public function container($contents, $classes = null, $id = null) {
|
public function container($contents, $classes = null, $id = null, $attributes = []) {
|
||||||
return $this->container_start($classes, $id) . $contents . $this->container_end();
|
return $this->container_start($classes, $id, $attributes) . $contents . $this->container_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3421,12 +3422,13 @@ EOD;
|
||||||
*
|
*
|
||||||
* @param string $classes A space-separated list of CSS classes
|
* @param string $classes A space-separated list of CSS classes
|
||||||
* @param string $id An optional ID
|
* @param string $id An optional ID
|
||||||
|
* @param array $attributes Optional other attributes as array
|
||||||
* @return string the HTML to output.
|
* @return string the HTML to output.
|
||||||
*/
|
*/
|
||||||
public function container_start($classes = null, $id = null) {
|
public function container_start($classes = null, $id = null, $attributes = []) {
|
||||||
$this->opencontainers->push('container', html_writer::end_tag('div'));
|
$this->opencontainers->push('container', html_writer::end_tag('div'));
|
||||||
return html_writer::start_tag('div', array('id' => $id,
|
$attributes = array_merge(['id' => $id, 'class' => renderer_base::prepare_classes($classes)], $attributes);
|
||||||
'class' => renderer_base::prepare_classes($classes)));
|
return html_writer::start_tag('div', $attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,11 +68,21 @@
|
||||||
}}{{#get_items}}
|
}}{{#get_items}}
|
||||||
{{#has_action}}
|
{{#has_action}}
|
||||||
<li class="breadcrumb-item{{#is_hidden}} dimmed_text{{/is_hidden}}">
|
<li class="breadcrumb-item{{#is_hidden}} dimmed_text{{/is_hidden}}">
|
||||||
<a href="{{{action}}}" {{#is_last}}aria-current="page"{{/is_last}} {{#get_title}}title="{{get_title}}"{{/get_title}}>{{{get_content}}}</a>
|
<a href="{{{action}}}"
|
||||||
|
{{#is_last}}aria-current="page"{{/is_last}}
|
||||||
|
{{#get_title}}title="{{get_title}}"{{/get_title}}
|
||||||
|
{{#attributes}}{{name}}="{{value}}" {{/attributes}}
|
||||||
|
>
|
||||||
|
{{{get_content}}}
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/has_action}}
|
{{/has_action}}
|
||||||
{{^has_action}}
|
{{^has_action}}
|
||||||
<li class="breadcrumb-item{{#is_hidden}} dimmed_text{{/is_hidden}}"><span>{{{text}}}</span></li>
|
<li class="breadcrumb-item{{#is_hidden}} dimmed_text{{/is_hidden}}">
|
||||||
|
<span {{#attributes}}{{name}}="{{value}}" {{/attributes}}>
|
||||||
|
{{{text}}}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
{{/has_action}}
|
{{/has_action}}
|
||||||
{{/get_items}}{{!
|
{{/get_items}}{{!
|
||||||
}}</ol>
|
}}</ol>
|
||||||
|
|
|
@ -152,6 +152,22 @@ class navigationlib_test extends \advanced_testcase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the add_attribute method.
|
||||||
|
* @covers \navigation_node::add_attribute
|
||||||
|
*/
|
||||||
|
public function test_node_add_attribute(): void {
|
||||||
|
$this->setup_node();
|
||||||
|
|
||||||
|
$node = $this->node->get('demo1');
|
||||||
|
$this->assertInstanceOf('navigation_node', $node);
|
||||||
|
if ($node !== false) {
|
||||||
|
$node->add_attribute('data-foo', 'bar');
|
||||||
|
$attribute = reset($node->attributes);
|
||||||
|
$this->assertEqualsCanonicalizing(['name' => 'data-foo', 'value' => 'bar'], $attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function test_node_check_if_active() {
|
public function test_node_check_if_active() {
|
||||||
$this->setup_node();
|
$this->setup_node();
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,9 @@ information provided here is intended especially for developers.
|
||||||
- `question_category_options`
|
- `question_category_options`
|
||||||
- `question_add_context_in_key`
|
- `question_add_context_in_key`
|
||||||
- `question_fix_top_names`
|
- `question_fix_top_names`
|
||||||
|
* Added a new parameter to `core_renderer::container` and `core_renderer::container_start` to allow for the addition of
|
||||||
|
custom attributes.
|
||||||
|
* Added a new method `navigation_node::add_attribute()` to allow adding HTML attributes to the node.
|
||||||
|
|
||||||
=== 4.3 ===
|
=== 4.3 ===
|
||||||
|
|
||||||
|
|
|
@ -2216,7 +2216,7 @@ class page_wiki_viewversion extends page_wiki {
|
||||||
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
|
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
|
||||||
|
|
||||||
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
|
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
|
||||||
$content = $OUTPUT->container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
|
$content = $OUTPUT->container(format_text($parseroutput['parsed_text'], FORMAT_HTML, ['overflowdiv' => true]));
|
||||||
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
|
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue