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");
137 if ($this->title and $this->author and $this->questiontext)
164 return ($this->maxchars) ? $this->maxchars : NULL;
177 if ($affectedRows == 1)
179 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
181 array($this->
getId())
183 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
184 array(
'integer',
'integer',
'integer',
'integer'),
198 function toXML($a_include_header = TRUE, $obligatory_state =
"")
200 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
203 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
204 $xml = $a_xml_writer->xmlDumpMem(FALSE);
205 if (!$a_include_header)
207 $pos = strpos($xml,
"?>");
208 $xml = substr($xml, $pos + 2);
221 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
224 "id" => $this->
getId(),
226 "type" => $this->getQuestiontype(),
229 $a_xml_writer->xmlStartTag(
"question", $attrs);
231 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
232 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
233 if (strlen($this->label))
236 "label" => $this->label,
243 $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
245 $a_xml_writer->xmlEndTag(
"questiontext");
247 $a_xml_writer->xmlStartTag(
"responses");
257 $a_xml_writer->xmlElement(
"response_text", $attrs);
258 $a_xml_writer->xmlEndTag(
"responses");
260 if (count($this->material))
262 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
265 "label" => $this->material[
"title"]
267 $a_xml_writer->xmlStartTag(
"material", $attrs);
268 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
269 if (strcmp($matches[1],
"") != 0)
271 $intlink = $this->material[
"internal_link"];
273 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
274 $a_xml_writer->xmlEndTag(
"material");
278 $a_xml_writer->xmlEndTag(
"question");
290 $result = $ilDB->queryF(
"SELECT maxchars FROM svy_question WHERE question_id = %s",
297 return $row[
"maxchars"];
310 return "SurveyTextQuestion";
321 return "svy_qst_text";
332 $entered_value = $post_data[$this->
getId() .
"_text_question"];
334 if (strlen($entered_value))
336 array_push(
$data, array(
"textanswer" => $entered_value));
352 $entered_value = $post_data[$this->
getId() .
"_text_question"];
356 if (strlen($entered_value) == 0)
return $this->lng->txt(
"text_question_not_filled_out");
364 $char_list =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
365 $char_list .=
"abcdefghijklmnopqrstuvwxyz";
366 $char_list .=
"1234567890";
367 for($i = 0; $i < $length; $i++)
369 $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
370 if (!rand(0,5)) $random .=
' ';
384 $randomtext = $this->
randomText(rand(25,100));
385 $next_id = $ilDB->nextId(
'svy_answer');
386 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
387 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
388 array($next_id, $this->
getId(), $active_id, NULL, $randomtext, time())
396 include_once
"./Services/Utilities/classes/class.ilUtil.php";
401 $entered_value = substr($entered_value, 0,
$maxchars);
403 if (strlen($entered_value) == 0)
return;
404 $next_id = $ilDB->nextId(
'svy_answer');
405 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
406 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
407 array($next_id, $this->
getId(), $active_id, NULL, (strlen($entered_value)) ? $entered_value : NULL, time())
415 $question_id = $this->
getId();
417 $result_array = array();
419 $textvalues = array();
421 $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",
422 array(
'integer',
'integer'),
429 array_push($textvalues, $row[
"textanswer"]);
434 $result_array[
"USERS_ANSWERED"] =
$result->numRows();
435 $result_array[
"USERS_SKIPPED"] = $nr_of_users -
$result->numRows();
436 $result_array[
"QUESTION_TYPE"] =
"SurveyTextQuestion";
437 $result_array[
"textvalues"] = $textvalues;
438 return $result_array;
452 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
453 $worksheet =& $workbook->addWorksheet();
455 switch ($export_label)
481 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_ANSWERED"]);
484 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_SKIPPED"]);
489 if (is_array($eval_data[
"textvalues"]))
491 foreach ($eval_data[
"textvalues"] as $textvalue)
507 if (count($resultset[
"answers"][$this->
getId()]))
509 foreach ($resultset[
"answers"][$this->
getId()] as $key => $answer)
511 array_push($a_array, $answer[
"textanswer"]);
516 array_push($a_array, $this->lng->txt(
"skipped"));
533 $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",
534 array(
'integer',
'integer'),
539 $answers[
$row[
"active_fi"]] = $row[
"textanswer"];
554 if (
$data[
"maxlength"] > 0)
558 if (
$data[
"rows"] > 0)
562 if (
$data[
"columns"] > 0)
588 return ($this->textwidth) ? $this->textwidth : NULL;
599 return ($this->textheight) ? $this->textheight : NULL;
610 if ($a_textwidth < 1)
612 $this->textwidth = 50;
616 $this->textwidth = $a_textwidth;
628 if ($a_textheight < 1)
630 $this->textheight = 5;
634 $this->textheight = $a_textheight;