Commit 10a23118 authored by Kurzenberger's avatar Kurzenberger
Browse files

adjusted for the "mark as done" Button

Showing with 47 additions and 12 deletions
+47 -12
No preview for this file type
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment