From 112e5bdcb37b00d336944e0f1ed2fa66367909e8 Mon Sep 17 00:00:00 2001
From: Elke Kreim <elke.kreim@hs-hannover.de>
Date: Wed, 6 Sep 2023 11:53:10 +0200
Subject: [PATCH] Show message when no results found and redirect to dashboard

---
 amd/src/jmodule.js | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/amd/src/jmodule.js b/amd/src/jmodule.js
index 06e381c..47444f0 100644
--- a/amd/src/jmodule.js
+++ b/amd/src/jmodule.js
@@ -52,12 +52,16 @@ define(['jquery'], function ($) {
                                 + '<a href="' + wwwroot + '/course/view.php?id=' + course.id + '">' + displaystr + '</a> </li>')
                                 .appendTo(list);
                         });
+                    } else {
+                        $('<li class="list-group-item hshcoursesearchlistitem " value="">'
+                            + '<a href="' + wwwroot + '/my/">Keine Ergebnisse gefunden.</a> </li>')
+                            .appendTo(list);
                     }
                     $("#hshcourselistul").replaceWith(list);
                     $("#hshcourseprogress").hide();
                 },
                 error: function (a) {
-                    console.error("error " + JSON.stringify(a));
+                    $(location).attr('href', wwwroot + '/my/');
                 }
             });
         } else {
-- 
GitLab