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__);
320 $this->lng->loadLanguageModule(
"form");
322 while (substr($_FILES[
"upload"][
"name"],-1) ==
'/')
324 $_FILES[
"upload"][
"name"] = substr($_FILES[
"upload"][
"name"],0,-1);
328 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
329 $suffix = $filename_arr[
"extension"];
330 $mimetype = $_FILES[
"upload"][
"type"];
331 $size_bytes = $_FILES[
"upload"][
"size"];
332 $temp_name = $_FILES[
"upload"][
"tmp_name"];
333 $error = $_FILES[
"upload"][
"error"];
346 case UPLOAD_ERR_INI_SIZE:
351 case UPLOAD_ERR_FORM_SIZE:
356 case UPLOAD_ERR_PARTIAL:
361 case UPLOAD_ERR_NO_FILE:
366 case UPLOAD_ERR_NO_TMP_DIR:
371 case UPLOAD_ERR_CANT_WRITE:
376 case UPLOAD_ERR_EXTENSION:
394 if (strlen($temp_name))
397 if ($vir[0] ==
false)
411 if (is_null($question_id)) $question_id = $this->
getId();
412 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
420 return CLIENT_WEB_DIR .
"/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
430 if (is_null($question_id)) $question_id = $this->
getId();
431 include_once
"./Services/Utilities/classes/class.ilUtil.php";
441 include_once
"./Services/Utilities/classes/class.ilUtil.php";
458 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
459 array(
"integer",
"integer",
"integer"),
463 while ($data = $ilDB->fetchAssoc(
$result))
465 array_push($found, $data);
485 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
494 foreach ($found as $idx => $data)
496 $found[$idx][
'webpath'] =
$path;
513 foreach ($files as $solution_id)
515 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s",
521 $data = $ilDB->fetchAssoc(
$result);
522 $pass = $data[
'pass'];
523 $active_id = $data[
'active_fi'];
527 foreach ($files as $solution_id)
529 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s",
538 foreach($files as $name)
540 if( isset($userSolution[$name]) )
542 unset($userSolution[$name]);
547 return $userSolution;
560 $max_filesize = sprintf(
"%d Bytes",
$size);
562 else if (
$size < 1024*1024)
564 $max_filesize = sprintf(
"%.1f KB",
$size/1024);
568 $max_filesize = sprintf(
"%.1f MB",
$size/1024/1024);
571 return $max_filesize;
588 $umf = get_cfg_var(
"upload_max_filesize");
590 $pms = get_cfg_var(
"post_max_size");
593 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
595 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
596 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
598 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
599 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
602 $max_filesize = min($umf, $pms);
604 if (!$max_filesize) $max_filesize=max($umf, $pms);
605 return $max_filesize;
624 include_once
"./Modules/Test/classes/class.ilObjTest.php";
628 if(
$_POST[
'cmd'][$this->questionActionCmd] != $this->lng->txt(
'delete')
629 && strlen($_FILES[
"upload"][
"tmp_name"]) )
635 $checkUploadResult =
false;
638 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
651 $entered_values =
false;
652 if(
$_POST[
'cmd'][$this->questionActionCmd] == $this->lng->txt(
'delete') )
654 if (is_array(
$_POST[
'deletefiles']) && count(
$_POST[
'deletefiles']) > 0)
663 elseif( $checkUploadResult )
667 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
668 $extension = $filename_arr[
"extension"];
669 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $version .
"." . $extension;
671 $next_id = $ilDB->nextId(
'tst_solutions');
672 $affectedRows = $ilDB->insert(
"tst_solutions", array(
673 "solution_id" => array(
"integer", $next_id),
674 "active_fi" => array(
"integer", $active_id),
675 "question_fi" => array(
"integer", $this->
getId()),
676 "value1" => array(
"clob", $newfile),
677 "value2" => array(
"clob", $_FILES[
'upload'][
'name']),
678 "pass" => array(
"integer",
$pass),
679 "tstamp" => array(
"integer", time())
681 $entered_values =
true;
688 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
696 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
710 if( !is_array($userSolution) )
712 $userSolution = array();
715 if (strcmp(
$_POST[
'cmd'][$this->questionActionCmd], $this->lng->txt(
'delete')) == 0)
717 if (is_array(
$_POST[
'deletefiles']) && count(
$_POST[
'deletefiles']) > 0)
728 if (strlen($_FILES[
"upload"][
"tmp_name"]))
738 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
739 $extension = $filename_arr[
"extension"];
740 $newfile =
"file_".md5($_FILES[
"upload"][
"name"]).
"_" . $version .
"." . $extension;
743 $userSolution[$newfile] = array(
744 'solution_id' => $newfile,
745 'value1' => $newfile,
746 'value2' => $_FILES[
'upload'][
'name'],
747 'tstamp' => $version,
781 global $ilObjDataCache;
799 include_once
'Modules/Test/classes/class.ilObjTestAccess.php';
800 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
815 return "assFileUpload";
825 return "qpl_qst_fileupload";
870 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
875 foreach ($solutions as $solution)
878 if (strlen($solution[
"value1"]))
885 return $startrow + $i + 1;
900 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
902 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
904 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
913 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
915 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
917 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
927 $user_solution = array();
928 return $user_solution;
948 $this->maxsize = $a_value;
958 if (strlen($this->allowedextensions))
960 return array_filter(array_map(
'trim', explode(
",", $this->allowedextensions)));
982 $this->allowedextensions = strtolower(trim($a_value));
995 case "allowedextensions":
998 case 'completion_by_submission':
1017 case "allowedextensions":
1020 case 'completion_by_submission':
1040 SELECT tst_solutions.solution_id
1041 FROM tst_solutions, tst_active, qpl_questions
1042 WHERE tst_solutions.active_fi = tst_active.active_id
1043 AND tst_solutions.question_fi = qpl_questions.question_id
1044 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1046 array(
"integer",
"integer"),
1070 tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
1071 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
1072 FROM tst_solutions, tst_active, qpl_questions
1073 WHERE tst_solutions.active_fi = tst_active.active_id
1074 AND tst_solutions.question_fi = qpl_questions.question_id
1075 AND tst_solutions.question_fi = %s
1076 AND tst_active.test_fi = %s
1077 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp";
1080 array(
"integer",
"integer"),
1087 $userdata = array();
1088 $data .=
"<html><head>";
1089 $data .=
'<meta http-equiv="content-type" content="text/html; charset=UTF-8" />';
1091 table { border: 1px #333 solid; border-collapse:collapse;}
1092 td, th { border: 1px #333 solid; padding: 0.25em;}
1093 th { color: #fff; background-color: #666;}
1096 $data .=
"<title>" . $this->
getTitle() .
"</title></head><body>\n";
1097 $data .=
"<h1>" . $this->
getTitle() .
"</h1>\n";
1098 $data .=
"<table><thead>\n";
1099 $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";
1103 @copy($this->
getFileUploadPath(
$test_id,
$row[
"active_fi"],
$row[
"question_fi"]) .
$row[
"value1"], $tempdir .
"/" . $row[
"active_fi"].
"/".$row[
"question_fi"] .
"/" . $row[
"value1"]);
1104 if (!array_key_exists(
$row[
"active_fi"], $userdata))
1106 include_once
"./Modules/Test/classes/class.ilObjTestAccess.php";
1109 $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>";
1113 $data .=
"</tbody></table>\n";
1114 $data .=
"</body></html>\n";
1116 $indexfile = $tempdir .
"/index.html";
1117 $fh = fopen($indexfile,
'w');
1150 $this->completion_by_submission = (bool)$bool;
1169 return $numExistingSolutionRecords > 0;