mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-80248 course: Display only content for the General section
This commit is contained in:
parent
810554ee83
commit
e6f75b59a3
@ -108,7 +108,7 @@ abstract class base extends area_base {
|
||||
*/
|
||||
public static function get_edit_url(\stdClass $componentinfo): \moodle_url {
|
||||
if ($componentinfo->tablename == 'course_sections') {
|
||||
return new \moodle_url('/course/editsection.php', ['id' => $componentinfo->itemid, 'sr' => '']);
|
||||
return new \moodle_url('/course/editsection.php', ['id' => $componentinfo->itemid]);
|
||||
} else if ($componentinfo->tablename == 'course_categories') {
|
||||
return new \moodle_url('/course/editcategory.php', ['id' => $componentinfo->itemid]);
|
||||
} else {
|
||||
|
@ -108,6 +108,6 @@ abstract class module_area_base extends area_base {
|
||||
* @return \moodle_url
|
||||
*/
|
||||
public static function get_edit_url(\stdClass $componentinfo): \moodle_url {
|
||||
return new \moodle_url('/course/mod.php', ['update' => $componentinfo->cmid, 'sr' => 0, 'sesskey' => sesskey()]);
|
||||
return new \moodle_url('/course/mod.php', ['update' => $componentinfo->cmid, 'sr' => null, 'sesskey' => sesskey()]);
|
||||
}
|
||||
}
|
||||
|
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
2
course/amd/build/activitychooser.min.js
vendored
2
course/amd/build/activitychooser.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
@ -335,7 +335,7 @@ define(
|
||||
methodname: 'core_course_edit_module',
|
||||
args: {id: cmid,
|
||||
action: action,
|
||||
sectionreturn: target.attr('data-sectionreturn') ? target.attr('data-sectionreturn') : 0
|
||||
sectionreturn: target.attr('data-sectionreturn') ? target.attr('data-sectionreturn') : null
|
||||
}
|
||||
}], true);
|
||||
|
||||
@ -694,7 +694,7 @@ define(
|
||||
*/
|
||||
var editSection = function(sectionElement, sectionid, target, courseformat) {
|
||||
var action = target.attr('data-action'),
|
||||
sectionreturn = target.attr('data-sectionreturn') ? target.attr('data-sectionreturn') : 0;
|
||||
sectionreturn = target.attr('data-sectionreturn') ? target.attr('data-sectionreturn') : null;
|
||||
|
||||
// Filter direct component handled actions.
|
||||
if (courseeditor.supportComponents && componentActions.includes(action)) {
|
||||
|
@ -197,7 +197,10 @@ const sectionIdMapper = (webServiceData, id, sectionreturnid, beforemod) => {
|
||||
// We need to take a fresh deep copy of the original data as an object is a reference type.
|
||||
const newData = JSON.parse(JSON.stringify(webServiceData));
|
||||
newData.content_items.forEach((module) => {
|
||||
module.link += '§ion=' + id + '&sr=' + (sectionreturnid ?? 0) + '&beforemod=' + (beforemod ?? 0);
|
||||
module.link += '§ion=' + id + '&beforemod=' + (beforemod ?? 0);
|
||||
if (sectionreturnid) {
|
||||
module.link += '&sr=' + sectionreturnid;
|
||||
}
|
||||
});
|
||||
return newData.content_items;
|
||||
};
|
||||
|
@ -28,11 +28,16 @@ require_once("lib.php");
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course_sections.id
|
||||
$sectionreturn = optional_param('sr', 0, PARAM_INT);
|
||||
$sectionreturn = optional_param('sr', null, PARAM_INT);
|
||||
$deletesection = optional_param('delete', 0, PARAM_BOOL);
|
||||
$showonly = optional_param('showonly', 0, PARAM_TAGLIST);
|
||||
|
||||
$params = ['id' => $id, 'sr' => $sectionreturn];
|
||||
$returnparams = [];
|
||||
$params = ['id' => $id];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$params['sr'] = $sectionreturn;
|
||||
$returnparams['sr'] = $sectionreturn;
|
||||
}
|
||||
if (!empty($showonly)) {
|
||||
$params['showonly'] = $showonly;
|
||||
}
|
||||
@ -51,7 +56,7 @@ $sectioninfo = get_fast_modinfo($course)->get_section_info($sectionnum);
|
||||
|
||||
// Deleting the section.
|
||||
if ($deletesection) {
|
||||
$cancelurl = course_get_url($course, $sectioninfo, array('sr' => $sectionreturn));
|
||||
$cancelurl = course_get_url($course, $sectioninfo, $returnparams);
|
||||
if (course_can_delete_section($course, $sectioninfo)) {
|
||||
$confirm = optional_param('confirm', false, PARAM_BOOL) && confirm_sesskey();
|
||||
if (!$confirm && optional_param('sesskey', null, PARAM_RAW) !== null &&
|
||||
@ -61,7 +66,7 @@ if ($deletesection) {
|
||||
}
|
||||
if ($confirm) {
|
||||
course_delete_section($course, $sectioninfo, true, true);
|
||||
$courseurl = course_get_url($course, $sectioninfo->section - 1, array('sr' => $sectionreturn));
|
||||
$courseurl = course_get_url($course, $sectioninfo->section - 1, $returnparams);
|
||||
redirect($courseurl);
|
||||
} else {
|
||||
if (get_string_manager()->string_exists('deletesection', 'format_' . $course->format)) {
|
||||
@ -123,7 +128,7 @@ if (!empty($showonly)) {
|
||||
|
||||
if ($mform->is_cancelled()){
|
||||
// Form cancelled, return to course.
|
||||
redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $section, $returnparams));
|
||||
} else if ($data = $mform->get_data()) {
|
||||
// Data submitted and validated, update and return to course.
|
||||
|
||||
@ -139,7 +144,7 @@ if ($mform->is_cancelled()){
|
||||
course_update_section($course, $section, $data);
|
||||
|
||||
$PAGE->navigation->clear_cache();
|
||||
redirect(course_get_url($course, $section, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $section, $returnparams));
|
||||
}
|
||||
|
||||
// The edit form is displayed for the first time or if there was validation error on the previous step.
|
||||
|
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
@ -6,6 +6,6 @@ define("core_courseformat/local/content/section",["exports","core_courseformat/l
|
||||
* @class core_courseformat/local/content/section
|
||||
* @copyright 2021 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_header=_interopRequireDefault(_header),_dndsection=_interopRequireDefault(_dndsection),_templates=_interopRequireDefault(_templates);class _default extends _dndsection.default{create(){this.name="content_section",this.selectors={SECTION_ITEM:"[data-for='section_title']",CM:'[data-for="cmitem"]',SECTIONINFO:'[data-for="sectioninfo"]',SECTIONBADGES:'[data-region="sectionbadges"]',SHOWSECTION:'[data-action="sectionShow"]',HIDESECTION:'[data-action="sectionHide"]',ACTIONTEXT:".menu-action-text",ICON:".icon"},this.classes={LOCKED:"editinprogress",HASDESCRIPTION:"description",HIDE:"d-none",HIDDEN:"hidden",CURRENT:"current"},this.id=this.element.dataset.id}stateReady(state){if(this.configState(state),this.reactive.isEditing&&this.reactive.supportComponents){const sectionItem=this.getElement(this.selectors.SECTION_ITEM);if(sectionItem){const headerComponent=new _header.default({...this,element:sectionItem,fullregion:this.element});this.configDragDrop(headerComponent)}}}getWatchers(){return[{watch:"section[".concat(this.id,"]:updated"),handler:this._refreshSection}]}validateDropData(dropdata){return("section"!==(null==dropdata?void 0:dropdata.type)||0==this.reactive.sectionReturn)&&super.validateDropData(dropdata)}getLastCm(){const cms=this.getElements(this.selectors.CM);return cms&&0!==cms.length?cms[cms.length-1]:null}_refreshSection(_ref){var _element$dragging,_element$locked,_element$visible,_element$current;let{element:element}=_ref;this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.element.classList.toggle(this.classes.HIDDEN,null!==(_element$visible=!element.visible)&&void 0!==_element$visible&&_element$visible),this.element.classList.toggle(this.classes.CURRENT,null!==(_element$current=element.current)&&void 0!==_element$current&&_element$current),this.locked=element.locked;const sectioninfo=this.getElement(this.selectors.SECTIONINFO);sectioninfo&§ioninfo.classList.toggle(this.classes.HASDESCRIPTION,element.hasrestrictions),this._updateBadges(element),this._updateActionsMenu(element)}_updateBadges(section){const current=this.getElement("".concat(this.selectors.SECTIONBADGES," [data-type='iscurrent']"));null==current||current.classList.toggle(this.classes.HIDE,!section.current);const hiddenFromStudents=this.getElement("".concat(this.selectors.SECTIONBADGES," [data-type='hiddenfromstudents']"));null==hiddenFromStudents||hiddenFromStudents.classList.toggle(this.classes.HIDE,section.visible)}async _updateActionsMenu(section){var _affectedAction$datas,_affectedAction$datas2;let selector,newAction;section.visible?(selector=this.selectors.SHOWSECTION,newAction="sectionHide"):(selector=this.selectors.HIDESECTION,newAction="sectionShow");const affectedAction=this.getElement(selector);if(!affectedAction)return;affectedAction.dataset.action=newAction;const actionText=affectedAction.querySelector(this.selectors.ACTIONTEXT);if(null!==(_affectedAction$datas=affectedAction.dataset)&&void 0!==_affectedAction$datas&&_affectedAction$datas.swapname&&actionText){const oldText=null==actionText?void 0:actionText.innerText;actionText.innerText=affectedAction.dataset.swapname,affectedAction.dataset.swapname=oldText}const icon=affectedAction.querySelector(this.selectors.ICON);if(null!==(_affectedAction$datas2=affectedAction.dataset)&&void 0!==_affectedAction$datas2&&_affectedAction$datas2.swapicon&&icon){const newIcon=affectedAction.dataset.swapicon;if(newIcon){const pixHtml=await _templates.default.renderPix(newIcon,"core");_templates.default.replaceNode(icon,pixHtml,"")}}}}return _exports.default=_default,_exports.default}));
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_header=_interopRequireDefault(_header),_dndsection=_interopRequireDefault(_dndsection),_templates=_interopRequireDefault(_templates);class _default extends _dndsection.default{create(){this.name="content_section",this.selectors={SECTION_ITEM:"[data-for='section_title']",CM:'[data-for="cmitem"]',SECTIONINFO:'[data-for="sectioninfo"]',SECTIONBADGES:'[data-region="sectionbadges"]',SHOWSECTION:'[data-action="sectionShow"]',HIDESECTION:'[data-action="sectionHide"]',ACTIONTEXT:".menu-action-text",ICON:".icon"},this.classes={LOCKED:"editinprogress",HASDESCRIPTION:"description",HIDE:"d-none",HIDDEN:"hidden",CURRENT:"current"},this.id=this.element.dataset.id}stateReady(state){if(this.configState(state),this.reactive.isEditing&&this.reactive.supportComponents){const sectionItem=this.getElement(this.selectors.SECTION_ITEM);if(sectionItem){const headerComponent=new _header.default({...this,element:sectionItem,fullregion:this.element});this.configDragDrop(headerComponent)}}}getWatchers(){return[{watch:"section[".concat(this.id,"]:updated"),handler:this._refreshSection}]}validateDropData(dropdata){return("section"!==(null==dropdata?void 0:dropdata.type)||null===this.reactive.sectionReturn)&&super.validateDropData(dropdata)}getLastCm(){const cms=this.getElements(this.selectors.CM);return cms&&0!==cms.length?cms[cms.length-1]:null}_refreshSection(_ref){var _element$dragging,_element$locked,_element$visible,_element$current;let{element:element}=_ref;this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.element.classList.toggle(this.classes.HIDDEN,null!==(_element$visible=!element.visible)&&void 0!==_element$visible&&_element$visible),this.element.classList.toggle(this.classes.CURRENT,null!==(_element$current=element.current)&&void 0!==_element$current&&_element$current),this.locked=element.locked;const sectioninfo=this.getElement(this.selectors.SECTIONINFO);sectioninfo&§ioninfo.classList.toggle(this.classes.HASDESCRIPTION,element.hasrestrictions),this._updateBadges(element),this._updateActionsMenu(element)}_updateBadges(section){const current=this.getElement("".concat(this.selectors.SECTIONBADGES," [data-type='iscurrent']"));null==current||current.classList.toggle(this.classes.HIDE,!section.current);const hiddenFromStudents=this.getElement("".concat(this.selectors.SECTIONBADGES," [data-type='hiddenfromstudents']"));null==hiddenFromStudents||hiddenFromStudents.classList.toggle(this.classes.HIDE,section.visible)}async _updateActionsMenu(section){var _affectedAction$datas,_affectedAction$datas2;let selector,newAction;section.visible?(selector=this.selectors.SHOWSECTION,newAction="sectionHide"):(selector=this.selectors.HIDESECTION,newAction="sectionShow");const affectedAction=this.getElement(selector);if(!affectedAction)return;affectedAction.dataset.action=newAction;const actionText=affectedAction.querySelector(this.selectors.ACTIONTEXT);if(null!==(_affectedAction$datas=affectedAction.dataset)&&void 0!==_affectedAction$datas&&_affectedAction$datas.swapname&&actionText){const oldText=null==actionText?void 0:actionText.innerText;actionText.innerText=affectedAction.dataset.swapname,affectedAction.dataset.swapname=oldText}const icon=affectedAction.querySelector(this.selectors.ICON);if(null!==(_affectedAction$datas2=affectedAction.dataset)&&void 0!==_affectedAction$datas2&&_affectedAction$datas2.swapicon&&icon){const newIcon=affectedAction.dataset.swapicon;if(newIcon){const pixHtml=await _templates.default.renderPix(newIcon,"core");_templates.default.replaceNode(icon,pixHtml,"")}}}}return _exports.default=_default,_exports.default}));
|
||||
|
||||
//# sourceMappingURL=section.min.js.map
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -76,7 +76,7 @@ export default class Component extends BaseComponent {
|
||||
this.sections = {};
|
||||
this.cms = {};
|
||||
// The page section return.
|
||||
this.sectionReturn = descriptor.sectionReturn ?? 0;
|
||||
this.sectionReturn = descriptor.sectionReturn ?? null;
|
||||
this.debouncedReloads = new Map();
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ export default class Component extends BaseComponent {
|
||||
*/
|
||||
_refreshCourseSectionlist({element}) {
|
||||
// If we have a section return means we only show a single section so no need to fix order.
|
||||
if (this.reactive.sectionReturn != 0) {
|
||||
if (this.reactive.sectionReturn !== null) {
|
||||
return;
|
||||
}
|
||||
const sectionlist = element.sectionlist ?? [];
|
||||
@ -541,7 +541,7 @@ export default class Component extends BaseComponent {
|
||||
{
|
||||
id: cmId,
|
||||
courseid: Config.courseId,
|
||||
sr: this.reactive.sectionReturn ?? 0,
|
||||
sr: this.reactive.sectionReturn ?? null,
|
||||
}
|
||||
);
|
||||
promise.then((html, js) => {
|
||||
@ -608,7 +608,7 @@ export default class Component extends BaseComponent {
|
||||
{
|
||||
id: element.id,
|
||||
courseid: Config.courseId,
|
||||
sr: this.reactive.sectionReturn ?? 0,
|
||||
sr: this.reactive.sectionReturn ?? null,
|
||||
}
|
||||
);
|
||||
promise.then((html, js) => {
|
||||
|
@ -100,7 +100,7 @@ export default class extends DndSection {
|
||||
*/
|
||||
validateDropData(dropdata) {
|
||||
// If the format uses one section per page sections dropping in the content is ignored.
|
||||
if (dropdata?.type === 'section' && this.reactive.sectionReturn != 0) {
|
||||
if (dropdata?.type === 'section' && this.reactive.sectionReturn !== null) {
|
||||
return false;
|
||||
}
|
||||
return super.validateDropData(dropdata);
|
||||
|
@ -52,9 +52,9 @@ export default class extends Reactive {
|
||||
* The current page section return
|
||||
* @attribute sectionReturn
|
||||
* @type number
|
||||
* @default 0
|
||||
* @default null
|
||||
*/
|
||||
sectionReturn = 0;
|
||||
sectionReturn = null;
|
||||
|
||||
/**
|
||||
* Set up the course editor when the page is ready.
|
||||
|
@ -37,7 +37,6 @@ use moodle_exception;
|
||||
use coding_exception;
|
||||
use moodle_url;
|
||||
use lang_string;
|
||||
use completion_info;
|
||||
use core_external\external_api;
|
||||
use stdClass;
|
||||
use cache;
|
||||
@ -78,8 +77,10 @@ abstract class base {
|
||||
protected $course = false;
|
||||
/** @var array caches format options, please use course_format::get_format_options() */
|
||||
protected $formatoptions = array();
|
||||
/** @var int the section number in single section format, zero for multiple section formats. */
|
||||
protected $singlesection = 0;
|
||||
/** @var int|null the section number in single section format, null for multiple section formats. */
|
||||
protected $singlesection = null;
|
||||
/** @var int|null the sectionid when a single section is selected, null when multiple sections are displayed. */
|
||||
protected $singlesectionid = null;
|
||||
/** @var course_modinfo the current course modinfo, please use course_format::get_modinfo() */
|
||||
private $modinfo = null;
|
||||
/** @var array cached instances */
|
||||
@ -560,6 +561,43 @@ abstract class base {
|
||||
return get_string('highlighted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the current format instance will show multiple sections or an individual one.
|
||||
*
|
||||
* Some formats has the hability to swith from one section to multiple sections per page.
|
||||
*
|
||||
* @param int|null $sectionid null for all sections or a sectionid.
|
||||
*/
|
||||
public function set_sectionid(?int $sectionid): void {
|
||||
if ($sectionid === null) {
|
||||
$this->singlesection = null;
|
||||
$this->singlesectionid = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$modinfo = get_fast_modinfo($this->courseid);
|
||||
$sectioninfo = $modinfo->get_section_info_by_id($sectionid);
|
||||
if ($sectioninfo === null) {
|
||||
throw new coding_exception('Invalid sectionid: '. $sectionid);
|
||||
}
|
||||
|
||||
$this->singlesection = $sectioninfo->section;
|
||||
$this->singlesectionid = $sectionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if the current format instance will show multiple sections or an individual one.
|
||||
*
|
||||
* Some formats has the hability to swith from one section to multiple sections per page,
|
||||
* output components will use this method to know if the current display is a single or
|
||||
* multiple sections.
|
||||
*
|
||||
* @return int|null null for all sections or the sectionid.
|
||||
*/
|
||||
public function get_sectionid(): ?int {
|
||||
return $this->singlesectionid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the current format instance will show multiple sections or an individual one.
|
||||
*
|
||||
@ -571,6 +609,41 @@ abstract class base {
|
||||
$this->singlesection = $singlesection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current section number to display.
|
||||
* Some formats has the hability to swith from one section to multiple sections per page.
|
||||
*
|
||||
* @since Moodle 4.4
|
||||
* @param int|null $sectionnum null for all sections or a sectionid.
|
||||
*/
|
||||
public function set_sectionnum(?int $sectionnum): void {
|
||||
if ($sectionnum === null) {
|
||||
$this->singlesection = null;
|
||||
$this->singlesectionid = null;
|
||||
return;
|
||||
}
|
||||
|
||||
$modinfo = get_fast_modinfo($this->courseid);
|
||||
$sectioninfo = $modinfo->get_section_info($sectionnum);
|
||||
if ($sectioninfo === null) {
|
||||
throw new coding_exception('Invalid sectionnum: '. $sectionnum);
|
||||
}
|
||||
|
||||
$this->singlesection = $sectionnum;
|
||||
$this->singlesectionid = $sectioninfo->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current section number to display.
|
||||
* Some formats has the hability to swith from one section to multiple sections per page.
|
||||
*
|
||||
* @since Moodle 4.4
|
||||
* @return int|null the current section number or null when there is no single section.
|
||||
*/
|
||||
public function get_sectionnum(): ?int {
|
||||
return $this->singlesection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if the current format instance will show multiple sections or an individual one.
|
||||
*
|
||||
@ -773,7 +846,9 @@ abstract class base {
|
||||
'/course/mod.php',
|
||||
['sesskey' => sesskey(), $nonajaxaction => $cm->id]
|
||||
);
|
||||
if (!is_null($this->get_sectionid())) {
|
||||
$nonajaxurl->param('sr', $this->get_section_number());
|
||||
}
|
||||
return $nonajaxurl;
|
||||
}
|
||||
|
||||
|
@ -94,14 +94,14 @@ class content implements named_templatable, renderable {
|
||||
'initialsection' => $initialsection,
|
||||
'sections' => $sections,
|
||||
'format' => $format->get_format(),
|
||||
'sectionreturn' => 0,
|
||||
'sectionreturn' => null,
|
||||
];
|
||||
|
||||
// The single section format has extra navigation.
|
||||
$singlesection = $this->format->get_section_number();
|
||||
if ($singlesection) {
|
||||
if ($this->format->get_sectionid()) {
|
||||
$singlesectionnum = $this->format->get_section_number();
|
||||
if (!$PAGE->theme->usescourseindex) {
|
||||
$sectionnavigation = new $this->sectionnavigationclass($format, $singlesection);
|
||||
$sectionnavigation = new $this->sectionnavigationclass($format, $singlesectionnum);
|
||||
$data->sectionnavigation = $sectionnavigation->export_for_template($output);
|
||||
|
||||
$sectionselector = new $this->sectionselectorclass($format, $sectionnavigation);
|
||||
@ -109,7 +109,7 @@ class content implements named_templatable, renderable {
|
||||
}
|
||||
$data->hasnavigation = true;
|
||||
$data->singlesection = array_shift($data->sections);
|
||||
$data->sectionreturn = $singlesection;
|
||||
$data->sectionreturn = $singlesectionnum;
|
||||
}
|
||||
|
||||
if ($this->hasaddsection) {
|
||||
@ -181,10 +181,10 @@ class content implements named_templatable, renderable {
|
||||
* @return section_info[] an array of section_info to display
|
||||
*/
|
||||
private function get_sections_to_display(course_modinfo $modinfo): array {
|
||||
$singlesection = $this->format->get_section_number();
|
||||
if ($singlesection) {
|
||||
$singlesectionid = $this->format->get_sectionid();
|
||||
if ($singlesectionid) {
|
||||
return [
|
||||
$modinfo->get_section_info($singlesection),
|
||||
$modinfo->get_section_info_by_id($singlesectionid),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ class section implements named_templatable, renderable {
|
||||
'highlightedlabel' => $format->get_section_highlighted_name(),
|
||||
'sitehome' => $course->id == SITEID,
|
||||
'editing' => $PAGE->user_is_editing(),
|
||||
'displayonesection' => ($course->id != SITEID && $format->get_section_number() !== 0),
|
||||
'displayonesection' => ($course->id != SITEID && !is_null($format->get_sectionid())),
|
||||
];
|
||||
|
||||
$haspartials = [];
|
||||
|
@ -124,7 +124,7 @@ class controlmenu implements named_templatable, renderable {
|
||||
$format = $this->format;
|
||||
$section = $this->section;
|
||||
$course = $format->get_course();
|
||||
$sectionreturn = $format->get_section_number();
|
||||
$sectionreturn = !is_null($format->get_sectionid()) ? $format->get_section_number() : null;
|
||||
$user = $USER;
|
||||
|
||||
$usecomponents = $format->supports_components();
|
||||
@ -144,15 +144,16 @@ class controlmenu implements named_templatable, renderable {
|
||||
];
|
||||
|
||||
if (!$isstealth && has_capability('moodle/course:update', $coursecontext, $user)) {
|
||||
if ($section->section > 0
|
||||
&& get_string_manager()->string_exists('editsection', 'format_'.$format->get_format())) {
|
||||
$params = ['id' => $section->id];
|
||||
$params['sr'] = $section->section;
|
||||
if (get_string_manager()->string_exists('editsection', 'format_'.$format->get_format())) {
|
||||
$streditsection = get_string('editsection', 'format_'.$format->get_format());
|
||||
} else {
|
||||
$streditsection = get_string('editsection');
|
||||
}
|
||||
|
||||
$controls['edit'] = [
|
||||
'url' => new moodle_url('/course/editsection.php', ['id' => $section->id, 'sr' => $sectionreturn]),
|
||||
'url' => new moodle_url('/course/editsection.php', $params),
|
||||
'icon' => 'i/settings',
|
||||
'name' => $streditsection,
|
||||
'pixattr' => ['class' => ''],
|
||||
@ -162,6 +163,9 @@ class controlmenu implements named_templatable, renderable {
|
||||
$duplicatesectionurl = clone($baseurl);
|
||||
$duplicatesectionurl->param('section', $section->section);
|
||||
$duplicatesectionurl->param('duplicatesection', $section->section);
|
||||
if (!is_null($sectionreturn)) {
|
||||
$duplicatesectionurl->param('sr', $sectionreturn);
|
||||
}
|
||||
$controls['duplicate'] = [
|
||||
'url' => $duplicatesectionurl,
|
||||
'icon' => 't/copy',
|
||||
@ -267,14 +271,17 @@ class controlmenu implements named_templatable, renderable {
|
||||
} else {
|
||||
$strdelete = get_string('deletesection');
|
||||
}
|
||||
$url = new moodle_url(
|
||||
'/course/editsection.php',
|
||||
[
|
||||
$params = [
|
||||
'id' => $section->id,
|
||||
'sr' => $sectionreturn,
|
||||
'delete' => 1,
|
||||
'sesskey' => sesskey(),
|
||||
]
|
||||
];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$params['sr'] = $sectionreturn;
|
||||
}
|
||||
$url = new moodle_url(
|
||||
'/course/editsection.php',
|
||||
$params,
|
||||
);
|
||||
$controls['delete'] = [
|
||||
'url' => $url,
|
||||
|
@ -82,7 +82,7 @@ class header implements named_templatable, renderable {
|
||||
$data->title = $output->section_title_without_link($section, $course);
|
||||
$data->sitehome = true;
|
||||
} else {
|
||||
if ($format->get_section_number() === 0) {
|
||||
if (is_null($format->get_sectionid())) {
|
||||
// All sections are displayed.
|
||||
if (!$data->editing) {
|
||||
$data->title = $output->section_title($section, $course);
|
||||
|
@ -94,7 +94,7 @@ class sectionnavigation implements named_templatable, renderable {
|
||||
];
|
||||
|
||||
$back = $this->sectionno - 1;
|
||||
while ($back > 0 and empty($data->previousurl)) {
|
||||
while ($back >= 0 && empty($data->previousurl)) {
|
||||
if ($canviewhidden || $sections[$back]->uservisible) {
|
||||
if (!$sections[$back]->visible) {
|
||||
$data->previoushidden = true;
|
||||
|
@ -106,6 +106,7 @@
|
||||
{{/ core_courseformat/local/content/section/badges }}
|
||||
</div>
|
||||
{{#collapsemenu}}
|
||||
{{^displayonesection}}
|
||||
<div class="flex-fill d-flex justify-content-end mr-2 align-self-start mt-2">
|
||||
<a
|
||||
id="collapsesections"
|
||||
@ -119,6 +120,7 @@
|
||||
<span class="expandall text-nowrap">{{#str}}expandall{{/str}}</span>
|
||||
</a>
|
||||
</div>
|
||||
{{/displayonesection}}
|
||||
{{/collapsemenu}}
|
||||
{{#controlmenu}}
|
||||
{{$ core_courseformat/local/content/section/controlmenu }}
|
||||
|
@ -770,6 +770,109 @@ class base_test extends advanced_testcase {
|
||||
$format = course_get_format($course);
|
||||
$this->assertEmpty($format->get_required_jsfiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set_sectionid().
|
||||
*
|
||||
* @covers ::set_sectionid
|
||||
* @covers ::get_sectionid
|
||||
* @covers ::get_sectionnum
|
||||
*/
|
||||
public function test_set_sectionid(): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course(['numsections' => 2]);
|
||||
$format = course_get_format($course);
|
||||
|
||||
// No section.
|
||||
$this->assertNull($format->get_sectionid());
|
||||
$this->assertNull($format->get_sectionnum());
|
||||
|
||||
// Valid section.
|
||||
$sectionnum = 1;
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
$sectioninfo = $modinfo->get_section_info($sectionnum);
|
||||
$sectionid = $sectioninfo->id;
|
||||
$format->set_sectionid($sectionid);
|
||||
$this->assertEquals($sectionid, $format->get_sectionid());
|
||||
$this->assertEquals($sectionnum, $format->get_sectionnum());
|
||||
|
||||
// Null section.
|
||||
$format->set_sectionid(null);
|
||||
$this->assertNull($format->get_sectionid());
|
||||
$this->assertNull($format->get_sectionnum());
|
||||
|
||||
// Invalid section.
|
||||
$this->expectException(\coding_exception::class);
|
||||
$format->set_sectionid(-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set_sectionnum().
|
||||
*
|
||||
* @dataProvider set_sectionnum_provider
|
||||
* @covers ::set_sectionnum
|
||||
* @param int|null $sectionnum The section number
|
||||
* @param bool $nullexpected If null is expected
|
||||
* @param bool $exceptionexpected If an exception is expected
|
||||
*/
|
||||
public function test_set_sectionnum(?int $sectionnum, bool $nullexpected = false, bool $exceptionexpected = false): void {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course(['numsections' => 2]);
|
||||
$format = course_get_format($course);
|
||||
|
||||
if ($exceptionexpected) {
|
||||
$this->expectException(\coding_exception::class);
|
||||
}
|
||||
$format->set_sectionnum($sectionnum);
|
||||
if ($nullexpected) {
|
||||
$this->assertNull($format->get_sectionid());
|
||||
$this->assertNull($format->get_sectionnum());
|
||||
} else {
|
||||
$this->assertNotNull($format->get_sectionid());
|
||||
$this->assertNotNull($format->get_sectionnum());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for test_set_sectionnum.
|
||||
*
|
||||
* @return array The testing scenarios
|
||||
*/
|
||||
public static function set_sectionnum_provider(): array {
|
||||
return [
|
||||
'General sectionnumber' => [
|
||||
'sectionnum' => 0,
|
||||
'nullexpected' => false,
|
||||
],
|
||||
'Existing sectionnumber' => [
|
||||
'sectionnum' => 1,
|
||||
'nullexpected' => false,
|
||||
],
|
||||
'Another existing sectionnumber' => [
|
||||
'sectionnum' => 2,
|
||||
'nullexpected' => false,
|
||||
],
|
||||
'Null sectionnumber' => [
|
||||
'sectionnum' => null,
|
||||
'nullexpected' => true,
|
||||
],
|
||||
'Invalid sectionnumber' => [
|
||||
'sectionnum' => 3,
|
||||
'nullexpected' => true,
|
||||
'exceptionexpected' => true,
|
||||
],
|
||||
'Another invalid sectionnumber' => [
|
||||
'sectionnum' => -1,
|
||||
'nullexpected' => true,
|
||||
'exceptionexpected' => true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ class format_topics extends core_courseformat\base {
|
||||
*/
|
||||
public function get_view_url($section, $options = []) {
|
||||
$course = $this->get_course();
|
||||
if (array_key_exists('sr', $options)) {
|
||||
if (array_key_exists('sr', $options) && !is_null($options['sr'])) {
|
||||
$sectionno = $options['sr'];
|
||||
} else if (is_object($section)) {
|
||||
$sectionno = $section->section;
|
||||
|
@ -124,7 +124,7 @@ class format_weeks extends core_courseformat\base {
|
||||
*/
|
||||
public function get_view_url($section, $options = array()) {
|
||||
$course = $this->get_course();
|
||||
if (array_key_exists('sr', $options)) {
|
||||
if (array_key_exists('sr', $options) && !is_null($options['sr'])) {
|
||||
$sectionno = $options['sr'];
|
||||
} else if (is_object($section)) {
|
||||
$sectionno = $section->section;
|
||||
|
@ -51,7 +51,15 @@ foreach (compact('indent','update','hide','show','copy','moveto','movetosection'
|
||||
$url->param($key, $value);
|
||||
}
|
||||
}
|
||||
// Force it to be null if it's not a valid section number.
|
||||
if ($sectionreturn < 0) {
|
||||
$sectionreturn = null;
|
||||
}
|
||||
$urloptions = [];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$url->param('sr', $sectionreturn);
|
||||
$urloptions['sr'] = $sectionreturn;
|
||||
}
|
||||
if ($add !== '') {
|
||||
$url->param('add', $add);
|
||||
}
|
||||
@ -73,26 +81,42 @@ if (!empty($add)) {
|
||||
$returntomod = optional_param('return', 0, PARAM_BOOL);
|
||||
$beforemod = optional_param('beforemod', 0, PARAM_INT);
|
||||
|
||||
redirect(
|
||||
new moodle_url(
|
||||
'/course/modedit.php',
|
||||
[
|
||||
$params = [
|
||||
'add' => $add,
|
||||
'type' => $type,
|
||||
'course' => $id,
|
||||
'section' => $section,
|
||||
'return' => $returntomod,
|
||||
'sr' => $sectionreturn,
|
||||
'beforemod' => $beforemod,
|
||||
]
|
||||
];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$params['sr'] = $sectionreturn;
|
||||
}
|
||||
|
||||
redirect(
|
||||
new moodle_url(
|
||||
'/course/modedit.php',
|
||||
$params,
|
||||
)
|
||||
);
|
||||
|
||||
} else if (!empty($update)) {
|
||||
$cm = get_coursemodule_from_id('', $update, 0, true, MUST_EXIST);
|
||||
$returntomod = optional_param('return', 0, PARAM_BOOL);
|
||||
redirect("$CFG->wwwroot/course/modedit.php?update=$update&return=$returntomod&sr=$sectionreturn");
|
||||
|
||||
$params = [
|
||||
'update' => $update,
|
||||
'return' => $returntomod,
|
||||
];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$params['sr'] = $sectionreturn;
|
||||
}
|
||||
redirect(
|
||||
new moodle_url(
|
||||
'/course/modedit.php',
|
||||
$params,
|
||||
)
|
||||
);
|
||||
} else if (!empty($duplicate) and confirm_sesskey()) {
|
||||
$cm = get_coursemodule_from_id('', $duplicate, 0, true, MUST_EXIST);
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
@ -103,7 +127,7 @@ if (!empty($add)) {
|
||||
|
||||
// Duplicate the module.
|
||||
$newcm = duplicate_module($course, $cm);
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $cm->sectionnum, $urloptions));
|
||||
|
||||
} else if (!empty($delete)) {
|
||||
$cm = get_coursemodule_from_id('', $delete, 0, true, MUST_EXIST);
|
||||
@ -113,13 +137,19 @@ if (!empty($add)) {
|
||||
$modcontext = context_module::instance($cm->id);
|
||||
require_capability('moodle/course:manageactivities', $modcontext);
|
||||
|
||||
$return = course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn));
|
||||
$return = course_get_url($course, $cm->sectionnum, $urloptions);
|
||||
|
||||
if (!$confirm or !confirm_sesskey()) {
|
||||
$fullmodulename = get_string('modulename', $cm->modname);
|
||||
|
||||
$optionsyes = array('confirm'=>1, 'delete'=>$cm->id, 'sesskey'=>sesskey(), 'sr' => $sectionreturn);
|
||||
|
||||
$optionsyes = [
|
||||
'confirm' => 1,
|
||||
'delete' => $cm->id,
|
||||
'sesskey' => sesskey(),
|
||||
];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$optionsyes['sr'] = $sectionreturn;
|
||||
}
|
||||
$strdeletecheck = get_string('deletecheck', '', $fullmodulename);
|
||||
$strparams = (object)array('type' => $fullmodulename, 'name' => $cm->name);
|
||||
$strdeletechecktypename = get_string('deletechecktypename', '', $strparams);
|
||||
@ -183,7 +213,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
unset($USER->activitycopyname);
|
||||
unset($USER->activitycopysectionreturn);
|
||||
|
||||
redirect(course_get_url($course, $section->section, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $section->section, $urloptions));
|
||||
|
||||
} else if (!empty($indent) and confirm_sesskey()) {
|
||||
$id = required_param('id', PARAM_INT);
|
||||
@ -208,7 +238,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
// Rebuild invalidated module cache.
|
||||
rebuild_course_cache($cm->course, false, true);
|
||||
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $cm->sectionnum, $urloptions));
|
||||
|
||||
} else if (!empty($hide) and confirm_sesskey()) {
|
||||
$cm = get_coursemodule_from_id('', $hide, 0, true, MUST_EXIST);
|
||||
@ -222,7 +252,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
if (set_coursemodule_visible($cm->id, 0)) {
|
||||
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
|
||||
}
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $cm->sectionnum, $urloptions));
|
||||
|
||||
} else if (!empty($stealth) and confirm_sesskey()) {
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($stealth);
|
||||
@ -243,7 +273,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
if (set_coursemodule_visible($cm->id, 1)) {
|
||||
\core\event\course_module_updated::create_from_cm($cm)->trigger();
|
||||
}
|
||||
redirect(course_get_url($course, $section->section, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $section->section, $urloptions));
|
||||
|
||||
} else if ($groupmode > -1 and confirm_sesskey()) {
|
||||
$id = required_param('id', PARAM_INT);
|
||||
@ -258,7 +288,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
|
||||
set_coursemodule_groupmode($cm->id, $groupmode);
|
||||
\core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $cm->sectionnum, $urloptions));
|
||||
|
||||
} else if (!empty($copy) and confirm_sesskey()) { // value = course module
|
||||
$cm = get_coursemodule_from_id('', $copy, 0, true, MUST_EXIST);
|
||||
@ -276,7 +306,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
$USER->activitycopyname = $cm->name;
|
||||
$USER->activitycopysectionreturn = $sectionreturn;
|
||||
|
||||
redirect(course_get_url($course, $section->section, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $section->section, $urloptions));
|
||||
|
||||
} else if (!empty($cancelcopy) and confirm_sesskey()) { // value = course module
|
||||
|
||||
@ -289,7 +319,7 @@ if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
|
||||
unset($USER->activitycopycourse);
|
||||
unset($USER->activitycopyname);
|
||||
unset($USER->activitycopysectionreturn);
|
||||
redirect(course_get_url($course, $cm->sectionnum, array('sr' => $sectionreturn)));
|
||||
redirect(course_get_url($course, $cm->sectionnum, $urloptions));
|
||||
} else {
|
||||
throw new \moodle_exception('unknowaction');
|
||||
}
|
||||
|
@ -39,8 +39,15 @@ $sectionreturn = optional_param('sr', null, PARAM_INT);
|
||||
$beforemod = optional_param('beforemod', 0, PARAM_INT);
|
||||
$showonly = optional_param('showonly', '', PARAM_TAGLIST); // Settings group to show expanded and hide the rest.
|
||||
|
||||
// Force it to be null if it's not a valid section number.
|
||||
if ($sectionreturn < 0) {
|
||||
$sectionreturn = null;
|
||||
}
|
||||
|
||||
$url = new moodle_url('/course/modedit.php');
|
||||
if (!is_null($sectionreturn)) {
|
||||
$url->param('sr', $sectionreturn);
|
||||
}
|
||||
if (!empty($return)) {
|
||||
$url->param('return', $return);
|
||||
}
|
||||
@ -76,7 +83,9 @@ if (!empty($add)) {
|
||||
|
||||
list($module, $context, $cw, $cm, $data) = prepare_new_moduleinfo_data($course, $add, $section);
|
||||
$data->return = 0;
|
||||
if (!is_null($sectionreturn)) {
|
||||
$data->sr = $sectionreturn;
|
||||
}
|
||||
$data->add = $add;
|
||||
$data->beforemod = $beforemod;
|
||||
if (!empty($type)) { //TODO: hopefully will be removed in 2.0
|
||||
@ -115,7 +124,9 @@ if (!empty($add)) {
|
||||
|
||||
list($cm, $context, $module, $data, $cw) = get_moduleinfo_data($cm, $course);
|
||||
$data->return = $return;
|
||||
if (!is_null($sectionreturn)) {
|
||||
$data->sr = $sectionreturn;
|
||||
}
|
||||
$data->update = $update;
|
||||
if (!empty($showonly)) {
|
||||
$data->showonly = $showonly;
|
||||
@ -173,7 +184,11 @@ if ($mform->is_cancelled()) {
|
||||
$activityurl = new moodle_url("/mod/$module->name/view.php", $urlparams);
|
||||
redirect($activityurl);
|
||||
} else {
|
||||
redirect(course_get_url($course, $cw->section, array('sr' => $sectionreturn)));
|
||||
$options = [];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$options['sr'] = $sectionreturn;
|
||||
}
|
||||
redirect(course_get_url($course, $cw->section, $options));
|
||||
}
|
||||
} else if ($fromform = $mform->get_data()) {
|
||||
// Mark that this is happening in the front-end UI. This is used to indicate that we are able to
|
||||
@ -193,7 +208,11 @@ if ($mform->is_cancelled()) {
|
||||
$url = $fromform->gradingman->get_management_url($url);
|
||||
}
|
||||
} else {
|
||||
$url = course_get_url($course, $cw->section, array('sr' => $sectionreturn));
|
||||
$options = [];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$options['sr'] = $sectionreturn;
|
||||
}
|
||||
$url = course_get_url($course, $cw->section, $options);
|
||||
}
|
||||
|
||||
// If we need to regrade the course with a progress bar as a result of updating this module,
|
||||
|
@ -868,7 +868,9 @@ abstract class moodleform_mod extends moodleform {
|
||||
$mform->addElement('hidden', 'return', 0);
|
||||
$mform->setType('return', PARAM_BOOL);
|
||||
|
||||
$mform->addElement('hidden', 'sr', 0);
|
||||
// The section number where to return: -1 means no section (0 can't be used because it is a valid section number and
|
||||
// null can't be used because it's converted to 0).
|
||||
$mform->addElement('hidden', 'sr', -1);
|
||||
$mform->setType('sr', PARAM_INT);
|
||||
|
||||
$mform->addElement('hidden', 'beforemod', 0);
|
||||
|
@ -168,7 +168,7 @@ echo $renderer->container_start('course-content');
|
||||
// Include course AJAX.
|
||||
include_course_ajax($course, $modinfo->get_used_module_names());
|
||||
|
||||
$format->set_section_number($section->section);
|
||||
$format->set_sectionid($section->id);
|
||||
$outputclass = $format->get_output_classname('content');
|
||||
$widget = new $outputclass($format);
|
||||
echo $renderer->render($widget);
|
||||
|
@ -30,7 +30,9 @@
|
||||
}
|
||||
}}
|
||||
<button class="btn btn-link text-decoration-none section-modchooser section-modchooser-link activity-add bulk-hidden d-flex align-items-center p-3 mb-5"
|
||||
data-action="open-chooser" data-sectionid="{{sectionid}}" data-sectionreturnid="{{sectionreturn}}">
|
||||
data-action="open-chooser"
|
||||
data-sectionid="{{sectionid}}"
|
||||
{{#sectionreturn}}data-sectionreturnid="{{.}}"{{/sectionreturn}}>
|
||||
<span class="pluscontainer icon-no-margin icon-size-3 d-flex p-2 mr-2">
|
||||
{{#pix}} t/add, core {{/pix}}
|
||||
</span>
|
||||
|
@ -32,6 +32,11 @@
|
||||
}
|
||||
}}
|
||||
<button class="btn btn-link text-decoration-none section-modchooser section-modchooser-link activity-add d-flex align-items-center activitychooser-button"
|
||||
data-action="open-chooser" data-sectionid="{{num}}" data-sectionreturnid="{{sectionreturn}}" data-beforemod="{{id}}" aria-label="{{#str}}insertresourceoractivitybefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}" tabindex="0">
|
||||
data-action="open-chooser"
|
||||
data-sectionid="{{num}}"
|
||||
{{#sectionreturn}}data-sectionreturnid="{{.}}"{{/sectionreturn}}
|
||||
data-beforemod="{{id}}"
|
||||
aria-label="{{#str}}insertresourceoractivitybefore, core, { "activityname": {{#quote}} {{activityname}} {{/quote}} } {{/str}}"
|
||||
tabindex="0">
|
||||
{{#pix}} t/add, core {{/pix}}
|
||||
</button>
|
||||
|
@ -400,7 +400,7 @@ class behat_course extends behat_base {
|
||||
|
||||
// We need to know the course format as the text strings depends on them.
|
||||
$courseformat = $this->get_course_format();
|
||||
if ($sectionnumber > 0 && get_string_manager()->string_exists('editsection', $courseformat)) {
|
||||
if (get_string_manager()->string_exists('editsection', $courseformat)) {
|
||||
$stredit = get_string('editsection', $courseformat);
|
||||
} else {
|
||||
$stredit = get_string('editsection');
|
||||
|
@ -36,7 +36,7 @@ $show = optional_param('show', 0, PARAM_INT);
|
||||
$duplicatesection = optional_param('duplicatesection', 0, PARAM_INT);
|
||||
$idnumber = optional_param('idnumber', '', PARAM_RAW);
|
||||
$sectionid = optional_param('sectionid', 0, PARAM_INT);
|
||||
$section = optional_param('section', 0, PARAM_INT);
|
||||
$section = optional_param('section', null, PARAM_INT);
|
||||
$expandsection = optional_param('expandsection', -1, PARAM_INT);
|
||||
$move = optional_param('move', 0, PARAM_INT);
|
||||
$marker = optional_param('marker', -1 , PARAM_INT);
|
||||
@ -62,7 +62,7 @@ $urlparams = ['id' => $course->id];
|
||||
if ($sectionid) {
|
||||
$section = $DB->get_field('course_sections', 'section', ['id' => $sectionid, 'course' => $course->id], MUST_EXIST);
|
||||
}
|
||||
if ($section) {
|
||||
if (!is_null($section)) {
|
||||
$urlparams['section'] = $section;
|
||||
}
|
||||
if ($expandsection !== -1) {
|
||||
|
@ -2379,8 +2379,16 @@ function lti_get_configured_types($courseid, $sectionreturn = 0) {
|
||||
}
|
||||
$type->icon = html_writer::empty_tag('img', ['src' => $iconurl, 'alt' => '', 'class' => "icon $iconclass"]);
|
||||
|
||||
$type->link = new moodle_url('/course/modedit.php', array('add' => 'lti', 'return' => 0, 'course' => $courseid,
|
||||
'sr' => $sectionreturn, 'typeid' => $ltitype->id));
|
||||
$params = [
|
||||
'add' => 'lti',
|
||||
'return' => 0,
|
||||
'course' => $courseid,
|
||||
'typeid' => $ltitype->id,
|
||||
];
|
||||
if (!is_null($sectionreturn)) {
|
||||
$params['sr'] = $sectionreturn;
|
||||
}
|
||||
$type->link = new moodle_url('/course/modedit.php', $params);
|
||||
$types[] = $type;
|
||||
}
|
||||
return $types;
|
||||
|
Loading…
x
Reference in New Issue
Block a user