-
Notifications
You must be signed in to change notification settings - Fork 2
/
EvasysPlugin.class.php
1635 lines (1512 loc) · 80.3 KB
/
EvasysPlugin.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* Copyright (c) 2011-2018 Rasmus Fuhse <[email protected]>
*
* This program 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 2 of
* the License, or (at your option) any later version.
*/
require_once __DIR__."/lib/EvasysSeminar.php";
require_once __DIR__."/lib/EvasysForm.php";
require_once __DIR__."/lib/EvasysCourseProfile.php";
require_once __DIR__."/lib/EvasysInstituteProfile.php";
require_once __DIR__."/lib/EvasysGlobalProfile.php";
require_once __DIR__."/lib/EvasysProfileSemtypeForm.php";
require_once __DIR__."/lib/EvasysMatching.php";
require_once __DIR__."/lib/EvasysAdditionalField.php";
require_once __DIR__."/lib/EvasysSoapLog.php";
if (!interface_exists('AdminCourseWidgetPlugin')) {
interface AdminCourseWidgetPlugin {}
}
class EvasysPlugin extends StudIPPlugin implements SystemPlugin, StandardPlugin, AdminCourseAction, Loggable, AdminCourseContents, AdminCourseWidgetPlugin
{
static protected $ruecklauf = null;
public function __construct()
{
bindtextdomain("evasys", __DIR__."/locale");
parent::__construct();
$this->initializeTranslation('reporting');
//The user must be root
if (self::isRoot()) {
$nav = new Navigation($this->getDisplayName(), PluginEngine::getURL($this, [], "globalprofile"));
Navigation::addItem("/admin/evasys", $nav);
$nav = new Navigation(dgettext("evasys", "Standardwerte"), PluginEngine::getURL($this, [], "globalprofile"));
Navigation::addItem("/admin/evasys/globalprofile", clone $nav);
$nav = new Navigation(sprintf(dgettext("evasys", "Standardwerte der %s"), EvasysMatching::wording("Einrichtungen")), PluginEngine::getURL($this, [], "instituteprofile"));
Navigation::addItem("/admin/evasys/instituteprofile", clone $nav);
$nav = new Navigation(dgettext("evasys", "Freie Felder"), PluginEngine::getURL($this, [], "config/additionalfields"));
Navigation::addItem("/admin/evasys/additionalfields", clone $nav);
$nav = new Navigation(dgettext("evasys", "Fragebögen"), PluginEngine::getURL($this, [], "forms/index"));
Navigation::addItem("/admin/evasys/forms", clone $nav);
$nav = new Navigation(dgettext("evasys", "Logs"), PluginEngine::getURL($this, [], "logs/index"));
Navigation::addItem("/admin/evasys/logs", clone $nav);
$nav = new Navigation(dgettext("evasys", "Matching Veranstaltungstypen"), PluginEngine::getURL($this, [], "matching/seminartypes"));
Navigation::addItem("/admin/evasys/matchingtypes", clone $nav);
$nav = new Navigation(dgettext("evasys", "Matching Einrichtungen"), PluginEngine::getURL($this, [], "matching/institutes"));
Navigation::addItem("/admin/evasys/matchinginstitutes", clone $nav);
$nav = new Navigation(dgettext("evasys", "Begrifflichkeiten"), PluginEngine::getURL($this, [], "matching/wording"));
Navigation::addItem("/admin/evasys/wording", clone $nav);
} elseif (Config::get()->EVASYS_ENABLE_PROFILES_FOR_ADMINS && Navigation::hasItem("/admin/institute")) {
$nav = new Navigation(dgettext("evasys", "Standard-Evaluationsprofil"), PluginEngine::getURL($this, [], "instituteprofile"));
if (!self::isAdmin()) {
$nav->setEnabled(false);
}
Navigation::addItem("/admin/institute/instituteprofile", $nav);
}
if (((stripos($_SERVER['REQUEST_URI'], "dispatch.php/admin/courses") !== false)
|| (stripos($_SERVER['REQUEST_URI'], "plugins.php/evasysplugin/profile/bulkedit") !== false))) {
$this->addStylesheet("assets/evasys.less");
if ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin" && StudipVersion::olderThan('5.4.0')) {
if ($GLOBALS['perm']->have_perm(Config::get()->EVASYS_TRANSFER_PERMISSION) && ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== "all")) {
PageLayout::addScript($this->getPluginURL() . "/assets/insert_button.js");
}
}
if (StudipVersion::olderThan('5.3.99')) {
NotificationCenter::addObserver($this, "addTransferredFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addTransferdateFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addNonfittingDatesFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addRecentEvalCoursesFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addFormFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addPaperOnlineFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addMainphaseFilterToSidebar", "SidebarWillRender");
NotificationCenter::addObserver($this, "addIndividualFilterToSidebar", "SidebarWillRender");
}
}
if (Navigation::hasItem("/course/admin") && Context::isCourse()) {
if (Navigation::hasItem("/course/admin/evaluation")) {
$nav = Navigation::getItem("/course/admin/evaluation");
$nav->setTitle(dgettext("evasys", "Eigene Evaluationen"));
}
$nav = new Navigation(dgettext("evasys", "Lehrveranst.-Evaluation"), PluginEngine::getURL($this, [], "profile/edit/".Context::get()->id));
$nav->setImage(Icon::create("checkbox-checked", "clickable"));
$nav->setDescription(dgettext("evasys", "Beantragen Sie für diese Veranstaltung eine Lehrevaluation oder sehen Sie, ob eine Lehrevaluation für diese Veranstaltung vorgesehen ist."));
Navigation::addItem("/course/admin/evasys", $nav);
}
if (Config::get()->EVASYS_ENABLE_PASSIVE_ACCOUNT && $GLOBALS['perm']->get_perm() === "dozent") {
$tab = new Navigation(dgettext("evasys", "EvaSys"), PluginEngine::getURL($this, [], "passiveaccount/index"));
Navigation::addItem("/profile/evasyspassiveaccount", $tab);
}
if (StudipVersion::olderThan('5.3.99')) {
NotificationCenter::addObserver($this, "addNonfittingDatesFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addRecentEvalCoursesFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addTransferredFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addTransferdateFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addFormFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addPaperOnlineFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addMainphaseFilter", "AdminCourseFilterWillQuery");
NotificationCenter::addObserver($this, "addIndividualFilter", "AdminCourseFilterWillQuery");
}
NotificationCenter::addObserver($this, "removeEvasysCourse", "CourseDidDelete");
}
public function isActivatableForContext(Range $context)
{
return $context->getRangeType() === 'course';
}
//Transferred Filter:
public function addTransferredFilterToSidebar()
{
if ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin"
|| $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED")) {
$widget = new SelectWidget(dgettext("evasys", "Transfer-Filter"), PluginEngine::getURL($this, [], "change_transferred_filter"), "transferstatus", "post");
$widget->addElement(new SelectElement(
'',
""
));
$widget->addElement(new SelectElement(
'applied',
dgettext("evasys", "Beantragt"),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "applied"
));
$widget->addElement(new SelectElement(
'notapplied',
dgettext("evasys", "Nicht beantragt"),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "notapplied"
));
$widget->addElement(new SelectElement(
'nottransferred',
dgettext("evasys", "Beantragt und noch nicht übertragen"),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "nottransferred"
));
$widget->addElement(new SelectElement(
'transferred',
dgettext("evasys", "Beantragt und nach EvaSys übertragen"),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "transferred"
));
$widget->addElement(new SelectElement(
'changedtransferred',
dgettext("evasys", "Nach Übertragung verändert"),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "changedtransferred"
));
Sidebar::Get()->insertWidget($widget, "editmode", "filter_transferred");
}
}
public function change_transferred_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_TRANSFERRED", Request::option("transferstatus"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addTransferredFilter($event, $filter)
{
if (StudipVersion::newerThan('5.3.99')) {
$GLOBALS['user']->cfg->store("EVASYS_FILTER_TRANSFERRED", Request::get('transferstatus'));
}
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED")) {
//old usage:
if ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE === 'all') {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id
"
];
} else {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['parameter']['evasys_semester_id'] = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
}
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "transferred") {
$filter->settings['query']['where']['evasys_transferred']
= "evasys_course_profiles.transferred = '1' ";
} elseif($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "applied") {
$filter->settings['query']['where']['evasys_transferred']
= "evasys_course_profiles.applied = '1'";
} elseif($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "notapplied") {
$filter->settings['query']['where']['evasys_transferred']
= "(evasys_course_profiles.applied = '0' OR evasys_course_profiles.applied IS NULL)";
} elseif($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "nottransferred") {
$filter->settings['query']['where']['evasys_transferred']
= "(evasys_course_profiles.applied = '1' AND evasys_course_profiles.transferred = '0')";
} elseif($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED") === "changedtransferred") {
$filter->settings['query']['where']['evasys_transferred']
= "(evasys_course_profiles.transferred = '1' AND evasys_course_profiles.transferdate < evasys_course_profiles.chdate)";
}
}
}
//add transferdate filter:
public function addTransferdateFilterToSidebar()
{
if ($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin"
|| $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERRED")) {
$widget = new OptionsWidget(dgettext("evasys", "Post-Transfer-Filter"));
$widget->addCheckbox(
dgettext("evasys", "Nach Transfer veränderte Veranstaltungen"),
(bool) $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERDATE"),
PluginEngine::getURL($this, ['transferdate' => 1], "change_transferdate_filter"),
PluginEngine::getURL($this, ['transferdate' => 0], "change_transferdate_filter")
);
Sidebar::Get()->insertWidget($widget, "editmode", "filter_transferdate");
}
}
public function change_transferdate_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_TRANSFERDATE", Request::option("transferdate"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addTransferdateFilter($event, $filter)
{
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_TRANSFERDATE")) {
if (!$GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE || $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE === 'all') {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
"
];
} else {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['parameter']['evasys_semester_id'] = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
}
$filter->settings['query']['where']['evasys_transferdate']
= "evasys_course_profiles.transferdate < evasys_course_profiles.chdate ";
}
}
//Nonfitting-dates filter
public function addNonfittingDatesFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_NONFITTING_DATES"))) {
$widget = new OptionsWidget();
$widget->setTitle(dgettext("evasys","Zeiten im Evaluationszeitraum"));
$widget->addCheckbox(
(dgettext("evasys","Nur Veranstaltungen, die im Eval-Zeitraum keine Termine haben")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_NONFITTING_DATES"),
PluginEngine::getURL($this, [], "toggle_nonfittingdates_filter")
);
Sidebar::Get()->insertWidget($widget, "editmode", "filter_nonfittingdates");
}
}
/**
* Toggle the filter in the sidebar of the admin-page and redirect there
*/
public function toggle_nonfittingdates_filter_action()
{
$oldvalue = (bool) $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_NONFITTING_DATES");
$GLOBALS['user']->cfg->store("EVASYS_FILTER_NONFITTING_DATES", $oldvalue ? 0 : 1);
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addNonfittingDatesFilter($event, $filter)
{
if (StudipVersion::newerThan('5.3.99')) {
$GLOBALS['user']->cfg->store("EVASYS_FILTER_NONFITTING_DATES", Request::get('nonfittingdates'));
}
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_NONFITTING_DATES")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['query']['joins']['evasys_institute_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_institute_profiles.institut_id = seminare.Institut_id
AND evasys_institute_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_fakultaet_profiles'] = [
'join' => "LEFT JOIN",
'table' => "evasys_institute_profiles",
'on' => "evasys_fakultaet_profiles.institut_id = Institute.fakultaets_id
AND evasys_fakultaet_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_global_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_global_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['termine'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = termine.range_id
AND (
(termine.date >= IFNULL(evasys_course_profiles.begin, IFNULL(evasys_institute_profiles.begin, IFNULL(evasys_fakultaet_profiles.begin, evasys_global_profiles.begin))) AND termine.date < IFNULL(evasys_course_profiles.end, IFNULL(evasys_institute_profiles.end, IFNULL(evasys_fakultaet_profiles.end, evasys_global_profiles.end))))
OR (termine.end_time > IFNULL(evasys_course_profiles.begin, IFNULL(evasys_institute_profiles.begin, IFNULL(evasys_fakultaet_profiles.begin, evasys_global_profiles.begin))) AND termine.end_time <= IFNULL(evasys_course_profiles.end, IFNULL(evasys_institute_profiles.end, IFNULL(evasys_fakultaet_profiles.end, evasys_global_profiles.end))))
OR (termine.date < IFNULL(evasys_course_profiles.begin, IFNULL(evasys_institute_profiles.begin, IFNULL(evasys_fakultaet_profiles.begin, evasys_global_profiles.begin))) AND termine.end_time > IFNULL(evasys_course_profiles.end, IFNULL(evasys_institute_profiles.end, IFNULL(evasys_fakultaet_profiles.end, evasys_global_profiles.end))))
)
"
];
$filter->settings['query']['where']['date_not_in_timespan'] = "termine.termin_id IS NULL";
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
//Recent evaluations filter
public function addRecentEvalCoursesFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_RECENT_EVAL_COURSES"))) {
$widget = new OptionsWidget();
$widget->setTitle(dgettext("evasys","Ausreißer-Filter"));
$widget->addCheckbox(
(dgettext("evasys","Ausreißer-Veranstaltungen der nächsten 7 Tage anzeigen.")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_RECENT_EVAL_COURSES"),
PluginEngine::getURL($this, [], "toggle_recentevalcourses_filter")
);
Sidebar::Get()->insertWidget($widget, "editmode", "filter_recentevalcourses");
}
}
public function toggle_recentevalcourses_filter_action()
{
$oldvalue = (bool) $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_RECENT_EVAL_COURSES");
$GLOBALS['user']->cfg->store("EVASYS_FILTER_RECENT_EVAL_COURSES", $oldvalue ? 0 : 1);
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addRecentEvalCoursesFilter($event, $filter)
{
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_RECENT_EVAL_COURSES")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['query']['where']['eval_starts_next_days'] = "evasys_course_profiles.applied = '1' AND evasys_course_profiles.begin IS NOT NULL AND evasys_course_profiles.begin > UNIX_TIMESTAMP() AND evasys_course_profiles.begin < UNIX_TIMESTAMP() + 86400 * 7 ";
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
//Form filter:
public function addFormFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_FORM_ID"))) {
$widget = new SelectWidget(dgettext("evasys","Fragebogen-Filter"), PluginEngine::getURL($this, [], "change_form_filter"), "form_id", "post");
$widget->addElement(new SelectElement(
'',
""
));
foreach (EvasysForm::findBySQL("`active` = '1' ORDER BY name ASC") as $form) {
$widget->addElement(new SelectElement(
$form->getId(),
$form['name'],
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_FORM_ID") === $form->getId(),
$form['description']
));
}
Sidebar::Get()->insertWidget($widget, "editmode", "filter_form");
}
}
public function change_form_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_FORM_ID", Request::get("form_id"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addFormFilter($event, $filter)
{
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_FORM_ID")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['query']['joins']['evasys_institute_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_institute_profiles.institut_id = seminare.Institut_id
AND evasys_institute_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_profiles_semtype_forms'] = [
'join' => "LEFT JOIN",
'on' => "evasys_profiles_semtype_forms.profile_id = evasys_institute_profiles.institute_profile_id
AND evasys_profiles_semtype_forms.profile_type = 'institute'
AND evasys_profiles_semtype_forms.sem_type = seminare.status
AND evasys_profiles_semtype_forms.`standard` = '1'"
];
$filter->settings['query']['joins']['evasys_fakultaet_profiles'] = [
'join' => "LEFT JOIN",
'table' => "evasys_institute_profiles",
'on' => "evasys_fakultaet_profiles.institut_id = Institute.fakultaets_id
AND evasys_fakultaet_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_profiles_semtype_forms_fakultaet'] = [
'table' => "evasys_profiles_semtype_forms",
'join' => "LEFT JOIN",
'on' => "evasys_profiles_semtype_forms_fakultaet.profile_id = evasys_fakultaet_profiles.institute_profile_id
AND evasys_profiles_semtype_forms_fakultaet.profile_type = 'institute'
AND evasys_profiles_semtype_forms_fakultaet.sem_type = seminare.status
AND evasys_profiles_semtype_forms_fakultaet.`standard` = '1'"
];
$filter->settings['query']['joins']['evasys_global_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_global_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_profiles_semtype_forms_global'] = [
'table' => "evasys_profiles_semtype_forms",
'join' => "LEFT JOIN",
'on' => "evasys_profiles_semtype_forms_global.profile_id = evasys_global_profiles.semester_id
AND evasys_profiles_semtype_forms_global.profile_type = 'global'
AND evasys_profiles_semtype_forms_global.sem_type = seminare.status
AND evasys_profiles_semtype_forms_global.`standard` = '1'"
];
$filter->settings['query']['where']['evasys_form_filter'] = "IFNULL(evasys_course_profiles.form_id, IFNULL(evasys_profiles_semtype_forms.form_id, IFNULL(evasys_profiles_semtype_forms_fakultaet.form_id, IFNULL(evasys_profiles_semtype_forms_global.form_id, IFNULL(evasys_institute_profiles.form_id, IFNULL(evasys_fakultaet_profiles.form_id, evasys_global_profiles.form_id)))))) = :evasys_form_id";
$filter->settings['parameter']['evasys_form_id'] = $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_FORM_ID");
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
//Filter for online/paper evaluation
public function addPaperOnlineFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_FORM_ID"))) {
$widget = new SelectWidget(dgettext("evasys","Modus der Evaluation"), PluginEngine::getURL($this, [], "change_paperonline_filter"), "paperonline", "post");
$widget->addElement(new SelectElement(
'',
""
));
$widget->addElement(new SelectElement(
"online",
(dgettext("evasys","Online-Evaluationen")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_PAPER_ONLINE") === "online"
));
$widget->addElement(new SelectElement(
"paper",
(dgettext("evasys","Papier-Evaluationen")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_PAPER_ONLINE") === "paper"
));
Sidebar::Get()->insertWidget($widget, "editmode", "filter_paperonline");
}
}
public function change_paperonline_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_PAPER_ONLINE", Request::get("paperonline"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addPaperOnlineFilter($event, $filter)
{
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_PAPER_ONLINE")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['query']['joins']['evasys_institute_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_institute_profiles.institut_id = seminare.Institut_id
AND evasys_institute_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_fakultaet_profiles'] = [
'join' => "LEFT JOIN",
'table' => "evasys_institute_profiles",
'on' => "evasys_fakultaet_profiles.institut_id = Institute.fakultaets_id
AND evasys_fakultaet_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['joins']['evasys_global_profiles'] = [
'join' => "LEFT JOIN",
'on' => "evasys_global_profiles.semester_id = :evasys_semester_id"
];
$filter->settings['query']['where']['evasys_paperonline_filter'] = "IFNULL(evasys_course_profiles.mode, IFNULL(evasys_institute_profiles.mode, IFNULL(evasys_fakultaet_profiles.mode, evasys_global_profiles.mode))) = :evasys_mode";
$filter->settings['parameter']['evasys_mode'] = $GLOBALS['user']->cfg->getValue("EVASYS_FILTER_PAPER_ONLINE");
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
//Filter for main-phase
public function addMainphaseFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE"))) {
$widget = new SelectWidget(dgettext("evasys","Hauptphasen-Filter"), PluginEngine::getURL($this, [], "change_mainphase_filter"), "mainphase", "post");
$widget->addElement(new SelectElement(
'',
""
));
$widget->addElement(new SelectElement(
"mainphase",
(dgettext("evasys","Veranstaltungen in der Hauptphase")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE") === "mainphase"
));
$widget->addElement(new SelectElement(
"nonmainphase",
(dgettext("evasys","Veranstaltungen außerhalb der Hauptphase")),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE") === "nonmainphase"
));
Sidebar::Get()->insertWidget($widget, "editmode", "filter_mainphase");
}
}
public function change_mainphase_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_MAINPHASE", Request::get("mainphase"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addMainphaseFilter($event, $filter)
{
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE") === "nonmainphase") {
$filter->settings['query']['where']['evasys_mainphase_filter'] = "evasys_course_profiles.`begin` IS NOT NULL";
} elseif($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_MAINPHASE") === "mainphase") {
$filter->settings['query']['where']['evasys_mainphase_filter'] = "evasys_course_profiles.`begin` IS NULL";
}
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
public function addIndividualFilterToSidebar()
{
if (($GLOBALS['user']->cfg->MY_COURSES_ACTION_AREA === "EvasysPlugin")
|| ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_INDIVIDUAL"))) {
$widget = new SelectWidget(dgettext("evasys", ucfirst(EvasysMatching::wording('freiwillige Evaluationen'))), PluginEngine::getURL($this, [], "change_individual_filter"), "individual", "post");
$widget->addElement(new SelectElement(
'',
""
));
$widget->addElement(new SelectElement(
"individual",
(sprintf(dgettext("evasys","Nur %s"), EvasysMatching::wording('freiwillige Evaluationen'))),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_INDIVIDUAL") === "individual"
));
$widget->addElement(new SelectElement(
"nonindividual",
(sprintf(dgettext("evasys","Keine %s"), EvasysMatching::wording('freiwillige Evaluation'))),
$GLOBALS['user']->cfg->getValue("EVASYS_FILTER_INDIVIDUAL") === "nonindividual"
));
Sidebar::Get()->insertWidget($widget, "editmode", "filter_individual");
}
}
public function change_individual_filter_action()
{
$GLOBALS['user']->cfg->store("EVASYS_FILTER_INDIVIDUAL", Request::get("individual"));
header("Location: ".URLHelper::getURL("dispatch.php/admin/courses"));
}
public function addIndividualFilter($event, $filter)
{
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all'
? $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE
: Semester::findCurrent()->id;
if ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_INDIVIDUAL")) {
$filter->settings['query']['joins']['evasys_course_profiles'] = [
'join' => "LEFT JOIN",
'on' => "
seminare.Seminar_id = evasys_course_profiles.seminar_id AND evasys_course_profiles.applied = '1'
AND evasys_course_profiles.semester_id = :evasys_semester_id
"
];
$filter->settings['query']['where']['evasys_individual_filter'] = "evasys_course_profiles.by_dozent = :evasys_individual";
$filter->settings['parameter']['evasys_individual'] = ($GLOBALS['user']->cfg->getValue("EVASYS_FILTER_INDIVIDUAL") === 'individual') ? 1 : 0;
$filter->settings['parameter']['evasys_semester_id'] = $semester_id;
}
}
public function getIconNavigation($course_id, $last_visit, $user_id = null)
{
$activated = false;
$evasys_seminar = EvasysSeminar::findBySeminar($course_id);
$profile = EvasysCourseProfile::findBySemester($course_id);
if ($GLOBALS['perm']->have_studip_perm('dozent', $course_id)) {
if ($profile['applied']) {
$activated = true;
}
} else {
if ($profile['applied']
&& $profile['transferred']
&& ($profile->getFinalBegin() <= time())
&& ($profile->getFinalEnd() > time())) {
$activated = true;
}
}
if ($activated) {
$tab = new Navigation(dgettext("evasys", "Lehrveranst.-Evaluation"), PluginEngine::getLink($this, [], "evaluation/show"));
$tab->setImage(Icon::create("evaluation", "inactive"), ['title' => dgettext("evasys", "Lehrveranstaltungsevaluationen")]);
if (!Config::get()->EVASYS_NO_RED_ICONS) {
if (Config::get()->EVASYS_RED_ICONS_STOP_UNTIL > time()) {
$tab->setImage(Icon::create("evaluation", "new"), ['title' => dgettext("evasys", "Neue Evaluation")]);
} else {
$number = 0;
if ($evasys_seminar) {
$number += $evasys_seminar->getEvaluationStatus();
}
if ($number > 0) {
$tab->setImage(Icon::create("evaluation", "new"), ['title' => sprintf(dgettext("evasys", "%s neue Evaluation"), $number)]);
}
}
}
return $tab;
} elseif($profile && $profile['applied'] && $GLOBALS['perm']->have_studip_perm("dozent", $course_id)) {
$tab = new Navigation(dgettext("evasys", "Lehrveranst.-Evaluation"), PluginEngine::getURL($this, [], "profile/edit/".$course_id));
$tab->setImage(Icon::create("evaluation", "inactive"), ['title' => dgettext("evasys", "Evaluationen")]);
return $tab;
}
}
public function getTabNavigation($course_id)
{
$activated = false;
$profiles = EvasysCourseProfile::findBySQL("seminar_id = ?", [$course_id]);
foreach ($profiles as $profile) {
if ($GLOBALS['perm']->have_studip_perm('dozent', $course_id) && $profile['applied']) {
$activated = true;
break;
} else {
if ($profile['applied']
&& $profile['transferred']
&& ($profile->getFinalBegin() <= time())) {
if ($profile->getFinalAttribute('mode') === 'online' || $profile->evasys_seminar['publishing_allowed']) {
$activated = true;
break;
} elseif($profile['split']) {
foreach ($profile->course->members->findBy('status','dozent') as $dozent) {
if ($profile->evasys_seminar['publishing_allowed_by_dozent'] == $dozent['user_id']) {
$activated = true;
break 2;
}
}
}
}
}
}
if ($activated) {
$tab = new Navigation(dgettext("evasys", "Lehrveranst.-Evaluation"), PluginEngine::getLink($this, [], "evaluation/show"));
$tab->setImage(Icon::create("evaluation", "info_alt"));
return ['evasys' => $tab];
}
}
public function getNotificationObjects($course_id, $since, $user_id)
{
return null;
}
public function getInfoTemplate($course_id)
{
return null;
}
public function getDisplayName()
{
if (Navigation::hasItem("/course") && Navigation::getItem("/course")->isActive()) {
return Context::getHeaderLine().": ".dgettext("evasys", "Evaluation");
} else {
return dgettext("evasys", "EvaSys");
}
}
public function getAdminActionURL()
{
return $GLOBALS['perm']->have_perm(Config::get()->EVASYS_TRANSFER_PERMISSION) && ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== "all")
? PluginEngine::getURL($this, [], "admin/upload_courses")
: PluginEngine::getURL($this, [], "profile/bulkedit");
}
public function useMultimode()
{
if (StudipVersion::newerThan('5.3.99')) {
$factory = new Flexi_TemplateFactory(__DIR__."/views");
$template = $factory->open("admin/bottom_buttons.php");
$template->plugin = $this;
return $template;
} else {
return $GLOBALS['perm']->have_perm(Config::get()->EVASYS_TRANSFER_PERMISSION) && ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== "all")
? dgettext("evasys", "Übertragen")
: dgettext("evasys", "Bearbeiten");
}
}
public function getAdminCourseActionTemplate($course_id, $values = null, $semester = null)
{
$factory = new Flexi_TemplateFactory(__DIR__."/views");
$template = $factory->open("admin/_admin_checkbox.php");
if (Request::option("semester_id")) {
$semester_id = Request::option("semester_id");
} elseif($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== "all") {
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
}
if (isset($semester_id) && $semester_id) {
$profiles = [EvasysCourseProfile::findBySemester(
$course_id,
$semester_id
)];
} else {
$profiles = EvasysCourseProfile::findBySQL("seminar_id = :course_id", [
'course_id' => $course_id
]);
//sort
usort($profiles, function ($a, $b) {
return $a->semester->beginn > $a->semester->beginn ? -1 : 1;
});
}
$course = Course::find($course_id);
$template->set_attribute("semesters", $course->isOpenEnded() ? Semester::getAll() : $course->semesters);
$template->set_attribute("profiles", $profiles);
$template->set_attribute("course_id", $course_id);
$template->set_attribute("plugin", $this);
return $template;
}
static public function isRoot()
{
return $GLOBALS['perm']->have_perm("root");
}
static public function isAdmin($seminar_id = null)
{
if ($GLOBALS['perm']->have_perm("root")) {
return false;
} elseif ($seminar_id && $GLOBALS['perm']->have_studip_perm("admin", $seminar_id) && Config::get()->EVASYS_ENABLE_PROFILES_FOR_ADMINS) {
$course = Course::find($seminar_id);
$semester = null;
if ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && ($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== 'all')) {
$s = Semester::find($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE);
if ($course->isInSemester($s)) {
$semester = $s;
}
}
if ($semester === null) {
$semester = $course->start_semester;
}
if ($semester) {
$global_profile = EvasysGlobalProfile::find($semester['semester_id']);
}
if (!$global_profile) {
$global_profile = EvasysGlobalProfile::findCurrent();
}
if ($global_profile['adminedit_begin']) {
return (time() >= $global_profile['adminedit_begin']) && (!$global_profile['adminedit_end'] || time() <= $global_profile['adminedit_end']);
}
} elseif ($GLOBALS['perm']->have_perm("admin") && Config::get()->EVASYS_ENABLE_PROFILES_FOR_ADMINS) {
$global_profile = EvasysGlobalProfile::findCurrent();
if ($global_profile['adminedit_begin']) {
return (time() >= $global_profile['adminedit_begin']) && (!$global_profile['adminedit_end'] || time() <= $global_profile['adminedit_end']);
}
} elseif ($GLOBALS['perm']->have_perm("dozent") && Config::get()->EVASYS_ENABLE_PROFILES_FOR_ADMINS) {
$statement = DBManager::get()->prepare("
SELECT *
FROM roles
INNER JOIN roles_user ON (roles_user.roleid = roles.roleid)
WHERE rolename = 'Evasys-Dozent-Admin'
AND roles_user.userid = ?
");
$statement->execute([$GLOBALS['user']->id]);
$roles = $statement->fetchAll(PDO::FETCH_ASSOC);
if (!$seminar_id && !empty($roles)) {
return true;
} else {
$course = Course::find($seminar_id);
foreach ($roles as $role) {
if (!$role['institut_id']
|| $role['institut_id'] === $course['institut_id']
|| $role['institut_id'] === $course->institut['fakultaet_id']) {
return true;
}
}
}
}
return false;
}
public function perform($unconsumed_path)
{
$this->addStylesheet("assets/evasys.less");
parent::perform($unconsumed_path);
}
public function adminAvailableContents()
{
$array = [
'form' => dgettext("evasys", "Fragebogen"),
'mode' => dgettext("evasys", "Modus der Evalation"),
'timespan' => dgettext("evasys", "Eval-Zeitraum"),
'applied' => dgettext("evasys", "Evaluation beantragt"),
'lehrende_emails' => dgettext("evasys", 'Eval: Beantragte Lehrende (Emails)'),
'ruecklauf' => dgettext("evasys", "Rückläufer"),
'individual' => ucfirst(EvasysMatching::wording('freiwillige Evaluation'))
];
if (Config::get()->EVASYS_ENABLE_SPLITTING_COURSES) {
$array['split'] = dgettext("evasys", "Teilevaluation");
}
if (EvasysGlobalProfile::findOneBySQL("`enable_objection_to_publication` = 'yes'")) {
$array['objection_to_publication'] = dgettext("evasys", "Widerspruch");
$array['objection_reason'] = dgettext("evasys", "Begründung des Widerspruchs");
}
return $array;
}
public function adminAreaGetCourseContent($course, $index)
{
if (Request::option("semester_id")) {
$semester_id = Request::option("semester_id");
} elseif($GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE && $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE !== "all") {
$semester_id = $GLOBALS['user']->cfg->MY_COURSES_SELECTED_CYCLE;
} else {
$semester_id = $course->start_semester->getId();
}
$profile = EvasysCourseProfile::findBySemester($course->getId(), $semester_id);
switch ($index) {
case "form":
if (!$profile || !$profile['applied']) {
return "";
}
$form_id = $profile->getFinalFormId();
if ($form_id) {
$form = EvasysForm::find($form_id);
return $form['name'];
} else {
return "";
}
case "mode":
if (!$profile || !$profile['applied']) {
return "";
}
if (Config::get()->EVASYS_FORCE_ONLINE) {
return dgettext("evasys", "Online");
}
return $profile->getFinalMode() === "online" ? dgettext("evasys", "Online") : dgettext("evasys", "Papier");
case "timespan":
if (!$profile || !$profile['applied']) {
return "";
}
$begin = $profile->getFinalBegin();
$end = $profile->getFinalEnd();
return date("d.m.Y H:i", $begin)." - ".date("d.m.Y H:i", $end);
case "applied":
return $profile && $profile['applied'] ? 1 : 0;
case "lehrende_emails":
if (!$profile || !$profile['applied']) {
return "";
}
$emails = [];
if ($profile['teachers']) {
foreach ((array) $profile['teachers']->getArrayCopy() as $teacher_id) {
$teacher = User::find($teacher_id);
if ($teacher) {
$emails[] = $teacher->email;
}
}
}
return implode(";", $emails);
case "split":
return $profile && $profile['split'] ? 1 : 0;
case "individual":
return $profile && $profile['by_dozent'] ? 1 : 0;
case "ruecklauf":
$active_seminar_ids = [];
$profile;
if (!$profile['applied'] || !$profile['transferred'] || $profile->getFinalBegin() >= time()) {
return ""; //nothing to show for this course
}
if ($profile['split']) {
foreach ($profile->teachers as $teacher_id) {
$active_seminar_ids[$profile['seminar_id'].$teacher_id] = $profile['seminar_id'];
}
} else {
$active_seminar_ids[$profile['seminar_id']] = $profile['seminar_id'];
}
$results = [];
$soap = EvasysSoap::get();
foreach (array_keys($active_seminar_ids) as $course_code) {
$evasys_surveys_object = $soap->soapCall("GetCourse", [
'CourseId' => $course_code,
'IdType' => "PUBLIC",
'IncludeSurveys' => true,
'IncludeParticipants' => false
]
);
if (is_a($evasys_surveys_object, "SoapFault")) {
if ($evasys_surveys_object->getMessage() === "ERR_312") {
PageLayout::postError(sprintf(dgettext("evasys", "Veranstaltung %s existiert nicht mehr in EvaSys"), htmlReady($course['name'])));
} else {
PageLayout::postError("SOAP-error: " . $evasys_surveys_object->getMessage());
}
return;
}
if (isset($evasys_surveys_object->m_oSurveyHolder->m_aSurveys->Surveys)) {
foreach ((array)$evasys_surveys_object->m_oSurveyHolder->m_aSurveys->Surveys as $survey_data) {
$count_forms = $survey_data->m_nFormCount;
$tans = $survey_data->m_nPswdCount;
$open = $survey_data->m_nOpenState;
$return = round(100 * $count_forms / ($tans ?: 1));
$color = $return >= 80 ? '#8bbd40' : ($return >= 30 ? '#a1aec7' : '#d60000');
$results[] = '<div style="background-image: linear-gradient(0deg, ' . $color . ', ' . $color . '); background-repeat: no-repeat; background-size: ' . (int)$return . '% 100%;">' . htmlReady($count_forms . " / " . $tans) . '</div>';
}
}
}
return implode("\n", $results);
case 'objection_to_publication':
return $profile->getPresetAttribute('enable_objection_to_publication') === 'yes' && $profile['objection_to_publication']
? 1
: 0;
case 'objection_reason':
return $profile->getPresetAttribute('enable_objection_to_publication') === 'yes' && $profile['objection_to_publication']
? $profile['objection_reason']
: '';
}
}
public static function logFormat(LogEvent $event)
{
$tmpl = $event->action->info_template;
if (strpos($event->action->name, 'EVASYS') !== false) {
$course = Course::find($event->coaffected_range_id);
$semester = Semester::find($event->info);
if ($course) {
$url = PluginEngine::getURL('EvasysPlugin', [], '/profile/edit/'
. $event->coaffected_range_id, true);
$name = sprintf('<a data-dialog href="%s">%s - %s (%s)</a>',
$url, $course->veranstaltungsnummer,
$course->name, $semester->name);
$tmpl = str_replace('%coaffected(%info)', $name, $tmpl);
}
}
return $tmpl;
}