/** * Loads a question from the DB * @access public * @param EvaluationQuestion &$questionObject The question object */ function load(&$questionObject) { $db = DBManager::get(); /* load question ------------------------------------------------------- */ $query = "SELECT" . " * " . "FROM" . " evalquestion " . "WHERE" . " evalquestion_id = ? " . "ORDER BY" . " position "; $row = $db->fetchOne($query, array($questionObject->getObjectID())); if (!count($row)) { return $this->throwError(1, _("Keine Frage mit dieser ID gefunden.")); } $questionObject->setParentID($row['parent_id']); $questionObject->setType($row['type']); $questionObject->setPosition($row['position']); $questionObject->setText($row['text']); $questionObject->setMultiplechoice($row['multiplechoice']); /* --------------------------------------------------------------------- */ /* load children ------------------------------------------------------- */ if ($questionObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { EvaluationAnswerDB::addChildren($questionObject); } /* ------------------------------------------------------ end: questions */ }
/** * Exports the headline * @access public */ function exportHeader() { if (empty($this->filehandle)) { return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); } fputs($this->filehandle, EVALEXPORT_DELIMITER . _("Nummer") . EVALEXPORT_DELIMITER . EVALEXPORT_SEPERATOR); fputs($this->filehandle, EVALEXPORT_DELIMITER . _("Benutzername") . EVALEXPORT_DELIMITER . EVALEXPORT_SEPERATOR); fputs($this->filehandle, EVALEXPORT_DELIMITER . _("Nachname") . EVALEXPORT_DELIMITER . EVALEXPORT_SEPERATOR); fputs($this->filehandle, EVALEXPORT_DELIMITER . _("Vorname") . EVALEXPORT_DELIMITER . EVALEXPORT_SEPERATOR); fputs($this->filehandle, EVALEXPORT_DELIMITER . _("Email") . EVALEXPORT_DELIMITER . EVALEXPORT_SEPERATOR); $db = new EvaluationAnswerDB(); /* for each question -------------------------------------------------- */ foreach ($this->evalquestions as $evalquestion) { $type = $evalquestion->getType(); $residual = ""; /* Questiontype: likert scale -------------------------------------- */ if ($type == EVALQUESTION_TYPE_LIKERT) { $db->addChildren($evalquestion); $header = $evalquestion->getText() . ":"; while ($answer =& $evalquestion->getNextChild()) { if ($answer->isResidual()) { $residual = $evalquestion->getText() . ":" . $answer->getText(); } else { $header .= $answer->getText(); $header .= "(" . $answer->getPosition() . ")"; $header .= ","; } } $header = substr($header, 0, strlen($header) - 1); $this->addCol($header); if (!empty($residual)) { $this->addCol($residual); $this->evalquestions_residual[$evalquestion->getObjectID()] = true; } /* ----------------------------------------------------- end: likert */ /* Questiontype: pol scale ----------------------------------------- */ } elseif ($type == EVALQUESTION_TYPE_POL) { $db->addChildren($evalquestion); $header = $evalquestion->getText() . ":"; $answer = $evalquestion->getNextChild(); $header .= $answer->getText(); $header .= "(" . $answer->getPosition() . ")"; $header .= "-"; while ($answer =& $evalquestion->getNextChild()) { if ($answer->isResidual()) { $residual = $evalquestion->getText() . ":" . $answer->getText(); } else { $last = $answer->getText() . "(" . $answer->getPosition() . ")"; } } $header .= $last; $this->addCol($header); if (!empty($residual)) { $this->addCol($residual); $this->evalquestions_residual[$evalquestion->getObjectID()] = true; } /* -------------------------------------------------------- end: pol */ /* Questiontype: multiple chioice ---------------------------------- */ } elseif ($type == EVALQUESTION_TYPE_MC) { if ($evalquestion->isMultiplechoice()) { $db->addChildren($evalquestion); while ($answer =& $evalquestion->getNextChild()) { $header = $evalquestion->getText(); $header .= ":" . $answer->getText(); $this->addCol($header); } } else { $header = $evalquestion->getText(); $this->addCol($header); } /* --------------------------------------------------------- end: mc */ /* Questiontype: undefined ----------------------------------------- */ } else { return $this->throwError(2, _("ExportManager::Ungültiger Typ.")); } /* -------------------------------------------------- end: undefined */ } /* ---------------------------------------------- end: foreach question */ fputs($this->filehandle, EVALEXPORT_ENDROW); }