Skip to content

Commit

Permalink
37770: Download all submissions, Umlaut-problems
Browse files Browse the repository at this point in the history
  • Loading branch information
alex40724 committed Jan 7, 2025
1 parent 851e673 commit 0811b82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
25 changes: 15 additions & 10 deletions Modules/Exercise/classes/class.ilFSStorageExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,7 @@ public function uploadFile(
if (isset($a_http_post_file) && $a_http_post_file['size']) {
$filename = $a_http_post_file['name'];

$filename = ilFileUtils::getValidFilename($filename);
// replace whitespaces with underscores
$filename = preg_replace("/\s/", "_", $filename);
// remove all special characters
$filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
$filename = $this->getStorageFilename($filename);

if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
ilFileUtils::makeDir($savepath);
Expand Down Expand Up @@ -261,6 +257,19 @@ public function uploadFile(
return $result;
}

protected function getStorageFilename(string $filename): string
{
global $DIC;

$filename = ilFileUtils::getValidFilename($filename);
// replace whitespaces with underscores
$filename = preg_replace("/\s/", "_", $filename);
$filename = (new \ilFileServicesPolicy($DIC->fileServiceSettings()))->ascii($filename);
// remove all special characters
$filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
return $filename;
}

/**
* store delivered file in filesystem
* @param array $a_http_post_file
Expand All @@ -277,11 +286,7 @@ public function addFileUpload(
$this->create();

$filename = $result->getName();
$filename = ilFileUtils::getValidFilename($filename);
// replace whitespaces with underscores
$filename = preg_replace("/\s/", "_", $filename);
// remove all special characters
$filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
$filename = $this->getStorageFilename($filename);

$savepath = $this->getRelativeSubmissionPath();
$savepath .= '/' . $user_id;
Expand Down
1 change: 0 additions & 1 deletion Services/UICore/classes/MetaTemplate/PageContentGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ protected function getMessageTextForType(string $type): ?string
protected function getTabsHTML(): void
{
global $DIC;

$ilTabs = $DIC["ilTabs"];

if ($this->template->blockExists("tabs_outer_start")) {
Expand Down

0 comments on commit 0811b82

Please sign in to comment.