Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CoTA
moodle-assignsubmission_dta
Commits
10a23118
Commit
10a23118
authored
Oct 18, 2024
by
Kurzenberger
Browse files
adjusted for the "mark as done" Button
parent
8b78ca5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
dta.zip
View file @
10a23118
No preview for this file type
dta/classes/database.php
View file @
10a23118
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment