19 declare(strict_types=1);
33 private string $objects_export_directory,
34 private bool $anonymized =
false 51 $assessment_setting =
new ilSetting(
'assessment');
52 $user_criteria = $assessment_setting->get(
'user_criteria');
53 if ($user_criteria ===
null || $user_criteria ===
'') {
54 $user_criteria =
'usr_id';
57 if ($this->anonymized) {
58 $result = $this->db->queryF(
59 'SELECT * FROM tst_active WHERE test_fi = %s',
64 $result = $this->db->queryF(
65 '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',
71 while ($row = $this->db->fetchAssoc($result)) {
73 'active_id' => $row[
'active_id'],
74 'user_fi' => $row[
'user_fi'] ??
'',
75 'anonymous_id' => $row[
'anonymous_id'] ??
'',
76 'test_fi' => $row[
'test_fi'],
77 'lastindex' => $row[
'lastindex'] ??
'',
78 'tries' => $row[
'tries'] ??
'',
79 'last_started_pass' => $row[
'last_started_pass'] ??
'',
80 'last_finished_pass' => $row[
'last_finished_pass'] ??
'',
81 'submitted' => $row[
'submitted'] ??
'',
82 'submittimestamp' => $row[
'submittimestamp'] ??
'',
83 'tstamp' => $row[
'tstamp'] ??
'' 86 if (!$this->anonymized) {
87 $attrs[
'user_criteria'] = $user_criteria;
88 $attrs[$user_criteria] = $row[$user_criteria];
90 array_push($this->active_ids, $row[
'active_id']);
98 $query =
'SELECT * FROM tst_pass_result WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi, pass';
99 $result = $this->db->query($query);
101 while ($row = $this->db->fetchAssoc($result)) {
103 'active_fi' => $row[
'active_fi'],
104 'pass' => $row[
'pass'] ??
'',
105 'points' => $row[
'points'] ??
'',
106 'maxpoints' => $row[
'maxpoints'] ??
'',
107 'questioncount' => $row[
'questioncount'] ??
'',
108 'answeredquestions' => $row[
'answeredquestions'] ??
'',
109 'workingtime' => $row[
'workingtime'] ??
'',
110 'tstamp' => $row[
'tstamp'] ??
'' 119 $query =
'SELECT * FROM tst_result_cache WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
120 $result = $this->db->query($query);
122 while ($row = $this->db->fetchAssoc($result)) {
124 'active_fi' => $row[
'active_fi'],
125 'pass' => $row[
'pass'],
126 'max_points' => $row[
'max_points'],
127 'reached_points' => $row[
'reached_points'],
128 'mark_short' => $row[
'mark_short'],
129 'mark_official' => $row[
'mark_official'],
130 'passed' => $row[
'passed'],
131 'failed' => $row[
'failed'],
132 'tstamp' => $row[
'tstamp']
141 $query =
'SELECT * FROM tst_sequence WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi, pass';
142 $result = $this->db->query($query);
144 while ($row = $this->db->fetchAssoc($result)) {
146 'active_fi' => $row[
'active_fi'],
147 'pass' => $row[
'pass'] ??
'',
148 'sequence' => $row[
'sequence'] ??
'',
149 'postponed' => $row[
'postponed'] ??
'',
150 'hidden' => $row[
'hidden'] ??
'',
151 'tstamp' => $row[
'tstamp'] ??
'' 160 $query =
'SELECT * FROM tst_solutions WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY solution_id';
161 $result = $this->db->query($query);
163 while ($row = $this->db->fetchAssoc($result)) {
165 'solution_id' => $row[
'solution_id'],
166 'active_fi' => $row[
'active_fi'],
167 'question_fi' => $row[
'question_fi'],
168 'points' => $row[
'points'] ??
'',
169 'pass' => $row[
'pass'] ??
'',
170 'value1' => $row[
'value1'] ??
'',
171 'value2' => $row[
'value2'] ??
'',
172 'tstamp' => $row[
'tstamp'] ??
'' 181 $result = $this->db->query(
" 182 SELECT * FROM tst_test_rnd_qst 183 WHERE {$this->db->in('active_fi', $this->active_ids, false, 'integer')} 184 ORDER BY test_random_question_id 188 while ($row = $this->db->fetchAssoc($result)) {
191 foreach ($row as $field => $value) {
192 $attrs[$field] = $value;
203 $query =
'SELECT * FROM tst_test_result WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
204 $result = $this->db->query($query);
206 while ($row = $this->db->fetchAssoc($result)) {
207 $active_fi = $row[
'active_fi'];
208 $pass = $row[
'pass'] ??
'';
210 'test_result_id' => $row[
'test_result_id'],
211 'active_fi' => $active_fi,
212 'question_fi' => $row[
'question_fi'],
213 'points' => $row[
'points'] ??
'',
215 'manual' => $row[
'manual'] ??
'',
216 'tstamp' => $row[
'tstamp'] ??
'' 233 foreach ($uploaded_files as $uploaded_file) {
234 if ($uploaded_file[
'value2'] !==
'rid') {
238 $rid_string = $uploaded_file[
'value1'];
239 $rid = $this->irss->manage()->find($rid_string);
244 $target_dir =
"$this->objects_export_directory/resources/$rid_string";
247 "$target_dir/{$this->irss->manage()->getCurrentRevision($rid)->getTitle()}",
248 $this->irss->consume()->stream($rid)->getStream(),
255 $query =
'SELECT * FROM tst_times WHERE ' . $this->db->in(
'active_fi', $this->active_ids,
false,
'integer') .
' ORDER BY active_fi';
256 $result = $this->db->query($query);
258 while ($row = $this->db->fetchAssoc($result)) {
260 'times_id' => $row[
'times_id'],
261 'active_fi' => $row[
'active_fi'],
262 'started' => $row[
'started'],
263 'finished' => $row[
'finished'],
264 'pass' => $row[
'pass'],
265 'tstamp' => $row[
'tstamp']
274 $this->active_ids = [];
276 $attrs = [
'version' =>
'4.1.0'];
296 return parent::xmlDumpMem($format);
299 public function xmlDumpFile(
string $file,
bool $format =
true): void
302 parent::xmlDumpFile($file, $format);
xmlDumpFile(string $file, bool $format=true)
xmlDumpMem(bool $format=true)
exportParticipantUploadedFiles(array $uploaded_files)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
isIncludeRandomTestQuestionsEnabled()
Class for file upload questions.
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static instantiateQuestion(int $question_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
bool $include_random_test_questions_enabled
setIncludeRandomTestQuestionsEnabled(bool $include_random_test_questions_enabled)
xmlHeader()
Writes xml header.
__construct(private int $test_id, private ilDBInterface $db, private ResourceStorage $irss, private string $objects_export_directory, private bool $anonymized=false)
__construct(Container $dic, ilPlugin $plugin)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
exportRandomTestQuestions()
static _getParticipantData(int $active_id)
Retrieves a participant name from active id.