24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
63 $this->textwidth = 50;
64 $this->textheight = 5;
83 return $ilDB->fetchAssoc(
$result);
110 $this->label =
$data[
'label'];
115 include_once(
"./Services/RTE/classes/class.ilRTE.php");
168 return ($this->maxchars) ? $this->maxchars : NULL;
181 if ($affectedRows == 1)
183 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
185 array($this->
getId())
187 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
188 array(
'integer',
'integer',
'integer',
'integer'),
202 function toXML($a_include_header = TRUE, $obligatory_state =
"")
204 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
207 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
208 $xml = $a_xml_writer->xmlDumpMem(FALSE);
209 if (!$a_include_header)
211 $pos = strpos($xml,
"?>");
212 $xml = substr($xml, $pos + 2);
225 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
228 "id" => $this->
getId(),
230 "type" => $this->getQuestiontype(),
233 $a_xml_writer->xmlStartTag(
"question", $attrs);
235 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
236 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
237 if (strlen($this->label))
240 "label" => $this->label,
247 $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
249 $a_xml_writer->xmlEndTag(
"questiontext");
251 $a_xml_writer->xmlStartTag(
"responses");
261 $a_xml_writer->xmlElement(
"response_text", $attrs);
262 $a_xml_writer->xmlEndTag(
"responses");
264 if (count($this->material))
266 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
269 "label" => $this->material[
"title"]
271 $a_xml_writer->xmlStartTag(
"material", $attrs);
272 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
273 if (strcmp($matches[1],
"") != 0)
275 $intlink = $this->material[
"internal_link"];
277 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
278 $a_xml_writer->xmlEndTag(
"material");
282 $a_xml_writer->xmlEndTag(
"question");
294 $result = $ilDB->queryF(
"SELECT maxchars FROM svy_question WHERE question_id = %s",
301 return $row[
"maxchars"];
314 return "SurveyTextQuestion";
325 return "svy_qst_text";
336 $entered_value = $post_data[$this->
getId() .
"_text_question"];
338 if (strlen($entered_value))
340 array_push(
$data, array(
"textanswer" => $entered_value));
356 $entered_value = $post_data[$this->
getId() .
"_text_question"];
360 if (strlen($entered_value) == 0)
return $this->lng->txt(
"text_question_not_filled_out");
368 $char_list =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
369 $char_list .=
"abcdefghijklmnopqrstuvwxyz";
370 $char_list .=
"1234567890";
371 for($i = 0; $i < $length; $i++)
373 $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
374 if (!rand(0,5)) $random .=
' ';
388 $randomtext = $this->
randomText(rand(25,100));
389 $next_id = $ilDB->nextId(
'svy_answer');
390 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
391 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
392 array($next_id, $this->
getId(), $active_id, NULL, $randomtext, time())
400 include_once
"./Services/Utilities/classes/class.ilUtil.php";
405 $entered_value = substr($entered_value, 0,
$maxchars);
410 return array(array(
"value"=>null,
"textanswer"=>$entered_value));
412 if (strlen($entered_value) == 0)
return;
414 $next_id = $ilDB->nextId(
'svy_answer');
415 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
416 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
417 array($next_id, $this->
getId(), $active_id, NULL, (strlen($entered_value)) ? $entered_value : NULL, time())
425 $question_id = $this->
getId();
427 $result_array = array();
429 $textvalues = array();
431 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
432 array(
'integer',
'integer'),
439 array_push($textvalues, $row[
"textanswer"]);
444 $result_array[
"USERS_ANSWERED"] =
$result->numRows();
445 $result_array[
"USERS_SKIPPED"] = $nr_of_users -
$result->numRows();
446 $result_array[
"QUESTION_TYPE"] =
"SurveyTextQuestion";
447 $result_array[
"textvalues"] = $textvalues;
448 return $result_array;
462 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
463 $worksheet =& $workbook->addWorksheet();
465 switch ($export_label)
491 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_ANSWERED"]);
494 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_SKIPPED"]);
499 if (is_array($eval_data[
"textvalues"]))
501 foreach ($eval_data[
"textvalues"] as $textvalue)
517 if (count($resultset[
"answers"][$this->
getId()]))
519 foreach ($resultset[
"answers"][$this->
getId()] as $key => $answer)
521 array_push($a_array, $answer[
"textanswer"]);
526 array_push($a_array, $this->lng->txt(
"skipped"));
543 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_finished.survey_fi = %s AND svy_answer.question_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
544 array(
'integer',
'integer'),
549 $answers[
$row[
"active_fi"]] = $row[
"textanswer"];
564 if (
$data[
"maxlength"] > 0)
568 if (
$data[
"rows"] > 0)
572 if (
$data[
"columns"] > 0)
598 return ($this->textwidth) ? $this->textwidth : NULL;
609 return ($this->textheight) ? $this->textheight : NULL;
620 if ($a_textwidth < 1)
622 $this->textwidth = 50;
626 $this->textwidth = $a_textwidth;
638 if ($a_textheight < 1)
640 $this->textheight = 5;
644 $this->textheight = $a_textheight;