ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilEssayKeywordWizardInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
5
7{
13 public function setValue($a_value)
14 {
15 $this->values = array();
16 if (is_array($a_value)) {
17 if (is_array($a_value['answer'])) {
18 foreach ($a_value['answer'] as $index => $value) {
19 include_once "./Modules/TestQuestionPool/classes/class.assAnswerMultipleResponseImage.php";
20 $answer = new ASS_AnswerMultipleResponseImage($value, $a_value['points'][$index], $index, $a_value['points_unchecked'][$index], $a_value['imagename'][$index]);
21 array_push($this->values, $answer);
22 }
23 }
24 }
25 }
26
32 public function checkInput()
33 {
34 global $lng;
35
36 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
37 if (is_array($_POST[$this->getPostVar()])) {
39 $_POST[$this->getPostVar()],
40 false,
42 "assessment"
43 )
44 );
45 }
46 $foundvalues = $_POST[$this->getPostVar()];
47 if (is_array($foundvalues)) {
48 // check answers
49 if (is_array($foundvalues['answer'])) {
50 foreach ($foundvalues['answer'] as $aidx => $answervalue) {
51 if (((strlen($answervalue)) == 0) && (strlen($foundvalues['imagename'][$aidx]) == 0)) {
52 $this->setAlert($lng->txt("msg_input_is_required"));
53 return false;
54 }
55 }
56 }
57 // check points
58 $max = 0;
59 if (is_array($foundvalues['points'])) {
60 foreach ($foundvalues['points'] as $points) {
61 if ($points > $max) {
62 $max = $points;
63 }
64 if (((strlen($points)) == 0) || (!is_numeric($points))) {
65 $this->setAlert($lng->txt("form_msg_numeric_value_required"));
66 return false;
67 }
68 }
69 }
70 if ($max == 0) {
71 $this->setAlert($lng->txt("enter_enough_positive_points"));
72 return false;
73 }
74 } else {
75 $this->setAlert($lng->txt("msg_input_is_required"));
76 return false;
77 }
78
79 return $this->checkSubItemsInput();
80 }
81
87 public function insert($a_tpl)
88 {
89 global $lng;
90
91 $tpl = new ilTemplate("tpl.prop_essaykeywordswizardinput.html", true, true, "Modules/TestQuestionPool");
92 $i = 0;
93 foreach ($this->values as $value) {
94 if ($this->getSingleline()) {
95 if (is_object($value)) {
96 $tpl->setCurrentBlock("prop_text_propval");
97 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->getAnswertext()));
98 $tpl->parseCurrentBlock();
99 $tpl->setCurrentBlock("prop_points_propval");
100 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->getPointsChecked()));
101 $tpl->parseCurrentBlock();
102 }
103 $tpl->setCurrentBlock('singleline');
104 $tpl->setVariable("SIZE", $this->getSize());
105 $tpl->setVariable("SINGLELINE_ID", $this->getPostVar() . "[answer][$i]");
106 $tpl->setVariable("SINGLELINE_ROW_NUMBER", $i);
107 $tpl->setVariable("SINGLELINE_POST_VAR", $this->getPostVar());
108 $tpl->setVariable("MAXLENGTH", $this->getMaxLength());
109 if ($this->getDisabled()) {
110 $tpl->setVariable("DISABLED_SINGLELINE", " disabled=\"disabled\"");
111 }
112 $tpl->parseCurrentBlock();
113 } else {
114 if (!$this->getSingleline()) {
115 if (is_object($value)) {
116 $tpl->setCurrentBlock("prop_points_propval");
117 $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($value->getPoints()));
118 $tpl->parseCurrentBlock();
119 }
120 }
121 }
122
123 $tpl->setCurrentBlock("row");
124 $tpl->setVariable("POST_VAR", $this->getPostVar());
125 $tpl->setVariable("ROW_NUMBER", $i);
126 $tpl->setVariable("ID", $this->getPostVar() . "[answer][$i]");
127 $tpl->setVariable("POINTS_ID", $this->getPostVar() . "[points][$i]");
128 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
129 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
130 if ($this->getDisabled()) {
131 $tpl->setVariable("DISABLED_POINTS", " disabled=\"disabled\"");
132 }
133 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
134 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
135 $tpl->parseCurrentBlock();
136 $i++;
137 }
138
139 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
140 $tpl->setVariable("TEXT_YES", $lng->txt('yes'));
141 $tpl->setVariable("TEXT_NO", $lng->txt('no'));
142 $tpl->setVariable("DELETE_IMAGE_HEADER", $lng->txt('delete_image_header'));
143 $tpl->setVariable("DELETE_IMAGE_QUESTION", $lng->txt('delete_image_question'));
144 $tpl->setVariable("ANSWER_TEXT", $lng->txt('answer_text'));
145 $tpl->setVariable("POINTS_TEXT", $lng->txt('points'));
146 $tpl->setVariable("COMMANDS_TEXT", $lng->txt('actions'));
147 $tpl->setVariable("POINTS_CHECKED_TEXT", $lng->txt('checkbox_checked'));
148
149 $a_tpl->setCurrentBlock("prop_generic");
150 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
151 $a_tpl->parseCurrentBlock();
152
153 global $tpl;
154 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
155 $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/essaykeywordwizard.js");
156 }
157}
$tpl
Definition: ilias.php:10
$_POST["username"]
ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked,...
An exception for terminatinating execution or to throw for unit testing.
checkInput()
Check input, strip slashes etc.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
static _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
This class represents a single choice wizard property in a property form.
special template class to simplify handling of ITX/PEAR
getMaxLength()
Get Max Length.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$i
Definition: disco.tpl.php:19
$index
Definition: metadata.php:60