53 $this->show_wizard =
false;
54 $this->show_save_phrase =
false;
55 $this->categorytext = $lng->txt(
'answer');
56 $this->use_other_answer =
false;
66 $this->use_other_answer = ($a_value) ?
true :
false;
71 if (!is_object($this->values))
return 0;
72 return $this->values->getCategoryCount();
77 if (is_object($this->values))
80 for ($i = 0; $i < $this->values->getCategoryCount(); $i++)
82 $cat = $this->values->getCategory($i);
83 if ($cat->neutral == 0) $scale += 1;
95 $this->show_neutral_category = $a_value;
105 $this->neutral_category_title = $a_title;
120 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
122 if (is_array($a_value))
124 if (is_array($a_value[
'answer']))
126 foreach ($a_value[
'answer'] as $index =>
$value)
128 $this->values->addCategory(
$value, $a_value[
'other'][$index], null, null, $a_value[
'scale'][$index]);
132 if (array_key_exists(
'neutral', $a_value))
134 $this->values->addCategory($a_value[
'neutral'], 0, 1, null,
$_POST[$this->postvar .
'_neutral_scale']);
145 $this->values = $a_values;
165 $this->allowMove = $a_allow_move;
180 $this->show_wizard = $a_value;
190 $this->categorytext = $a_text;
200 $this->show_save_phrase = $a_value;
215 $this->disabled_scale = $a_value;
228 if (is_array($foundvalues))
231 if (is_array($foundvalues[
'answer']))
233 foreach ($foundvalues[
'answer'] as $idx => $answervalue)
235 if (((strlen($answervalue)) == 0) && ($this->
getRequired() && (!$foundvalues[
'other'][$idx])))
237 $this->
setAlert($lng->txt(
"msg_input_is_required"));
243 if (array_key_exists(
'neutral', $foundvalues))
245 if ((strlen($foundvalues[
'neutral']) == 0) && ($this->getRequired))
247 $this->
setAlert($lng->txt(
"msg_input_is_required"));
252 if (is_array($foundvalues[
'scale']))
254 foreach ($foundvalues[
'scale'] as $scale)
256 if ((strlen($scale)) == 0)
258 $this->
setAlert($lng->txt(
"msg_input_is_required"));
264 if (is_array($foundvalues[
'scale']))
266 if (count(array_unique($foundvalues[
'scale'])) != count($foundvalues[
'scale']))
268 $this->
setAlert($lng->txt(
"msg_duplicate_scale"));
273 if (strlen(
$_POST[$this->postvar .
'_neutral_scale']))
275 if (is_array($foundvalues[
'scale']))
277 if (in_array(
$_POST[$this->postvar .
'_neutral_scale'], $foundvalues[
'scale']))
279 $this->
setAlert($lng->txt(
"msg_duplicate_scale"));
287 $this->
setAlert($lng->txt(
"msg_input_is_required"));
302 $neutral_category = null;
303 $tpl =
new ilTemplate(
"tpl.prop_categorywizardinput.html",
true,
true,
"Modules/SurveyQuestionPool");
305 if (is_object($this->values))
307 for ($i = 0; $i < $this->values->getCategoryCount(); $i++)
309 $cat = $this->values->getCategory($i);
312 $tpl->setCurrentBlock(
"prop_text_propval");
314 $tpl->parseCurrentBlock();
315 $tpl->setCurrentBlock(
"prop_scale_propval");
317 $tpl->parseCurrentBlock();
321 $tpl->setCurrentBlock(
"other_answer_checkbox");
323 $tpl->setVariable(
"OTHER_ID", $this->
getPostVar() .
"[other][$i]");
324 $tpl->setVariable(
"ROW_NUMBER", $i);
327 $tpl->setVariable(
"CHECKED_OTHER",
' checked="checked"');
329 $tpl->parseCurrentBlock();
334 $tpl->setCurrentBlock(
"move");
335 $tpl->setVariable(
"CMD_UP",
"cmd[up" . $this->
getFieldId() .
"][$i]");
336 $tpl->setVariable(
"CMD_DOWN",
"cmd[down" . $this->
getFieldId() .
"][$i]");
340 $tpl->parseCurrentBlock();
342 $tpl->setCurrentBlock(
"row");
343 $class = ($i % 2 == 0) ?
"even" :
"odd";
344 if ($i == 0) $class .=
" first";
345 if ($i == $this->values->getCategoryCount()-1) $class .=
" last";
346 $tpl->setVariable(
"ROW_CLASS", $class);
348 $tpl->setVariable(
"ROW_NUMBER", $i);
354 $tpl->setVariable(
"DISABLED",
" disabled=\"disabled\"");
357 $tpl->setVariable(
"SCALE_ID", $this->
getPostVar() .
"[scale][$i]");
360 $tpl->setVariable(
"DISABLED_SCALE",
" disabled=\"disabled\"");
363 $tpl->setVariable(
"CMD_ADD",
"cmd[add" . $this->
getFieldId() .
"][$i]");
364 $tpl->setVariable(
"CMD_REMOVE",
"cmd[remove" . $this->
getFieldId() .
"][$i]");
367 $tpl->parseCurrentBlock();
371 $neutral_category = $cat;
378 $tpl->setCurrentBlock(
"wizard");
379 $tpl->setVariable(
"CMD_WIZARD",
'cmd[wizard' . $this->
getFieldId() .
']');
381 $tpl->setVariable(
"WIZARD_TEXT", $lng->txt(
'add_phrase'));
382 $tpl->parseCurrentBlock();
387 $tpl->setCurrentBlock(
'savephrase');
389 $tpl->setVariable(
"VALUE_SAVE_PHRASE", $lng->txt(
'save_phrase'));
390 $tpl->parseCurrentBlock();
395 if (is_object($neutral_category) && strlen($neutral_category->title))
397 $tpl->setCurrentBlock(
"prop_text_neutral_propval");
399 $tpl->parseCurrentBlock();
403 $tpl->setCurrentBlock(
"neutral_category_title");
405 $tpl->parseCurrentBlock();
407 $tpl->setCurrentBlock(
"prop_scale_neutral_propval");
408 $scale = ($neutral_category->scale > 0) ? $neutral_category->scale : $this->values->getNewScale();
410 $tpl->parseCurrentBlock();
414 $tpl->touchBlock(
'other_answer_neutral');
417 $tpl->setCurrentBlock(
'neutral_row');
424 $tpl->setVariable(
"DISABLED",
" disabled=\"disabled\"");
426 $tpl->setVariable(
"SCALE_ID", $this->
getPostVar() .
"_neutral_scale");
429 $tpl->setVariable(
"DISABLED_SCALE",
" disabled=\"disabled\"");
431 $tpl->parseCurrentBlock();
436 $tpl->setCurrentBlock(
'other_answer_title');
437 $tpl->setVariable(
"OTHER_TEXT", $lng->txt(
'use_other_answer'));
438 $tpl->parseCurrentBlock();
443 $tpl->setVariable(
"SCALE_TEXT", $lng->txt(
'scale'));
444 $tpl->setVariable(
"ACTIONS_TEXT", $lng->txt(
'actions'));
446 $a_tpl->setCurrentBlock(
"prop_generic");
447 $a_tpl->setVariable(
"PROP_GENERIC",
$tpl->get());
448 $a_tpl->parseCurrentBlock();
451 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
453 $tpl->addJavascript(
"./Modules/SurveyQuestionPool/templates/default/categorywizard.js");