ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssFileUploadUploadsExporter Class Reference
+ Collaboration diagram for ilAssFileUploadUploadsExporter:

Public Member Functions

 __construct (ilDB $db, ilLanguage $lng)
 
 getTestId ()
 
 setTestId ($testId)
 
 getTestTitle ()
 
 setTestTitle ($testTitle)
 
 getQuestion ()
 
 setQuestion ($question)
 
 build ()
 
 getFinalZipFilePath ()
 
 getDispoZipFileName ()
 
 getZipFileMimeType ()
 

Data Fields

const ZIP_FILE_MIME_TYPE = 'application/zip'
 
const ZIP_FILE_EXTENSION = '.zip'
 

Protected Attributes

 $db
 
 $lng
 

Private Member Functions

 initFilenames ()
 
 getFileUploadSolutionData ()
 
 getParticipantData ($solutionData)
 
 collectUploadedFiles ($solutionData, ilTestParticipantData $participantData)
 
 getPassSubDirName ($pass)
 
 createFileUploadCollectionZipFile ()
 
 removeFileUploadCollection ()
 

Private Attributes

 $testId
 
 $testTitle
 
 $question
 
 $finalZipFilePath
 
 $tempZipFilePath
 
 $tempDirPath
 
 $mainFolderName
 

Detailed Description

Definition at line 11 of file class.ilAssFileUploadUploadsExporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssFileUploadUploadsExporter::__construct ( ilDB  $db,
ilLanguage  $lng 
)

Member Function Documentation

◆ build()

ilAssFileUploadUploadsExporter::build ( )
Returns
string

Definition at line 121 of file class.ilAssFileUploadUploadsExporter.php.

122 {
123 $this->initFilenames();
124
125 $solutionData = $this->getFileUploadSolutionData();
126
127 $participantData = $this->getParticipantData($solutionData);
128
129 $this->collectUploadedFiles($solutionData, $participantData);
130
132
134 }
collectUploadedFiles($solutionData, ilTestParticipantData $participantData)

References collectUploadedFiles(), createFileUploadCollectionZipFile(), getFileUploadSolutionData(), getParticipantData(), initFilenames(), and removeFileUploadCollection().

+ Here is the call graph for this function:

◆ collectUploadedFiles()

ilAssFileUploadUploadsExporter::collectUploadedFiles (   $solutionData,
ilTestParticipantData  $participantData 
)
private

Definition at line 201 of file class.ilAssFileUploadUploadsExporter.php.

202 {
203 foreach($solutionData as $activeId => $passes)
204 {
205 foreach($passes as $pass => $files)
206 {
207 foreach($files as $file)
208 {
209 $uploadedFileDir = $this->question->getFileUploadPath(
210 $this->getTestId(), $activeId, $this->question->getId()
211 );
212
213 $destinationDir = $this->tempDirPath.'/'.$this->mainFolderName.'/';
214 $destinationDir .= $participantData->getFileSystemCompliantFullnameByActiveId($activeId).'/';
215 $destinationDir .= $this->getPassSubDirName($file['pass']).'/';
216
217 ilUtil::makeDirParents($destinationDir);
218
219 copy($uploadedFileDir.$file['value1'], $destinationDir.$file['value2']);
220 }
221 }
222 }
223 }
print $file
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References $file, $pass, ilTestParticipantData\getFileSystemCompliantFullnameByActiveId(), getPassSubDirName(), getTestId(), and ilUtil\makeDirParents().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFileUploadCollectionZipFile()

ilAssFileUploadUploadsExporter::createFileUploadCollectionZipFile ( )
private

Definition at line 230 of file class.ilAssFileUploadUploadsExporter.php.

231 {
232 ilUtil::zip($this->tempDirPath.'/'.$this->mainFolderName, $this->tempZipFilePath);
233
234 $pathinfo = pathinfo($this->tempZipFilePath);
235 $this->finalZipFilePath = dirname($pathinfo['dirname']).'/'.$pathinfo['basename'];
236
237 try
238 {
239 require_once 'Services/Utilities/classes/class.ilFileUtils.php';
240 ilFileUtils::rename($this->tempZipFilePath, $this->finalZipFilePath);
241 }
242 catch (\ilFileUtilsException $e)
243 {
244 \ilLoggerFactory::getRootLogger()->error($e->getMessage());
245 }
246 }
Class to report exception.
static rename($a_source, $a_target)
Rename a file.
static getRootLogger()
The unique root logger has a fixed error level.
static zip($a_dir, $a_file, $compress_content=false)

References ilLoggerFactory\getRootLogger(), ilFileUtils\rename(), and ilUtil\zip().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDispoZipFileName()

ilAssFileUploadUploadsExporter::getDispoZipFileName ( )

Definition at line 258 of file class.ilAssFileUploadUploadsExporter.php.

259 {
261 $this->mainFolderName.self::ZIP_FILE_EXTENSION
262 );
263 }
static getASCIIFilename($a_filename)
convert utf8 to ascii filename

References ilUtil\getASCIIFilename().

+ Here is the call graph for this function:

◆ getFileUploadSolutionData()

ilAssFileUploadUploadsExporter::getFileUploadSolutionData ( )
private

Definition at line 147 of file class.ilAssFileUploadUploadsExporter.php.

148 {
149 $query = "
150 SELECT tst_solutions.solution_id, tst_solutions.pass, tst_solutions.active_fi, tst_solutions.question_fi,
151 tst_solutions.value1, tst_solutions.value2, tst_solutions.tstamp
152 FROM tst_solutions, tst_active, qpl_questions
153 WHERE tst_solutions.active_fi = tst_active.active_id
154 AND tst_solutions.question_fi = qpl_questions.question_id
155 AND tst_solutions.question_fi = %s
156 AND tst_active.test_fi = %s
157 ORDER BY tst_solutions.active_fi, tst_solutions.tstamp
158 ";
159
160 $res = $this->db->queryF(
161 $query, array("integer", "integer"), array($this->question->getId(), $this->getTestId())
162 );
163
164 $solutionData = array();
165
166 while( $row = $this->db->fetchAssoc($res) )
167 {
168 if( !isset($solutionData[$row['active_fi']]) )
169 {
170 $solutionData[ $row['active_fi'] ] = array();
171 }
172
173 if( !isset($solutionData[ $row['active_fi'] ][ $row['pass'] ]) )
174 {
175 $solutionData[ $row['active_fi'] ][ $row['pass'] ] = array();
176 }
177
178 $solutionData[ $row['active_fi'] ][ $row['pass'] ][] = $row;
179 }
180
181 return $solutionData;
182 }

References $query, $res, and $row.

Referenced by build().

+ Here is the caller graph for this function:

◆ getFinalZipFilePath()

ilAssFileUploadUploadsExporter::getFinalZipFilePath ( )

◆ getParticipantData()

ilAssFileUploadUploadsExporter::getParticipantData (   $solutionData)
private

Definition at line 184 of file class.ilAssFileUploadUploadsExporter.php.

185 {
186 $activeIds = array();
187
188 foreach($solutionData as $activeId => $passes)
189 {
190 $activeIds[] = $activeId;
191 }
192
193 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
194 $participantData = new ilTestParticipantData($this->db, $this->lng);
195 $participantData->setActiveIds($activeIds);
196 $participantData->load($this->getTestId());
197
198 return $participantData;
199 }

References getTestId().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPassSubDirName()

ilAssFileUploadUploadsExporter::getPassSubDirName (   $pass)
private

Definition at line 225 of file class.ilAssFileUploadUploadsExporter.php.

226 {
227 return $this->lng->txt('pass').'_'.($pass + 1);
228 }

References $pass.

Referenced by collectUploadedFiles().

+ Here is the caller graph for this function:

◆ getQuestion()

ilAssFileUploadUploadsExporter::getQuestion ( )

◆ getTestId()

ilAssFileUploadUploadsExporter::getTestId ( )
Returns
int

Definition at line 73 of file class.ilAssFileUploadUploadsExporter.php.

References $testId.

Referenced by collectUploadedFiles(), and getParticipantData().

+ Here is the caller graph for this function:

◆ getTestTitle()

ilAssFileUploadUploadsExporter::getTestTitle ( )
Returns
string

Definition at line 89 of file class.ilAssFileUploadUploadsExporter.php.

References $testTitle.

Referenced by initFilenames().

+ Here is the caller graph for this function:

◆ getZipFileMimeType()

ilAssFileUploadUploadsExporter::getZipFileMimeType ( )

◆ initFilenames()

ilAssFileUploadUploadsExporter::initFilenames ( )
private

Definition at line 136 of file class.ilAssFileUploadUploadsExporter.php.

137 {
138 $this->tempDirPath = ilUtil::ilTempnam();
139
140 $this->tempZipFilePath = ilUtil::ilTempnam($this->tempDirPath).self::ZIP_FILE_EXTENSION;
141
142 $this->mainFolderName = ilUtil::getASCIIFilename(
143 str_replace(' ', '', $this->getTestTitle().'_'.$this->question->getTitle())
144 );
145 }
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.

References ilUtil\getASCIIFilename(), getTestTitle(), and ilUtil\ilTempnam().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeFileUploadCollection()

ilAssFileUploadUploadsExporter::removeFileUploadCollection ( )
private

Definition at line 248 of file class.ilAssFileUploadUploadsExporter.php.

249 {
250 ilUtil::delDir($this->tempDirPath);
251 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir().

Referenced by build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setQuestion()

ilAssFileUploadUploadsExporter::setQuestion (   $question)
Parameters
ilObjFileHandlingQuestionType$question

Definition at line 113 of file class.ilAssFileUploadUploadsExporter.php.

114 {
115 $this->question = $question;
116 }

References $question.

◆ setTestId()

ilAssFileUploadUploadsExporter::setTestId (   $testId)
Parameters
int$testId

Definition at line 81 of file class.ilAssFileUploadUploadsExporter.php.

82 {
83 $this->testId = $testId;
84 }

References $testId.

◆ setTestTitle()

ilAssFileUploadUploadsExporter::setTestTitle (   $testTitle)
Parameters
string$testTitle

Definition at line 97 of file class.ilAssFileUploadUploadsExporter.php.

98 {
99 $this->testTitle = $testTitle;
100 }

References $testTitle.

Field Documentation

◆ $db

ilAssFileUploadUploadsExporter::$db
protected

Definition at line 19 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by __construct().

◆ $finalZipFilePath

ilAssFileUploadUploadsExporter::$finalZipFilePath
private

Definition at line 44 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getFinalZipFilePath().

◆ $lng

ilAssFileUploadUploadsExporter::$lng
protected

Definition at line 24 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by __construct().

◆ $mainFolderName

ilAssFileUploadUploadsExporter::$mainFolderName
private

Definition at line 59 of file class.ilAssFileUploadUploadsExporter.php.

◆ $question

ilAssFileUploadUploadsExporter::$question
private

Definition at line 39 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getQuestion(), and setQuestion().

◆ $tempDirPath

ilAssFileUploadUploadsExporter::$tempDirPath
private

Definition at line 54 of file class.ilAssFileUploadUploadsExporter.php.

◆ $tempZipFilePath

ilAssFileUploadUploadsExporter::$tempZipFilePath
private

Definition at line 49 of file class.ilAssFileUploadUploadsExporter.php.

◆ $testId

ilAssFileUploadUploadsExporter::$testId
private

Definition at line 29 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getTestId(), and setTestId().

◆ $testTitle

ilAssFileUploadUploadsExporter::$testTitle
private

Definition at line 34 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getTestTitle(), and setTestTitle().

◆ ZIP_FILE_EXTENSION

const ilAssFileUploadUploadsExporter::ZIP_FILE_EXTENSION = '.zip'

Definition at line 14 of file class.ilAssFileUploadUploadsExporter.php.

◆ ZIP_FILE_MIME_TYPE

const ilAssFileUploadUploadsExporter::ZIP_FILE_MIME_TYPE = 'application/zip'

Definition at line 13 of file class.ilAssFileUploadUploadsExporter.php.

Referenced by getZipFileMimeType().


The documentation for this class was generated from the following file: