CSS und Templates
This commit is contained in:
parent
45e9e4cf6a
commit
e642b6702c
6 changed files with 90 additions and 29 deletions
|
@ -266,10 +266,12 @@ class timetable {
|
|||
$mylesson['flag'] = "";
|
||||
if ($lesson->flag) $mylesson['flag'] = $lesson->flag;
|
||||
|
||||
/*
|
||||
if ($this->type == 'class') $mylesson['class'] = "";
|
||||
if ($this->type == 'teacher') $mylesson['teacher'] = "";
|
||||
if ($this->type == 'room') $mylesson['room'] = "";
|
||||
$days[$day]['lessons'][] = $mylesson;
|
||||
*/
|
||||
if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson;
|
||||
/*
|
||||
- für diese Woche wurden keine Daten ausgegeben
|
||||
0 in dieser Woche findet der Unterricht nicht statt
|
||||
|
|
|
@ -57,6 +57,7 @@ class mod_timetable_external extends external_api {
|
|||
throw new moodle_exception('cannotviewprofile');
|
||||
}
|
||||
|
||||
|
||||
$results = array();
|
||||
//return $params['searchstring'] . $USER->firstname ;
|
||||
$classes = $DB->get_records_select('timetable_class', 'class like ? OR description like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%'));
|
||||
|
@ -142,18 +143,38 @@ class mod_timetable_external extends external_api {
|
|||
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
||||
self::validate_context($context);
|
||||
|
||||
//$contextmodule = context_module::instance($cm->id);
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
|
||||
|
||||
//Capability checking
|
||||
//OPTIONAL but in most web service it should present
|
||||
if (!has_capability('moodle/user:viewdetails', $context)) {
|
||||
throw new moodle_exception('cannotviewprofile');
|
||||
if (!has_capability('mod/timetable:view_'.$params['type'], $usercontext)) {
|
||||
if (!(($params['type'] == 'class') && has_capability('mod/timetable:view_own_class', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department))))
|
||||
throw new \moodle_exception('cannotviewtimetable'.$params['type']);
|
||||
}
|
||||
|
||||
/*
|
||||
if ($USER->department == "Lehrer" || $USER->department == "Lehrer_fvs") {
|
||||
|
||||
} elseif (($params['type'] == 'class') && ($params['name'] == str_replace('_','/',$USER->department))) {
|
||||
|
||||
} else {
|
||||
throw new \moodle_exeption('Forbidden');
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//echo "Type: ".$params['type']."\n";
|
||||
//echo "Name: ".$params['name']."\n";
|
||||
//echo "Week: ".$params['week']."\n";
|
||||
if(!($params['week'])) {
|
||||
$today = new \DateTime();
|
||||
$params['week'] = $today->format("W");
|
||||
$dayofweek = $today->format('w');
|
||||
if ($dayofweek > 5 + get_config('timetable', 'saturday')) {
|
||||
$params['week']++;
|
||||
}
|
||||
}
|
||||
|
||||
$ttable = new \mod_timetable\timetable($params['type'],$params['name']);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="search-box">
|
||||
<div class="timetable_searchbox">
|
||||
Suche Stundenplan: <input type="text" name="searchstring" autocomplete="off" placeholder="Suchtext..." class="searchstring"/>
|
||||
<div class="searchresult"></div>
|
||||
<div style="display: flex; flex-wrap: wrap;">
|
||||
<div class="timetable"></div>
|
||||
<div class="timetables"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<div class="searchresult">
|
||||
<ul>
|
||||
{{#searchresults}}
|
||||
<li><a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="0">{{description}}</a> <a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="1">+</a></li>
|
||||
<li><a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="0">{{description}}</a>
|
||||
<a href="javascript:;" class="searchresults" data-type="{{type}}" data-name="{{name}}" data-add="1">{{# pix}} t/add, core, Hinzufügen {{/ pix}}</a></li>
|
||||
{{/searchresults}}
|
||||
</ul>
|
||||
{{^searchresults}}Keine Treffer{{/searchresults}}
|
||||
|
@ -20,9 +21,8 @@ require([
|
|||
|
||||
if (add=='1') {
|
||||
promises[0].done(function(response) {
|
||||
console.log('mod_timetable/get is' + response);
|
||||
templates.render('mod_timetable/timetable',response).done(function(html, js) {
|
||||
$('.timetable').last().after(html);
|
||||
$('.timetables').append(html);
|
||||
templates.runTemplateJS(js);
|
||||
}).fail(notification.exception);
|
||||
}).fail(function(ex) {
|
||||
|
@ -30,9 +30,11 @@ require([
|
|||
});
|
||||
} else {
|
||||
promises[0].done(function(response) {
|
||||
console.log('mod_timetable/get is' + response);
|
||||
templates.render('mod_timetable/timetable',response).done(function(html, js) {
|
||||
$('.timetable').first().replaceWith(html);
|
||||
if (!($('.timetables .timetable').length)) {
|
||||
$('.timetables').prepend("<div class='timetable'></div>");
|
||||
}
|
||||
$('.timetables .timetable').first().replaceWith(html);
|
||||
templates.runTemplateJS(js);
|
||||
}).fail(notification.exception);
|
||||
}).fail(function(ex) {
|
||||
|
@ -44,7 +46,13 @@ require([
|
|||
|
||||
|
||||
$(".searchresults").click(function() {
|
||||
load_timetable($(event.target).data('type'),$(event.target).data('name'),$(event.target).data('add'));
|
||||
console.log($(event.target));
|
||||
element = $(event.target);
|
||||
while (!(element.is('a'))) {
|
||||
element = element.parent();
|
||||
}
|
||||
console.log(element);
|
||||
load_timetable(element.data('type'),element.data('name'),element.data('add'));
|
||||
});
|
||||
});
|
||||
{{/ js }}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<div class="timetable" style="border-width:1px; border-style: solid; border-spacing:5px;" id="{{id}}">
|
||||
<div class="timetable_head" style="padding-left:5px; padding-right:5px">
|
||||
<span class="description" style="display:block; float: left; width:95%; text-align: center; font-weight: bold;">{{description}}</span>
|
||||
<span id='close' onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;' style="display:block; float:right"><a href="javascript:;" title="Stundenplan schließen">x</a></span>
|
||||
<div class="timetable" id="{{id}}">
|
||||
<div class="timetable_head">
|
||||
<span class="timetable_description">{{description}}</span>
|
||||
<span id='close' onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;'><a href="javascript:;" title="Stundenplan schließen">{{#pix}}e/cancel, core, Stundenplan schließen{{/pix}}</a></span>
|
||||
</div>
|
||||
<div class="generaltable" style="font-size:8pt; padding-top:0rem; padding-bottom:0rem">
|
||||
<table style="xxwidth:100%; text-align:center; spacing:0rem; padding-top:0rem; padding-bottom:0rem; border: 1px dotted">
|
||||
<div class="minicalendar generaltable" style="padding-top:0rem; padding-bottom:0rem">
|
||||
<table>
|
||||
<caption style="padding-top:0pt; padding-bottom:0pt">
|
||||
<div style="display: block; font-size: 10pt">
|
||||
<span style="display: block; float: left; width:10%; text-align: left;"><a href="javascript:;" class="prevweek" data-type='{{type}}' data-id='{{id}}' data-name='{{name}}' data-week='{{prevweek}}' title="vorherige Woche">◄</a></span>
|
||||
|
@ -12,19 +12,13 @@
|
|||
<span style="display:block; float:right; width:10%; text-align: right"><a href="javascript:;" class="nextweek" data-type='{{type}}' data-id='{{id}}' data-name='{{name}}' data-week='{{nextweek}}' title="nächste Woche">►</a></span>
|
||||
</div>
|
||||
</caption>
|
||||
<tr style="text-align:center">
|
||||
<th></th>
|
||||
<th style="width:4rem">Mo</th>
|
||||
<th style="width:4rem">Di</th>
|
||||
<th style="width:4rem">Mi</th>
|
||||
<th style="width:4rem">Do</th>
|
||||
<th style="width:4rem">Fr</th>
|
||||
{{#saturday}}
|
||||
<th style="width:4rem">Samstag</th>
|
||||
{{/saturday}}
|
||||
<thead>
|
||||
<tr ssstyle="text-align:center">
|
||||
<th></th><th>Mo</th><th>Di</th><th>Mi</th><th>Do</th><th>Fr</th>{{#saturday}}<th ssstyle="width:4rem">Sa</th>{{/saturday}}
|
||||
</tr>
|
||||
</thead>
|
||||
{{#periods}}
|
||||
<tr style="border:1px black; padding-top:0rem; padding-bottom:0rem">
|
||||
<tr sstyle="border:1px black; padding-top:0rem; padding-bottom:0rem">
|
||||
<th>{{number}}</th>
|
||||
{{#days}}
|
||||
<td style="padding-top:0rem; padding-bottom:0rem; vertical-alig:middle; border-left:1px black;" {{#substitution}}bgcolor="pink" data-toggle='tooltip' title='{{substitution}}'{{/substitution}}>
|
||||
|
@ -49,6 +43,22 @@
|
|||
{{/periods}}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="timetable_legend" sssstyle="text-align:left; width:100%; align:center;">
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="class">{{#pix}}i/show, core, Klassen anzeigen{{/pix}}Klassen</a><br>
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="teacher">{{#pix}}i/hide, core, Lehrer ausblenden{{/pix}}Lehrer</a><br>
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="subject">{{#pix}}i/show, core, Fächer anzeigen{{/pix}}Fächer</a><br>
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="room">{{#pix}}i/show, core, Räume anzeigen{{/pix}}Räume</a><br>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="timetable_legend" style="text-align:center; width:100%; align:center; display: none;">
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="class">Klassen</a> -
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="teacher">Lehrer</a> -
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="subject">Fächer</a> -
|
||||
<a href="javascript:;" class="block_timetable_select" data-type="room">Räume</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{# js }}
|
||||
require([
|
||||
|
@ -75,6 +85,15 @@ require([
|
|||
});
|
||||
}
|
||||
|
||||
function select_type(type) {
|
||||
$(".subject").hide();
|
||||
$(".class").hide();
|
||||
$(".teacher").hide();
|
||||
$(".room").hide();
|
||||
$("."+type).show();
|
||||
block_timetable_type = type;
|
||||
}
|
||||
|
||||
//alert("Hi, this is a test");
|
||||
$(".nextweek").click(function() {
|
||||
load_timetable($(event.target).data('type'), $(event.target).data('name'), $(event.target).data('week'), $(event.target).data('id')); //.parentNode.parentNode.parentNode.parentNode);
|
||||
|
@ -82,5 +101,16 @@ require([
|
|||
$(".prevweek").click(function() {
|
||||
load_timetable($(event.target).data('type'), $(event.target).data('name'), $(event.target).data('week'), $(event.target).data('id')); //.parentNode.parentNode.parentNode);
|
||||
});
|
||||
$(".block_timetable_select").click(function() {
|
||||
select_type($(event.target).data('type'));
|
||||
});
|
||||
|
||||
if (typeof block_timetable_type !== 'undefined') {
|
||||
console.log("block_timetable_type found:"+block_timetable_type);
|
||||
select_type(block_timetable_type);
|
||||
} else {
|
||||
select_type('subject');
|
||||
}
|
||||
|
||||
});
|
||||
{{/ js }}
|
||||
|
|
|
@ -26,6 +26,6 @@ defined('MOODLE_INTERNAL') || die();
|
|||
|
||||
$plugin->component = 'mod_timetable';
|
||||
$plugin->release = '0.1.0';
|
||||
$plugin->version = 2020083003;
|
||||
$plugin->version = 2020083004;
|
||||
$plugin->requires = 2020061500;
|
||||
$plugin->maturity = MATURITY_ALPHA;
|
||||
|
|
Loading…
Add table
Reference in a new issue