24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
62 $this->textwidth = 50;
63 $this->textheight = 5;
82 return $ilDB->fetchAssoc(
$result);
106 $data = $ilDB->fetchAssoc(
$result);
107 $this->
setId($data[
"question_id"]);
109 $this->label = $data[
'label'];
114 include_once(
"./Services/RTE/classes/class.ilRTE.php");
167 return ($this->maxchars) ? $this->maxchars : NULL;
180 if ($affectedRows == 1)
182 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
184 array($this->
getId())
186 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxchars, width, height) VALUES (%s, %s, %s, %s)",
187 array(
'integer',
'integer',
'integer',
'integer'),
201 function toXML($a_include_header = TRUE, $obligatory_state =
"")
203 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
206 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
207 $xml = $a_xml_writer->xmlDumpMem(FALSE);
208 if (!$a_include_header)
210 $pos = strpos($xml,
"?>");
211 $xml = substr($xml, $pos + 2);
224 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
227 "id" => $this->
getId(),
229 "type" => $this->getQuestiontype(),
232 $a_xml_writer->xmlStartTag(
"question", $attrs);
234 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
235 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
236 if (strlen($this->label))
239 "label" => $this->label,
246 $a_xml_writer->xmlStartTag(
"questiontext", $attrs);
248 $a_xml_writer->xmlEndTag(
"questiontext");
250 $a_xml_writer->xmlStartTag(
"responses");
260 $a_xml_writer->xmlElement(
"response_text", $attrs);
261 $a_xml_writer->xmlEndTag(
"responses");
263 if (count($this->material))
265 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
268 "label" => $this->material[
"title"]
270 $a_xml_writer->xmlStartTag(
"material", $attrs);
271 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
272 if (strcmp($matches[1],
"") != 0)
274 $intlink = $this->material[
"internal_link"];
276 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
277 $a_xml_writer->xmlEndTag(
"material");
281 $a_xml_writer->xmlEndTag(
"question");
293 $result = $ilDB->queryF(
"SELECT maxchars FROM svy_question WHERE question_id = %s",
300 return $row[
"maxchars"];
313 return "SurveyTextQuestion";
324 return "svy_qst_text";
335 $entered_value = $post_data[$this->
getId() .
"_text_question"];
337 if (strlen($entered_value))
339 array_push($data, array(
"textanswer" => $entered_value));
355 $entered_value = $post_data[$this->
getId() .
"_text_question"];
359 if (strlen($entered_value) == 0)
return $this->lng->txt(
"text_question_not_filled_out");
367 $char_list =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
368 $char_list .=
"abcdefghijklmnopqrstuvwxyz";
369 $char_list .=
"1234567890";
370 for($i = 0; $i < $length; $i++)
372 $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
373 if (!rand(0,5)) $random .=
' ';
387 $randomtext = $this->
randomText(rand(25,100));
388 $next_id = $ilDB->nextId(
'svy_answer');
389 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
390 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
391 array($next_id, $this->
getId(), $active_id, NULL, $randomtext, time())
399 include_once
"./Services/Utilities/classes/class.ilUtil.php";
404 $entered_value = substr($entered_value, 0,
$maxchars);
409 return array(array(
"value"=>null,
"textanswer"=>$entered_value));
411 if (strlen($entered_value) == 0)
return;
413 $next_id = $ilDB->nextId(
'svy_answer');
414 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
415 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
416 array($next_id, $this->
getId(), $active_id, NULL, (strlen($entered_value)) ? $entered_value : NULL, time())
424 $question_id = $this->
getId();
426 $result_array = array();
428 $textvalues = array();
430 $sql =
"SELECT svy_answer.* FROM svy_answer".
431 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
432 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id,
"integer").
433 " AND svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer");
436 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
443 array_push($textvalues, $row[
"textanswer"]);
448 $result_array[
"USERS_ANSWERED"] =
$result->numRows();
449 $result_array[
"USERS_SKIPPED"] = $nr_of_users -
$result->numRows();
450 $result_array[
"QUESTION_TYPE"] =
"SurveyTextQuestion";
451 $result_array[
"textvalues"] = $textvalues;
452 return $result_array;
466 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
467 $worksheet =& $workbook->addWorksheet();
469 switch ($export_label)
495 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_ANSWERED"]);
498 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_SKIPPED"]);
503 if (is_array($eval_data[
"textvalues"]))
505 foreach ($eval_data[
"textvalues"] as $textvalue)
521 if (count($resultset[
"answers"][$this->
getId()]))
523 foreach ($resultset[
"answers"][$this->
getId()] as $key => $answer)
525 array_push($a_array, $answer[
"textanswer"]);
547 $sql =
"SELECT svy_answer.* FROM svy_answer, svy_finished".
548 " WHERE svy_finished.survey_fi = ".$ilDB->quote(
$survey_id,
"integer").
549 " AND svy_answer.question_fi = ".$ilDB->quote($this->
getId(),
"integer").
550 " AND svy_finished.finished_id = svy_answer.active_fi";
553 $sql .=
" AND ".$ilDB->in(
"svy_finished.finished_id", $finished_ids,
"",
"integer");
558 $answers[
$row[
"active_fi"]] = $row[
"textanswer"];
571 foreach ($a_data as
$id => $data)
573 if ($data[
"maxlength"] > 0)
577 if ($data[
"rows"] > 0)
581 if ($data[
"columns"] > 0)
607 return ($this->textwidth) ? $this->textwidth : NULL;
618 return ($this->textheight) ? $this->textheight : NULL;
629 if ($a_textwidth < 1)
631 $this->textwidth = 50;
635 $this->textwidth = $a_textwidth;
647 if ($a_textheight < 1)
649 $this->textheight = 5;
653 $this->textheight = $a_textheight;