19declare(strict_types=1);
98 $this->matchingpairs = [];
101 $this->definitions = [];
102 $this->randomGroup =
$DIC->refinery()->random();
117 if (strlen($this->title)
120 && count($this->matchingpairs)
141 $this->db->manipulateF(
142 "DELETE FROM qpl_a_mterm WHERE question_fi = %s",
148 $this->db->manipulateF(
149 "DELETE FROM qpl_a_mdef WHERE question_fi = %s",
156 foreach ($this->terms as $key => $term) {
157 $next_id = $this->db->nextId(
'qpl_a_mterm');
158 $this->db->insert(
'qpl_a_mterm', [
159 'term_id' => [
'integer', $next_id],
160 'question_fi' => [
'integer', $this->
getId()],
161 'picture' => [
'text', $term->getPicture()],
162 'term' => [
'text', $term->getText()],
163 'ident' => [
'integer', $term->getIdentifier()]
165 $termids[$term->getIdentifier()] = $next_id;
170 foreach ($this->definitions as $key => $definition) {
171 $next_id = $this->db->nextId(
'qpl_a_mdef');
172 $this->db->insert(
'qpl_a_mdef', [
173 'def_id' => [
'integer', $next_id],
174 'question_fi' => [
'integer', $this->
getId()],
175 'picture' => [
'text', $definition->getPicture()],
176 'definition' => [
'text', $definition->getText()],
177 'ident' => [
'integer', $definition->getIdentifier()]
179 $definitionids[$definition->getIdentifier()] = $next_id;
182 $this->db->manipulateF(
183 "DELETE FROM qpl_a_matching WHERE question_fi = %s",
189 $next_id = $this->db->nextId(
'qpl_a_matching');
190 $this->db->manipulateF(
191 "INSERT INTO qpl_a_matching (answer_id, question_fi, points, term_fi, definition_fi) VALUES (%s, %s, %s, %s, %s)",
192 [
'integer',
'integer',
'float',
'integer',
'integer' ],
197 $termids[$pair->getTerm()->getIdentifier()],
198 $definitionids[$pair->getDefinition()->getIdentifier()]
206 $this->db->manipulateF(
213 'question_fi' => [
'integer', $this->
getId()],
215 'matching_type' => [
'text', $this->matching_type],
230 SELECT qpl_questions.*,
231 {$this->getAdditionalTableName()}.*
233 LEFT JOIN {$this->getAdditionalTableName()}
234 ON {$this->getAdditionalTableName()}.question_fi = qpl_questions.question_id
235 WHERE qpl_questions.question_id = %s
238 $result = $this->db->queryF(
244 if ($result->numRows() == 1) {
245 $data = $this->db->fetchAssoc($result);
246 $this->
setId((
int) $question_id);
248 $this->
setTitle((
string) $data[
"title"]);
249 $this->
setComment((
string) $data[
"description"]);
253 $this->
setPoints((
float) $data[
"points"]);
254 $this->
setOwner((
int) $data[
"owner"]);
259 $this->
setMatchingMode($data[
'matching_mode'] ===
null ? self::MATCHING_MODE_1_ON_1 :
$data[
'matching_mode']);
274 $result = $this->db->queryF(
275 "SELECT * FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id ASC",
280 if ($result->numRows() > 0) {
281 while (
$data = $this->db->fetchAssoc($result)) {
283 $this->terms[] = $term;
284 $termids[
$data[
'term_id']] = $term;
289 $result = $this->db->queryF(
290 "SELECT * FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id ASC",
295 $this->definitions = [];
296 if ($result->numRows() > 0) {
297 while (
$data = $this->db->fetchAssoc($result)) {
299 array_push($this->definitions, $definition);
300 $definitionids[
$data[
'def_id']] = $definition;
304 $this->matchingpairs = [];
305 $result = $this->db->queryF(
306 "SELECT * FROM qpl_a_matching WHERE question_fi = %s ORDER BY answer_id",
310 if ($result->numRows() > 0) {
311 while (
$data = $this->db->fetchAssoc($result)) {
313 $termids[
$data[
'term_fi']],
314 $definitionids[
$data[
'definition_fi']],
315 (
float)
$data[
'points']
317 array_push($this->matchingpairs, $pair);
320 parent::loadFromDb((
int) $question_id);
331 int $source_question_id,
332 int $source_parent_id,
333 int $target_question_id,
334 int $target_parent_id
336 $image_source_path = $this->getImagePath($source_question_id, $source_parent_id);
337 $image_target_path = $this->getImagePath($target_question_id, $target_parent_id);
339 if (!file_exists($image_target_path)) {
342 $this->removeAllImageFiles($image_target_path);
345 foreach ($this->terms as $term) {
346 if ($term->getPicture() ===
'') {
351 if (!file_exists($image_source_path .
$filename)
353 $this->log->root()->warning(
'matching question image could not be copied: '
356 if (!file_exists($image_source_path . $this->getThumbPrefix() .
$filename)
358 $image_source_path . $this->getThumbPrefix() .
$filename,
359 $image_target_path . $this->getThumbPrefix() .
$filename
361 $this->log->root()->warning(
'matching question image thumbnail could not be copied: '
362 . $image_source_path . $this->getThumbPrefix() .
$filename);
365 foreach ($this->definitions as $definition) {
366 if ($definition->getPicture() ===
'') {
371 if (!file_exists($image_source_path .
$filename)
373 $this->log->root()->warning(
'matching question image could not be copied: '
377 if (!file_exists($image_source_path . $this->getThumbPrefix() .
$filename)
379 $image_source_path . $this->getThumbPrefix() .
$filename,
380 $image_target_path . $this->getThumbPrefix() .
$filename
382 $this->log->root()->warning(
'matching question image thumbnail could not be copied: '
383 . $image_source_path . $this->getThumbPrefix() .
$filename);
400 $pair = $this->createMatchingPair($term, $definition, $points);
402 if ($position < count($this->matchingpairs)) {
403 $part1 = array_slice($this->matchingpairs, 0, $position);
404 $part2 = array_slice($this->matchingpairs, $position);
405 $this->matchingpairs = array_merge($part1, [$pair], $part2);
407 array_push($this->matchingpairs, $pair);
424 $pair = $this->createMatchingPair($term, $definition, $points);
425 array_push($this->matchingpairs, $pair);
433 foreach ($this->terms as $term) {
434 if ($term->getIdentifier() == $a_identifier) {
446 foreach ($this->definitions as $definition) {
447 if ($definition->getIdentifier() == $a_identifier) {
467 if (count($this->matchingpairs) < 1) {
470 if ($index >= count($this->matchingpairs)) {
473 return $this->matchingpairs[$index];
488 if (count($this->matchingpairs) < 1) {
491 if ($index >= count($this->matchingpairs)) {
494 unset($this->matchingpairs[$index]);
495 $this->matchingpairs = array_values($this->matchingpairs);
504 $this->matchingpairs = [];
512 $clone = clone $this;
513 $clone->matchingpairs = $pairs;
526 return count($this->matchingpairs);
548 return $this->definitions;
559 return count($this->terms);
570 return count($this->definitions);
575 $this->terms[] = $term;
586 array_push($this->definitions, $definition);
597 if (is_null($term)) {
598 $term = $this->createMatchingTerm();
600 if ($position < count($this->terms)) {
601 $part1 = array_slice($this->terms, 0, $position);
602 $part2 = array_slice($this->terms, $position);
603 $this->terms = array_merge($part1, [$term], $part2);
605 array_push($this->terms, $term);
617 if (is_null($definition)) {
618 $definition = $this->createMatchingDefinition();
620 if ($position < count($this->definitions)) {
621 $part1 = array_slice($this->definitions, 0, $position);
622 $part2 = array_slice($this->definitions, $position);
623 $this->definitions = array_merge($part1, [$definition], $part2);
625 array_push($this->definitions, $definition);
644 $this->definitions = [];
655 unset($this->terms[$position]);
656 $this->terms = array_values($this->terms);
667 unset($this->definitions[$position]);
668 $this->definitions = array_values($this->definitions);
680 $this->terms[$index] = $term;
686 bool $authorized_solution =
true
689 if (is_null($pass)) {
690 $pass = $this->getSolutionMaxPass($active_id);
692 $result = $this->getCurrentSolutionResultSet($active_id, (
int) $pass, $authorized_solution);
693 while (
$data = $this->db->fetchAssoc($result)) {
694 if (
$data[
'value1'] ===
'') {
698 if (!isset($found_values[
$data[
'value2']])) {
699 $found_values[
$data[
'value2']] = [];
702 $found_values[
$data[
'value2']][] =
$data[
'value1'];
705 $points = $this->calculateReachedPointsForSolution($found_values);
717 foreach ($this->getMaximumScoringMatchingPairs() as $pair) {
718 $points += $pair->getPoints();
726 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
727 return $this->getPositiveScoredMatchingPairs();
728 } elseif ($this->getMatchingMode() == self::MATCHING_MODE_1_ON_1) {
729 return $this->getMostPositiveScoredUniqueTermMatchingPairs();
739 foreach ($this->matchingpairs as $pair) {
740 if ($pair->getPoints() <= 0) {
744 $matchingPairs[] = $pair;
747 return $matchingPairs;
752 $matchingPairsByDefinition = [];
754 foreach ($this->matchingpairs as $pair) {
755 if ($pair->getPoints() <= 0) {
759 $defId = $pair->getDefinition()->getIdentifier();
761 if (!isset($matchingPairsByDefinition[$defId])) {
762 $matchingPairsByDefinition[$defId] = $pair;
763 } elseif ($pair->getPoints() > $matchingPairsByDefinition[$defId]->getPoints()) {
764 $matchingPairsByDefinition[$defId] = $pair;
768 return $matchingPairsByDefinition;
779 foreach ($valuePairs as $valuePair) {
780 if (!isset($indexedValues[$valuePair[
'value2']])) {
781 $indexedValues[$valuePair[
'value2']] = [];
784 $indexedValues[$valuePair[
'value2']][] = $valuePair[
'value1'];
787 return $indexedValues;
801 if (preg_match(
"/.*\\.(\\w+)$/",
$filename, $matches)) {
802 $extension = $matches[1];
804 return md5(
$filename) .
"." . $extension;
809 $term = $this->terms[$index] ??
null;
810 if (is_object($term)) {
811 $this->deleteImagefile($term->getPicture());
812 $term = $term->withPicture(
'');
818 $definition = $this->definitions[$index] ??
null;
819 if (is_object($definition)) {
820 $this->deleteImagefile($definition->getPicture());
821 $definition = $definition->withPicture(
'');
836 $result = unlink($this->getImagePath() . $deletename)
837 && unlink($this->getImagePath() . $this->getThumbPrefix() . $deletename);
838 }
catch (Throwable
$e) {
845 string $image_tempfilename,
846 string $image_filename,
847 string $previous_filename =
''
850 if ($image_tempfilename ===
'') {
854 $image_filename = str_replace(
' ',
'_', $image_filename);
855 $imagepath = $this->getImagePath();
856 if (!file_exists($imagepath)) {
863 $imagepath . $image_filename
870 $thumbpath = $imagepath . $this->getThumbPrefix() . $image_filename;
872 $imagepath . $image_filename,
875 (
string) $this->getThumbGeometry()
879 && $image_filename !== $previous_filename
880 && $previous_filename !==
''
882 $this->deleteImagefile($previous_filename);
889 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
895 foreach ($submitted_matchings as $terms) {
896 if (count($terms) > 1) {
897 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"multiple_matching_values_selected"),
true);
901 foreach ($terms as $i => $term) {
902 if (isset($handledTerms[$term])) {
903 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"duplicate_matching_values_selected"),
true);
907 $handledTerms[$term] = $term;
917 bool $authorized =
true
919 if ($pass === null) {
923 $submitted_matchings = $this->questionpool_request->getMatchingPairs();
924 if (!$this->checkSubmittedMatchings($submitted_matchings)) {
928 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
929 function () use ($submitted_matchings, $active_id, $pass, $authorized) {
930 $this->removeCurrentSolution($active_id, $pass, $authorized);
931 foreach ($submitted_matchings as $definition => $terms) {
932 foreach ($terms as $i => $term) {
933 $this->saveCurrentSolution($active_id, $pass, $term, $definition, $authorized);
944 $submitted_matchings = $this->questionpool_request->getMatchingPairs();
946 if ($this->checkSubmittedMatchings($submitted_matchings)) {
953 mt_srand((
float) microtime() * 1000000);
954 $random_number = mt_rand(1, 100000);
958 foreach ($this->matchingpairs as $key => $pair) {
959 if (($pair->getTerm()->getIdentifier() == $random_number) || ($pair->getDefinition()->getIdentifier() == $random_number)) {
965 return $random_number;
970 $this->shuffle = (bool) $shuffle;
980 return "assMatchingQuestion";
985 return "qpl_qst_matching";
990 return [
"qpl_a_matching",
"qpl_a_mterm"];
999 return parent::getRTETextWithMediaObjects();
1007 return $this->matchingpairs;
1017 return $this->thumb_geometry;
1027 return $this->getThumbGeometry();
1037 $this->thumb_geometry = ($a_geometry < 1) ? 100 : $a_geometry;
1046 foreach ($this->terms as $term) {
1047 if ($term->getPicture() !==
'') {
1048 $current_file_path = $this->getImagePath() . $term->getPicture();
1049 if (!file_exists($current_file_path)) {
1050 $new_terms[] = $term;
1053 $new_file_name = $this->buildHashedImageFilename($term->getPicture(),
true);
1054 $new_file_path = $this->getImagePath() . $new_file_name;
1055 rename($current_file_path, $new_file_path);
1056 $term = $term->withPicture($new_file_name);
1057 $this->generateThumbForFile($this->getImagePath(), $term->getPicture());
1059 $new_terms[] = $term;
1061 $this->terms = $new_terms;
1063 $new_definitions = [];
1064 foreach ($this->definitions as $definition) {
1065 if ($definition->getPicture() !==
'') {
1066 $current_file_path = $this->getImagePath() . $definition->getPicture();
1067 if (!file_exists($current_file_path)) {
1068 $new_definitions[] = $definition;
1071 $new_file_name = $this->buildHashedImageFilename($definition->getPicture(),
true);
1072 $new_file_path = $this->getImagePath() . $new_file_name;
1073 rename($current_file_path, $new_file_path);
1074 $definition = $definition->withPicture($new_file_name);
1075 $this->generateThumbForFile($this->getImagePath(), $definition->getPicture());
1077 $new_definitions[] = $definition;
1079 $this->definitions = $new_definitions;
1091 $thumbpath =
$path . $this->getThumbPrefix() . $file;
1094 switch (strtoupper($path_info[
'extension'])) {
1116 $result[
'id'] = $this->
getId();
1117 $result[
'type'] = (string) $this->getQuestionType();
1118 $result[
'title'] = $this->getTitleForHTMLOutput();
1119 $result[
'question'] = $this->formatSAQuestion($this->getQuestion());
1120 $result[
'nr_of_tries'] = $this->getNrOfTries();
1121 $result[
'matching_mode'] = $this->getMatchingMode();
1122 $result[
'shuffle'] =
true;
1123 $result[
'feedback'] = [
1124 'onenotcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1125 'allcorrect' => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1128 $this->setShuffler($this->randomGroup->shuffleArray(
new RandomSeed()));
1131 foreach ($this->getShuffler()->
transform($this->getTerms()) as $term) {
1133 "text" => $this->formatSAQuestion($term->getText()),
1134 "id" => $this->
getId() . $term->getIdentifier()
1137 $result[
'terms'] = $terms;
1139 $this->setShuffler($this->randomGroup->shuffleArray(
new RandomSeed()));
1142 foreach ($this->getShuffler()->
transform($this->getDefinitions()) as $def) {
1144 "text" => $this->formatSAQuestion((
string) $def->getText()),
1145 "id" => $this->
getId() . $def->getIdentifier()
1148 $result[
'definitions'] = $definitions;
1152 foreach ($this->getMatchingPairs() as $pair) {
1154 if ($pair->getPoints() <= 0) {
1159 $pid = $pair->getDefinition()->getIdentifier();
1160 if ($this->getMatchingMode() == self::MATCHING_MODE_N_ON_N) {
1161 $pid .=
'::' . $pair->getTerm()->getIdentifier();
1164 if (!isset($matchings[$pid]) || $matchings[$pid][
"points"] < $pair->getPoints()) {
1165 $matchings[$pid] = [
1166 "term_id" => $this->
getId() . $pair->getTerm()->getIdentifier(),
1167 "def_id" => $this->
getId() . $pair->getDefinition()->getIdentifier(),
1168 "points" => (
int) $pair->getPoints()
1173 $result[
'matchingPairs'] = array_values($matchings);
1176 $result[
'mobs'] = $mobs;
1178 $this->
lng->loadLanguageModule(
'assessment');
1179 $result[
'reset_button_label'] = $this->
lng->txt(
"reset_terms");
1181 return json_encode($result);
1186 $this->matching_mode = $matching_mode;
1191 return $this->matching_mode;
1197 if (!is_array($found_values)) {
1200 foreach ($found_values as $definition => $terms) {
1201 if (!is_array($terms)) {
1204 foreach ($terms as $term) {
1205 foreach ($this->matchingpairs as $pair) {
1206 if ($pair->getDefinition()->getIdentifier() == $definition
1207 && $pair->getTerm()->getIdentifier() == $term) {
1208 $points += $pair->getPoints();
1237 $data = $this->db->queryF(
1238 "SELECT ident FROM qpl_a_mdef WHERE question_fi = %s ORDER BY def_id",
1244 for ($index = 1; $index <= $this->db->numRows(
$data); ++$index) {
1245 $row = $this->db->fetchAssoc(
$data);
1246 $definitions[$row[
"ident"]] = $index;
1249 $data = $this->db->queryF(
1250 "SELECT ident FROM qpl_a_mterm WHERE question_fi = %s ORDER BY term_id",
1256 for ($index = 1; $index <= $this->db->numRows(
$data); ++$index) {
1257 $row = $this->db->fetchAssoc(
$data);
1258 $terms[$row[
"ident"]] = $index;
1261 $maxStep = $this->lookupMaxStep($active_id, $pass);
1264 $data = $this->db->queryF(
1265 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s AND step = %s",
1266 [
"integer",
"integer",
"integer",
"integer"],
1267 [$active_id, $pass, $this->
getId(), $maxStep]
1270 $data = $this->db->queryF(
1271 "SELECT value1, value2 FROM tst_solutions WHERE active_fi = %s AND pass = %s AND question_fi = %s",
1272 [
"integer",
"integer",
"integer"],
1273 [$active_id, $pass, $this->
getId()]
1277 while ($row = $this->db->fetchAssoc(
$data)) {
1278 if ($row[
"value1"] > 0) {
1279 $result->addKeyValue($definitions[$row[
"value2"]], $terms[$row[
"value1"]]);
1283 $points = $this->calculateReachedPoints($active_id, $pass);
1284 $max_points = $this->getMaximumPoints();
1286 $result->setReachedPercentage(($points / $max_points) * 100);
1299 if ($index !==
null) {
1300 return $this->getMatchingPair($index);
1302 return $this->getMatchingPairs();
1310 int $original_question_id,
1311 int $clone_question_id,
1312 int $original_parent_id,
1313 int $clone_parent_id
1315 parent::afterSyncWithOriginal($original_question_id, $clone_question_id, $original_parent_id, $clone_parent_id);
1317 $original_image_path = $this->question_files->buildImagePath($original_question_id, $original_parent_id);
1318 $clone_image_path = $this->question_files->buildImagePath($clone_question_id, $clone_parent_id);
1321 if (is_dir($clone_image_path)) {
1340 $term = $term ?? $this->createMatchingTerm();
1341 $definition = $definition ?? $this->createMatchingDefinition();
1348 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
1349 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
1350 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
1351 AdditionalInformationGenerator::KEY_QUESTION_SHUFFLE_ANSWER_OPTIONS => $additional_info
1353 'qpl_qst_inp_matching_mode' => $this->getMatchingMode() === self::MATCHING_MODE_1_ON_1 ?
'{{ qpl_qst_inp_matching_mode_one_on_one }}' :
'{{ qpl_qst_inp_matching_mode_all_on_all }}',
1354 AdditionalInformationGenerator::KEY_FEEDBACK => [
1355 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
false)),
1356 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(),
true))
1360 foreach ($this->getTerms() as $term) {
1361 $result[AdditionalInformationGenerator::KEY_QUESTION_MATCHING_TERMS][] = $term->getText();
1364 foreach ($this->getDefinitions() as $definition) {
1365 $result[AdditionalInformationGenerator::KEY_QUESTION_MATCHING_DEFINITIONS][] = $this->formatSAQuestion((
string) $definition->getText());
1369 $matching_pairs = [];
1371 foreach ($this->getMatchingPairs() as $pair) {
1372 $matching_pairs[$i++] = [
1373 AdditionalInformationGenerator::KEY_QUESTION_MATCHING_TERM => $pair->getTerm()->getText(),
1374 AdditionalInformationGenerator::KEY_QUESTION_MATCHING_DEFINITION => $this->formatSAQuestion((
string) $pair->getDefinition()->getText()),
1375 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => (
int) $pair->getPoints()
1379 $result[AdditionalInformationGenerator::KEY_QUESTION_CORRECT_ANSWER_OPTIONS] = $matching_pairs;
1385 array $solution_values
1387 return $this->solutionValuesToText($solution_values);
1393 $c[$v->getIdentifier()] = $v->getText() !==
''
1399 $terms_by_identifier = array_reduce(
1405 $definitions_by_identifier = array_reduce(
1406 $this->getDefinitions(),
1412 static fn(array $v):
string => $definitions_by_identifier[$v[
'value2']]
1413 .
':' . $terms_by_identifier[$v[
'value1']],
1423 $this->getMatchingPairs()
Class for matching question definitions.
Class for matching question pairs.
Class for matching question terms.
Class for matching questions.
afterSyncWithOriginal(int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
{}
deleteDefinition($position)
Deletes a definition.
getCorrectSolutionForTextOutput(int $active_id, int $pass)
getEncryptedFilename($filename)
Returns the encrypted save filename of a matching picture Images are saved with an encrypted filename...
removeDefinitionImage($index)
getMatchingPairCount()
Returns the number of matching pairs.
addDefinition($definition)
Adds a definition.
getMaximumPoints()
Calculates and Returns the maximum points, a learner can reach answering the question.
setThumbGeometry(int $a_geometry)
Set the thumbnail geometry.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
getMostPositiveScoredUniqueTermMatchingPairs()
const MT_TERMS_DEFINITIONS
toJSON()
Returns a JSON representation of the question.
solutionValuesToLog(AdditionalInformationGenerator $additional_info, array $solution_values)
MUST convert the given solution values into an array or a string that can be stored in the log.
getDefinitionCount()
Returns the number of definitions.
getDefinitions()
Returns the definitions of the matching question.
getMatchingPair($index=0)
Returns a matching pair with a given index.
createMatchingDefinition(string $term='', string $picture='', int $identifier=0)
withMatchingPairs(array $pairs)
getQuestionType()
Returns the question type of the question.
rebuildThumbnails()
Rebuild the thumbnail images with a new thumbnail size.
getPositiveScoredMatchingPairs()
addMatchingPair(?assAnswerMatchingTerm $term=null, ?assAnswerMatchingDefinition $definition=null, $points=0.0)
Adds an matching pair for an matching choice question.
getMatchingPairs()
Returns the matchingpairs array.
getTermCount()
Returns the number of terms.
toLog(AdditionalInformationGenerator $additional_info)
MUST return an array of the question settings that can be stored in the log.
getThumbGeometry()
Get the thumbnail geometry.
deleteTerm($position)
Deletes a term.
cloneImages(int $source_question_id, int $source_parent_id, int $target_question_id, int $target_parent_id)
createMatchingTerm(string $term='', string $picture='', int $identifier=0)
getTerms()
Returns the terms of the matching question.
createMatchingPair(?assAnswerMatchingTerm $term=null, ?assAnswerMatchingDefinition $definition=null, float $points=0.0)
insertDefinition($position, ?assAnswerMatchingDefinition $definition=null)
Inserts a definition.
calculateReachedPoints(int $active_id, ?int $pass=null, bool $authorized_solution=true)
flushDefinitions()
Deletes all definitions.
fetchIndexedValuesFromValuePairs(array $valuePairs)
loadFromDb($question_id)
Loads a assMatchingQuestion object from a database.
getDefinitionWithIdentifier($a_identifier)
Returns a definition with a given identifier.
solutionValuesToText(array $solution_values)
MUST convert the given solution values into text.
calculateReachedPointsForSolution(?array $found_values)
flushTerms()
Deletes all terms.
flushMatchingPairs()
Deletes all matching pairs.
setShuffleMode(int $shuffle)
checkSubmittedMatchings(array $submitted_matchings)
addTerm(assAnswerMatchingTerm $term)
getOperators(string $expression)
Get all available operations for a specific question.
getAvailableAnswerOptions($index=null)
If index is null, the function returns an array with all anwser options Else it returns the specific ...
setShuffle($shuffle=true)
getThumbSize()
Get the thumbnail geometry.
getTermWithIdentifier($a_identifier)
Returns a term with a given identifier.
setTerm($term, $index)
Sets a specific term.
saveWorkingData(int $active_id, ?int $pass=null, bool $authorized=true)
cloneQuestionTypeSpecificProperties(\assQuestion $target)
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
__construct( $title="", $comment="", $author="", $owner=-1, $question="", $matching_type=self::MT_TERMS_DEFINITIONS)
assMatchingQuestion constructor
getUserQuestionResult(int $active_id, int $pass)
Get the user solution for a question by active_id and the test pass.
setImageFile(string $image_tempfilename, string $image_filename, string $previous_filename='')
deleteImagefile(string $filename)
Deletes an imagefile from the system if the file is deleted manually.
saveAnswerSpecificDataToDb()
Saves the answer specific records into a question types answer table.
saveToDb(?int $original_id=null)
getExpressionTypes()
Get all available expression types for a specific question.
insertTerm($position, ?assAnswerMatchingTerm $term=null)
Inserts a term.
const MATCHING_MODE_1_ON_1
setMatchingMode(string $matching_mode)
getMaximumScoringMatchingPairs()
deleteMatchingPair($index=0)
Deletes a matching pair with a given index.
const MATCHING_MODE_N_ON_N
insertMatchingPair($position, $term=null, $definition=null, $points=0.0)
Inserts a matching pair for an matching choice question.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
generateThumbForFile($path, $file)
setOriginalId(?int $original_id)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
saveQuestionDataToDb(?int $original_id=null)
static getDraftInstance()
static getInstance($identifier)
setParticipantsSolution($participantSolution)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static getOperatorsByExpression(string $expression)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static convertImage(string $a_from, string $a_to, string $a_target_format="", string $a_geometry="", string $a_background_color="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const PercentageResultExpression
const MatchingResultExpression
const NumericResultExpression
const EmptyAnswerExpression
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))