19declare(strict_types=1);
32 private readonly ResourceStorage $irss,
35 private string $objects_export_directory
52 $user_criteria = (
new ilSetting(
'assessment'))->
get(
'user_criteria',
'usr_id');
54 $query = $this->test_obj->getAnonymity()
55 ?
'SELECT * FROM tst_active WHERE test_fi = %s'
56 :
"SELECT tst_active.*, usr_data.{$user_criteria} FROM tst_active, usr_data WHERE tst_active.test_fi = %s AND tst_active.user_fi = usr_data.usr_id";
60 $test_participant_list->initializeFromDbRows($this->test_obj->getTestParticipants());
63 while ($row = $this->db->fetchAssoc($result)) {
64 $this->active_ids[] = $row[
'active_id'];
65 $participant = $test_participant_list->getParticipantByActiveId($row[
'active_id']);
68 'active_id' => $row[
'active_id'],
69 'user_fi' => $this->test_obj->getAnonymity() ?
'' : ($row[
'user_fi'] ??
''),
70 'fullname' => $participant ? $test_participant_list->buildFullname($participant) :
'',
71 'anonymous_id' => $row[
'anonymous_id'] ??
'',
72 'test_fi' => $row[
'test_fi'],
73 'lastindex' => $row[
'lastindex'] ??
'',
74 'tries' => $row[
'tries'] ??
'',
75 'last_started_pass' => $row[
'last_started_pass'] ??
'',
76 'last_finished_pass' => $row[
'last_finished_pass'] ??
'',
77 'submitted' => $row[
'submitted'] ??
'',
78 'submittimestamp' => $row[
'submittimestamp'] ??
'',
79 'tstamp' => $row[
'tstamp'] ??
''
82 if (!$this->test_obj->getAnonymity()) {
83 $attrs[
'user_criteria'] = $user_criteria;
84 $attrs[$user_criteria] = $row[$user_criteria];
94 $query =
'SELECT * FROM tst_pass_result WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi, pass';
95 $result = $this->db->query($query);
97 while ($row = $this->db->fetchAssoc($result)) {
99 'active_fi' => $row[
'active_fi'],
100 'pass' => $row[
'pass'] ??
'',
101 'points' => $row[
'points'] ??
'',
102 'maxpoints' => $row[
'maxpoints'] ??
'',
103 'questioncount' => $row[
'questioncount'] ??
'',
104 'answeredquestions' => $row[
'answeredquestions'] ??
'',
105 'workingtime' => $row[
'workingtime'] ??
'',
106 'tstamp' => $row[
'tstamp'] ??
''
115 $query =
'SELECT * FROM tst_result_cache WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
116 $result = $this->db->query($query);
118 while ($row = $this->db->fetchAssoc($result)) {
120 'active_fi' => $row[
'active_fi'],
121 'pass' => $row[
'pass'],
122 'max_points' => $row[
'max_points'],
123 'reached_points' => $row[
'reached_points'],
124 'mark_short' => $row[
'mark_short'],
125 'mark_official' => $row[
'mark_official'],
126 'passed' => $row[
'passed'],
127 'failed' => $row[
'failed'],
128 'tstamp' => $row[
'tstamp']
137 $query =
'SELECT * FROM tst_sequence WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi, pass';
138 $result = $this->db->query($query);
140 while ($row = $this->db->fetchAssoc($result)) {
142 'active_fi' => $row[
'active_fi'],
143 'pass' => $row[
'pass'] ??
'',
144 'sequence' => $row[
'sequence'] ??
'',
145 'postponed' => $row[
'postponed'] ??
'',
146 'hidden' => $row[
'hidden'] ??
'',
147 'tstamp' => $row[
'tstamp'] ??
''
156 $query =
'SELECT * FROM tst_solutions WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY solution_id';
157 $result = $this->db->query($query);
159 while ($row = $this->db->fetchAssoc($result)) {
161 'solution_id' => $row[
'solution_id'],
162 'active_fi' => $row[
'active_fi'],
163 'question_fi' => $row[
'question_fi'],
164 'points' => $row[
'points'] ??
'',
165 'pass' => $row[
'pass'] ??
'',
166 'value1' => $row[
'value1'] ??
'',
167 'value2' => $row[
'value2'] ??
'',
168 'tstamp' => $row[
'tstamp'] ??
''
177 $result = $this->db->query(
"
178 SELECT * FROM tst_test_rnd_qst
179 WHERE {$this->db->in('active_fi', $this->active_ids, false, 'integer')}
180 ORDER BY test_random_question_id
184 while ($row = $this->db->fetchAssoc($result)) {
187 foreach ($row as $field => $value) {
188 $attrs[$field] = $value;
199 $query =
'SELECT * FROM tst_test_result WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
200 $result = $this->db->query($query);
202 while ($row = $this->db->fetchAssoc($result)) {
203 $active_fi = $row[
'active_fi'];
204 $pass = $row[
'pass'] ??
'';
206 'test_result_id' => $row[
'test_result_id'],
207 'active_fi' => $active_fi,
208 'question_fi' => $row[
'question_fi'],
209 'points' => $row[
'points'] ??
'',
211 'manual' => $row[
'manual'] ??
'',
212 'tstamp' => $row[
'tstamp'] ??
''
229 foreach ($uploaded_files as $uploaded_file) {
230 if ($uploaded_file[
'value2'] !==
'rid') {
234 $rid_string = $uploaded_file[
'value1'];
235 $rid = $this->irss->manage()->find($rid_string);
240 $target_dir =
"$this->objects_export_directory/resources/$rid_string";
243 "$target_dir/{$this->irss->manage()->getCurrentRevision($rid)->getTitle()}",
244 $this->irss->consume()->stream($rid)->getStream(),
251 $query =
'SELECT * FROM tst_times WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
252 $result = $this->db->query($query);
254 while ($row = $this->db->fetchAssoc($result)) {
256 'times_id' => $row[
'times_id'],
257 'active_fi' => $row[
'active_fi'],
258 'started' => $row[
'started'],
259 'finished' => $row[
'finished'],
260 'pass' => $row[
'pass'],
261 'tstamp' => $row[
'tstamp']
270 $this->active_ids = [];
272 $attrs = [
'version' =>
'4.1.0'];
292 return parent::xmlDumpMem($format);
295 public function xmlDumpFile(
string $file,
bool $format =
true): void
298 parent::xmlDumpFile($file, $format);
Class for file upload questions.
static instantiateQuestion(int $question_id)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
xmlDumpMem(bool $format=true)
Returns xml document from memory.
exportRandomTestQuestions()
__construct(private readonly ilObjTest $test_obj, private readonly ilDBInterface $db, private readonly ResourceStorage $irss, private readonly ilObjUser $user, private readonly ilLanguage $lng, private string $objects_export_directory)
bool $include_random_test_questions_enabled
xmlDumpFile(string $file, bool $format=true)
Dumps xml document from memory into a file.
exportParticipantUploadedFiles(array $uploaded_files)
isIncludeRandomTestQuestionsEnabled()
setIncludeRandomTestQuestionsEnabled(bool $include_random_test_questions_enabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlHeader()
Writes xml header.
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc