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);
114 include_once(
"./Services/RTE/classes/class.ilRTE.php");
136 if ($this->title and $this->author and $this->questiontext)
163 return ($this->maxchars) ? $this->maxchars : NULL;
176 if ($affectedRows == 1)
178 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
180 array($this->
getId())
182 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
183 array(
'integer',
'integer',
'integer',
'integer'),
197 function toXML($a_include_header = TRUE, $obligatory_state =
"")
199 include_once(
"./classes/class.ilXmlWriter.php");
202 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
203 $xml = $a_xml_writer->xmlDumpMem(FALSE);
204 if (!$a_include_header)
206 $pos = strpos($xml,
"?>");
207 $xml = substr($xml, $pos + 2);
220 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
223 "id" => $this->
getId(),
225 "type" => $this->getQuestiontype(),
228 $a_xml_writer->xmlStartTag(
"question", $attrs);
230 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
231 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
232 $a_xml_writer->xmlStartTag(
"questiontext");
234 $a_xml_writer->xmlEndTag(
"questiontext");
236 $a_xml_writer->xmlStartTag(
"responses");
246 $a_xml_writer->xmlElement(
"response_text", $attrs);
247 $a_xml_writer->xmlEndTag(
"responses");
249 if (count($this->material))
251 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
254 "label" => $this->material[
"title"]
256 $a_xml_writer->xmlStartTag(
"material", $attrs);
257 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
258 if (strcmp($matches[1],
"") != 0)
260 $intlink = $this->material[
"internal_link"];
262 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
263 $a_xml_writer->xmlEndTag(
"material");
267 $a_xml_writer->xmlEndTag(
"question");
279 $result = $ilDB->queryF(
"SELECT maxchars FROM svy_question WHERE question_id = %s",
286 return $row[
"maxchars"];
299 return "SurveyTextQuestion";
310 return "svy_qst_text";
321 $entered_value = $post_data[$this->
getId() .
"_text_question"];
323 if (strlen($entered_value))
325 array_push(
$data, array(
"textanswer" => $entered_value));
341 $entered_value = $post_data[$this->
getId() .
"_text_question"];
345 if (strlen($entered_value) == 0)
return $this->lng->txt(
"text_question_not_filled_out");
353 $char_list =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
354 $char_list .=
"abcdefghijklmnopqrstuvwxyz";
355 $char_list .=
"1234567890";
356 for($i = 0; $i < $length; $i++)
358 $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
359 if (!rand(0,5)) $random .=
' ';
373 $randomtext = $this->
randomText(rand(25,100));
374 $next_id = $ilDB->nextId(
'svy_answer');
375 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
376 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
377 array($next_id, $this->
getId(), $active_id, NULL, $randomtext, time())
385 include_once
"./Services/Utilities/classes/class.ilUtil.php";
390 $entered_value = substr($entered_value, 0,
$maxchars);
392 if (strlen($entered_value) == 0)
return;
393 $next_id = $ilDB->nextId(
'svy_answer');
394 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
395 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
396 array($next_id, $this->
getId(), $active_id, NULL, (strlen($entered_value)) ? $entered_value : NULL, time())
404 $question_id = $this->
getId();
406 $result_array = array();
408 $textvalues = array();
410 $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",
411 array(
'integer',
'integer'),
418 array_push($textvalues, $row[
"textanswer"]);
423 $result_array[
"USERS_ANSWERED"] =
$result->numRows();
424 $result_array[
"USERS_SKIPPED"] = $nr_of_users -
$result->numRows();
425 $result_array[
"QUESTION_TYPE"] =
"SurveyTextQuestion";
426 $result_array[
"textvalues"] = $textvalues;
427 return $result_array;
441 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
442 $worksheet =& $workbook->addWorksheet();
450 $worksheet->write(3, 1, $eval_data[
"USERS_ANSWERED"]);
452 $worksheet->write(4, 1, $eval_data[
"USERS_SKIPPED"]);
457 if (is_array($eval_data[
"textvalues"]))
459 foreach ($eval_data[
"textvalues"] as $textvalue)
475 if (count($resultset[
"answers"][$this->
getId()]))
477 foreach ($resultset[
"answers"][$this->
getId()] as
$key => $answer)
479 array_push($a_array, $answer[
"textanswer"]);
484 array_push($a_array, $this->lng->txt(
"skipped"));
501 $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",
502 array(
'integer',
'integer'),
507 $answers[
$row[
"active_fi"]] = $row[
"textanswer"];
522 if (
$data[
"maxlength"] > 0)
526 if (
$data[
"rows"] > 0)
530 if (
$data[
"columns"] > 0)
556 return ($this->textwidth) ? $this->textwidth : NULL;
567 return ($this->textheight) ? $this->textheight : NULL;
578 if ($a_textwidth < 1)
580 $this->textwidth = 50;
584 $this->textwidth = $a_textwidth;
596 if ($a_textheight < 1)
598 $this->textheight = 5;
602 $this->textheight = $a_textheight;