4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjFileHandlingQuestionType.php';
87 array( $this->
getId() )
90 ) .
" (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
91 array(
"integer",
"float",
"text",
"integer" ),
115 $data = $ilDB->fetchAssoc(
$result);
116 $this->
setId($question_id);
127 include_once(
"./Services/RTE/classes/class.ilRTE.php");
129 $this->
setEstimatedWorkingTime(substr($data[
"working_time"], 0, 2), substr($data[
"working_time"], 3, 2), substr($data[
"working_time"], 6, 2));
156 $this_id = $this->
getId();
160 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
164 if( (
int)$testObjId > 0 )
166 $clone->setObjId($testObjId);
193 $clone->copyPageOfQuestion($this_id);
195 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
197 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
214 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
217 $source_questionpool_id = $this->
getObjId();
218 $clone->setObjId($target_questionpool_id);
230 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
243 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
246 $sourceParentId = $this->
getObjId();
252 $clone->setObjId($targetParentId);
254 if ($targetQuestionTitle)
256 $clone->setTitle($targetQuestionTitle);
261 $clone->copyPageOfQuestion($sourceQuestionId);
263 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
265 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
294 throw new ilTestException(
'return details not implemented for '.__METHOD__);
314 $this->lng->loadLanguageModule(
"form");
316 while (substr($_FILES[
"upload"][
"name"],-1) ==
'/')
318 $_FILES[
"upload"][
"name"] = substr($_FILES[
"upload"][
"name"],0,-1);
322 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
323 $suffix = $filename_arr[
"extension"];
324 $mimetype = $_FILES[
"upload"][
"type"];
325 $size_bytes = $_FILES[
"upload"][
"size"];
326 $temp_name = $_FILES[
"upload"][
"tmp_name"];
327 $error = $_FILES[
"upload"][
"error"];
340 case UPLOAD_ERR_INI_SIZE:
345 case UPLOAD_ERR_FORM_SIZE:
350 case UPLOAD_ERR_PARTIAL:
355 case UPLOAD_ERR_NO_FILE:
360 case UPLOAD_ERR_NO_TMP_DIR:
365 case UPLOAD_ERR_CANT_WRITE:
370 case UPLOAD_ERR_EXTENSION:
388 if (strlen($temp_name))
391 if ($vir[0] ==
false)
405 if (is_null($question_id)) $question_id = $this->
getId();
406 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
416 if (is_null($question_id)) $question_id = $this->
getId();
417 include_once
"./Services/Utilities/classes/class.ilUtil.php";
434 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
435 array(
"integer",
"integer",
"integer"),
439 while ($data = $ilDB->fetchAssoc(
$result))
441 array_push($found, $data);
456 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
465 foreach ($found as $idx => $data)
467 $found[$idx][
'webpath'] =
$path;
484 foreach ($files as $solution_id)
486 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s",
492 $data = $ilDB->fetchAssoc(
$result);
493 $pass = $data[
'pass'];
494 $active_id = $data[
'active_fi'];
498 foreach ($files as $solution_id)
500 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
517 $max_filesize = sprintf(
"%d Bytes",
$size);
519 else if (
$size < 1024*1024)
521 $max_filesize = sprintf(
"%.1f KB",
$size/1024);
525 $max_filesize = sprintf(
"%.1f MB",
$size/1024/1024);
528 return $max_filesize;
545 $umf = get_cfg_var(
"upload_max_filesize");
547 $pms = get_cfg_var(
"post_max_size");
550 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
552 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
553 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
555 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
556 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
559 $max_filesize = min($umf, $pms);
561 if (!$max_filesize) $max_filesize=max($umf, $pms);
562 return $max_filesize;
581 include_once
"./Modules/Test/classes/class.ilObjTest.php";
585 if(
$_POST[
'cmd'][
'handleQuestionAction'] != $this->lng->txt(
'delete')
586 && strlen($_FILES[
"upload"][
"tmp_name"]) )
592 $checkUploadResult =
false;
595 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
608 $entered_values =
false;
609 if(
$_POST[
'cmd'][
'handleQuestionAction'] == $this->lng->txt(
'delete') )
611 if (is_array(
$_POST[
'deletefiles']) && count(
$_POST[
'deletefiles']) > 0)
620 elseif( $checkUploadResult )
624 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
625 $extension = $filename_arr[
"extension"];
626 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $version .
"." . $extension;
628 $next_id = $ilDB->nextId(
'tst_solutions');
629 $affectedRows = $ilDB->insert(
"tst_solutions", array(
630 "solution_id" => array(
"integer", $next_id),
631 "active_fi" => array(
"integer", $active_id),
632 "question_fi" => array(
"integer", $this->
getId()),
633 "value1" => array(
"clob", $newfile),
634 "value2" => array(
"clob", $_FILES[
'upload'][
'name']),
635 "pass" => array(
"integer",
$pass),
636 "tstamp" => array(
"integer", time())
638 $entered_values =
true;
645 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
653 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
687 global $ilObjDataCache;
705 include_once
'Modules/Test/classes/class.ilObjTestAccess.php';
706 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
721 return "assFileUpload";
731 return "qpl_qst_fileupload";
776 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
781 foreach ($solutions as $solution)
784 if (strlen($solution[
"value1"]))
791 return $startrow + $i + 1;
806 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
808 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
810 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
819 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
821 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
823 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
833 $user_solution = array();
834 return $user_solution;
854 $this->maxsize = $a_value;
864 if (strlen($this->allowedextensions))
866 return array_filter(array_map(
'trim', explode(
",", $this->allowedextensions)));
888 $this->allowedextensions = strtolower(trim($a_value));
901 case "allowedextensions":
904 case 'completion_by_submission':
923 case "allowedextensions":
926 case 'completion_by_submission':
946 SELECT tst_solutions.solution_id
947 FROM tst_solutions, tst_active, qpl_questions
948 WHERE tst_solutions.active_fi = tst_active.active_id
949 AND tst_solutions.question_fi = qpl_questions.question_id
950 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
952 array(
"integer",
"integer"),
976 tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
977 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
978 FROM tst_solutions, tst_active, qpl_questions
979 WHERE tst_solutions.active_fi = tst_active.active_id
980 AND tst_solutions.question_fi = qpl_questions.question_id
981 AND tst_solutions.question_fi = %s
982 AND tst_active.test_fi = %s
983 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp";
986 array(
"integer",
"integer"),
994 $data .=
"<html><head>";
995 $data .=
'<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
997 table { border: 1px #333 solid; border-collapse:collapse;}
998 td, th { border: 1px #333 solid; padding: 0.25em;}
999 th { color: #fff; background-color: #666;}
1002 $data .=
"<title>" . $this->
getTitle() .
"</title></head><body>\n";
1003 $data .=
"<h1>" . $this->
getTitle() .
"</h1>\n";
1004 $data .=
"<table><thead>\n";
1005 $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";
1009 @copy($this->
getFileUploadPath(
$test_id,
$row[
"active_fi"],
$row[
"question_fi"]) .
$row[
"value1"], $tempdir .
"/" . $row[
"active_fi"].
"/".$row[
"question_fi"] .
"/" . $row[
"value1"]);
1010 if (!array_key_exists(
$row[
"active_fi"], $userdata))
1012 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
1015 $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>";
1019 $data .=
"</tbody></table>\n";
1020 $data .=
"</body></html>\n";
1022 $indexfile = $tempdir .
"/index.html";
1023 $fh = fopen($indexfile,
'w');
1056 $this->completion_by_submission = (bool)$bool;