aboutsummaryrefslogtreecommitdiff
path: root/lib/modules/EvaluationsWidget.php
diff options
context:
space:
mode:
authorElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-05-11 07:19:42 +0000
committerElmar Ludwig <elmar.ludwig@uni-osnabrueck.de>2022-05-11 07:19:42 +0000
commit20240b2aacb15ab3264afbfbbc9dae952db4bb63 (patch)
tree597cae73c5ae7ab9eda6d066d45430c3f17a4560 /lib/modules/EvaluationsWidget.php
parentc054faf90288a75fc3680480434ba93b7f5b287b (diff)
convert old core plugins to new model, re #814
Merge request studip/studip!440
Diffstat (limited to 'lib/modules/EvaluationsWidget.php')
-rw-r--r--lib/modules/EvaluationsWidget.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/modules/EvaluationsWidget.php b/lib/modules/EvaluationsWidget.php
new file mode 100644
index 0000000..4c902c7
--- /dev/null
+++ b/lib/modules/EvaluationsWidget.php
@@ -0,0 +1,62 @@
+<?php
+/*
+ * EvaluationsWidget.php - widget plugin for start page
+ *
+ * Copyright (C) 2014 - Nadine Werner <nadwerner@uos.de>
+ * 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.
+ */
+
+class EvaluationsWidget extends CorePlugin implements PortalPlugin
+{
+ public function getPluginName()
+ {
+ return _('Fragebögen');
+ }
+
+ public function getMetadata()
+ {
+ return [
+ 'description' => _('Mit diesem Widget haben Sie Zugriff auf systemweite Umfragen.')
+ ];
+ }
+
+ /**
+ * Returns the portal widget template.
+ *
+ * Due to a seriously messed up architecture, the suppress_empty_output
+ * variable is used to determine when an according message should be
+ * presented to the user. If no evaluations and questionnaires are present,
+ * the message from the questionnaires should be displayed. The according
+ * message from evaluations should never be shown in the widget. Thus, the
+ * evaluation controller will always suppress this message and the variable
+ * is adjusted if the evaluation returned no content so that the
+ * questionnaire controller will display it's message. If you think, we're
+ * slowly running out of duct tape, you might be absolutely right...
+ */
+ public function getPortalTemplate()
+ {
+ // include and show votes and tests
+ if (Config::get()->VOTE_ENABLE) {
+ $controller = new AuthenticatedController(new StudipDispatcher());
+ $controller->suppress_empty_output = true;
+
+ $response = $controller->relay('evaluation/display/studip')->body;
+
+ $controller->suppress_empty_output = (bool)$response;
+ $response .= $controller->relay('questionnaire/widget/start')->body;
+
+ $template = $GLOBALS['template_factory']->open('shared/string');
+ $template->content = $response;
+
+ if ($GLOBALS['perm']->have_perm('root')) {
+ $navigation = new Navigation('', 'dispatch.php/questionnaire/overview');
+ $navigation->setImage(Icon::create('add', 'clickable', ["title" => _('Umfragen bearbeiten')]));
+ $template->icons = [$navigation];
+ }
+ return $template;
+ }
+ }
+}