"start" not "end" should be mandatory
This commit is contained in:
parent
c4d10badf6
commit
282e62ef6f
|
|
@ -60,7 +60,9 @@ function editTask(task: AssignmentEvaluationTask) {
|
|||
|
||||
const assignmentDetail = computed(() => findAssignmentDetail(props.assignment.id));
|
||||
|
||||
const dueDate = computed(() => dayjs(assignmentDetail.value?.evaluation_deadline_end));
|
||||
const dueDate = computed(() =>
|
||||
dayjs(assignmentDetail.value?.evaluation_deadline_start)
|
||||
);
|
||||
|
||||
const inEvaluationTask = computed(
|
||||
() => stepIndex.value >= 1 && stepIndex.value <= numTasks.value
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ const assignmentDetail = computed(() =>
|
|||
<div v-if="assignmentDetail">
|
||||
<span>
|
||||
Abgabetermin:
|
||||
{{ dayjs(assignmentDetail.submission_deadline_end).format("DD.MM.YYYY") }}
|
||||
{{ dayjs(assignmentDetail.submission_deadline_start).format("DD.MM.YYYY") }}
|
||||
</span>
|
||||
-
|
||||
<span>
|
||||
Freigabetermin:
|
||||
{{ dayjs(assignmentDetail.evaluation_deadline_end).format("DD.MM.YYYY") }}
|
||||
{{ dayjs(assignmentDetail.evaluation_deadline_start).format("DD.MM.YYYY") }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ const showPreviousButton = computed(() => stepIndex.value != 0);
|
|||
const showNextButton = computed(() => stepIndex.value + 1 < numPages.value);
|
||||
const showExitButton = computed(() => numPages.value === stepIndex.value + 1);
|
||||
const dueDate = computed(() =>
|
||||
dayjs(state.courseSessionAssignment?.submission_deadline_end)
|
||||
dayjs(state.courseSessionAssignment?.submission_deadline_start)
|
||||
);
|
||||
const currentTask = computed(() => {
|
||||
if (stepIndex.value > 0 && stepIndex.value <= numTasks.value) {
|
||||
|
|
|
|||
|
|
@ -428,9 +428,9 @@ export interface CourseSessionAssignment {
|
|||
course_session_id: number;
|
||||
learning_content_id: number;
|
||||
submission_deadline_id: number;
|
||||
submission_deadline_end: string;
|
||||
submission_deadline_start: string;
|
||||
evaluation_deadline_id: number;
|
||||
evaluation_deadline_end: string;
|
||||
evaluation_deadline_start: string;
|
||||
}
|
||||
|
||||
export interface CourseSession {
|
||||
|
|
|
|||
|
|
@ -180,11 +180,11 @@ def create_course_session_assignment(course_session, assignment):
|
|||
course_session.save()
|
||||
submission_deadline = csa.submission_deadline
|
||||
if submission_deadline:
|
||||
submission_deadline.end = course_session.start_date + timedelta(days=14)
|
||||
submission_deadline.start = course_session.start_date + timedelta(days=14)
|
||||
submission_deadline.save()
|
||||
evaluation_deadline = csa.evaluation_deadline
|
||||
if evaluation_deadline:
|
||||
evaluation_deadline.end = course_session.start_date + timedelta(days=28)
|
||||
evaluation_deadline.start = course_session.start_date + timedelta(days=28)
|
||||
evaluation_deadline.save()
|
||||
return csa
|
||||
|
||||
|
|
|
|||
|
|
@ -589,11 +589,11 @@ def create_course_session_assignments(course_session, assignment_slug, i=1):
|
|||
course_session.save()
|
||||
submission_deadline = csa.submission_deadline
|
||||
if submission_deadline:
|
||||
submission_deadline.end = course_session.start_date + timedelta(days=14)
|
||||
submission_deadline.start = course_session.start_date + timedelta(days=14)
|
||||
submission_deadline.save()
|
||||
evaluation_deadline = csa.evaluation_deadline
|
||||
if evaluation_deadline:
|
||||
evaluation_deadline.end = course_session.start_date + timedelta(days=28)
|
||||
evaluation_deadline.start = course_session.start_date + timedelta(days=28)
|
||||
evaluation_deadline.save()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ class CourseSessionAttendanceCourseSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
class CourseSessionAssignmentSerializer(serializers.ModelSerializer):
|
||||
submission_deadline_end = serializers.SerializerMethodField()
|
||||
evaluation_deadline_end = serializers.SerializerMethodField()
|
||||
submission_deadline_start = serializers.SerializerMethodField()
|
||||
evaluation_deadline_start = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = CourseSessionAssignment
|
||||
|
|
@ -41,15 +41,15 @@ class CourseSessionAssignmentSerializer(serializers.ModelSerializer):
|
|||
"course_session_id",
|
||||
"learning_content_id",
|
||||
"submission_deadline_id",
|
||||
"submission_deadline_end",
|
||||
"submission_deadline_start",
|
||||
"evaluation_deadline_id",
|
||||
"evaluation_deadline_end",
|
||||
"evaluation_deadline_start",
|
||||
]
|
||||
|
||||
def get_evaluation_deadline_end(self, obj):
|
||||
def get_evaluation_deadline_start(self, obj):
|
||||
if obj.evaluation_deadline:
|
||||
return obj.evaluation_deadline.end
|
||||
return obj.evaluation_deadline.start
|
||||
|
||||
def get_submission_deadline_end(self, obj):
|
||||
def get_submission_deadline_start(self, obj):
|
||||
if obj.submission_deadline:
|
||||
return obj.submission_deadline.end
|
||||
return obj.submission_deadline.start
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ class CourseSessionModelsTestCase(TestCase):
|
|||
deadline_date = datetime(
|
||||
2023, 7, 6, 8, 30, tzinfo=timezone.get_current_timezone()
|
||||
)
|
||||
due_date.end = deadline_date
|
||||
due_date.start = deadline_date
|
||||
due_date.save()
|
||||
|
||||
this_date = DueDate.objects.get(pk=due_date.pk)
|
||||
self.assertEqual(this_date.end, deadline_date)
|
||||
self.assertEqual(this_date.start, deadline_date)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 3.2.13 on 2023-07-12 07:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("duedate", "0009_alter_duedate_course_session"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="duedate",
|
||||
name="description",
|
||||
field=models.CharField(blank=True, default="", max_length=1024),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="duedate",
|
||||
name="end",
|
||||
field=models.DateTimeField(blank=True, db_index=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="duedate",
|
||||
name="learning_content_description",
|
||||
field=models.CharField(blank=True, default="", max_length=1024),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="duedate",
|
||||
name="start",
|
||||
field=models.DateTimeField(db_index=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="duedate",
|
||||
name="title",
|
||||
field=models.CharField(default="", max_length=1024),
|
||||
),
|
||||
]
|
||||
|
|
@ -10,12 +10,13 @@ from vbv_lernwelt.course.models import CourseSession
|
|||
|
||||
|
||||
class DueDate(models.Model):
|
||||
start = models.DateTimeField(null=True, blank=True, db_index=True)
|
||||
end = models.DateTimeField(db_index=True, null=True)
|
||||
# TODO: Welcher Default Wert ist hier sinnvoll?
|
||||
title = models.CharField(default=_("Termin"), max_length=1024)
|
||||
learning_content_description = models.CharField(default="", max_length=1024)
|
||||
description = models.CharField(default="", max_length=1024)
|
||||
start = models.DateTimeField(null=True, db_index=True)
|
||||
end = models.DateTimeField(null=True, blank=True, db_index=True)
|
||||
title = models.CharField(default="", max_length=1024)
|
||||
learning_content_description = models.CharField(
|
||||
default="", blank=True, max_length=1024
|
||||
)
|
||||
description = models.CharField(default="", blank=True, max_length=1024)
|
||||
url = models.CharField(default="", blank=True, max_length=1024)
|
||||
course_session = models.ForeignKey(
|
||||
"course.CourseSession",
|
||||
|
|
@ -28,20 +29,27 @@ class DueDate(models.Model):
|
|||
def Meta(self):
|
||||
ordering = ["start", "end"]
|
||||
verbose_name = _("Termin")
|
||||
help = "The end date is mandatory. You can set the start date if you want to have a deadline with a duration."
|
||||
help = "The start date is mandatory. You can set the end date if you want to have a deadline with a duration."
|
||||
|
||||
def __str__(self):
|
||||
if self.is_undefined:
|
||||
return f"DueDate: {self.title} undefined"
|
||||
start_str = self.start.strftime("%Y-%m-%d %H:%M") if self.start else "-"
|
||||
end_str = self.end.strftime("%Y-%m-%d %H:%M") if self.end else "-"
|
||||
return f"DueDate: {self.title} {start_str} to {end_str}"
|
||||
result = f"DueDate: {self.title} {start_str}"
|
||||
|
||||
if self.end:
|
||||
end_str = self.end.strftime("%Y-%m-%d %H:%M") if self.end else "-"
|
||||
result += f" - {end_str}"
|
||||
|
||||
return result
|
||||
|
||||
@property
|
||||
def is_undefined(self):
|
||||
return self.end is None
|
||||
return self.start is None
|
||||
|
||||
@property
|
||||
def duration(self):
|
||||
if self.start is None:
|
||||
if self.end is None:
|
||||
return datetime.timedelta(0)
|
||||
return self.end - self.start
|
||||
|
||||
|
|
@ -65,12 +73,12 @@ class DueDate(models.Model):
|
|||
else:
|
||||
qs = qs.filter(course_session__course_assignment__user=user)
|
||||
|
||||
qs = qs.order_by("end")[:limit]
|
||||
qs = qs.order_by("start")[:limit]
|
||||
|
||||
return qs
|
||||
|
||||
@classmethod
|
||||
def get_next_due_dates_qs(cls):
|
||||
now = timezone.now()
|
||||
qs = cls.objects.filter(end__gte=now)
|
||||
qs = cls.objects.filter(start__gte=now)
|
||||
return qs
|
||||
|
|
|
|||
Loading…
Reference in New Issue