23 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
101 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
103 array($this->
getId())
105 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
106 array(
"integer",
"float",
"text",
"integer"),
133 $this->
setId($question_id);
144 include_once(
"./Services/RTE/classes/class.ilRTE.php");
165 $this_id = $this->
getId();
167 if( (
int)$testObjId > 0 )
173 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
177 if( (
int)$testObjId > 0 )
179 $clone->setObjId($testObjId);
206 $clone->copyPageOfQuestion($this_id);
208 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
210 $clone->duplicateFeedbackGeneric($this_id);
212 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
229 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
232 $source_questionpool = $this->
getObjId();
233 $clone->setObjId($target_questionpool);
290 $this->lng->loadLanguageModule(
"form");
292 while (substr($_FILES[
"upload"][
"name"],-1) ==
'/')
294 $_FILES[
"upload"][
"name"] = substr($_FILES[
"upload"][
"name"],0,-1);
298 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
299 $suffix = $filename_arr[
"extension"];
300 $mimetype = $_FILES[
"upload"][
"type"];
301 $size_bytes = $_FILES[
"upload"][
"size"];
302 $temp_name = $_FILES[
"upload"][
"tmp_name"];
303 $error = $_FILES[
"upload"][
"error"];
316 case UPLOAD_ERR_INI_SIZE:
321 case UPLOAD_ERR_FORM_SIZE:
326 case UPLOAD_ERR_PARTIAL:
327 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_partially_uploaded"),
true);
331 case UPLOAD_ERR_NO_FILE:
336 case UPLOAD_ERR_NO_TMP_DIR:
341 case UPLOAD_ERR_CANT_WRITE:
342 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_cannot_write_to_disk"),
true);
346 case UPLOAD_ERR_EXTENSION:
347 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_upload_stopped_ext"),
true);
364 if (strlen($temp_name))
367 if ($vir[0] ==
false)
369 ilUtil::sendInfo($this->lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1],
true);
381 if (is_null($question_id)) $question_id = $this->
getId();
382 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
392 if (is_null($question_id)) $question_id = $this->
getId();
393 include_once
"./Services/Utilities/classes/class.ilUtil.php";
410 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
411 array(
"integer",
"integer",
"integer"),
417 array_push($found,
$data);
432 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
441 foreach ($found as $idx =>
$data)
443 $found[$idx][
'webpath'] =
$path;
460 foreach (
$files as $solution_id)
462 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s",
470 $active_id =
$data[
'active_fi'];
474 foreach (
$files as $solution_id)
476 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
493 $max_filesize = sprintf(
"%.1f Bytes",
$size);
495 else if (
$size < 1024*1024)
497 $max_filesize = sprintf(
"%.1f KB",
$size/1024);
501 $max_filesize = sprintf(
"%.1f MB",
$size/1024/1024);
504 return $max_filesize;
521 $umf = get_cfg_var(
"upload_max_filesize");
523 $pms = get_cfg_var(
"post_max_size");
526 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
528 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
529 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
531 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
532 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
535 $max_filesize = min($umf, $pms);
537 if (!$max_filesize) $max_filesize=max($umf, $pms);
538 return $max_filesize;
556 include_once
"./Modules/Test/classes/class.ilObjTest.php";
560 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
571 $entered_values =
false;
572 if (strcmp(
$_POST[
'cmd'][
'gotoquestion'], $this->lng->txt(
'delete')) == 0)
574 $deletefiles =
$_POST[
'file'];
575 if (is_array($deletefiles) && count($deletefiles) > 0)
586 if (strlen($_FILES[
"upload"][
"tmp_name"]))
592 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
593 $extension = $filename_arr[
"extension"];
594 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $version .
"." . $extension;
596 $next_id = $ilDB->nextId(
'tst_solutions');
597 $affectedRows = $ilDB->insert(
"tst_solutions", array(
598 "solution_id" => array(
"integer", $next_id),
599 "active_fi" => array(
"integer", $active_id),
600 "question_fi" => array(
"integer", $this->
getId()),
601 "value1" => array(
"clob", $newfile),
602 "value2" => array(
"clob", $_FILES[
'upload'][
'name']),
603 "pass" => array(
"integer",
$pass),
604 "tstamp" => array(
"integer", time())
606 $entered_values =
true;
612 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
620 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
646 global $ilObjDataCache;
664 include_once
'Modules/Test/classes/class.ilObjTestAccess.php';
665 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
680 return "assFileUpload";
690 return "qpl_qst_fileupload";
735 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
740 foreach ($solutions as $solution)
743 if (strlen($solution[
"value1"]))
750 return $startrow + $i + 1;
765 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
767 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
769 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
778 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
780 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
782 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
792 $user_solution = array();
793 return $user_solution;
813 $this->maxsize = $a_value;
823 if (strlen($this->allowedextensions))
825 return split(
",", $this->allowedextensions);
847 $this->allowedextensions = strtolower(trim($a_value));
860 case "allowedextensions":
863 case 'completion_by_submission':
882 case "allowedextensions":
885 case 'completion_by_submission':
903 SELECT tst_solutions.solution_id
904 FROM tst_solutions, tst_active, qpl_questions
905 WHERE tst_solutions.active_fi = tst_active.active_id
906 AND tst_solutions.question_fi = qpl_questions.question_id
907 AND qpl_questions.question_id = %s
908 AND tst_active.test_fi = %s
910 array(
"integer",
"integer"),
926 public function getFileUploadZIPFile(
$test_id)
932 tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
933 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
934 FROM tst_solutions, tst_active, qpl_questions
935 WHERE tst_solutions.active_fi = tst_active.active_id
936 AND tst_solutions.question_fi = qpl_questions.question_id
937 AND tst_solutions.question_fi = %s
938 AND tst_active.test_fi = %s
939 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp";
942 array(
"integer",
"integer"),
951 $data .=
"<html><head>";
952 $data .=
'<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
954 table { border: 1px #333 solid; border-collapse:collapse;}
955 td, th { border: 1px #333 solid; padding: 0.25em;}
956 th { color: #fff; background-color: #666;}
959 $data .=
"<title>" . $this->
getTitle() .
"</title></head><body>\n";
961 $data .=
"<table><thead>\n";
962 $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";
966 @copy($this->
getFileUploadPath(
$test_id,
$row[
"active_fi"],
$row[
"question_fi"]) .
$row[
"value1"], $tempdir .
"/" . $row[
"active_fi"].
"/".$row[
"question_fi"] .
"/" . $row[
"value1"]);
967 if (!array_key_exists(
$row[
"active_fi"], $userdata))
969 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
972 $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>";
976 $data .=
"</tbody></table>\n";
977 $data .=
"</body></html>\n";
979 $indexfile = $tempdir .
"/index.html";
980 $fh = fopen($indexfile,
'w');
1013 $this->completion_by_submission = (bool)$bool;