diff --git a/dta.zip b/dta.zip
index 806f286e97041a2790c23cc5984d4f2ce657f6f2..b63cd5fd0c2660cc8626519f46958bd7ae94f5df 100644
Binary files a/dta.zip and b/dta.zip differ
diff --git a/dta/classes/database.php b/dta/classes/database.php
index a384b9607a71c7612100cda97e86eb96dcc3d7c3..f93fd066d39c411c6d3da3aafe50f30fd4674bd9 100644
--- a/dta/classes/database.php
+++ b/dta/classes/database.php
@@ -34,23 +34,58 @@ class DbUtils {
 
     private const TABLE_RECOMMENDATIONS = "assignsubmission_dta_recommendations";
 
-    /**
-     * Gets the recommendations for a given submission.
-     *
-     * @param int $submissionid ID of the submission
-     * @return array list of recommendations
-     */
-    public static function get_recommendations_from_database(int $assignmentid,int $submissionid ): array {
-        global $DB;
-
-        // Query the database to get all recommendations for the given submission id.
+    public static function get_recommendations_from_database(int $assignmentid, int $submissionid): array {
+        global $DB,$USER;
+        $userid = $USER->id;
+    
+        // Schritt 1: Alle Empfehlungen abrufen
         $records = $DB->get_records(self::TABLE_RECOMMENDATIONS, [
             'assignment_id' => $assignmentid,
             'submission_id' => $submissionid,
-    ]);
-
+        ]);
+    
+        // Schritt 2: Modul-ID für 'assign' abrufen
+        $module = $DB->get_record('modules', ['name' => 'assign'], 'id');
+        if (!$module) {
+            // Fehlerbehandlung, falls das Modul nicht gefunden wird
+            return $records;
+        }
+        $moduleid = $module->id;
+    
+        // Schritt 3: Überprüfe jeden Datensatz
+        foreach ($records as $key => $record) {
+            // Hol den Namen der Ãœbung aus dem Datensatz
+            $exercisename = $record->exercise_name;
+    
+            // Suche das Assignment mit diesem Namen
+            $assign = $DB->get_record('assign', ['name' => $exercisename], 'id');
+    
+            if ($assign) {
+                // Hole die Kursmodul-ID (coursemoduleid) für dieses Assignment
+                $cm = $DB->get_record('course_modules', [
+                    'module' => $moduleid,
+                    'instance' => $assign->id
+                ], 'id');
+    
+                if ($cm) {
+                    // Überprüfe den Abschlussstatus für dieses Kursmodul und den Benutzer
+                    $completion = $DB->get_record('course_modules_completion', [
+                        'coursemoduleid' => $cm->id,
+                        'userid' => $userid
+                    ], 'completionstate');
+    
+                    // Wenn der Abschlussstatus 1 ist, entferne den Datensatz aus $records
+                    if ($completion && $completion->completionstate == 1) {
+                        unset($records[$key]);
+                    }
+                }
+            }
+        }
+    
+        // Rückgabe der gefilterten Datensätze
         return $records;
     }
+    
 
     /**
      * gets summary with all corresponding result entries