function getResultHTML($id) { $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $content = $RapidfeedbackExtension->loadTemplate("questiontypes/textareaquestion.template.html"); $content->setCurrentBlock("BLOCK_RESULTS"); $content->setVariable("QUESTION_TEXT", $id . ". " . $this->questionText); foreach ($this->results as $result) { $content->setCurrentBlock("BLOCK_RESULT"); $content->setVariable("RESULT_TEXT", $result); $content->parse("BLOCK_RESULT"); } $content->parse("BLOCK_RESULTS"); return $content->get(); }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $survey = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]); $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback); $xml = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey->get_path() . "/survey.xml"); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $RapidfeedbackExtension->addCSS(); $RapidfeedbackExtension->addJS(); $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_results.template.html"); $content->setCurrentBlock("BLOCK_RESULTS"); $content->setVariable("RESULTS_LABEL", "Auswertung"); if ($survey->get_attribute("RAPIDFEEDBACK_RESULTS") != 1) { $content->setVariable("RESULTS_AMOUNT", $survey->get_attribute("RAPIDFEEDBACK_RESULTS") . " Abgaben"); } else { $content->setVariable("RESULTS_AMOUNT", $survey->get_attribute("RAPIDFEEDBACK_RESULTS") . " Abgabe"); } $survey_object->parseXML($xml); $survey_object->generateResults($survey); $questions = $survey_object->getQuestions(); $question_html = ' <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); </script>'; for ($count = 0; $count < count($questions); $count++) { $question_html = $question_html . $questions[$count]->getResultHTML($count + 1); } $content->setVariable("QUESTIONS_HTML", $question_html); $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $this->id); $content->parse("BLOCK_RESULTS"); $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback", "link" => $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()), array("name" => "Auswertung"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $RapidfeedbackExtension->addCSS(); $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_configuration.template.html"); $content->setCurrentBlock("BLOCK_CONFIGURATION_TABLE"); $content->setVariable("RAPIDFEEDBACK_OPTIONS", "Konfiguration"); $content->setVariable("TITLE_LABEL", "Titel:*"); $content->setVariable("TITLE_VALUE", $rapidfeedback->get_name()); $content->setVariable("DESC_LABEL", "Beschreibung:"); if ($rapidfeedback->get_attribute("OBJ_DESC") != "0") { $content->setVariable("DESC_VALUE", $rapidfeedback->get_attribute("OBJ_DESC")); } $content->setVariable("ADMINSURVEY_LABEL", "Administratoren können auch an den Umfragen teilnehmen"); if ($rapidfeedback->get_attribute("RAPIDFEEDBACK_ADMIN_SURVEY") == 1) { $content->setVariable("ADMINSURVEY_CHECKED", "checked"); } $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $this->id); $content->setVariable("EDIT_RAPIDFEEDBACK", "Änderungen speichern"); $content->parse("BLOCK_CONFIGURATION_TABLE"); $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback", "link" => $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $this->id), array("name" => "Konfiguration"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $RapidfeedbackExtension->addCSS(); // TODO: import funktion if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["import_survey"])) { echo $_POST["id"]; $bidowl_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["id"]); if (!$bidowl_container instanceof \steam_container || $bidowl_container->get_attribute("bid:doctype") != "questionary") { // error } else { $name = $bidowl_container->get_name(); /* $description = $bidowl_container->get_attribute("bid:questionary:description"); $fillout = $bidowl_container->get_attribute("bid:questionary:fillout"); // wie oft kann ein benutzer fragebogen ausfüllen; 1 oder n $editanswer = $bidowl_container->get_attribute("bid:questionary:editanswer"); // können autoren antworten später bearbeiten $editownanswer = $bidowl_container->get_attribute("bid:questionary:editownanswer"); // kann der benutzer selbst seine antworten bearbeiten $numbering = $bidowl_container->get_attribute("bid:questionary:number"); // fragen des fragebogens nummerieren $resultcreationtime = $bidowl_container->get_attribute("bid:questionary:resultcreationtime"); // creationtime in auswertung anzeigen $resultcreator = $bidowl_container->get_attribute("bid:questionary:resultcreator"); // creator in auswertung anzeigen $enabled = $bidowl_container->get_attribute("bid:questionary:enabled"); $layout = $bidowl_container->get_attribute("bid:questionary:layout"); $analyst_rights = $bidowl_container->get_attribute("bid:questionary:analyst_rights");; $editor_rights = $bidowl_container->get_attribute("bid:questionary:editor_rights");; $author_rights = $bidowl_container->get_attribute("bid:questionary:author_rights");; */ // TODO: einstellungen am container setzen $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback); $survey_object->setName($name); $survey_object->setBeginText(""); $survey_object->setEndText(""); // TODO: fragen hinzufügen $question_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $bidowl_container->get_path() . "/questions"); $questions = $question_container->get_inventory(); // TODO: evtl. erst noch sortieren foreach ($questions as $question) { $isQuestion = false; $question_geometry = $question->get_attribute("bid:question:geometry"); switch ($question_geometry["type"]) { case 0: // description break; case 1: // empty line break; case 2: // checkbox $newquestion = new \Rapidfeedback\Model\MultipleChoiceQuestion(); foreach ($question_geometry["options"] as $option) { $newquestion->addOption($option); } $newquestion->setArrangement($question_geometry["columns"]); $isQuestion = true; break; case 3: // input file break; case 4: // radio $newquestion = new \Rapidfeedback\Model\SingleChoiceQuestion(); foreach ($question_geometry["options"] as $option) { $newquestion->addOption($option); } $newquestion->setArrangement($question_geometry["columns"]); $isQuestion = true; break; case 5: // select $newquestion = new \Rapidfeedback\Model\SingleChoiceQuestion(); foreach ($question_geometry["options"] as $option) { $newquestion->addOption($option); } $isQuestion = true; break; case 6: // caption break; case 7: // text $newquestion = new \Rapidfeedback\Model\TextQuestion(); $isQuestion = true; break; case 8: // textarea $newquestion = new \Rapidfeedback\Model\TextareaQuestion(); $isQuestion = true; break; case 9: // new page break; case 10: // full line break; case 11: // grading $newquestion = new \Rapidfeedback\Model\GradingQuestion(); foreach ($question_geometry["grading_options"] as $option) { $newquestion->addRow($option); } $question_geometry["question"] = $question_geometry["description"]; $isQuestion = true; break; case 12: // tendency $newquestion = new \Rapidfeedback\Model\TendencyQuestion(); foreach ($question_geometry["tendency_elements"] as $option) { $newquestion->addOption($option); } $question_geometry["question"] = $question_geometry["description"]; $newquestion->setSteps($question_geometry["tendency_steps"]); $isQuestion = true; break; } // TODO: bug: bearbeiten single choice geöffnet --> auf neue frage erstellen klicken --> antwortmöglichkeiten // TODO: evtl weitere attribute if ($isQuestion) { $newquestion->setQuestionText($question_geometry["question"]); $newquestion->setHelpText(""); $newquestion->setRequired($question_geometry["must"]); $survey_object->addQuestion($newquestion); } } // TODO: einstellungen am container setzen $survey_container = $survey_object->createSurvey(); $edittime = $bidowl_container->get_attribute("bid:questionary:edittime"); if ($edittime[0]) { $times = array(); array_push($times, $edittime[2]); array_push($times, $edittime[1]); $survey_container->set_attribute("RAPIDFEEDBACK_STARTTYPE", $times); } } } $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_import.template.html"); $content->setCurrentBlock("BLOCK_IMPORT_DIALOG"); $content->setVariable("RAPIDFEEDBACK_IMPORT", "Fragebogen importieren"); $content->setVariable("ID_LABEL", "Objekt ID:*"); $content->setVariable("IMPORT_SURVEY", "Fragebogen importieren"); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()); $content->setVariable("BACK_LABEL", "Zurück"); $content->parse("BLOCK_IMPORT_DIALOG"); $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback", "link" => $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()), array("name" => "Import"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $RapidfeedbackExtension->addJS(); // admin action (start, stop, copy, delete) got submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["admin_action"])) { $element = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $_POST["element_id"]); if ($element instanceof \steam_object) { switch ($_POST["admin_action"]) { case 1: $element->set_attribute("RAPIDFEEDBACK_STATE", 1); break; case 2: $element->set_attribute("RAPIDFEEDBACK_STATE", 2); break; case 3: $copy = \steam_factory::create_copy($GLOBALS["STEAM"]->get_id(), $element); $copy->move($rapidfeedback); $copy->set_attribute("RAPIDFEEDBACK_PARTICIPANTS", array()); $copy->set_attribute("RAPIDFEEDBACK_STATE", 0); $copy->set_attribute("RAPIDFEEDBACK_RESULTS", 0); $copy->set_attribute("RAPIDFEEDBACK_STARTTYPE", 0); $resultContainer = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $copy->get_path() . "/results"); $results = $resultContainer->get_inventory(); foreach ($results as $result) { $result->delete(); } break; case 4: $element->delete(); break; } } } // edit configuration got submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["edit_rapidfeedback"])) { $rapidfeedback->set_name($_POST["title"]); $rapidfeedback->set_attribute("OBJ_DESC", $_POST["desc"]); if (isset($_POST["adminsurvey"]) && $_POST["adminsurvey"] == "on") { $rapidfeedback->set_attribute("RAPIDFEEDBACK_ADMIN_SURVEY", 1); } else { $rapidfeedback->set_attribute("RAPIDFEEDBACK_ADMIN_SURVEY", 0); } } // create/edit survey got submitted if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["create_survey"])) { $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback); $survey_object->setName($_POST["title"]); $survey_object->setBeginText($_POST["begintext"]); $survey_object->setEndText($_POST["endtext"]); $questioncounter = 0; $sortedQuestions = $_POST["sortable_array"]; $sortedQuestions != '' ? $sortedQuestions = explode(',', $sortedQuestions) : ''; foreach ($sortedQuestions as $question) { if ($question != "newquestion" && $question != "newlayout" && $question != "") { $questionValues = $_POST[$question]; $questionValues != '' ? $questionValues = explode(',', $questionValues) : ''; switch ($questionValues[0]) { case 0: $newquestion = new \Rapidfeedback\Model\TextQuestion(); break; case 1: $newquestion = new \Rapidfeedback\Model\TextareaQuestion(); break; case 2: $newquestion = new \Rapidfeedback\Model\SingleChoiceQuestion(); $options = $_POST[$question . "_options"]; $options != '' ? $options = explode(',', $options) : ''; foreach ($options as $option) { $newquestion->addOption(rawurldecode($option)); } $newquestion->setArrangement($questionValues[4]); break; case 3: $newquestion = new \Rapidfeedback\Model\MultipleChoiceQuestion(); $options = $_POST[$question . "_options"]; $options != '' ? $options = explode(',', $options) : ''; foreach ($options as $option) { $newquestion->addOption(rawurldecode($option)); } $newquestion->setArrangement($questionValues[4]); break; case 4: $newquestion = new \Rapidfeedback\Model\MatrixQuestion(); $columns = $_POST[$question . "_columns"]; $columns != '' ? $columns = explode(',', $columns) : ''; foreach ($columns as $column) { $newquestion->addcolumn(rawurldecode($column)); } $rows = $_POST[$question . "_rows"]; $rows != '' ? $rows = explode(',', $rows) : ''; foreach ($rows as $row) { $newquestion->addRow(rawurldecode($row)); } break; case 5: $newquestion = new \Rapidfeedback\Model\GradingQuestion(); $options = $_POST[$question . "_rows"]; $options != '' ? $options = explode(',', $options) : ''; foreach ($options as $option) { $newquestion->addRow(rawurldecode($option)); } break; case 6: $newquestion = new \Rapidfeedback\Model\TendencyQuestion(); $options = $_POST[$question . "_options"]; $options != '' ? $options = explode(',', $options) : ''; $newquestion->setSteps($questionValues[4]); for ($count = 0; $count < count($options); $count = $count + 2) { $newquestion->addOption(array($options[$count], $options[$count + 1])); } break; } $newquestion->setQuestionText(rawurldecode($questionValues[1])); $newquestion->setHelpText(rawurldecode($questionValues[2])); $newquestion->setRequired($questionValues[3]); $survey_object->addQuestion($newquestion); } } if ($_POST["starttype"] == 1) { $survey_object->setStartType(1, $_POST["begin"], $_POST["end"]); } else { $survey_object->setStartType(0); } if (isset($this->params[1])) { $survey_object->createSurvey($this->params[1]); } else { $survey_object->createSurvey(); } } // display actionbar if current user is admin $staff = $rapidfeedback->get_attribute("RAPIDFEEDBACK_STAFF"); $admin = 0; if ($staff instanceof \steam_group && $staff->is_member($user) || $staff instanceof \steam_user && $staff->get_id() == $user->get_id()) { $admin = 1; $actionbar = new \Widgets\Actionbar(); $actions = array(array("name" => "Konfiguration", "link" => $RapidfeedbackExtension->getExtensionUrl() . "configuration/" . $this->id), array("name" => "Import", "link" => $RapidfeedbackExtension->getExtensionUrl() . "import/" . $this->id), array("name" => "Umfrage erstellen", "link" => $RapidfeedbackExtension->getExtensionUrl() . "edit/" . $this->id)); $actionbar->setActions($actions); $frameResponseObject->addWidget($actionbar); } // get the surveys that are to be shown and sort them $surveys = $rapidfeedback->get_inventory(); $surveys_inactive = array(); $surveys_running = array(); $surveys_ended = array(); foreach ($surveys as $survey) { if ($survey instanceof \steam_container && !$survey instanceof \steam_user) { $starttype = $survey->get_attribute("RAPIDFEEDBACK_STARTTYPE"); $state = $survey->get_attribute("RAPIDFEEDBACK_STATE"); // if survey is started/ended automatically check the times if (is_array($starttype)) { if (time() > $starttype[1] && $state == 0) { $survey->set_attribute("RAPIDFEEDBACK_STATE", 1); } if (time() > $starttype[0] && $state == 1) { $survey->set_attribute("RAPIDFEEDBACK_STATE", 2); } } $state = $survey->get_attribute("RAPIDFEEDBACK_STATE"); if ($state == 0) { array_push($surveys_inactive, $survey); } else { if ($state == 1) { $participants = $survey->get_attribute("RAPIDFEEDBACK_PARTICIPANTS"); if ($admin == 1 || !in_array($user->get_id(), $participants)) { array_push($surveys_running, $survey); } } else { array_push($surveys_ended, $survey); } } } } usort($surveys_inactive, "sort_workplans"); usort($surveys_running, "sort_workplans"); usort($surveys_ended, "sort_workplans"); if ($admin == 1) { $surveys = array_merge($surveys_inactive, $surveys_running, $surveys_ended); } else { $surveys = $surveys_running; } // display surveys $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_index.template.html"); if (count($surveys) == 0) { $content->setCurrentBlock("BLOCK_NO_SURVEYS"); $content->setVariable("NO_SURVEYS", "Keine Umfragen vorhanden."); $content->setVariable("RAPIDFEEDBACK_NAME", $rapidfeedback->get_name()); if ($rapidfeedback->get_attribute("OBJ_DESC") != "0") { $content->setVariable("RAPIDFEEDBACK_DESC", $rapidfeedback->get_attribute("OBJ_DESC")); } $content->parse("BLOCK_NO_SURVEYS"); } else { $content->setCurrentBlock("BLOCK_SURVEY_TABLE"); $content->setVariable("RAPIDFEEDBACK_NAME", $rapidfeedback->get_name()); if ($rapidfeedback->get_attribute("OBJ_DESC") != "0") { $content->setVariable("RAPIDFEEDBACK_DESC", $rapidfeedback->get_attribute("OBJ_DESC")); } $content->setVariable("NAME_LABEL", "Name der Umfrage"); $content->setVariable("STATUS_LABEL", "Status"); $content->setVariable("QUESTIONS_LABEL", "Anzahl der Fragen"); $content->setVariable("RESULTS_LABEL", "Anzahl der Abgaben"); $content->setVariable("ACTIONS_LABEL", "Aktionen"); foreach ($surveys as $survey) { $content->setCurrentBlock("BLOCK_SURVEY_ELEMENT"); $content->setVariable("NAME_VALUE", $survey->get_name()); $participants = $survey->get_attribute("RAPIDFEEDBACK_PARTICIPANTS"); $state = $survey->get_attribute("RAPIDFEEDBACK_STATE"); $adminsAllowed = $rapidfeedback->get_attribute("RAPIDFEEDBACK_ADMIN_SURVEY"); if ($admin == 1 && in_array($user->get_id(), $participants) | $state != 1 | $adminsAllowed == 0) { $content->setVariable("DISPLAY_LINK", "none"); $content->setVariable("NAME_DONE", $survey->get_name()); } $starttype = $survey->get_attribute("RAPIDFEEDBACK_STARTTYPE"); if ($state == 0) { if (is_array($starttype)) { $content->setVariable("STATE_VALUE", "Inaktiv (Start: " . date('d.m.Y', $starttype[1]) . ")"); $content->setVariable("DISPLAY_START", "none"); } else { $content->setVariable("STATE_VALUE", "Inaktiv"); } $content->setVariable("DISPLAY_RESULTS", "none"); $content->setVariable("DISPLAY_STOP", "none"); $content->setVariable("DISPLAY_REPEAT", "none"); } else { if ($state == 1) { if (is_array($starttype)) { $content->setVariable("STATE_VALUE", "Aktiv (Ende: " . date('d.m.Y', $starttype[0]) . ")"); $content->setVariable("DISPLAY_STOP", "none"); } else { $content->setVariable("STATE_VALUE", "Aktiv"); } $content->setVariable("DISPLAY_EDIT", "none"); $content->setVariable("DISPLAY_START", "none"); $content->setVariable("DISPLAY_REPEAT", "none"); if ($survey->get_attribute("RAPIDFEEDBACK_RESULTS") == 0) { $content->setVariable("DISPLAY_RESULTS", "none"); } } else { $content->setVariable("STATE_VALUE", "Beendet"); $content->setVariable("DISPLAY_EDIT", "none"); $content->setVariable("DISPLAY_START", "none"); $content->setVariable("DISPLAY_STOP", "none"); if ($survey->get_attribute("RAPIDFEEDBACK_RESULTS") == 0) { $content->setVariable("DISPLAY_RESULTS", "none"); } } } $content->setVariable("QUESTIONS_VALUE", $survey->get_attribute("RAPIDFEEDBACK_QUESTIONS")); $content->setVariable("RESULTS_VALUE", $survey->get_attribute("RAPIDFEEDBACK_RESULTS")); $content->setVariable("ASSET_URL", $RapidfeedbackExtension->getAssetUrl() . "icons"); $content->setVariable("PREVIEW_TITLE", "Vorschau"); $content->setVariable("VIEW_URL", $RapidfeedbackExtension->getExtensionUrl() . "view/" . $this->id . "/" . $survey->get_id()); $content->setVariable("PREVIEW_URL", $RapidfeedbackExtension->getExtensionUrl() . "view/" . $this->id . "/" . $survey->get_id() . "/1"); $content->setVariable("EDIT_TITLE", "Umfrage bearbeiten"); $content->setVariable("EDIT_URL", $RapidfeedbackExtension->getExtensionUrl() . "edit/" . $this->id . "/" . $survey->get_id()); $content->setVariable("RESULTS_TITLE", "Auswertung"); $content->setVariable("RESULTS_URL", $RapidfeedbackExtension->getExtensionUrl() . "results/" . $this->id . "/" . $survey->get_id()); $content->setVariable("DELETE_TITLE", "Umfrage löschen"); $content->setVariable("START_TITLE", "Umfrage starten"); $content->setVariable("STOP_TITLE", "Umfrage beenden"); $content->setVariable("REPEAT_TITLE", "Umfrage wiederholen"); $content->setVariable("ELEMENT_ID", $survey->get_id()); if ($admin == 0) { $content->setVariable("DISPLAY_ADMIN_ELEMENT", "none"); } $content->parse("BLOCK_SURVEY_ELEMENT"); } if ($admin == 0) { $content->setVariable("DISPLAY_ADMIN", "none"); } $content->parse("BLOCK_SURVEY_TABLE"); } $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback"))); return $frameResponseObject; }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $RapidfeedbackExtension->addCSS(); $RapidfeedbackExtension->addJS(); $create_label = "Neue Umfrage erstellen"; $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_edit.template.html"); $content->setCurrentBlock("BLOCK_CREATE_SURVEY"); $content->setVariable("CREATE_LABEL", "Umfrage erstellen"); $content->setVariable("TITLE_LABEL", "Titel:*"); $content->setVariable("BEGINTEXT_LABEL", "Willkommenstext:"); $content->setVariable("ENDTEXT_LABEL", "Abschlusstext:"); $content->setVariable("STARTTYPE_LABEL", "Starttyp:*"); $content->setVariable("STARTTYPE0_LABEL", "Manuell"); $content->setVariable("STARTTYPE1_LABEL", "Automatisch"); $content->setVariable("START_LABEL", "von:"); $content->setVariable("END_LABEL", "bis:"); $content->setVariable("ELEMENT_COUNTER", 0); $content->setVariable("STARTTYPE_FIRST", "checked"); $content->setVariable("DISPLAY_DATEPICKER", "none"); $content->setVariable("QUESTION_LABEL", "Frage"); $content->setVariable("HELPTEXT_LABEL", "Hilfetext"); $content->setVariable("QUESTIONTYPE_LABEL", "Fragetyp"); $content->setVariable("TEXTQUESTION_LABEL", "Text"); $content->setVariable("TEXTAREAQUESTION_LABEL", "Textarea"); $content->setVariable("SINGLECHOICE_LABEL", "Single Choice"); $content->setVariable("MULTIPLECHOICE_LABEL", "Multiple Choice"); $content->setVariable("MATRIX_LABEL", "Matrix"); $content->setVariable("GRADING_LABEL", "Benotung"); $content->setVariable("TENDENCY_LABEL", "Tendenz"); $content->setVariable("ARRANGEMENT_LABEL", "Anordnung in"); $content->setVariable("SCALE_LABEL", "Skala"); $content->setVariable("STEPS_LABEL", "Schritte"); $content->setVariable("POSSIBLEANSWERS_LABEL", "Antwortmöglichkeiten"); $content->setVariable("ADDOPTION_LABEL", "Weitere Option hinzufügen"); $content->setVariable("COLUMNS_LABEL", "Spalten"); $content->setVariable("COLUMNSLABEL_LABEL", "Spalten Label"); $content->setVariable("ROWSLABEL_LABEL", "Zeilen Label"); $content->setvariable("ELEMENTS_LABEL", "Elemente"); $content->setVariable("ADDROWS_LABEL", "Weitere Zeilen hinzufügen"); $content->setVariable("MANDATORY_LABEL", "Als Pflichtfrage definieren"); $content->setVariable("SAVE_LABEL", "Speichern"); $content->setVariable("CANCEL_LABEL", "Abbrechen"); $content->setVariable("ADDQUESTION_LABEL", "Neue Frage hinzufügen"); $content->setVariable("ADDLAYOUT_LABEL", "Layout-Element hinzufügen"); $content->setVariable("CREATE_SURVEY", "Umfrage erstellen"); $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()); // if command is called with an object id load the corresponding survey data if (isset($this->params[1])) { $survey = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]); $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback); $xml = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey->get_path() . "/survey.xml"); $survey_object->parseXML($xml); $content->setVariable("TITLE_VALUE", $survey_object->getName()); $content->setVariable("BEGINTEXT_VALUE", $survey_object->getBeginText()); $content->setVariable("ENDTEXT_VALUE", $survey_object->getEndText()); $starttype = $survey->get_attribute("RAPIDFEEDBACK_STARTTYPE"); if (is_array($starttype)) { $content->setVariable("STARTTYPE_FIRST", ""); $content->setVariable("STARTTYPE_SECOND", "checked"); $content->setVariable("DISPLAY_DATEPICKER", ""); $content->setVariable("BEGIN_VALUE", date('d.m.Y', $starttype[1])); $content->setVariable("END_VALUE", date('d.m.Y', $starttype[0])); } $questions = $survey_object->getQuestions(); $question_html = ""; $id_counter = 0; $asseturl = $RapidfeedbackExtension->getAssetUrl() . "icons/"; for ($count = 0; $count < count($questions); $count++) { $question_html = $question_html . $questions[$count]->getEditHTML($id_counter); $id_counter++; } $content->setVariable("ELEMENT_COUNTER", $id_counter); $content->setVariable("QUESTIONS_HTML", $question_html); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id() . "/" . $survey->get_id()); $content->setVariable("CREATE_LABEL", "Umfrage bearbeiten"); $content->setVariable("CREATE_SURVEY", "Änderungen speichern"); $create_label = "Umfrage bearbeiten"; } $content->setVariable("ASSET_URL", $RapidfeedbackExtension->getAssetUrl() . "icons"); $content->parse("BLOCK_CREATE_SURVEY"); $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($content->get()); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback", "link" => $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()), array("name" => $create_label))); return $frameResponseObject; }
function getResultHTML($id) { $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $content = $RapidfeedbackExtension->loadTemplate("questiontypes/multiplechoicequestion.template.html"); $content->setCurrentBlock("BLOCK_RESULTS"); $content->setVariable("QUESTION_TEXT", $id . ". " . $this->questionText); $counter = 0; foreach ($this->options as $option) { $content->setCurrentBlock("BLOCK_RESULTS_OPTION"); $content->setVariable("OPTION_LABEL", $option); $content->setVariable("OPTION_RESULT", $this->results[$counter]); $content->setVariable("OPTION_PERCENT", round($this->results[$counter] / $this->resultCount * 100, 1)); $content->parse("BLOCK_RESULTS_OPTION"); $counter++; } $content->setVariable("QUESTION_ID", $id); $content->setVariable("OPTION_COUNT", count($this->options)); $counter = 0; foreach ($this->options as $option) { $content->setCurrentBlock("BLOCK_SCRIPT_OPTION"); $content->setVariable("OPTION_SCRIPT_LABEL", $option); $content->setVariable("OPTION_COUNTER", $counter); $content->setVariable("OPTION_SCRIPT_RESULT", round($this->results[$counter] / $this->resultCount * 100, 1)); $content->parse("BLOCK_SCRIPT_OPTION"); $counter++; } $content->parse("BLOCK_RESULTS"); return $content->get(); }
function getViewHTML($id, $error, $input = -1) { $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $content = $RapidfeedbackExtension->loadTemplate("questiontypes/tendencyquestion.template.html"); $content->setCurrentBlock("BLOCK_VIEW"); if ($error == 1) { $content->setVariable("ERROR_BORDER", "border-right-color:red;"); } if ($this->required == 1) { $content->setCurrentBlock("BLOCK_VIEW_REQUIRED"); $content->setVariable("QUESTION_TEXT", $id + 1 . ". " . $this->questionText); $content->parse("BLOCK_VIEW_REQUIRED"); } else { $content->setCurrentBlock("BLOCK_VIEW_NOT_REQUIRED"); $content->setVariable("QUESTION_TEXT", $id + 1 . ". " . $this->questionText); $content->parse("BLOCK_VIEW_NOT_REQUIRED"); } $content->setVariable("HELP_TEXT", $this->helpText); $counter = 0; foreach ($this->options as $option) { $content->setCurrentBlock("BLOCK_OPTION_VIEW"); $content->setVariable("OPTION_VIEW1", $option[0]); $content->setVariable("OPTION_VIEW2", $option[1]); for ($count = 0; $count < $this->steps; $count++) { $content->setCurrentBlock("BLOCK_STEP_VIEW"); $content->setVariable("QUESTION_ID", $id); $content->setVariable("STEP_COUNTER", $counter); $content->setVariable("STEP_VALUE", $count); $content->parse("BLOCK_STEP_VIEW"); } $content->parse("BLOCK_OPTION_VIEW"); $counter++; } $content->parse("BLOCK_VIEW"); return $content->get(); }
function getResultHTML($id) { $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $content = $RapidfeedbackExtension->loadTemplate("questiontypes/matrixquestion.template.html"); $content->setCurrentBlock("BLOCK_RESULTS"); $content->setVariable("QUESTION_TEXT", $id . ". " . $this->questionText); $content->setVariable("QUESTION_ID", $id); $content->setVariable("COL_WIDTH", 1 / (count($this->columns) + 1)); $content->setVariable("COL_SPAN", count($this->columns) + 1); foreach ($this->columns as $column) { $content->setCurrentBlock("BLOCK_RESULTS_COLUMN"); $content->setVariable("COLUMN_LABEL", $column); $content->parse("BLOCK_RESULTS_COLUMN"); } $counter = 0; foreach ($this->rows as $row) { $content->setCurrentBlock("BLOCK_RESULTS_ROW"); $content->setVariable("ROW_LABEL", $row); for ($count = 0; $count < count($this->columns); $count++) { $content->setCurrentBlock("BLOCK_RESULTS_ROW_ELEMENT"); $content->setVariable("RESULT_ELEMENT", $this->results[$counter][$count] . ' (' . round($this->results[$counter][$count] / $this->resultCount * 100, 1) . '%)'); $content->parse("BLOCK_RESULTS_ROW_ELEMENT"); } $content->parse("BLOCK_RESULTS_ROW"); $counter++; } for ($count = 0; $count < count($this->rows); $count = $count + 2) { $content->setCurrentBlock("BLOCK_CHART_ROW"); $content->setVariable("CHART_ID", $id); $content->setVariable("CHART_COUNTER", $count); $content->setVariable("CHART_COUNTER2", $count + 1); $content->parse("BLOCK_CHART_ROW"); } $counter = 0; foreach ($this->rows as $row) { $content->setCurrentBlock("BLOCK_CHART_SCRIPT"); $content->setVariable("CHART_ID_SCRIPT", $id); $content->setVariable("COUNTER_ID", $counter); $content->setVariable("OPTION_COUNT", count($this->columns)); $content->setVariable("CHART_TITLE", $this->rows[$counter]); for ($count = 0; $count < count($this->columns); $count++) { $content->setCurrentBlock("BLOCK_CHART_SCRIPT_OPTION"); $content->setVariable("OPTION_COUNTER", $count); $content->setVariable("OPTION_LABEL", $this->columns[$count]); $content->setVariable("OPTION_RESULT", round($this->results[$counter][$count] / $this->resultCount * 100, 1)); $content->parse("BLOCK_CHART_SCRIPT_OPTION"); } $content->parse("BLOCK_CHART_SCRIPT"); $counter++; } $content->parse("BLOCK_RESULTS"); return $content->get(); }
public function frameResponse(\FrameResponseObject $frameResponseObject) { $rapidfeedback = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id); $RapidfeedbackExtension = \Rapidfeedback::getInstance(); $survey = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params[1]); $survey_object = new \Rapidfeedback\Model\Survey($rapidfeedback); $xml = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey->get_path() . "/survey.xml"); $survey_object->parseXML($xml); $questions = $survey_object->getQuestions(); $user = $GLOBALS["STEAM"]->get_current_steam_user(); $RapidfeedbackExtension->addCSS(); // check if current user is admin $staff = $rapidfeedback->get_attribute("RAPIDFEEDBACK_STAFF"); $admin = 0; if ($staff instanceof \steam_group && $staff->is_member($user) || $staff instanceof \steam_user && $staff->get_id() == $user->get_id()) { $admin = 1; } // collect user input if view got submitted (and check for errors) $values = array(); $errors = array(); if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_survey"])) { $questionCounter = 0; foreach ($questions as $question) { if ($question instanceof \Rapidfeedback\Model\TextQuestion | $question instanceof \Rapidfeedback\Model\TextareaQuestion) { $value = $_POST["question" . $questionCounter]; if ($question->getRequired() == 1 && trim($value) == "") { array_push($errors, $questionCounter); } else { if (trim($value) == "") { $values[$questionCounter] = -1; } else { $values[$questionCounter] = trim($value); } } } else { if ($question instanceof \Rapidfeedback\Model\SingleChoiceQuestion) { if (!isset($_POST["question" . $questionCounter])) { if ($question->getRequired() == 1) { array_push($errors, $questionCounter); } else { $values[$questionCounter] = -1; } } else { $values[$questionCounter] = $_POST["question" . $questionCounter]; } } else { if ($question instanceof \Rapidfeedback\Model\MultipleChoiceQuestion) { $optionsCount = count($question->getOptions()); $results = array(); for ($count = 0; $count < $optionsCount; $count++) { if (isset($_POST["question" . $questionCounter . "_" . $count])) { array_push($results, $count); } } if ($question->getRequired() == 1 && empty($results)) { array_push($errors, $questionCounter); } else { $values[$questionCounter] = $results; } } else { if ($question instanceof \Rapidfeedback\Model\MatrixQuestion) { $rowCount = count($question->getRows()); $results = array(); for ($count = 0; $count < $rowCount; $count++) { if (isset($_POST["question" . $questionCounter . "_" . $count])) { array_push($results, $_POST["question" . $questionCounter . "_" . $count]); } } if ($question->getRequired() == 1 && count($results) < $rowCount) { array_push($errors, $questionCounter); $values[$questionCounter] = $results; } else { $values[$questionCounter] = $results; } } } } } $questionCounter++; } // if there are errors show error msg, else save answers if (!empty($errors)) { $problemdescription = "Erforderliche Fragen nicht beantwortet: "; foreach ($errors as $error) { $problemdescription = $problemdescription . ($error + 1) . ", "; } $problemdescription = substr($problemdescription, 0, strlen($problemdescription) - 2); $frameResponseObject->setProblemDescription($problemdescription); } else { $participants = $survey->get_attribute("RAPIDFEEDBACK_PARTICIPANTS"); $adminsAllowed = $rapidfeedback->get_attribute("RAPIDFEEDBACK_ADMIN_SURVEY"); if (!in_array($user->get_id(), $participants) && ($admin == 1 && $adminsAllowed == 1) | $admin == 0) { $resultCount = $survey->get_attribute("RAPIDFEEDBACK_RESULTS"); array_push($participants, $user->get_id()); $survey->set_attribute("RAPIDFEEDBACK_PARTICIPANTS", $participants); $survey->set_attribute("RAPIDFEEDBACK_RESULTS", $resultCount + 1); $resultContainer = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey->get_path() . "/results"); $resultObject = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "results" . $user->get_id(), "", "text/plain", $resultContainer, "Results of user " . $user->get_id()); $questionCounter = 0; foreach ($questions as $question) { if (isset($values[$questionCounter])) { $resultObject->set_attribute("RAPIDFEEDBACK_ANSWER_" . $questionCounter, $values[$questionCounter]); } else { $resultObject->set_attribute("RAPIDFEEDBACK_ANSWER_" . $questionCounter, -1); } $questionCounter++; } } } } // display success msg if there was a submit, else just display survey if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_survey"]) && empty($errors)) { $headline_label = "Antworten gespeichert"; $html = ' <center> <h1>Ihre Antworten wurden erfolgreich gespeichert.</h1> <div style="text-align:center" class="buttons"> <a class="button" href="' . $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id() . '">Zurück zur Übersicht</a> </div> </center> '; } else { $content = $RapidfeedbackExtension->loadTemplate("rapidfeedback_view.template.html"); $content->setCurrentBlock("BLOCK_VIEW_SURVEY"); $content->setVariable("SURVEY_NAME", $survey_object->getName()); $content->setVariable("SURVEY_BEGIN", $survey_object->getBeginText()); $content->setVariable("SURVEY_END", $survey_object->getEndText()); $content->setVariable("QUESTION_NEEDED", "Erforderlich"); $state = $survey->get_attribute("RAPIDFEEDBACK_STATE"); if ($admin == 0 | $state != 0) { $content->setVariable("DISPLAY_EDIT", "none"); } $content->setVariable("ASSET_URL", $RapidfeedbackExtension->getAssetUrl() . "icons"); $content->setVariable("EDIT_TITLE", "Umfrage bearbeiten"); $content->setVariable("EDIT_URL", $RapidfeedbackExtension->getExtensionUrl() . "edit/" . $this->id . "/" . $survey->get_id()); $html = ""; $counter = 0; foreach ($questions as $question) { if (in_array($counter, $errors)) { if (isset($values[$counter])) { $html = $html . $question->getViewHTML($counter, 1, $values[$counter]); } else { $html = $html . $question->getViewHTML($counter, 1); } } else { if (isset($values[$counter])) { $html = $html . $question->getViewHTML($counter, 0, $values[$counter]); } else { $html = $html . $question->getViewHTML($counter, 0); } } $counter++; } $content->setVariable("QUESTIONS_HTML", $html); $content->setVariable("SUBMIT_SURVEY", "Antworten abschicken"); $preview = 0; if (isset($this->params[2])) { $preview = 1; } if ($preview == 1) { $content->setVariable("DISPLAY_SUBMIT", "none"); $headline_label = "Umfrage: Vorschau"; } else { $headline_label = "Umfrage ausfüllen"; } $content->setVariable("BACK_LABEL", "Zurück"); $content->setVariable("BACK_URL", $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()); $content->parse("BLOCK_VIEW_SURVEY"); $html = $content->get(); } $group = $rapidfeedback->get_attribute("RAPIDFEEDBACK_GROUP"); if ($group->get_name() == "learners") { $parent = $group->get_parent_group(); $courseOrGroup = "Kurs: " . $parent->get_attribute("OBJ_DESC") . " (" . $parent->get_name() . ")"; $courseOrGroupUrl = PATH_URL . "semester/" . $parent->get_id(); } else { $courseOrGroup = "Gruppe: " . $group->get_name(); $courseOrGroupUrl = PATH_URL . "groups/" . $group->get_id(); } $rawWidget = new \Widgets\RawHtml(); $rawWidget->setHtml($html); $frameResponseObject->addWidget($rawWidget); $frameResponseObject->setHeadline(array(array("name" => $courseOrGroup, "link" => $courseOrGroupUrl), array("name" => "Rapid Feedback", "link" => $RapidfeedbackExtension->getExtensionUrl() . "Index/" . $rapidfeedback->get_id()), array("name" => $headline_label))); return $frameResponseObject; }