23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
68 if (($this->title) and ($this->author) and ($this->question) and ($this->
getMaximumPoints() > 0))
90 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
94 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxsize, allowedextensions) VALUES (%s, %s, %s)",
95 array(
"integer",
"float",
"text"),
118 if ($result->numRows() == 1)
120 $data = $ilDB->fetchAssoc($result);
121 $this->
setId($question_id);
132 include_once(
"./Services/RTE/classes/class.ilRTE.php");
152 $this_id = $this->
getId();
154 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
181 $clone->copyPageOfQuestion($this_id);
183 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
185 $clone->duplicateFeedbackGeneric($this_id);
187 $clone->onDuplicate($this_id);
203 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
206 $source_questionpool = $this->
getObjId();
207 $clone->setObjId($target_questionpool);
264 $this->lng->loadLanguageModule(
"form");
266 while (substr($_FILES[
"upload"][
"name"],-1) ==
'/')
268 $_FILES[
"upload"][
"name"] = substr($_FILES[
"upload"][
"name"],0,-1);
272 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
273 $suffix = $filename_arr[
"extension"];
274 $mimetype = $_FILES[
"upload"][
"type"];
275 $size_bytes = $_FILES[
"upload"][
"size"];
276 $temp_name = $_FILES[
"upload"][
"tmp_name"];
277 $error = $_FILES[
"upload"][
"error"];
290 case UPLOAD_ERR_INI_SIZE:
295 case UPLOAD_ERR_FORM_SIZE:
300 case UPLOAD_ERR_PARTIAL:
301 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_partially_uploaded"),
true);
305 case UPLOAD_ERR_NO_FILE:
310 case UPLOAD_ERR_NO_TMP_DIR:
315 case UPLOAD_ERR_CANT_WRITE:
316 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_cannot_write_to_disk"),
true);
320 case UPLOAD_ERR_EXTENSION:
321 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_upload_stopped_ext"),
true);
338 if (strlen($temp_name))
341 if ($vir[0] ==
false)
343 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1],
true);
355 if (is_null($question_id)) $question_id = $this->
getId();
356 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
366 if (is_null($question_id)) $question_id = $this->
getId();
367 include_once
"./Services/Utilities/classes/class.ilUtil.php";
384 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
385 array(
"integer",
"integer",
"integer"),
389 while (
$data = $ilDB->fetchAssoc($result))
391 array_push($found,
$data);
406 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
410 if ($result->numRows() == 1)
412 $row = $ilDB->fetchAssoc($result);
415 foreach ($found as $idx =>
$data)
417 $found[$idx][
'webpath'] =
$path;
434 foreach (
$files as $solution_id)
436 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s",
440 if ($result->numRows() == 1)
442 $data = $ilDB->fetchAssoc($result);
444 $active_id =
$data[
'active_fi'];
448 foreach (
$files as $solution_id)
450 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
467 $max_filesize = sprintf(
"%.1f Bytes",$size);
469 else if ($size < 1024*1024)
471 $max_filesize = sprintf(
"%.1f KB",$size/1024);
475 $max_filesize = sprintf(
"%.1f MB",$size/1024/1024);
478 return $max_filesize;
495 $umf = get_cfg_var(
"upload_max_filesize");
497 $pms = get_cfg_var(
"post_max_size");
500 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
502 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
503 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
505 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
506 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
509 $max_filesize = min($umf, $pms);
511 if (!$max_filesize) $max_filesize=max($umf, $pms);
512 return $max_filesize;
530 include_once
"./Modules/Test/classes/class.ilObjTest.php";
534 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
539 if ($result->numRows() == 1)
541 $row = $ilDB->fetchAssoc($result);
545 $entered_values =
false;
546 if (strcmp(
$_POST[
'cmd'][
'gotoquestion'], $this->lng->txt(
'delete')) == 0)
548 $deletefiles =
$_POST[
'file'];
549 if (is_array($deletefiles) && count($deletefiles) > 0)
560 if (strlen($_FILES[
"upload"][
"tmp_name"]))
566 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
567 $extension = $filename_arr[
"extension"];
568 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $version .
"." . $extension;
570 $next_id = $ilDB->nextId(
'tst_solutions');
571 $affectedRows = $ilDB->insert(
"tst_solutions", array(
572 "solution_id" => array(
"integer", $next_id),
573 "active_fi" => array(
"integer", $active_id),
574 "question_fi" => array(
"integer", $this->
getId()),
575 "value1" => array(
"clob", $newfile),
576 "value2" => array(
"clob", $_FILES[
'upload'][
'name']),
577 "pass" => array(
"integer",
$pass),
578 "tstamp" => array(
"integer", time())
580 $entered_values =
true;
586 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
594 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
611 return "assFileUpload";
621 return "qpl_qst_fileupload";
663 $adapter->setCellValue($startrow, 0, $this->lng->txt($this->getQuestionType()),
CELL_FORMAT_TITLE);
669 foreach ($solutions as $solution)
671 $adapter->setCellValue($startrow + $i, 0, $this->lng->txt(
"result"),
CELL_FORMAT_BOLD);
673 if (strlen($solution[
"value1"]))
675 $adapter->setCellValue($startrow + $i, 1, $solution[
"value1"]);
676 $adapter->setCellValue($startrow + $i, 2, $solution[
"value2"]);
682 return $startrow + $i + 1;
697 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
699 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
701 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
710 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
712 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
714 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
724 $user_solution = array();
725 return $user_solution;
745 $this->maxsize = $a_value;
755 if (strlen($this->allowedextensions))
757 return split(
",", $this->allowedextensions);
779 $this->allowedextensions = strtolower(trim($a_value));
792 case "allowedextensions":
811 case "allowedextensions":
828 $result = $ilDB->queryF(
"SELECT tst_solutions.solution_id FROM tst_solutions, tst_active, qpl_questions WHERE tst_solutions.active_fi = tst_active.active_id AND tst_solutions.question_fi = qpl_questions.question_id AND qpl_questions.question_id = %s AND tst_active.test_fi = %s",
829 array(
"integer",
"integer"),
832 if ($result->numRows() > 0)
848 $result = $ilDB->queryF(
"SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi, tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp FROM tst_solutions, tst_active, qpl_questions WHERE tst_solutions.active_fi = tst_active.active_id AND tst_solutions.question_fi = qpl_questions.question_id AND qpl_questions.question_id = %s AND tst_active.test_fi = %s ORDER BY tst_solutions.active_fi, tst_solutions.tstamp",
849 array(
"integer",
"integer"),
854 if ($result->numRows())
857 $data .=
"<html><head>";
858 $data .=
'<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
860 table { border: 1px #333 solid; border-collapse:collapse;}
861 td, th { border: 1px #333 solid; padding: 0.25em;}
862 th { color: #fff; background-color: #666;}
865 $data .=
"<title>" . $this->
getTitle() .
"</title></head><body>\n";
867 $data .=
"<table><thead>\n";
868 $data .=
"<tr><th>" . $this->lng->txt(
"name") .
"</th><th>" . $this->lng->txt(
"filename") .
"</th><th>" . $this->lng->txt(
"pass") .
"</th><th>" . $this->lng->txt(
"location") .
"</th><th>" . $this->lng->txt(
"date") .
"</th></tr></thead><tbody>\n";
869 while (
$row = $ilDB->fetchAssoc($result))
872 @copy($this->
getFileUploadPath(
$test_id, $row[
"active_fi"], $row[
"question_fi"]) . $row[
"value1"], $tempdir .
"/" . $row[
"active_fi"].
"/".$row[
"question_fi"] .
"/" . $row[
"value1"]);
873 if (!array_key_exists($row[
"active_fi"], $userdata))
875 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
878 $data .=
"<tr><td>".$userdata[$row[
"active_fi"]].
"</td><td><a href=\"".$row[
"active_fi"].
"/".$row[
"question_fi"].
"/".$row[
"value1"].
"\" target=\"_blank\">".$row[
"value2"].
"</a></td><td>".$row[
"pass"].
"</td><td>".$row[
"active_fi"].
"/".$row[
"question_fi"].
"/".$row[
"value1"].
"</td>";
882 $data .=
"</tbody></table>\n";
883 $data .=
"</body></html>\n";
885 $indexfile = $tempdir .
"/index.html";
886 $fh = fopen($indexfile,
'w');