public function copyQuestionObject() { global $ilAccess; if (!$ilAccess->checkAccess("write", "", $this->ref_id)) { // allow only write access ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true); $this->ctrl->redirect($this, "infoScreen"); } if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id'])) { $ids = array($_REQUEST['q_id']); } else { if ($_REQUEST['q_id']) { $ids = $_REQUEST['q_id']; } else { ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'), true); $this->ctrl->redirect($this, 'questions'); } } $copy_count = 0; $questionTitles = $this->object->getQuestionTitles(); foreach ($ids as $id) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $question = assQuestion::_instanciateQuestionGUI($id); if ($question) { $title = $question->object->getTitle(); $i = 2; while (in_array($title . ' (' . $i . ')', $questionTitles)) { $i++; } $title .= ' (' . $i . ')'; $questionTitles[] = $title; $new_id = $question->object->duplicate(false, $title); $clone = assQuestion::_instanciateQuestionGUI($new_id); $clone->object->setObjId($this->object->getId()); $clone->object->saveToDb(); $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true); $copy_count++; } } ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true); $this->ctrl->redirect($this, 'questions'); }
function &createQuestion($question_type, $question_id = -1) { include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; if ($question_id > 0) { return assQuestion::_instanciateQuestionGUI($question_id); } assQuestion::_includeClass($question_type, 1); $question_type_gui = $question_type . "GUI"; $question_gui =& new $question_type_gui(); return $question_gui; }
/** * fill row * * @access public * @param * @return */ public function fillRow($data) { ilDatePresentation::setUseRelativeDates(false); $this->tpl->setVariable("TITLE", ilUtil::prepareFormOutput($data['title'])); foreach ($this->getSelectedColumns() as $c) { if (strcmp($c, 'description') == 0) { $this->tpl->setCurrentBlock('description'); $this->tpl->setVariable("DESCRIPTION", ilUtil::prepareFormOutput($data['description'])); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'author') == 0) { $this->tpl->setCurrentBlock('author'); $this->tpl->setVariable("AUTHOR", ilUtil::prepareFormOutput($data['author'])); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'ttype') == 0) { $this->tpl->setCurrentBlock('ttype'); $this->tpl->setVariable("TYPE", ilUtil::prepareFormOutput($data['ttype'])); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'created') == 0) { $this->tpl->setCurrentBlock('created'); $this->tpl->setVariable('CREATED', ilDatePresentation::formatDate(new ilDateTime($data['created'], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } if (strcmp($c, 'updated') == 0) { $this->tpl->setCurrentBlock('updated'); $this->tpl->setVariable('UPDATED', ilDatePresentation::formatDate(new ilDateTime($data['updated'], IL_CAL_UNIX))); $this->tpl->parseCurrentBlock(); } } if (strcmp($this->outputmode, "detailed") == 0 || strcmp($this->outputmode, "detailed_printview") == 0) { $this->tpl->setCurrentBlock("overview_row_detail"); include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $question_gui = assQuestion::_instanciateQuestionGUI($data["question_id"]); if (strcmp($this->outputmode, "detailed") == 0) { $solutionoutput = $question_gui->getSolutionOutput($active_id = "", $pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = FALSE, $show_feedback = FALSE, $show_correct_solution = true, $show_manual_scoring = false); if (strlen($solutionoutput) == 0) { $solutionoutput = $question_gui->getPreview(); } $this->tpl->setVariable("DETAILS", $solutionoutput); } else { $this->tpl->setVariable("DETAILS", $question_gui->getPreview()); } $this->tpl->parseCurrentBlock(); } ilDatePresentation::setUseRelativeDates(true); }