From 858000e396b4ef55539cfe700ea2be71ec2a2d94 Mon Sep 17 00:00:00 2001
From: Elke Kreim <elke.kreim@hs-hannover.de>
Date: Wed, 2 Oct 2024 10:17:19 +0200
Subject: [PATCH] Replace comma with minus in filename

---
 classes/local/helpers/download.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/classes/local/helpers/download.php b/classes/local/helpers/download.php
index 9176edc..581cf30 100644
--- a/classes/local/helpers/download.php
+++ b/classes/local/helpers/download.php
@@ -41,12 +41,16 @@ class download {
         }
 
         $timestamp = download::get_file_timestamp();
+        $filename = $course_code;
 
-        if ($course_code != null) {
-            $filename = FILENAME_PREFIX . $course_code . '_' . $timestamp;
-        } else {
-            $filename = FILENAME_PREFIX . $course->shortname . '_' . $timestamp;
+        // use course shortname if no course_code is given
+        if ($course_code == null) {
+            $filename = str_replace(',', '-', $course->shortname);
         }
+
+        // extend filename with prefix and date
+        $filename = FILENAME_PREFIX . $filename . '_' . $timestamp;
+
         return $filename;
     }
 
-- 
GitLab