00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
00025 include_once "./Modules/Survey/classes/inc.SurveyConstants.php";
00026
00038 class SurveyMatrixQuestionGUI extends SurveyQuestionGUI
00039 {
00040 var $show_layout_row;
00041
00050 function SurveyMatrixQuestionGUI(
00051 $id = -1
00052 )
00053
00054 {
00055 $this->SurveyQuestionGUI();
00056 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMatrixQuestion.php";
00057 $this->object = new SurveyMatrixQuestion();
00058 $this->show_layout_row = FALSE;
00059 if ($id >= 0)
00060 {
00061 $this->object->loadFromDb($id);
00062 }
00063 }
00064
00068 function &executeCommand()
00069 {
00070 $cmd = $this->ctrl->getCmd();
00071 $next_class = $this->ctrl->getNextClass($this);
00072
00073 $cmd = $this->getCommand($cmd);
00074 switch($next_class)
00075 {
00076 default:
00077 $ret =& $this->$cmd();
00078 break;
00079 }
00080 return $ret;
00081 }
00082
00090 function editQuestion()
00091 {
00092 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_matrix.html", "Modules/SurveyQuestionPool");
00093 $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", "Modules/SurveyQuestionPool");
00094
00095 $subtypes = array(
00096 "0" => "matrix_subtype_sr",
00097 "1" => "matrix_subtype_mr",
00098
00099
00100
00101
00102
00103 );
00104
00105 foreach ($subtypes as $value => $text)
00106 {
00107 $this->tpl->setCurrentBlock("subtype_row");
00108 $this->tpl->setVariable("VALUE_SUBTYPE", $value);
00109 $this->tpl->setVariable("TEXT_SUBTYPE", $this->lng->txt($text));
00110 if ($value == $this->object->getSubtype())
00111 {
00112 $this->tpl->setVariable("CHECKED_SUBTYPE", " checked=\"checked\"");
00113 }
00114 $this->tpl->parseCurrentBlock();
00115 }
00116
00117 $internallinks = array(
00118 "lm" => $this->lng->txt("obj_lm"),
00119 "st" => $this->lng->txt("obj_st"),
00120 "pg" => $this->lng->txt("obj_pg"),
00121 "glo" => $this->lng->txt("glossary_term")
00122 );
00123 foreach ($internallinks as $key => $value)
00124 {
00125 $this->tpl->setCurrentBlock("internallink");
00126 $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00127 $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00128 $this->tpl->parseCurrentBlock();
00129 }
00130
00131 $this->tpl->setCurrentBlock("adm_content");
00132 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
00133 if (count($this->object->material))
00134 {
00135 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
00136 $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00137 $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
00138 $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
00139 $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
00140 $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
00141 $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
00142 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00143 }
00144 else
00145 {
00146 $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
00147 }
00148 $this->tpl->setVariable("TEXT_ORIENTATION", $this->lng->txt("orientation"));
00149 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00150 $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
00151 $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
00152 $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
00153 $questiontext = $this->object->getQuestiontext();
00154 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00155 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00156 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00157 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00158 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00159 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
00160 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00161 if ($this->object->getObligatory())
00162 {
00163 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00164 }
00165
00166 $this->tpl->setVariable("TEXT_APPEARANCE", $this->lng->txt("matrix_appearance"));
00167 $this->tpl->setVariable("TEXT_COLUMN_SEPARATORS", $this->lng->txt("matrix_column_separators"));
00168 $this->tpl->setVariable("TEXT_ROW_SEPARATORS", $this->lng->txt("matrix_row_separators"));
00169 $this->tpl->setVariable("TEXT_NEUTRAL_COLUMN_SEPARATOR", $this->lng->txt("matrix_neutral_column_separator"));
00170 $this->tpl->setVariable("DESCRIPTION_NEUTRAL_COLUMN_SEPARATOR", $this->lng->txt("matrix_neutral_column_separator_description"));
00171 $this->tpl->setVariable("DESCRIPTION_ROW_SEPARATORS", $this->lng->txt("matrix_row_separators_description"));
00172 $this->tpl->setVariable("DESCRIPTION_COLUMN_SEPARATORS", $this->lng->txt("matrix_column_separators_description"));
00173 if ($this->object->getRowSeparators())
00174 {
00175 $this->tpl->setVariable("CHECKED_ROW_SEPARATORS", " checked=\"checked\"");
00176 }
00177 if ($this->object->getColumnSeparators())
00178 {
00179 $this->tpl->setVariable("CHECKED_COLUMN_SEPARATORS", " checked=\"checked\"");
00180 }
00181 if ($this->object->getNeutralColumnSeparator())
00182 {
00183 $this->tpl->setVariable("CHECKED_NEUTRAL_COLUMN_SEPARATOR", " checked=\"checked\"");
00184 }
00185
00186 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00187 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00188 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "editQuestion"));
00189 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
00190 $this->tpl->setVariable("TEXT_SUBTYPE", $this->lng->txt("subtype"));
00191 $this->tpl->setVariable("DESCRIPTION_SUBTYPE", $this->lng->txt("matrix_subtype_description"));
00192 $this->tpl->parseCurrentBlock();
00193
00194 include_once "./Services/RTE/classes/class.ilRTE.php";
00195 $rtestring = ilRTE::_getRTEClassname();
00196 include_once "./Services/RTE/classes/class.$rtestring.php";
00197 $rte = new $rtestring();
00198 $rte->addPlugin("latex");
00199 $rte->addButton("latex"); $rte->addButton("pastelatex");
00200 $rte->removePlugin("ibrowser");
00201 include_once "./classes/class.ilObject.php";
00202 $obj_id = $_GET["q_id"];
00203 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00204 $rte->addRTESupport($obj_id, $obj_type, "survey");
00205 }
00206
00214 function getWorkingForm($working_data = "", $question_title = 1, $show_questiontext = 1, $error_message = "")
00215 {
00216 $layout = $this->object->getLayout();
00217 $neutralstyle = "3px solid #808080";
00218 $bordercolor = "#808080";
00219 $template = new ilTemplate("tpl.il_svy_out_matrix.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00220 if (count($this->object->material))
00221 {
00222 $template->setCurrentBlock("material_matrix");
00223 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
00224 $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00225 $template->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00226 $template->parseCurrentBlock();
00227 }
00228
00229 if ($this->show_layout_row)
00230 {
00231 $layout_row = $this->getLayoutRow();
00232 $template->setCurrentBlock("matrix_row");
00233 $template->setVariable("ROW", $layout_row);
00234 $template->parseCurrentBlock();
00235 }
00236
00237 $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00238 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00239 {
00240 $tplheaders->setCurrentBlock("bipolar_start");
00241 $style = array();
00242 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective1"], "%"));
00243 if (count($style) > 0)
00244 {
00245 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00246 }
00247 $tplheaders->parseCurrentBlock();
00248 }
00249
00250 for ($i = 0; $i < $this->object->getColumnCount(); $i++)
00251 {
00252 $style = array();
00253 if ($this->object->getColumnSeparators() == 1)
00254 {
00255 if (($i < $this->object->getColumnCount() - 1))
00256 {
00257 array_push($style, "border-right: 1px solid $bordercolor!important");
00258 }
00259 }
00260 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_columns"] / $this->object->getColumnCount(), "%"));
00261 $tplheaders->setCurrentBlock("column_header");
00262 $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($this->object->getColumn($i)));
00263 $tplheaders->setVariable("CLASS", "center");
00264 if (count($style) > 0)
00265 {
00266 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00267 }
00268 $tplheaders->parseCurrentBlock();
00269 }
00270 if (strlen($this->object->getNeutralColumn()))
00271 {
00272 $tplheaders->setCurrentBlock("neutral_column_header");
00273 $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($this->object->getNeutralColumn()));
00274 $tplheaders->setVariable("CLASS", "rsep");
00275 $style = array();
00276 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_neutral"], "%"));
00277 if ($this->object->getNeutralColumnSeparator())
00278 {
00279 array_push($style, "border-left: $neutralstyle!important;");
00280 }
00281 if (count($style) > 0)
00282 {
00283 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00284 }
00285 $tplheaders->parseCurrentBlock();
00286 }
00287 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00288 {
00289 $tplheaders->setCurrentBlock("bipolar_end");
00290 $style = array();
00291 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective2"], "%"));
00292 if (count($style) > 0)
00293 {
00294 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00295 }
00296 $tplheaders->parseCurrentBlock();
00297 }
00298
00299 $style = array();
00300 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_row"], "%"));
00301 if (count($style) > 0)
00302 {
00303 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00304 }
00305
00306 $template->setCurrentBlock("matrix_row");
00307 $template->setVariable("ROW", $tplheaders->get());
00308 $template->parseCurrentBlock();
00309
00310 $rowclass = array("tblrow1", "tblrow2");
00311
00312 for ($i = 0; $i < $this->object->getRowCount(); $i++)
00313 {
00314 $tplrow = new ilTemplate("tpl.il_svy_out_matrix_row.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00315 for ($j = 0; $j < $this->object->getColumnCount(); $j++)
00316 {
00317 if (($i == 0) && ($j == 0))
00318 {
00319 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00320 {
00321 $tplrow->setCurrentBlock("bipolar_start");
00322 $tplrow->setVariable("TEXT_BIPOLAR_START", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0)));
00323 $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
00324 $tplrow->parseCurrentBlock();
00325 }
00326 }
00327 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
00328 {
00329 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00330 {
00331 $tplrow->setCurrentBlock("bipolar_end");
00332 $tplrow->setVariable("TEXT_BIPOLAR_END", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1)));
00333 $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
00334 $tplrow->parseCurrentBlock();
00335 }
00336 }
00337 switch ($this->object->getSubtype())
00338 {
00339 case 0:
00340 $tplrow->setCurrentBlock("radiobutton");
00341 $tplrow->setVariable("QUESTION_ID", $this->object->getId());
00342 $tplrow->setVariable("ROW", $i);
00343 $tplrow->setVariable("VALUE", $j);
00344 if (is_array($working_data))
00345 {
00346 foreach ($working_data as $data)
00347 {
00348 if (($data["value"] == $j) && ($data["row"] == $i))
00349 {
00350 $tplrow->setVariable("CHECKED_RADIOBUTTON", " checked=\"checked\"");
00351 }
00352 }
00353 }
00354 $tplrow->parseCurrentBlock();
00355 break;
00356 case 1:
00357 $tplrow->setCurrentBlock("checkbox");
00358 $tplrow->setVariable("QUESTION_ID", $this->object->getId());
00359 $tplrow->setVariable("ROW", $i);
00360 $tplrow->setVariable("VALUE", $j);
00361 if (is_array($working_data))
00362 {
00363 foreach ($working_data as $data)
00364 {
00365 if (($data["value"] == $j) && ($data["row"] == $i))
00366 {
00367 $tplrow->setVariable("CHECKED_CHECKBOX", " checked=\"checked\"");
00368 }
00369 }
00370 }
00371 $tplrow->parseCurrentBlock();
00372 break;
00373 }
00374 $tplrow->setCurrentBlock("answer");
00375 $style = array();
00376
00377 if ($this->object->getColumnSeparators() == 1)
00378 {
00379 if ($j < $this->object->getColumnCount() - 1)
00380 {
00381 array_push($style, "border-right: 1px solid $bordercolor!important");
00382 }
00383 }
00384
00385 if ($this->object->getRowSeparators() == 1)
00386 {
00387 if ($i < $this->object->getRowCount() - 1)
00388 {
00389 array_push($style, "border-bottom: 1px solid $bordercolor!important");
00390 }
00391 }
00392 if (count($style))
00393 {
00394 $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00395 }
00396 $tplrow->parseCurrentBlock();
00397
00398 }
00399
00400 if (strlen($this->object->getNeutralColumn()))
00401 {
00402 $j = $this->object->getNeutralColumnIndex();
00403 switch ($this->object->getSubtype())
00404 {
00405 case 0:
00406 $tplrow->setCurrentBlock("neutral_radiobutton");
00407 $tplrow->setVariable("QUESTION_ID", $this->object->getId());
00408 $tplrow->setVariable("ROW", $i);
00409 $tplrow->setVariable("VALUE", $j);
00410 if (is_array($working_data))
00411 {
00412 foreach ($working_data as $data)
00413 {
00414 if (($data["value"] == $j) && ($data["row"] == $i))
00415 {
00416 $tplrow->setVariable("CHECKED_RADIOBUTTON", " checked=\"checked\"");
00417 }
00418 }
00419 }
00420 $tplrow->parseCurrentBlock();
00421 break;
00422 case 1:
00423 $tplrow->setCurrentBlock("neutral_checkbox");
00424 $tplrow->setVariable("QUESTION_ID", $this->object->getId());
00425 $tplrow->setVariable("ROW", $i);
00426 $tplrow->setVariable("VALUE", $j);
00427 if (is_array($working_data))
00428 {
00429 foreach ($working_data as $data)
00430 {
00431 if (($data["value"] == $j) && ($data["row"] == $i))
00432 {
00433 $tplrow->setVariable("CHECKED_CHECKBOX", " checked=\"checked\"");
00434 }
00435 }
00436 }
00437 $tplrow->parseCurrentBlock();
00438 break;
00439 }
00440 $tplrow->setCurrentBlock("neutral_answer");
00441 $style = array();
00442 if ($this->object->getNeutralColumnSeparator())
00443 {
00444 array_push($style, "border-left: $neutralstyle!important");
00445 }
00446 if ($this->object->getColumnSeparators() == 1)
00447 {
00448 if ($j < $this->object->getColumnCount() - 1)
00449 {
00450 array_push($style, "border-right: 1px solid $bordercolor!important");
00451 }
00452 }
00453
00454 if ($this->object->getRowSeparators() == 1)
00455 {
00456 if ($i < $this->object->getRowCount() - 1)
00457 {
00458 array_push($style, "border-bottom: 1px solid $bordercolor!important");
00459 }
00460 }
00461 if (count($style))
00462 {
00463 $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00464 }
00465 $tplrow->parseCurrentBlock();
00466 }
00467
00468 $tplrow->setVariable("TEXT_ROW", ilUtil::prepareFormOutput($this->object->getRow($i)));
00469 $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
00470 if ($this->object->getRowSeparators() == 1)
00471 {
00472 if ($i < $this->object->getRowCount() - 1)
00473 {
00474 $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
00475 }
00476 }
00477 $template->setCurrentBlock("matrix_row");
00478 $template->setVariable("ROW", $tplrow->get());
00479 $template->parseCurrentBlock();
00480 }
00481
00482 if ($question_title)
00483 {
00484 $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00485 }
00486 $template->setCurrentBlock("question_data_matrix");
00487 if (strcmp($error_message, "") != 0)
00488 {
00489 $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00490 }
00491 if ($show_questiontext)
00492 {
00493 $questiontext = $this->object->getQuestiontext();
00494 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00495 }
00496 if (! $this->object->getObligatory())
00497 {
00498 $template->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
00499 }
00500 $template->parseCurrentBlock();
00501 return $template->get();
00502 }
00503
00511 function getPrintView($question_title = 1, $show_questiontext = 1)
00512 {
00513 $layout = $this->object->getLayout();
00514 $neutralstyle = "3px solid #808080";
00515 $bordercolor = "#808080";
00516 $template = new ilTemplate("tpl.il_svy_qpl_matrix_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00517
00518 if ($this->show_layout_row)
00519 {
00520 $layout_row = $this->getLayoutRow();
00521 $template->setCurrentBlock("matrix_row");
00522 $template->setVariable("ROW", $layout_row);
00523 $template->parseCurrentBlock();
00524 }
00525
00526 $tplheaders = new ilTemplate("tpl.il_svy_out_matrix_columnheaders.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00527 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00528 {
00529 $tplheaders->setCurrentBlock("bipolar_start");
00530 $style = array();
00531 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective1"], "%"));
00532 if (count($style) > 0)
00533 {
00534 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00535 }
00536 $tplheaders->parseCurrentBlock();
00537 }
00538
00539 for ($i = 0; $i < $this->object->getColumnCount(); $i++)
00540 {
00541 $style = array();
00542 if ($this->object->getColumnSeparators() == 1)
00543 {
00544 if (($i < $this->object->getColumnCount() - 1))
00545 {
00546 array_push($style, "border-right: 1px solid $bordercolor!important");
00547 }
00548 }
00549 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_columns"] / $this->object->getColumnCount(), "%"));
00550 $tplheaders->setCurrentBlock("column_header");
00551 $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($this->object->getColumn($i)));
00552 $tplheaders->setVariable("CLASS", "center");
00553 if (count($style) > 0)
00554 {
00555 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00556 }
00557 $tplheaders->parseCurrentBlock();
00558 }
00559 if (strlen($this->object->getNeutralColumn()))
00560 {
00561 $tplheaders->setCurrentBlock("neutral_column_header");
00562 $tplheaders->setVariable("TEXT", ilUtil::prepareFormOutput($this->object->getNeutralColumn()));
00563 $tplheaders->setVariable("CLASS", "rsep");
00564 $style = array();
00565 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_neutral"], "%"));
00566 if ($this->object->getNeutralColumnSeparator())
00567 {
00568 array_push($style, "border-left: $neutralstyle!important;");
00569 }
00570 if (count($style) > 0)
00571 {
00572 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00573 }
00574 $tplheaders->parseCurrentBlock();
00575 }
00576 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00577 {
00578 $tplheaders->setCurrentBlock("bipolar_end");
00579 $style = array();
00580 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_bipolar_adjective2"], "%"));
00581 if (count($style) > 0)
00582 {
00583 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00584 }
00585 $tplheaders->parseCurrentBlock();
00586 }
00587
00588 $style = array();
00589 array_push($style, sprintf("width: %.2f%s!important", $layout["percent_row"], "%"));
00590 if (count($style) > 0)
00591 {
00592 $tplheaders->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00593 }
00594
00595 $template->setCurrentBlock("matrix_row");
00596 $template->setVariable("ROW", $tplheaders->get());
00597 $template->parseCurrentBlock();
00598
00599 $rowclass = array("tblrow1", "tblrow2");
00600
00601 for ($i = 0; $i < $this->object->getRowCount(); $i++)
00602 {
00603 $tplrow = new ilTemplate("tpl.il_svy_qpl_matrix_printview_row.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00604 for ($j = 0; $j < $this->object->getColumnCount(); $j++)
00605 {
00606 if (($i == 0) && ($j == 0))
00607 {
00608 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00609 {
00610 $tplrow->setCurrentBlock("bipolar_start");
00611 $tplrow->setVariable("TEXT_BIPOLAR_START", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0)));
00612 $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
00613 $tplrow->parseCurrentBlock();
00614 }
00615 }
00616 if (($i == 0) && ($j == $this->object->getColumnCount()-1))
00617 {
00618 if ((strlen($this->object->getBipolarAdjective(0))) && (strlen($this->object->getBipolarAdjective(1))))
00619 {
00620 $tplrow->setCurrentBlock("bipolar_end");
00621 $tplrow->setVariable("TEXT_BIPOLAR_END", ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1)));
00622 $tplrow->setVariable("ROWSPAN", $this->object->getRowCount());
00623 $tplrow->parseCurrentBlock();
00624 }
00625 }
00626 switch ($this->object->getSubtype())
00627 {
00628 case 0:
00629 $tplrow->setCurrentBlock("radiobutton");
00630 $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.gif")));
00631 $tplrow->setVariable("ALT_RADIO", $this->lng->txt("unchecked"));
00632 $tplrow->setVariable("TITLE_RADIO", $this->lng->txt("unchecked"));
00633 $tplrow->parseCurrentBlock();
00634 break;
00635 case 1:
00636 $tplrow->setCurrentBlock("checkbox");
00637 $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
00638 $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
00639 $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
00640 $tplrow->parseCurrentBlock();
00641 break;
00642 }
00643 $tplrow->setCurrentBlock("answer");
00644 $style = array();
00645
00646 if ($this->object->getColumnSeparators() == 1)
00647 {
00648 if ($j < $this->object->getColumnCount() - 1)
00649 {
00650 array_push($style, "border-right: 1px solid $bordercolor!important");
00651 }
00652 }
00653
00654 if ($this->object->getRowSeparators() == 1)
00655 {
00656 if ($i < $this->object->getRowCount() - 1)
00657 {
00658 array_push($style, "border-bottom: 1px solid $bordercolor!important");
00659 }
00660 }
00661 if (count($style))
00662 {
00663 $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00664 }
00665 $tplrow->parseCurrentBlock();
00666 }
00667
00668 if (strlen($this->object->getNeutralColumn()))
00669 {
00670 $j = $this->object->getRowCount();
00671 switch ($this->object->getSubtype())
00672 {
00673 case 0:
00674 $tplrow->setCurrentBlock("neutral_radiobutton");
00675 $tplrow->setVariable("IMAGE_RADIO", ilUtil::getHtmlPath(ilUtil::getImagePath("radiobutton_unchecked.gif")));
00676 $tplrow->setVariable("ALT_RADIO", $this->lng->txt("unchecked"));
00677 $tplrow->setVariable("TITLE_RADIO", $this->lng->txt("unchecked"));
00678 $tplrow->parseCurrentBlock();
00679 break;
00680 case 1:
00681 $tplrow->setCurrentBlock("neutral_checkbox");
00682 $tplrow->setVariable("IMAGE_CHECKBOX", ilUtil::getHtmlPath(ilUtil::getImagePath("checkbox_unchecked.gif")));
00683 $tplrow->setVariable("ALT_CHECKBOX", $this->lng->txt("unchecked"));
00684 $tplrow->setVariable("TITLE_CHECKBOX", $this->lng->txt("unchecked"));
00685 $tplrow->parseCurrentBlock();
00686 break;
00687 }
00688 $tplrow->setCurrentBlock("neutral_answer");
00689 $style = array();
00690 if ($this->object->getNeutralColumnSeparator())
00691 {
00692 array_push($style, "border-left: $neutralstyle!important");
00693 }
00694 if ($this->object->getColumnSeparators() == 1)
00695 {
00696 if ($j < $this->object->getColumnCount() - 1)
00697 {
00698 array_push($style, "border-right: 1px solid $bordercolor!important");
00699 }
00700 }
00701
00702 if ($this->object->getRowSeparators() == 1)
00703 {
00704 if ($i < $this->object->getRowCount() - 1)
00705 {
00706 array_push($style, "border-bottom: 1px solid $bordercolor!important");
00707 }
00708 }
00709 if (count($style))
00710 {
00711 $tplrow->setVariable("STYLE", " style=\"" . implode(";", $style) . "\"");
00712 }
00713 $tplrow->parseCurrentBlock();
00714 }
00715
00716 $tplrow->setVariable("TEXT_ROW", ilUtil::prepareFormOutput($this->object->getRow($i)));
00717 $tplrow->setVariable("ROWCLASS", $rowclass[$i % 2]);
00718 if ($this->object->getRowSeparators() == 1)
00719 {
00720 if ($i < $this->object->getRowCount() - 1)
00721 {
00722 $tplrow->setVariable("STYLE", " style=\"border-bottom: 1px solid $bordercolor!important\"");
00723 }
00724 }
00725 $template->setCurrentBlock("matrix_row");
00726 $template->setVariable("ROW", $tplrow->get());
00727 $template->parseCurrentBlock();
00728 }
00729
00730 if ($question_title)
00731 {
00732 $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
00733 }
00734 $template->setCurrentBlock();
00735 if ($show_questiontext)
00736 {
00737 $questiontext = $this->object->getQuestiontext();
00738 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00739 }
00740 if (! $this->object->getObligatory())
00741 {
00742 $template->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
00743 }
00744 $template->parseCurrentBlock();
00745 return $template->get();
00746 }
00747
00755 function preview()
00756 {
00757 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", "Modules/SurveyQuestionPool");
00758 $question_output = $this->getWorkingForm();
00759 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
00760 $this->tpl->parseCurrentBlock();
00761 }
00762
00770 function layout()
00771 {
00772 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_layout.html", "Modules/SurveyQuestionPool");
00773 $this->show_layout_row = TRUE;
00774 $question_output = $this->getWorkingForm();
00775 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
00776 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "saveLayout"));
00777 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00778 $this->tpl->parseCurrentBlock();
00779 }
00780
00788 function saveLayout()
00789 {
00790 $this->object->saveLayout($_POST["percent_row"], $_POST['percent_columns'], $_POST['percent_bipolar_adjective1'], $_POST['percent_bipolar_adjective2'], $_POST["percent_neutral"]);
00791 $percent_values = array(
00792 "percent_row" => $_POST["percent_row"],
00793 "percent_columns" => $_POST["percent_columns"],
00794 "percent_bipolar_adjective1" => $_POST['percent_bipolar_adjective1'],
00795 "percent_bipolar_adjective2" => $_POST['percent_bipolar_adjective2'],
00796 "percent_neutral" => $_POST["percent_neutral"]
00797 );
00798 $this->object->setLayout($percent_values);
00799 $this->layout();
00800 }
00801
00809 function getLayoutRow()
00810 {
00811 $percent_values = $this->object->getLayout();
00812 $template = new ilTemplate("tpl.il_svy_out_matrix_layout.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
00813 if (strlen($this->object->getBipolarAdjective(0)) && strlen($this->object->getBipolarAdjective(1)))
00814 {
00815 $template->setCurrentBlock("bipolar_start");
00816 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE1", " value=\"" . $percent_values["percent_bipolar_adjective1"] . "\"");
00817 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective1"] . "%\"");
00818 $template->parseCurrentBlock();
00819 $template->setCurrentBlock("bipolar_end");
00820 $template->setVariable("VALUE_PERCENT_BIPOLAR_ADJECTIVE2", " value=\"" . $percent_values["percent_bipolar_adjective2"] . "\"");
00821 $template->setVariable("STYLE", " style=\"width:" . $percent_values["percent_bipolar_adjective2"] . "%\"");
00822 $template->parseCurrentBlock();
00823 }
00824 if (strlen($this->object->getNeutralColumn()))
00825 {
00826 $template->setCurrentBlock("bipolar_end");
00827 $template->setVariable("VALUE_PERCENT_NEUTRAL", " value=\"" . $percent_values["percent_neutral"] . "\"");
00828 $template->setVariable("STYLE_NEUTRAL", " style=\"width:" . $percent_values["percent_neutral"] . "%\"");
00829 $template->parseCurrentBlock();
00830 }
00831 $template->setVariable("VALUE_PERCENT_ROW", " value=\"" . $percent_values["percent_row"] . "\"");
00832 $template->setVariable("STYLE_ROW", " style=\"width:" . $percent_values["percent_row"] . "%\"");
00833 $counter = $this->object->getColumnCount();
00834 $template->setVariable("COLSPAN_COLUMNS", $counter);
00835 $template->setVariable("VALUE_PERCENT_COLUMNS", " value=\"" . $percent_values["percent_columns"] . "\"");
00836 $template->setVariable("STYLE_COLUMNS", " style=\"width:" . $percent_values["percent_columns"] . "%\"");
00837 return $template->get();
00838 }
00839
00848 function writePostData()
00849 {
00850 $result = 0;
00851 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00852 $result = 1;
00853
00854
00855 if ($_POST["id"] > 0)
00856 $this->object->setId($_POST["id"]);
00857 include_once "./Services/Utilities/classes/class.ilUtil.php";
00858 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00859 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00860 $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00861 $this->object->setOrientation($_POST["orientation"]);
00862 if (strlen($_POST["material"]))
00863 {
00864 $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00865 }
00866 include_once "./classes/class.ilObjAdvancedEditing.php";
00867 $questiontext = ilUtil::stripSlashes($_POST["question"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00868 $this->object->setQuestiontext($questiontext);
00869 if ($_POST["obligatory"])
00870 {
00871 $this->object->setObligatory(1);
00872 }
00873 else
00874 {
00875 $this->object->setObligatory(0);
00876 }
00877 $this->object->setSubtype($_POST["subtype"]);
00878 $this->object->setRowSeparators(($_POST["row_separators"]) ? 1 : 0);
00879 $this->object->setColumnSeparators(($_POST["column_separators"]) ? 1 : 0);
00880 $this->object->setNeutralColumnSeparator(($_POST["neutral_column_separator"]) ? 1 : 0);
00881
00882 if ($saved)
00883 {
00884
00885
00886
00887
00888 $this->object->saveToDb();
00889 }
00890 return $result;
00891 }
00892
00900 function moveColumnUp($column)
00901 {
00902 $complete = $this->writeRowColData();
00903 $columntext = $this->object->getColumn($column);
00904 $this->object->removeColumn($column);
00905 $this->object->addColumnAtPosition($columntext, $column - 1);
00906 $_SESSION["spl_modified"] = TRUE;
00907 }
00908
00916 function moveColumnDown($column)
00917 {
00918 $complete = $this->writeRowColData();
00919 $columntext = $this->object->getColumn($column);
00920 $this->object->removeColumn($column);
00921 $this->object->addColumnAtPosition($columntext, $column + 1);
00922 $_SESSION["spl_modified"] = TRUE;
00923 }
00924
00932 function categories()
00933 {
00934 if (count($_POST) == 0) $_SESSION["spl_modified"] = FALSE;
00935 if (is_array($_POST))
00936 {
00937 foreach ($_POST as $key => $value)
00938 {
00939 if (preg_match("/moveUp_(\d+)_x/", $key, $matches))
00940 {
00941 $this->moveColumnUp($matches[1]);
00942 }
00943 if (preg_match("/moveDown_(\d+)_x/", $key, $matches))
00944 {
00945 $this->moveColumnDown($matches[1]);
00946 }
00947 }
00948 }
00949 if ($this->object->getId() < 1)
00950 {
00951 ilUtil::sendInfo($this->lng->txt("fill_out_all_required_fields_add_category"), true);
00952 $this->ctrl->redirect($this, "editQuestion");
00953 }
00954 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_matrix_answers.html", "Modules/SurveyQuestionPool");
00955
00956
00957 if ($this->object->getSubtype() == 0)
00958 {
00959 $this->tpl->setCurrentBlock("ordinal");
00960 $this->tpl->setVariable("TEXT_COLUMN_SETTINGS", $this->lng->txt("matrix_column_settings"));
00961 $this->tpl->setVariable("TEXT_BIPOLAR_ADJECTIVES", $this->lng->txt("matrix_bipolar_adjectives"));
00962 $this->tpl->setVariable("TEXT_BIPOLAR_ADJECTIVES_DESCRIPTION", $this->lng->txt("matrix_bipolar_adjectives_description"));
00963 $this->tpl->setVariable("TEXT_ADJECTIVE_1", $this->lng->txt("matrix_adjective") . " 1");
00964 $this->tpl->setVariable("TEXT_ADJECTIVE_2", $this->lng->txt("matrix_adjective") . " 2");
00965 $this->tpl->setVariable("VALUE_BIPOLAR1", " value=\"" . ilUtil::prepareFormOutput($this->object->getBipolarAdjective(0)) . "\"");
00966 $this->tpl->setVariable("VALUE_BIPOLAR2", " value=\"" . ilUtil::prepareFormOutput($this->object->getBipolarAdjective(1)) . "\"");
00967 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00968 $this->tpl->parseCurrentBlock();
00969 }
00970
00971
00972 if ($this->object->getColumnCount() == 0)
00973 {
00974 $this->object->addColumn("");
00975 }
00976 if (strcmp($this->ctrl->getCmd(), "addColumn") == 0)
00977 {
00978 $nrOfCategories = $_POST["nrOfCategories"];
00979 if ($nrOfCategories < 1) $nrOfCategories = 1;
00980
00981 for ($i = 1; $i <= $nrOfCategories; $i++)
00982 {
00983 $this->object->addColumn("");
00984 }
00985 }
00986
00987 $hasneutralcolumn = FALSE;
00988 for ($i = 0; $i < $this->object->getColumnCount(); $i++)
00989 {
00990 $column = $this->object->getColumn($i);
00991 if ($this->object->getColumnCount() > 1)
00992 {
00993 if ($i == 0)
00994 {
00995 $this->tpl->setCurrentBlock("move_down");
00996 $this->tpl->setVariable("IMAGE_DOWN", ilUtil::getImagePath("a_down.gif"));
00997 $this->tpl->setVariable("ALT_DOWN", $this->lng->txt("move_down"));
00998 $this->tpl->setVariable("TITLE_DOWN", $this->lng->txt("move_down"));
00999 $this->tpl->setVariable("COLUMN", $i);
01000 $this->tpl->parseCurrentBlock();
01001 }
01002 else if ($i == $this->object->getColumnCount() - 1)
01003 {
01004 $this->tpl->setCurrentBlock("move_up");
01005 $this->tpl->setVariable("IMAGE_UP", ilUtil::getImagePath("a_up.gif"));
01006 $this->tpl->setVariable("ALT_UP", $this->lng->txt("move_up"));
01007 $this->tpl->setVariable("TITLE_UP", $this->lng->txt("move_up"));
01008 $this->tpl->setVariable("COLUMN", $i);
01009 $this->tpl->parseCurrentBlock();
01010 }
01011 else
01012 {
01013 $this->tpl->setCurrentBlock("move_down");
01014 $this->tpl->setVariable("IMAGE_DOWN", ilUtil::getImagePath("a_down.gif"));
01015 $this->tpl->setVariable("ALT_DOWN", $this->lng->txt("move_down"));
01016 $this->tpl->setVariable("TITLE_DOWN", $this->lng->txt("move_down"));
01017 $this->tpl->setVariable("COLUMN", $i);
01018 $this->tpl->parseCurrentBlock();
01019 $this->tpl->setCurrentBlock("move_up");
01020 $this->tpl->setVariable("IMAGE_UP", ilUtil::getImagePath("a_up.gif"));
01021 $this->tpl->setVariable("ALT_UP", $this->lng->txt("move_up"));
01022 $this->tpl->setVariable("TITLE_UP", $this->lng->txt("move_up"));
01023 $this->tpl->setVariable("COLUMN", $i);
01024 $this->tpl->parseCurrentBlock();
01025 }
01026 }
01027 $this->tpl->setCurrentBlock("categories");
01028 $this->tpl->setVariable("CATEGORY_ORDER", $i);
01029 $this->tpl->setVariable("CATEGORY_ORDER", $i);
01030 $this->tpl->setVariable("CATEGORY_NUMBER", $i+1);
01031 $this->tpl->setVariable("VALUE_CATEGORY", $column);
01032 $this->tpl->setVariable("TEXT_CATEGORY", $this->lng->txt("category"));
01033 $this->tpl->parseCurrentBlock();
01034 }
01035
01036 if (strlen($this->object->getNeutralColumn()))
01037 {
01038 $this->tpl->setVariable("VALUE_NEUTRAL", " value=\"" . ilUtil::prepareFormOutput($this->object->getNeutralColumn()) . "\"");
01039 }
01040 $this->tpl->setVariable("CATEGORY_NEUTRAL", $this->object->getColumnCount() + 1);
01041
01042 if ($this->object->getRowCount() == 0)
01043 {
01044 $this->object->addRow("");
01045 }
01046 if (strcmp($this->ctrl->getCmd(), "addRow") == 0)
01047 {
01048 $nrOfRows = $_POST["nrOfRows"];
01049 if ($nrOfRows < 1) $nrOfRows = 1;
01050
01051 for ($i = 1; $i <= $nrOfRows; $i++)
01052 {
01053 $this->object->addRow("");
01054 }
01055 }
01056
01057 for ($i = 0; $i < $this->object->getRowCount(); $i++)
01058 {
01059 $this->tpl->setCurrentBlock("rows");
01060 $this->tpl->setVariable("ROW_ORDER", $i);
01061 $row = $this->object->getRow($i);
01062 $this->tpl->setVariable("ROW_ORDER", $i);
01063 $this->tpl->setVariable("ROW_NUMBER", $i+1);
01064 $this->tpl->setVariable("VALUE_ROW", $row);
01065 $this->tpl->setVariable("TEXT_ROW", $this->lng->txt("row"));
01066 $this->tpl->parseCurrentBlock();
01067 }
01068
01069 include_once "./Services/Utilities/classes/class.ilUtil.php";
01070 if ($this->object->getColumnCount() > 0)
01071 {
01072 $this->tpl->setCurrentBlock("selectall");
01073 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01074 $this->tpl->parseCurrentBlock();
01075 $this->tpl->setCurrentBlock("existingcategories");
01076 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
01077 $this->tpl->setVariable("VALUE_SAVE_PHRASE", $this->lng->txt("save_phrase"));
01078 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
01079 $this->tpl->parseCurrentBlock();
01080 }
01081
01082 if ($this->object->getRowCount() > 0)
01083 {
01084 $this->tpl->setCurrentBlock("selectall_rows");
01085 $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
01086 $this->tpl->parseCurrentBlock();
01087 }
01088
01089 for ($i = 1; $i < 10; $i++)
01090 {
01091 $this->tpl->setCurrentBlock("numbers");
01092 $this->tpl->setVariable("VALUE_NUMBER", $i);
01093 if ($i == 1)
01094 {
01095 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("category"));
01096 }
01097 else
01098 {
01099 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("categories"));
01100 }
01101 $this->tpl->parseCurrentBlock();
01102 $this->tpl->setCurrentBlock("rownumbers");
01103 $this->tpl->setVariable("VALUE_NUMBER", $i);
01104 if ($i == 1)
01105 {
01106 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("row"));
01107 }
01108 else
01109 {
01110 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("rows"));
01111 }
01112 $this->tpl->parseCurrentBlock();
01113 }
01114
01115 $this->tpl->setCurrentBlock("adm_content");
01116 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "categories"));
01117 $this->tpl->setVariable("TEXT_ANSWERS", $this->lng->txt("matrix_columns"));
01118 $this->tpl->setVariable("VALUE_ADD_CATEGORY", $this->lng->txt("add"));
01119 $this->tpl->setVariable("VALUE_ADD_PHRASE", $this->lng->txt("add_phrase"));
01120 $this->tpl->setVariable("TEXT_STANDARD_ANSWERS", $this->lng->txt("matrix_standard_answers"));
01121 $this->tpl->setVariable("TEXT_NEUTRAL_ANSWER", $this->lng->txt("matrix_neutral_answer"));
01122 if (!$hasneutralcolumn)
01123 {
01124 $this->tpl->setVariable("CATEGORY_NEUTRAL", $this->object->getColumnCount()+1);
01125 }
01126 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
01127
01128 $this->tpl->setVariable("TEXT_ROWS", $this->lng->txt("matrix_rows"));
01129 $this->tpl->setVariable("SAVEROWS", $this->lng->txt("save"));
01130 $this->tpl->setVariable("VALUE_ADD_ROW", $this->lng->txt("add"));
01131 $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
01132 $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
01133
01134 if ($_SESSION["spl_modified"])
01135 {
01136 $this->tpl->setVariable("FORM_DATA_MODIFIED_PRESS_SAVE", $this->lng->txt("form_data_modified_press_save"));
01137 }
01138 $questiontext = $this->object->getQuestiontext();
01139 $this->tpl->setVariable("QUESTION_TEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
01140 $this->tpl->parseCurrentBlock();
01141 }
01142
01143 function setQuestionTabs()
01144 {
01145 global $rbacsystem,$ilTabs;
01146 $this->ctrl->setParameterByClass("$guiclass", "sel_question_types", $this->getQuestionType());
01147 $this->ctrl->setParameterByClass("$guiclass", "q_id", $_GET["q_id"]);
01148
01149 if (($_GET["calling_survey"] > 0) || ($_GET["new_for_survey"] > 0))
01150 {
01151 $ref_id = $_GET["calling_survey"];
01152 if (!strlen($ref_id)) $ref_id = $_GET["new_for_survey"];
01153 $addurl = "";
01154 if (strlen($_GET["new_for_survey"]))
01155 {
01156 $addurl = "&new_id=" . $_GET["q_id"];
01157 }
01158 $ilTabs->setBackTarget($this->lng->txt("menubacktosurvey"), "ilias.php?baseClass=ilObjSurveyGUI&ref_id=$ref_id&cmd=questions" . $addurl);
01159 }
01160 else
01161 {
01162 $ilTabs->setBackTarget($this->lng->txt("spl"), $this->ctrl->getLinkTargetByClass("ilObjSurveyQuestionPoolGUI", "questions"));
01163 }
01164 if ($_GET["q_id"])
01165 {
01166 $ilTabs->addTarget("preview",
01167 $this->ctrl->getLinkTarget($this, "preview"),
01168 array("preview"),
01169 "",
01170 "");
01171
01172 $ilTabs->addTarget("layout",
01173 $this->ctrl->getLinkTarget($this, "layout"),
01174 array("layout", "saveLayout"),
01175 "",
01176 "");
01177 }
01178 if ($rbacsystem->checkAccess('edit', $_GET["ref_id"]))
01179 {
01180 $ilTabs->addTarget("edit_properties",
01181 $this->ctrl->getLinkTarget($this, "editQuestion"),
01182 array("editQuestion", "cancelExplorer", "linkChilds", "addGIT", "addST",
01183 "addPG", "editQuestion", "addMaterial", "removeMaterial",
01184 "save", "cancel"),
01185 "",
01186 "");
01187 }
01188
01189 if ($this->object->getId() > 0)
01190 {
01191 $ilTabs->addTarget("matrix_columns_rows",
01192 $this->ctrl->getLinkTarget($this, "categories"),
01193 array("categories", "addColumn", "addRow", "deleteRow", "moveColumn",
01194 "deleteColumn", "saveRowColEditor", "savePhrase", "addPhrase",
01195 "savePhrase", "addSelectedPhrase", "cancelViewPhrase", "confirmSavePhrase",
01196 "cancelSavePhrase", "confirmdeleteColumn", "canceldeleteColumn"),
01197 "",
01198 ""
01199 );
01200 }
01201
01202 if ($this->object->getId() > 0)
01203 {
01204 $title = $this->lng->txt("edit") . " "" . $this->object->getTitle() . """;
01205 }
01206 else
01207 {
01208 $title = $this->lng->txt("create_new") . " " . $this->lng->txt($this->getQuestionType());
01209 }
01210
01211 $this->tpl->setVariable("HEADER", $title);
01212 }
01213
01221 function addPhrase()
01222 {
01223 $complete = $this->writeRowColData(true);
01224 $this->ctrl->setParameterByClass(get_class($this), "q_id", $this->object->getId());
01225 $this->ctrl->setParameterByClass("ilobjsurveyquestionpoolgui", "q_id", $this->object->getId());
01226
01227 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_addphrase.html", "Modules/SurveyQuestionPool");
01228
01229
01230 $this->tpl->setCurrentBlock("hidden");
01231 $this->tpl->setVariable("HIDDEN_NAME", "id");
01232 $this->tpl->setVariable("HIDDEN_VALUE", $this->object->getId());
01233 $this->tpl->parseCurrentBlock();
01234
01235 include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
01236 $phrases =& ilSurveyPhrases::_getAvailablePhrases();
01237 $colors = array("tblrow1", "tblrow2");
01238 $counter = 0;
01239 foreach ($phrases as $phrase_id => $phrase_array)
01240 {
01241 $this->tpl->setCurrentBlock("phraserow");
01242 $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
01243 $this->tpl->setVariable("PHRASE_VALUE", $phrase_id);
01244 $this->tpl->setVariable("PHRASE_NAME", $phrase_array["title"]);
01245 $columns =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
01246 $this->tpl->setVariable("PHRASE_CONTENT", join($columns, ","));
01247 $this->tpl->parseCurrentBlock();
01248 }
01249
01250 $this->tpl->setCurrentBlock("adm_content");
01251 $this->tpl->setVariable("TEXT_CANCEL", $this->lng->txt("cancel"));
01252 $this->tpl->setVariable("TEXT_PHRASE", $this->lng->txt("phrase"));
01253 $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("categories"));
01254 $this->tpl->setVariable("TEXT_ADD_PHRASE", $this->lng->txt("add_phrase"));
01255 $this->tpl->setVariable("TEXT_INTRODUCTION",$this->lng->txt("add_phrase_introduction"));
01256 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "addPhrase"));
01257 $this->tpl->parseCurrentBlock();
01258 }
01259
01267 function cancelViewPhrase()
01268 {
01269 $this->ctrl->redirect($this, "categories");
01270 }
01271
01279 function addSelectedPhrase()
01280 {
01281 if (strcmp($_POST["phrases"], "") == 0)
01282 {
01283 ilUtil::sendInfo($this->lng->txt("select_phrase_to_add"));
01284 $this->addPhrase();
01285 }
01286 else
01287 {
01288 if (strcmp($this->object->getPhrase($_POST["phrases"]), "dp_standard_numbers") != 0)
01289 {
01290 $this->object->addPhrase($_POST["phrases"]);
01291 $this->object->saveColumnsToDb();
01292 }
01293 else
01294 {
01295 $this->addStandardNumbers();
01296 return;
01297 }
01298 $this->ctrl->redirect($this, "categories");
01299 }
01300 }
01301
01309 function addStandardNumbers()
01310 {
01311 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_addphrase_standard_numbers.html", "Modules/SurveyQuestionPool");
01312
01313
01314 $this->tpl->setCurrentBlock("hidden");
01315 $this->tpl->setVariable("HIDDEN_NAME", "id");
01316 $this->tpl->setVariable("HIDDEN_VALUE", $this->object->getId());
01317 $this->tpl->parseCurrentBlock();
01318
01319 $this->tpl->setCurrentBlock("adm_content");
01320 $this->tpl->setVariable("ADD_STANDARD_NUMBERS", $this->lng->txt("add_standard_numbers"));
01321 $this->tpl->setVariable("TEXT_ADD_LIMITS", $this->lng->txt("add_limits_for_standard_numbers"));
01322 $this->tpl->setVariable("TEXT_LOWER_LIMIT",$this->lng->txt("lower_limit"));
01323 $this->tpl->setVariable("TEXT_UPPER_LIMIT",$this->lng->txt("upper_limit"));
01324 $this->tpl->setVariable("VALUE_LOWER_LIMIT", $_POST["lower_limit"]);
01325 $this->tpl->setVariable("VALUE_UPPER_LIMIT", $_POST["upper_limit"]);
01326 $this->tpl->setVariable("BTN_ADD",$this->lng->txt("add_phrase"));
01327 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
01328 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "addStandardNumbers"));
01329 $this->tpl->parseCurrentBlock();
01330 }
01331
01339 function cancelStandardNumbers()
01340 {
01341 $this->ctrl->redirect($this, "categories");
01342 }
01343
01351 function insertStandardNumbers()
01352 {
01353 if ((strcmp($_POST["lower_limit"], "") == 0) or (strcmp($_POST["upper_limit"], "") == 0))
01354 {
01355 ilUtil::sendInfo($this->lng->txt("missing_upper_or_lower_limit"));
01356 $this->addStandardNumbers();
01357 }
01358 else if ((int)$_POST["upper_limit"] <= (int)$_POST["lower_limit"])
01359 {
01360 ilUtil::sendInfo($this->lng->txt("upper_limit_must_be_greater"));
01361 $this->addStandardNumbers();
01362 }
01363 else
01364 {
01365 $this->object->addStandardNumbers($_POST["lower_limit"], $_POST["upper_limit"]);
01366 $this->object->saveColumnsToDb();
01367 $this->ctrl->redirect($this, "categories");
01368 }
01369 }
01370
01378 function savePhrase()
01379 {
01380 $complete = $this->writeRowColData(true);
01381 if (!$complete)
01382 {
01383 $_SESSION["spl_modified"] = TRUE;
01384 ilUtil::sendInfo($this->errormessage);
01385 return $this->categories();
01386 }
01387 $nothing_selected = true;
01388 if (array_key_exists("chb_category", $_POST))
01389 {
01390 if (count($_POST["chb_category"]))
01391 {
01392 $nothing_selected = false;
01393 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_savephrase.html", "Modules/SurveyQuestionPool");
01394 $rowclass = array("tblrow1", "tblrow2");
01395 $counter = 0;
01396 foreach ($_POST["chb_category"] as $column)
01397 {
01398 $this->tpl->setCurrentBlock("row");
01399 $this->tpl->setVariable("TXT_TITLE", $this->object->getColumn($column));
01400 $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
01401 $this->tpl->parseCurrentBlock();
01402 $this->tpl->setCurrentBlock("hidden");
01403 $this->tpl->setVariable("HIDDEN_NAME", "chb_category[]");
01404 $this->tpl->setVariable("HIDDEN_VALUE", $column["title"]);
01405 $this->tpl->parseCurrentBlock();
01406 }
01407
01408 $this->tpl->setCurrentBlock("adm_content");
01409 $this->tpl->setVariable("SAVE_PHRASE_INTRODUCTION", $this->lng->txt("save_phrase_introduction"));
01410 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("enter_phrase_title"));
01411 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("category"));
01412 $this->tpl->setVariable("VALUE_PHRASE_TITLE", $_POST["phrase_title"]);
01413 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
01414 $this->tpl->setVariable("BTN_CONFIRM",$this->lng->txt("confirm"));
01415 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "savePhrase"));
01416 $this->tpl->parseCurrentBlock();
01417 }
01418 }
01419 if ($nothing_selected)
01420 {
01421 ilUtil::sendInfo($this->lng->txt("check_category_to_save_phrase"), true);
01422 $this->ctrl->redirect($this, "categories");
01423 }
01424 }
01425
01433 function cancelSavePhrase()
01434 {
01435 $this->ctrl->redirect($this, "categories");
01436 }
01437
01445 function confirmSavePhrase()
01446 {
01447 if (!$_POST["phrase_title"])
01448 {
01449 ilUtil::sendInfo($this->lng->txt("qpl_savephrase_empty"));
01450 $this->savePhrase();
01451 return;
01452 }
01453
01454 if ($this->object->phraseExists($_POST["phrase_title"]))
01455 {
01456 ilUtil::sendInfo($this->lng->txt("qpl_savephrase_exists"));
01457 $this->savePhrase();
01458 return;
01459 }
01460
01461 $this->object->savePhrase($_POST["chb_category"], $_POST["phrase_title"]);
01462 ilUtil::sendInfo($this->lng->txt("phrase_saved"), true);
01463 $this->ctrl->redirect($this, "categories");
01464 }
01465
01473 function addColumn()
01474 {
01475 $result = $this->writeRowColData();
01476 if ($result == FALSE)
01477 {
01478 ilUtil::sendInfo($this->errormessage);
01479 }
01480 $_SESSION["spl_modified"] = true;
01481 $this->categories();
01482 }
01483
01484
01492 function addRow()
01493 {
01494 $this->addColumn();
01495 }
01496
01505 function writeRowColData($save = FALSE)
01506 {
01507
01508 $this->object->flushColumns();
01509 $this->object->flushRows();
01510 $messages = array();
01511 $columnscomplete = TRUE;
01512 $rowscomplete = TRUE;
01513
01514 include_once "./Services/Utilities/classes/class.ilUtil.php";
01515 $cats = "";
01516 $rows = "";
01517 foreach ($_POST as $key => $value)
01518 {
01519 if (preg_match("/^category_(\d+)/", $key, $matches))
01520 {
01521 $this->object->addColumn(ilUtil::stripSlashes($value));
01522 $cats .= $value;
01523 }
01524 if (preg_match("/^row_(\d+)/", $key, $matches))
01525 {
01526 $this->object->addRow(ilUtil::stripSlashes($value));
01527 $rows .= $value;
01528 }
01529 }
01530
01531 if (strlen($cats) == 0)
01532 {
01533 $columnscomplete = FALSE;
01534 array_push($messages, $this->lng->txt("matrix_error_no_columns"));
01535 }
01536 if (strlen($rows) == 0)
01537 {
01538 $rowscomplete = FALSE;
01539 array_push($messages, $this->lng->txt("matrix_error_no_rows"));
01540 }
01541
01542
01543 $this->object->setNeutralColumn(ilUtil::stripSlashes($_POST["neutral"]));
01544
01545
01546 $this->object->setBipolarAdjective(0, ilUtil::stripSlashes($_POST["bipolar1"]));
01547 $this->object->setBipolarAdjective(1, ilUtil::stripSlashes($_POST["bipolar2"]));
01548
01549 if ($save)
01550 {
01551 $this->object->saveColumnsToDb();
01552 $this->object->saveRowsToDb();
01553 if (array_key_exists("bipolar1", $_POST))
01554 {
01555 $this->object->saveBipolarAdjectives(ilUtil::stripSlashes($_POST["bipolar1"]), ilUtil::stripSlashes($_POST["bipolar2"]));
01556 }
01557 }
01558
01559 if (count($messages))
01560 {
01561 $this->errormessage = implode("<br />", $messages);
01562 }
01563 return $columnscomplete && $rowscomplete;
01564 }
01565
01573 function saveRowColEditor()
01574 {
01575 global $ilUser;
01576
01577 $complete = $this->writeRowColData(true);
01578 if (!$complete)
01579 {
01580 $_SESSION["spl_modified"] = TRUE;
01581 ilUtil::sendInfo($this->errormessage);
01582 $this->categories();
01583 }
01584 else
01585 {
01586 $_SESSION["spl_modified"] = FALSE;
01587 ilUtil::sendInfo($this->lng->txt("saved_successfully"), true);
01588 $originalexists = $this->object->_questionExists($this->object->original_id);
01589 $this->ctrl->setParameter($this, "q_id", $this->object->getId());
01590 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
01591 if ($_GET["calling_survey"] && $originalexists && SurveyQuestion::_isWriteable($this->object->original_id, $ilUser->getId()))
01592 {
01593 $this->originalSyncForm();
01594 return;
01595 }
01596 else
01597 {
01598 $this->ctrl->redirect($this, "categories");
01599 }
01600 }
01601 }
01602
01610 function deleteColumn()
01611 {
01612 $this->writeRowColData();
01613 $nothing_selected = true;
01614 if (array_key_exists("chb_category", $_POST))
01615 {
01616 if (count($_POST["chb_category"]))
01617 {
01618 $nothing_selected = false;
01619 $this->object->removeColumns($_POST["chb_category"]);
01620 }
01621 }
01622 if ($nothing_selected)
01623 {
01624 ilUtil::sendInfo($this->lng->txt("matrix_column_delete_select_none"));
01625 }
01626 else
01627 {
01628 $_SESSION["spl_modified"] = true;
01629 }
01630 $this->categories();
01631 }
01632
01640 function deleteRow()
01641 {
01642 $this->writeRowColData();
01643 $nothing_selected = true;
01644 if (array_key_exists("chb_row", $_POST))
01645 {
01646 if (count($_POST["chb_row"]))
01647 {
01648 $nothing_selected = false;
01649 $this->object->removeRows($_POST["chb_row"]);
01650 }
01651 }
01652 if ($nothing_selected)
01653 {
01654 ilUtil::sendInfo($this->lng->txt("matrix_row_delete_select_none"));
01655 }
01656 else
01657 {
01658 $_SESSION["spl_modified"] = true;
01659 }
01660 $this->categories();
01661 }
01662
01671 function getCumulatedResultRow($counter, $css_class, $survey_id)
01672 {
01673 $output = "";
01674 include_once "./classes/class.ilTemplate.php";
01675 if (count($this->cumulated) == 0)
01676 {
01677 include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
01678 $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
01679 $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users);
01680 }
01681 $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_row.html", TRUE, TRUE, "Modules/Survey");
01682 $template->setVariable("QUESTION_TITLE", ($counter+1) . ". ".$this->object->getTitle());
01683 $maxlen = 37;
01684 $questiontext = preg_replace("/<[^>]+?>/ims", "", $this->object->getQuestiontext());
01685 if (strlen($questiontext) > $maxlen + 3)
01686 {
01687 $questiontext = substr($questiontext, 0, $maxlen) . "...";
01688 }
01689 $template->setVariable("QUESTION_TEXT", $questiontext);
01690 $template->setVariable("USERS_ANSWERED", $this->cumulated["TOTAL"]["USERS_ANSWERED"]);
01691 $template->setVariable("USERS_SKIPPED", $this->cumulated["TOTAL"]["USERS_SKIPPED"]);
01692 $template->setVariable("QUESTION_TYPE", $this->lng->txt($this->cumulated["TOTAL"]["QUESTION_TYPE"]));
01693 $template->setVariable("MODE", $this->cumulated["TOTAL"]["MODE"]);
01694 $template->setVariable("MODE_NR_OF_SELECTIONS", $this->cumulated["TOTAL"]["MODE_NR_OF_SELECTIONS"]);
01695 $template->setVariable("MEDIAN", $this->cumulated["TOTAL"]["MEDIAN"]);
01696 $template->setVariable("ARITHMETIC_MEAN", $this->cumulated["TOTAL"]["ARITHMETIC_MEAN"]);
01697 $template->setVariable("COLOR_CLASS", $css_class);
01698 $output = $template->get();
01699 foreach ($this->cumulated as $key => $value)
01700 {
01701 if (is_numeric($key))
01702 {
01703 $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_row_matrix.html", TRUE, TRUE, "Modules/Survey");
01704 $template->setVariable("QUESTION_TITLE", "");
01705 $template->setVariable("ROW", ($key+1) . ". " . $value["ROW"]);
01706 $template->setVariable("USERS_ANSWERED", $value["USERS_ANSWERED"]);
01707 $template->setVariable("USERS_SKIPPED", $value["USERS_SKIPPED"]);
01708 $template->setVariable("MODE", $value["MODE"]);
01709 $template->setVariable("MODE_NR_OF_SELECTIONS", $value["MODE_NR_OF_SELECTIONS"]);
01710 $template->setVariable("MEDIAN", $value["MEDIAN"]);
01711 $template->setVariable("ARITHMETIC_MEAN", $value["ARITHMETIC_MEAN"]);
01712 $template->setVariable("COLOR_CLASS", $css_class);
01713 $output .= $template->get();
01714 }
01715 }
01716 return $output;
01717 }
01718
01729 function getCumulatedResultsDetails($survey_id, $counter)
01730 {
01731 if (count($this->cumulated) == 0)
01732 {
01733 include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
01734 $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
01735 $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users);
01736 }
01737
01738 $output = "";
01739 include_once "./classes/class.ilTemplate.php";
01740 $template = new ilTemplate("tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE, "Modules/Survey");
01741
01742 $template->setCurrentBlock("detail_row");
01743 $template->setVariable("TEXT_OPTION", $this->lng->txt("question"));
01744 $questiontext = $this->object->getQuestiontext();
01745 $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
01746 $template->parseCurrentBlock();
01747 $template->setCurrentBlock("detail_row");
01748 $template->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
01749 $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
01750 $template->parseCurrentBlock();
01751 $template->setCurrentBlock("detail_row");
01752 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
01753 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["TOTAL"]["USERS_ANSWERED"]);
01754 $template->parseCurrentBlock();
01755 $template->setCurrentBlock("detail_row");
01756 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
01757 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["TOTAL"]["USERS_SKIPPED"]);
01758 $template->parseCurrentBlock();
01759
01760 $template->setCurrentBlock("detail_row");
01761 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
01762 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["TOTAL"]["MODE"]);
01763 $template->parseCurrentBlock();
01764 $template->setCurrentBlock("detail_row");
01765 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
01766 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["TOTAL"]["MODE_NR_OF_SELECTIONS"]);
01767 $template->parseCurrentBlock();
01768 $template->setCurrentBlock("detail_row");
01769 $template->setVariable("TEXT_OPTION", $this->lng->txt("median"));
01770 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["TOTAL"]["MEDIAN"]);
01771 $template->parseCurrentBlock();
01772
01773 $template->setCurrentBlock("detail_row");
01774 $template->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
01775 $columns = "";
01776 foreach ($this->cumulated["TOTAL"]["variables"] as $key => $value)
01777 {
01778 $columns .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
01779 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
01780 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
01781 }
01782 $columns = "<ol>$columns</ol>";
01783 $template->setVariable("TEXT_OPTION_VALUE", $columns);
01784 $template->parseCurrentBlock();
01785
01786 foreach ($this->cumulated as $key => $value)
01787 {
01788 if (is_numeric($key))
01789 {
01790 $template->setCurrentBlock("detail_row");
01791 $template->setVariable("TEXT_OPTION", $this->lng->txt("row"));
01792 $questiontext = $value["ROW"];
01793 $template->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
01794 $template->parseCurrentBlock();
01795 $template->setCurrentBlock("detail_row");
01796 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
01797 $template->setVariable("TEXT_OPTION_VALUE", $value["USERS_ANSWERED"]);
01798 $template->parseCurrentBlock();
01799 $template->setCurrentBlock("detail_row");
01800 $template->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
01801 $template->setVariable("TEXT_OPTION_VALUE", $value["USERS_SKIPPED"]);
01802 $template->parseCurrentBlock();
01803
01804 $template->setCurrentBlock("detail_row");
01805 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
01806 $template->setVariable("TEXT_OPTION_VALUE", $value["MODE"]);
01807 $template->parseCurrentBlock();
01808 $template->setCurrentBlock("detail_row");
01809 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
01810 $template->setVariable("TEXT_OPTION_VALUE", $value["MODE_NR_OF_SELECTIONS"]);
01811 $template->parseCurrentBlock();
01812 $template->setCurrentBlock("detail_row");
01813 $template->setVariable("TEXT_OPTION", $this->lng->txt("median"));
01814 $template->setVariable("TEXT_OPTION_VALUE", $value["MEDIAN"]);
01815 $template->parseCurrentBlock();
01816
01817 $template->setCurrentBlock("detail_row");
01818 $template->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
01819 $columns = "";
01820 foreach ($value["variables"] as $key => $value)
01821 {
01822 $columns .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
01823 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
01824 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
01825 }
01826 $columns = "<ol>$columns</ol>";
01827 $template->setVariable("TEXT_OPTION_VALUE", $columns);
01828 $template->parseCurrentBlock();
01829 }
01830 }
01831
01832
01833 foreach ($this->cumulated as $key => $value)
01834 {
01835 if (is_numeric($key))
01836 {
01837 $template->setCurrentBlock("chartimage");
01838 $template->setVariable("ALT_CHART", $this->lng->txt("chart"));
01839 $this->ctrl->setParameterByClass("ilsurveyevaluationgui", "type", $key);
01840 $this->ctrl->setParameterByClass("ilsurveyevaluationgui", "survey", $survey_id);
01841 $this->ctrl->setParameterByClass("ilsurveyevaluationgui", "question", $this->object->getId());
01842 $template->setVariable("CHART", $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "outChart"));
01843 $template->parseCurrentBlock();
01844 }
01845 }
01846 $template->setCurrentBlock("chart");
01847 $template->setVariable("TEXT_CHART", $this->lng->txt("chart"));
01848 $template->parseCurrentBlock();
01849
01850 $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
01851 $output = $template->get();
01852 return $output;
01853 }
01854
01855 }
01856 ?>