Mark LearningContentAssignment completion in backend
This commit is contained in:
parent
36152a4364
commit
3d4654efbc
|
|
@ -4,9 +4,11 @@ import ItButton from "@/components/ui/ItButton.vue";
|
|||
import ItCheckbox from "@/components/ui/ItCheckbox.vue";
|
||||
import ItSuccessAlert from "@/components/ui/ItSuccessAlert.vue";
|
||||
import { useCurrentCourseSession } from "@/composables";
|
||||
import { bustItGetCache } from "@/fetchHelpers";
|
||||
import { UPSERT_ASSIGNMENT_COMPLETION_MUTATION } from "@/graphql/mutations";
|
||||
import AssignmentSubmissionResponses from "@/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionResponses.vue";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import type { Assignment, AssignmentCompletion, AssignmentTask } from "@/types";
|
||||
import { useMutation } from "@urql/vue";
|
||||
import type { Dayjs } from "dayjs";
|
||||
|
|
@ -61,7 +63,7 @@ const onEditTask = (task: AssignmentTask) => {
|
|||
const onSubmit = async () => {
|
||||
try {
|
||||
// noinspection TypeScriptValidateTypes
|
||||
upsertAssignmentCompletionMutation.executeMutation({
|
||||
await upsertAssignmentCompletionMutation.executeMutation({
|
||||
assignmentId: props.assignment.id.toString(),
|
||||
courseSessionId: courseSession.value.id.toString(),
|
||||
completionDataString: JSON.stringify({}),
|
||||
|
|
@ -70,6 +72,9 @@ const onSubmit = async () => {
|
|||
// @ts-ignore
|
||||
id: props.assignmentCompletion?.id,
|
||||
});
|
||||
bustItGetCache(
|
||||
`/api/course/completion/${courseSession.value.id}/${useUserStore().id}/`
|
||||
);
|
||||
} catch (error) {
|
||||
log.error("Could not submit assignment", error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,6 +163,9 @@ export const useCircleStore = defineStore({
|
|||
if (currentLearningContent) {
|
||||
if (currentLearningContent.can_user_self_toggle_course_completion) {
|
||||
this.markCompletion(currentLearningContent, "SUCCESS");
|
||||
} else {
|
||||
// reload completion data anyway
|
||||
currentLearningContent.parentCircle?.parentLearningPath?.reloadCompletionData();
|
||||
}
|
||||
this.closeLearningContent(currentLearningContent);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ from vbv_lernwelt.assignment.models import (
|
|||
)
|
||||
from vbv_lernwelt.core.models import User
|
||||
from vbv_lernwelt.core.utils import find_first
|
||||
from vbv_lernwelt.course.models import CourseSession
|
||||
from vbv_lernwelt.course.models import CourseCompletionStatus, CourseSession
|
||||
from vbv_lernwelt.course.services import mark_course_completion
|
||||
|
||||
|
||||
def update_assignment_completion(
|
||||
|
|
@ -172,11 +173,15 @@ def update_assignment_completion(
|
|||
acl.completion_data[key].update(task_data)
|
||||
acl.save()
|
||||
|
||||
# if completion_status == "SUBMITTED":
|
||||
# mark_course_completion(
|
||||
# user=assignment_user,
|
||||
# page=ac.
|
||||
# )
|
||||
if completion_status == "SUBMITTED":
|
||||
learning_content = assignment.learningcontentassignment_set.first()
|
||||
if learning_content:
|
||||
mark_course_completion(
|
||||
user=assignment_user,
|
||||
page=learning_content,
|
||||
course_session=course_session,
|
||||
completion_status=CourseCompletionStatus.SUCCESS.value,
|
||||
)
|
||||
|
||||
return ac
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +1,65 @@
|
|||
# Generated by Django 3.2.13 on 2023-06-26 15:24
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import vbv_lernwelt.course.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0083_workflowcontenttype'),
|
||||
('course', '0005_remove_coursesession_attendance_courses'),
|
||||
("wagtailcore", "0083_workflowcontenttype"),
|
||||
("course", "0005_remove_coursesession_attendance_courses"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='coursecompletion',
|
||||
name='course_completion_unique_user_page_key',
|
||||
model_name="coursecompletion",
|
||||
name="course_completion_unique_user_page_key",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='coursecompletion',
|
||||
name='page_key',
|
||||
model_name="coursecompletion",
|
||||
name="page_key",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='coursecompletion',
|
||||
name='page_slug',
|
||||
model_name="coursecompletion",
|
||||
name="page_slug",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='coursecompletion',
|
||||
name='page',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.page'),
|
||||
model_name="coursecompletion",
|
||||
name="page",
|
||||
field=models.ForeignKey(
|
||||
default=1,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="wagtailcore.page",
|
||||
),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='coursecompletion',
|
||||
name='completion_status',
|
||||
field=models.CharField(choices=[(vbv_lernwelt.course.models.CourseCompletionStatus['SUCCESS'], 'SUCCESS'), (vbv_lernwelt.course.models.CourseCompletionStatus['FAIL'], 'FAIL'), (vbv_lernwelt.course.models.CourseCompletionStatus['UNKNOWN'], 'UNKNOWN')], default='UNKNOWN', max_length=255),
|
||||
model_name="coursecompletion",
|
||||
name="completion_status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
(
|
||||
vbv_lernwelt.course.models.CourseCompletionStatus["SUCCESS"],
|
||||
"SUCCESS",
|
||||
),
|
||||
(vbv_lernwelt.course.models.CourseCompletionStatus["FAIL"], "FAIL"),
|
||||
(
|
||||
vbv_lernwelt.course.models.CourseCompletionStatus["UNKNOWN"],
|
||||
"UNKNOWN",
|
||||
),
|
||||
],
|
||||
default="UNKNOWN",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='coursecompletion',
|
||||
constraint=models.UniqueConstraint(fields=('user', 'page', 'course_session'), name='course_completion_unique_user_page_key'),
|
||||
model_name="coursecompletion",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("user", "page", "course_session"),
|
||||
name="course_completion_unique_user_page_key",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.13 on 2023-06-26 16:30
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("assignment", "0004_assignment_assignment_type"),
|
||||
("learnpath", "0008_auto_20230626_1747"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="learningcontentassignment",
|
||||
name="content_assignment",
|
||||
field=models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.PROTECT, to="assignment.assignment"
|
||||
),
|
||||
),
|
||||
]
|
||||
Loading…
Reference in New Issue