Skip to content
Snippets Groups Projects
Commit 90b7f27a authored by Peter Fricke's avatar Peter Fricke
Browse files

init

parents
Branches
No related tags found
No related merge requests found
/*! hsh_boostnavigation 2018-03-08 */
define(["jquery"],function(a){"use strict";function b(b,c){b.click(function(d){d.preventDefault(),"mycourses"==c?0==b.attr("data-collapse")?e.forEach(function(b){a(".list-group-item[data-key="+b+"]").attr("data-collapse","1"),a(".list-group-item[data-key="+b+"]").attr("data-hidden","0")}):1==b.attr("data-collapse")&&(e.forEach(function(b){a(".list-group-item[data-parent-key="+b+"]").attr("data-hidden","1"),a(".list-group-item[data-parent-key="+b+"]").attr("data-collapse","1")}),e.forEach(function(b){a(".list-group-item[data-key="+b+"]").attr("data-collapse","1"),a(".list-group-item[data-key="+b+"]").attr("data-hidden","1")})):0==b.attr("data-collapse")?(a(".list-group-item[data-parent-key="+c+"]").attr("data-hidden","1"),b.attr("data-collapse","1")):1==b.attr("data-collapse")&&(a(".list-group-item[data-parent-key="+c+"]").attr("data-hidden","0"),b.attr("data-collapse","0"))})}function c(c){""===e[0]&&(e=new Array);var d=a('.list-group-item[data-key="'+c+'"]');if("mycourses"===c?d.attr("data-collapse","0"):d.attr("data-collapse","1"),""!==c&&"mycourses"!==c){d.addClass("list-group-item-action semesternode"),d.attr("data-isexpandable","1");var f=a(".list-group-item[data-parent-key="+c+"]");f.attr("data-hidden","1"),f.attr("data-collapse","1"),e.includes(c)||e.push(c)}b(d,c)}function d(b){var c=a('.list-group-item[data-key="'+b+'"]');c.attr("data-hidden","0"),c.attr("data-collapse","0"),a(".list-group-item[data-parent-key="+b+"]").attr("data-hidden","0"),a(".list-group-item[data-parent-key="+b+"]").attr("data-collapse","0")}var e=[];return{init:function(a){for(var b=0,d=a.length;b<d;b++)c(a[b])},openSemester:function(a){d(a)}}});
\ No newline at end of file
// JavaScript Code genommen und angepasst von local/boostnavigation/amd/src
// User-Preferences erstmal entfernt
define(['jquery'], function($) {
"use strict";
var nodesArray = [];
function toggleClickHandler(node, nodename) {
node.click(function(e) {
// Prevent that the browser opens the node's default action link (if existing).
e.preventDefault();
if(nodename == "mycourses") {
// "MyCourses" angeklickt um diesen einzuklappen
if (node.attr('data-collapse') == 0) {
// Alle Semester verstecken
nodesArray.forEach(function(semster){
$('.list-group-item[data-key=' + semster + ']').attr("data-collapse", "1");
$('.list-group-item[data-key=' + semster + ']').attr("data-hidden", "0");
});
// TODO User-Preferences setzen
//M.util.set_user_preference('local_hsh_boostnavigation-collapse_' + nodename + '_node', 1);
// If the parent node is currently collapsed.
} else if (node.attr('data-collapse') == 1) {
// Alle Kurse verstecken
nodesArray.forEach(function(nodekey) {
// Set the hidden attribute to true for all elements which have the nodename as their data-parent-key attribute.
$('.list-group-item[data-parent-key=' + nodekey + ']').attr("data-hidden", "1");
$('.list-group-item[data-parent-key=' + nodekey + ']').attr("data-collapse", "1");
});
// Semester wieder sichtbar machen, Kurse weiterhin verstecken
nodesArray.forEach(function(semster){
$('.list-group-item[data-key=' + semster + ']').attr("data-collapse", "1");
$('.list-group-item[data-key=' + semster + ']').attr("data-hidden", "1");
});
//TODO: User-Preferences einbinden
//M.util.set_user_preference('local_hsh_boostnavigation-collapse_' + nodename + '_node', 0);
}
} else {
// Ein Semester angeklickt um dieses auf oder zu zu klappen
// If the parent node is currently expanded.
if (node.attr('data-collapse') == 0) {
// Set the hidden attribute to true for all elements which have the nodename as their data-parent-key attribute.
$('.list-group-item[data-parent-key=' + nodename + ']').attr("data-hidden", "1");
// Change the collapse attribute of the node itself to true.
node.attr("data-collapse", "1");
// TODO User-Preferences setzen
//M.util.set_user_preference('local_hsh_boostnavigation-collapse_' + nodename + '_node', 1);
// If the parent node is currently collapsed.
} else if (node.attr('data-collapse') == 1) {
// Set the hidden attribute to false for all elements which have the nodename as their data-parent-key attribute.
$('.list-group-item[data-parent-key=' + nodename + ']').attr("data-hidden", "0");
// Change the collapse attribute of the node itself to false.
node.attr("data-collapse", "0");
// TODO User-Preferences setzen
//M.util.set_user_preference('local_hsh_boostnavigation-collapse_' + nodename + '_node', 0);
}
}
});
}
function initToggleNodes(nodename) {
// Sonst wäre das Array mit "" initialisiert -> Fehler
if(nodesArray[0] === "") {
nodesArray = new Array();
}
// Search node to be collapsible.
var node = $('.list-group-item[data-key="' + nodename + '"]');
if(nodename === "mycourses") {
node.attr("data-collapse", "0");
} else {
node.attr("data-collapse", "1");
}
if(nodename !== "" && nodename !== "mycourses") {
node.addClass('list-group-item-action semesternode');
node.attr("data-isexpandable", "1");
var childNode = $('.list-group-item[data-parent-key=' + nodename + ']');
childNode.attr("data-hidden", "1");
childNode.attr("data-collapse", "1");
if(!nodesArray.includes(nodename)) {
nodesArray.push(nodename);
}
}
// Add a click handler to this node.
toggleClickHandler(node, nodename);
}
function openNode(nodename) {
var node = $('.list-group-item[data-key="' + nodename + '"]');
node.attr("data-hidden", "0");
node.attr("data-collapse", "0");
$('.list-group-item[data-parent-key=' + nodename + ']').attr("data-hidden", "0");
$('.list-group-item[data-parent-key=' + nodename + ']').attr("data-collapse", "0");
}
return {
init: function(params) {
for (var i = 0, len = params.length; i < len; i++) {
initToggleNodes(params[i]);
}
},
openSemester: function (nodename) {
openNode(nodename);
}
};
});
<?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/>.
/**
* English language file.
*
* @package local_hsh_boostnavigation
* @author Tobias Baden - Hochschule Hannover
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'HsH - BoostNavigation';
$string['settings_nodescount'] = 'Anzahl der anzuzeigenden Nodes';
$string['settings_nodescount_desc'] = 'Anzahl der anzuzeigenden Nodes (exclusive Semesterunabhängiger Knoten)';
$string['settings_unabhaengig'] = 'Semesterunabhängige Kurse anzeigen?';
$string['settings_unabhaengig_desc'] = 'Sollen Semesterunabhängige Kurse angezeigt werden?';
$string['settings_semesterorder'] = 'Semesterreihenfolge';
$string['settings_semesterorder_desc'] = 'Semesterreihenfolge in der Navigation';
$string['settings_unabhaengigposition'] = 'Position Semesterunabhängig-Knotens';
$string['settings_unabhaengigposition_desc'] = 'Anzeige oberhalb oder unterhalb der Semester';
$string['settings_opennewestsemester'] = 'Aktuellstes Semester aufklappen';
$string['settings_opennewestsemester_desc'] = 'Aktuellstes Semester immer direkt aufgeklappt darstellen';
\ No newline at end of file
lib.php 0 → 100644
<?php
include_once($CFG->dirroot . '/course/semester_date.php');
include_once($CFG->dirroot . '/local/hsh_boostnavigation/locallib.php');
function local_hsh_boostnavigation_extend_navigation(global_navigation $navigation) {
global $CFG, $PAGE;
$collapsenodesforjs[] = "";
$semesterList[] = "";
$semesterKeys[] = '';
// Settings übernahme
$maxSemesters = get_config('local_hsh_boostnavigation', 'settings_nodescount');
$showUnabhaengigeKurse = get_config('local_hsh_boostnavigation', 'settings_showunabhaengignode');
$semesterOrder = get_config('local_hsh_boostnavigation', 'settings_semesterorder');
$unabhaengigPosition = get_config('local_hsh_boostnavigation', 'settings_unabhaengigposition');
$openNewestSemester = get_config('local_hsh_boostnavigation', 'settings_opennewestsemester');
$customnav = $navigation->find('mycourses', global_navigation::TYPE_ROOTNODE);
$allchildrennodes = $customnav->get_children_key_list();
// Alle Unterkurse von "Meine Kurse" durchgehen und diese nicht mehr Anzeigen
foreach ($allchildrennodes as $cn) {
// Hide courses -> remove them
$customnav->find($cn, null)->showinflatnavigation = false;
}
// "Meine Kurse" zur Liste der einzuklappenden Nodes hinzufügen
$collapsenodesforjs[] = $customnav->key;
// Alle Kurse abfragen, in die die Person eingeschrieben ist
$courses = enrol_get_my_courses('*', '');
if (!empty($courses)) {
foreach ($courses as $course) {
$semester = getSemesterNodeHsH($customnav, $course, $semesterList,$semesterKeys);
$semester->showinflatnavigation = true;
if (!in_array($semester->key, $collapsenodesforjs)) {
$collapsenodesforjs[] = $semester->key;
}
$coursecontext = context_course::instance($course->id);
$shortname = format_string($course->shortname, true, array('context' => $coursecontext));
$fullname = format_string($course->fullname, true, array('context' => $coursecontext));
$coursename = empty($CFG->navshowfullcoursenames) ? $shortname : $fullname;
$string = $coursename;
$newCourse = navigation_node::create($string, new moodle_url('/course/view.php', array('id' => $course->id)), global_navigation::TYPE_COURSE, null, $string);
$newCourse->add_class('m-l-2');
$newCourse->showinflatnavigation = true;
$semester->add_node($newCourse);
}
}
if(!empty($semesterList)) {
array_shift($semesterList);
array_shift($semesterKeys);
// Semesterlise sortieren, so dass "no-semester" unten ist
arsort($semesterList);
$unabhaengig = array_pop($semesterList);
// Semesterliste sortieren (Neuestes Semeste oben)
if($semesterOrder == 0) { // Wenn die Order auf 1 ist -> Neueste Unten
rsort($semesterList);
$newestNode = $semesterList[0];
}
// Position der Semesterunabhängigen Kurse - Oberhalb der Semester
if(!$unabhaengigPosition) {
if($showUnabhaengigeKurse && $unabhaengig) {
$customnav->add_node($unabhaengig);
}
}
// Gewünsche Anzhal anzuzeigender Semester aus dem Array lesen und innerhalb der Navigation darstellen
if($semesterOrder == 0) {
// Neueste Oben
$newestNode = $semesterList[0]->key;
for ($i = 0; $i < $maxSemesters; $i++) {
if($i < sizeof($semesterList) && $semesterList[$i]) {
$customnav->add_node($semesterList[$i]);
} else {
break;
}
}
} else {
// Neueste Unten
$count = sizeof($semesterList) - $maxSemesters;
$newestNode = $semesterList[sizeof($semesterList)-1]->key;
if ($count < 0) {
$count = 0;
}
for($j = $count; $j < sizeof($semesterList); $j++) {
if($j < sizeof($semesterList) && $semesterList[$j]) {
$customnav->add_node($semesterList[$j]);
} else {
break;
}
}
}
// Position der Semesterunabhängigen Kurse - Unterhalb der Semester
if($unabhaengigPosition) {
if($showUnabhaengigeKurse && $unabhaengig) {
$customnav->add_node($unabhaengig);
}
}
}
// if settings gewählt "aktuelles Semester aufklappen"
if (!empty($collapsenodesforjs)) {
// Add JavaScript for collapsing nodes to the page.
// JavaScript-Code genommen und angepasst von local/boostnavigation/amd/src
$PAGE->requires->js_call_amd('local_hsh_boostnavigation/collapse', 'init', [$collapsenodesforjs]);
foreach ($collapsenodesforjs as $node) {
user_preference_allow_ajax_update('local_hsh_boostnavigation-collapse_'.$node.'_node', PARAM_BOOL);
}
}
if($openNewestSemester) {
$PAGE->requires->js_call_amd('local_hsh_boostnavigation/collapse', 'openSemester', [$newestNode]);
}
}
\ No newline at end of file
<?php
// Code genommen - semester_date.php
// Überarbeitet und angepasst - Tobias Baden HsH
function getSemesterNodeHsH(&$rootNode, $course, &$semesterList, &$semesterKeys) {
global $PAGE;
$unabhaengig = 'semesterunabhängig';
$unabhaengigKey = 'no-semester';
// Wenn Kurs kein Enddatum hat (Semesterunabhöngigkeit)
$startday = getFirstDayOfSem($course->startdate);
if($startday == 0) {
// Im Array suchen, ob der Knoten für die Semesterunabhängigen Kurse schon vorhanden ist
$parent = $semesterList[array_search($unabhaengigKey, $semesterKeys)];
// Knoten noch nicht vorhanden
if(!$parent) {
$parent = navigation_node::create($unabhaengig, null, navigation_node::TYPE_COURSE, $unabhaengig, /* data key */ $unabhaengigKey);
array_push($semesterList, $parent);
array_push($semesterKeys, $unabhaengigKey);
}
} else {
// Im Array suchen, ob der Knoten für das Semester schon vorhanden ist
$parent = $semesterList[array_search($startday, $semesterKeys)];
// Knoten nicht vorhanden
if (!$parent) {
$text = getSem($startday);
$parent = navigation_node::create($text, null, navigation_node::TYPE_COURSE, $text, /* data key */ $startday);
array_push($semesterList, $parent);
array_push($semesterKeys, $startday);
}
}
return $parent;
}
?>
<?php
defined('MOODLE_INTERNAL') || die();
require_once(__DIR__ . '/lib.php');
if ($hassiteconfig) {
// New settings page.
$page = new admin_settingpage('local_hsh_boostnavigation',
get_string('pluginname', 'local_hsh_boostnavigation', null, true));
if ($ADMIN->fulltree) {
// Default-Settings auf 0 da ein aktueller Bug besteht, der die Default-Settings nicht übernimmt.
$setting = new admin_setting_configtext('local_hsh_boostnavigation/settings_nodescount',
get_string('settings_nodescount', 'local_hsh_boostnavigation', null, true),
get_string('settings_nodescount_desc', 'local_hsh_boostnavigation', null, true), 0, PARAM_INT);
$page->add($setting);
// Default-Settings auf 0 da ein aktueller Bug besteht, der die Default-Settings nicht übernimmt.
$page->add(new admin_setting_configcheckbox('local_hsh_boostnavigation/settings_showunabhaengignode',
get_string('settings_unabhaengig', 'local_hsh_boostnavigation', null, true),
get_string('settings_unabhaengig_desc', 'local_hsh_boostnavigation', null, true),
0));
// Default-Settings auf 0 da ein aktueller Bug besteht, der die Default-Settings nicht übernimmt.
$page->add(new admin_setting_configcheckbox('local_hsh_boostnavigation/settings_opennewestsemester',
get_string('settings_opennewestsemester', 'local_hsh_boostnavigation', null, true),
get_string('settings_opennewestsemester_desc', 'local_hsh_boostnavigation', null, true),
0));
// Auswahl für die Semesterreihenfolge
$name = 'local_hsh_boostnavigation/settings_semesterorder';
$title = get_string('settings_semesterorder', 'local_hsh_boostnavigation');
$description = get_string('settings_semesterorder_desc', 'local_hsh_boostnavigation');
$choices[0] = 'Neueste Oben';
$choices[1] = 'Neueste Unten';
$setting = new admin_setting_configselect($name, $title, $description, null, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
// Auswahl für die Semesterreihenfolge
$name = 'local_hsh_boostnavigation/settings_unabhaengigposition';
$title = get_string('settings_unabhaengigposition', 'local_hsh_boostnavigation');
$description = get_string('settings_unabhaengigposition_desc', 'local_hsh_boostnavigation');
$choices[0] = 'Oberhalb der Semester';
$choices[1] = 'Unterhalb der Semester';
$setting = new admin_setting_configselect($name, $title, $description, null, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);
}
// Add settings page to the appearance settings category.
$ADMIN->add('appearance', $page);
}
/* Add the icon for the expanded node state. */
.jsenabled .list-group-item.semesternode[data-isexpandable="1"][data-collapse="0"] > div::after {
content: url([[pix:i/dropdown]]);
float: right;
padding-left: 0.2rem;
}
/* Add the icon for the collapsed node state. */
.jsenabled .list-group-item.semesternode[data-isexpandable="1"][data-collapse="1"] > div::after {
content: url([[pix:t/collapsed]]);
float: right;
padding-left: 0.2rem;
}
/* Set the cursor for the collapsible nodes. */
.jsenabled .list-group-item .semesternode[data-isexpandable="1"] {
cursor: pointer;
}
#nav-drawer .list-group-item[data-key|="mycourses"] ~ a.list-group-item[href*="course/view.php?id="] > div.m-l-1 {
margin-left: 1rem !important;
}
#nav-drawer .list-group-item[data-key|="mycourses"] ~ a.list-group-item[href*="course/view.php?id="] > div.m-l-2 {
margin-left: 2rem !important;
}
.semesternode {
cursor: pointer;
}
\ No newline at end of file
<?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/>.
/**
* Local plugin "Hsh modified Boost course overview on campus" - Version file
*
* @package local_hsh_boostnavigation
* @copyright 2017 Tobias Baden, Hochschule Hannover
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_hsh_boostnavigation';
$plugin->version = 2018030802;
$plugin->release = 'v0.7.3';
$plugin->requires = 2016120500;
#$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = array('theme_boost' => 2016120500,
'block_course_overview_campus' => 2017033100,
'local_boostnavigation' => 2017100901);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment