-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
200 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Load module for highlighting the main learningmap. | ||
* | ||
* @module mod_learningmap/initmainlearningmap | ||
* @copyright 2024 ISB Bayern | ||
* @author Stefan Hanauska <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
import MainLearningmap from 'mod_learningmap/mainlearningmap'; | ||
import {getCurrentCourseEditor} from 'core_courseformat/courseeditor'; | ||
|
||
export const init = (cmid, isfirstlearningmap = false) => { | ||
return new MainLearningmap({ | ||
element: document.querySelector('.activity[data-id="' + cmid + '"]'), | ||
reactive: getCurrentCourseEditor(), | ||
cmid: cmid, | ||
isfirstlearningmap: isfirstlearningmap, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Highlight main learningmap for format_learningmap. | ||
* | ||
* @module mod_learningmap/mainlearningmap | ||
* @copyright 2024 ISB Bayern | ||
* @author Stefan Hanauska <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
import {BaseComponent} from 'core/reactive'; | ||
import {refreshModule} from 'core_course/actions'; | ||
import {render as renderTemplate} from 'core/templates'; | ||
|
||
/** | ||
* The live updater component. | ||
*/ | ||
export default class extends BaseComponent { | ||
create(descriptor) { | ||
this.element = descriptor.element; | ||
this.reactive = descriptor.reactive; | ||
this.cmid = descriptor.cmid; | ||
this.isfirstlearningmap = descriptor.isfirstlearningmap; | ||
} | ||
|
||
getWatchers() { | ||
const watchers = [ | ||
{watch: `cm:deleted`, handler: this._updateLearningmap}, | ||
{watch: `section:updated`, handler: this._updateLearningmap}, | ||
{watch: `cm:added`, handler: this._updateLearningmap}, | ||
{watch: `cm[${this.cmid}]:deleted`, handler: this.destroy}, | ||
]; | ||
return watchers; | ||
} | ||
|
||
async destroy() { | ||
if (this._getFirstLearningmap() === undefined) { | ||
await renderTemplate('format_learningmap/notification', {}).then((html) => { | ||
document.querySelector('.format_learningmap-notification').innerHTML = html; | ||
return true; | ||
}); | ||
} | ||
} | ||
|
||
async _updateLearningmap() { | ||
if (this._isFirstLearningmap() && !this.isfirstlearningmap) { | ||
this.isfirstlearningmap = true; | ||
this.getElement().classList.add('format_learningmap-firstlearningmap'); | ||
refreshModule(this.element, this.cmid); | ||
document.querySelector('.format_learningmap-notification').innerHTML = ''; | ||
} else { | ||
if (this.isfirstlearningmap) { | ||
this.isfirstlearningmap = false; | ||
this.getElement().classList.remove('format_learningmap-firstlearningmap'); | ||
refreshModule(this.element, this.cmid); | ||
} | ||
} | ||
} | ||
|
||
_isFirstLearningmap() { | ||
let firstLearningmap = this._getFirstLearningmap(); | ||
return firstLearningmap == this.cmid; | ||
} | ||
|
||
_getFirstLearningmap() { | ||
let state = this.reactive.stateManager.state; | ||
let cmlist = this._getCmlist(); | ||
return cmlist.find((cmid) => { | ||
let cm = state.cm.get(cmid); | ||
return (cm.module == 'learningmap'); | ||
}); | ||
} | ||
|
||
_getCmlist() { | ||
let state = this.reactive.stateManager.state; | ||
let cmlist = []; | ||
state.course.sectionlist.forEach((sectionid) => { | ||
let section = state.section.get(sectionid); | ||
section.cmlist.forEach((cmid) => { | ||
cmlist.push(cmid); | ||
}); | ||
}); | ||
return cmlist; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
namespace mod_learningmap\output\courseformat; | ||
|
||
/** | ||
* Class activitybadge | ||
* | ||
* @package mod_learningmap | ||
* @copyright 2024 ISB Bayern | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class activitybadge extends \core_courseformat\output\activitybadge { | ||
|
||
protected function update_content(): void { | ||
$course = $this->cminfo->get_course(); | ||
if ($course->format == 'learningmap') { | ||
$courseformat = course_get_format($course); | ||
if($courseformat->main_learningmap_exists()) { | ||
$mainlearningmap = $courseformat->get_main_learningmap(); | ||
if ($this->cminfo->id == $mainlearningmap->id) { | ||
$this->content = get_string('mainlearningmap', 'format_learningmap'); | ||
$this->style = 'badge-primary'; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters