From 5e7554e90f11b89c77c52d0cf676725929804eb5 Mon Sep 17 00:00:00 2001 From: ublefo <90136978+ublefo@users.noreply.github.com> Date: Mon, 22 Apr 2024 09:36:11 +1000 Subject: [PATCH] refactor: refactor extension to days --- .../models/task-comment/extension-comment.ts | 2 +- src/app/api/models/task.ts | 16 +++++++-------- src/app/api/models/unit.ts | 2 +- src/app/api/services/task-comment.service.ts | 6 +++--- src/app/api/services/unit.service.ts | 4 ++-- .../extension-modal.component.html | 15 +++++++------- .../extension-modal.component.scss | 4 ++-- .../extension-modal.component.ts | 20 +++++++++---------- .../extension-comment.component.ts | 4 ++-- .../unit-details-editor.tpl.html | 8 ++++---- 10 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/app/api/models/task-comment/extension-comment.ts b/src/app/api/models/task-comment/extension-comment.ts index 443bb3420..aab3954fc 100644 --- a/src/app/api/models/task-comment/extension-comment.ts +++ b/src/app/api/models/task-comment/extension-comment.ts @@ -12,7 +12,7 @@ export class ExtensionComment extends TaskComment { granted: boolean; extensionResponse: string; dateAssessed: Date; - weeksRequested: number; + daysRequested: number; taskStatus: string; taskDueDate: Date; diff --git a/src/app/api/models/task.ts b/src/app/api/models/task.ts index 58e282efb..cd2d05c67 100644 --- a/src/app/api/models/task.ts +++ b/src/app/api/models/task.ts @@ -689,7 +689,7 @@ export class Task extends Entity { this.unit.allowStudentExtensionRequests && this.inStateThatAllowsExtension() && (!this.isPastDeadline() || this.wasSubmittedOnTime()) && - this.maxWeeksCanExtend() > 0 + this.maxDaysCanExtend() > 0 ); } @@ -697,20 +697,20 @@ export class Task extends Entity { return this.submissionDate && this.submissionDate.getTime() <= this.definition.finalDeadlineDate().getTime(); } - public maxWeeksCanExtend(): number { - return Math.ceil(this.daysBetween(this.localDueDate(), this.definition.localDeadlineDate()) / 7); + public maxDaysCanExtend(): number { + return this.daysBetween(this.localDueDate(), this.definition.localDeadlineDate()); } /** - * Returns the minimum number of weeks the task must be extended to be + * Returns the minimum number of days the task must be extended to be * able to available for tutors to provide feedback. */ - public minWeeksCanExtend(): number { - const minWeeks = Math.ceil(this.daysBetween(this.localDueDate(), new Date()) / 7); - if (minWeeks < 0) { + public minDaysCanExtend(): number { + const minDays = Math.ceil(this.daysBetween(this.localDueDate(), new Date())); + if (minDays < 0) { return 0; } else { - return minWeeks; + return minDays; } } diff --git a/src/app/api/models/unit.ts b/src/app/api/models/unit.ts index c977efe53..0726111fe 100644 --- a/src/app/api/models/unit.ts +++ b/src/app/api/models/unit.ts @@ -60,7 +60,7 @@ export class Unit extends Entity { draftTaskDefinition: TaskDefinition; allowStudentExtensionRequests: boolean; - extensionWeeksOnResubmitRequest: number; + extensionDaysOnResubmitRequest: number; allowStudentChangeTutorial: boolean; public readonly learningOutcomesCache: EntityCache = new EntityCache(); diff --git a/src/app/api/services/task-comment.service.ts b/src/app/api/services/task-comment.service.ts index 9e646be77..8ed773232 100644 --- a/src/app/api/services/task-comment.service.ts +++ b/src/app/api/services/task-comment.service.ts @@ -76,7 +76,7 @@ export class TaskCommentService extends CachedEntityService { 'extensionResponse', 'granted', 'dateAssessed', - 'weeksRequested', + 'daysRequested', 'taskStatus', ['taskDueDate', 'due_date'], ['taskExtensions', 'extensions'], @@ -184,12 +184,12 @@ export class TaskCommentService extends CachedEntityService { ); } - public requestExtension(reason: string, weeksRequested: number, task: any): Observable { + public requestExtension(reason: string, daysRequested: number, task: any): Observable { const opts: RequestOptions = { endpointFormat: this.requestExtensionEndpointFormat, body: { comment: reason, - weeks_requested: weeksRequested, + days_requested: daysRequested, }, cache: task.commentCache }; diff --git a/src/app/api/services/unit.service.ts b/src/app/api/services/unit.service.ts index 740e9b6cc..9264ba1c9 100644 --- a/src/app/api/services/unit.service.ts +++ b/src/app/api/services/unit.service.ts @@ -128,7 +128,7 @@ export class UnitService extends CachedEntityService { 'enableSyncEnrolments', 'enableSyncTimetable', 'allowStudentExtensionRequests', - 'extensionWeeksOnResubmitRequest', + 'extensionDaysOnResubmitRequest', 'allowStudentChangeTutorial', { keys: 'ilos', @@ -234,7 +234,7 @@ export class UnitService extends CachedEntityService { 'draftTaskDefinition', 'allowStudentExtensionRequests', - 'extensionWeeksOnResubmitRequest', + 'extensionDaysOnResubmitRequest', 'allowStudentChangeTutorial' ); } diff --git a/src/app/common/modals/extension-modal/extension-modal.component.html b/src/app/common/modals/extension-modal/extension-modal.component.html index 9c1e900df..b7b6b236a 100644 --- a/src/app/common/modals/extension-modal/extension-modal.component.html +++ b/src/app/common/modals/extension-modal/extension-modal.component.html @@ -12,13 +12,12 @@

Extension request

Requesting extension to: {{ newDueDate }}

+ [(ngModel)]="daysRequested" + > @@ -30,9 +29,9 @@

Extension request

mat-stroked-button color="primary" mat-button - [disabled]="weeksRequested === 0 || reason.length < 15" + [disabled]="daysRequested === 0 || reason.length < 15" (click)="submitApplication()" > - Request {{ weeksRequested }} {{ weeksRequested === 1 ? 'week' : 'weeks' }} + Request {{ daysRequested }} {{ daysRequested === 1 ? 'day' : 'days' }} diff --git a/src/app/common/modals/extension-modal/extension-modal.component.scss b/src/app/common/modals/extension-modal/extension-modal.component.scss index 70e79a1ff..f1372d68e 100644 --- a/src/app/common/modals/extension-modal/extension-modal.component.scss +++ b/src/app/common/modals/extension-modal/extension-modal.component.scss @@ -1,5 +1,5 @@ -#requestWeekSlider { - width: 100%; +#requestDaySlider { + width: 95%; } diff --git a/src/app/common/modals/extension-modal/extension-modal.component.ts b/src/app/common/modals/extension-modal/extension-modal.component.ts index 1926fb2b2..13cd08d17 100644 --- a/src/app/common/modals/extension-modal/extension-modal.component.ts +++ b/src/app/common/modals/extension-modal/extension-modal.component.ts @@ -12,7 +12,7 @@ import { formatDate } from '@angular/common'; styleUrls: ['./extension-modal.component.scss'], }) export class ExtensionModalComponent implements OnInit { - weeksRequested: number; + daysRequested: number; reason: string = ''; constructor( public dialogRef: MatDialogRef, @@ -21,14 +21,14 @@ export class ExtensionModalComponent implements OnInit { ) {} ngOnInit() { - this.weeksRequested = this.minWeeksCanExtend + 1; - if (this.weeksRequested > this.maxWeeksCanExtend) { - this.weeksRequested = this.maxWeeksCanExtend; + this.daysRequested = this.minDaysCanExtend + 1; + if (this.daysRequested > this.maxDaysCanExtend) { + this.daysRequested = this.maxDaysCanExtend; } } get newDueDate() { - const calculatedDueDate = new Date(this.data.task.localDueDate().getTime() + this.weeksRequested * 1000 * 60 * 60 * 24 * 7 ); + const calculatedDueDate = new Date(this.data.task.localDueDate().getTime() + this.daysRequested * 1000 * 60 * 60 * 24 ); const taskDeadlineDate: Date = this.data.task.definition.localDeadlineDate(); const locale: string = AppInjector.get(LOCALE_ID); @@ -40,12 +40,12 @@ export class ExtensionModalComponent implements OnInit { } } - get maxWeeksCanExtend() { - return this.data.task.maxWeeksCanExtend(); + get maxDaysCanExtend() { + return this.data.task.maxDaysCanExtend(); } - get minWeeksCanExtend() { - return this.data.task.minWeeksCanExtend(); + get minDaysCanExtend() { + return this.data.task.minDaysCanExtend(); } private scrollCommentsDown(): void { @@ -59,7 +59,7 @@ export class ExtensionModalComponent implements OnInit { submitApplication() { const tcs: TaskCommentService = AppInjector.get(TaskCommentService); - tcs.requestExtension(this.reason, this.weeksRequested, this.data.task).subscribe({ + tcs.requestExtension(this.reason, this.daysRequested, this.data.task).subscribe({ next: ((tc: TaskComment) => { this.alerts.add('success', 'Extension requested.', 2000); this.scrollCommentsDown(); diff --git a/src/app/tasks/task-comments-viewer/extension-comment/extension-comment.component.ts b/src/app/tasks/task-comments-viewer/extension-comment/extension-comment.component.ts index ae2a9513e..05093f348 100644 --- a/src/app/tasks/task-comments-viewer/extension-comment/extension-comment.component.ts +++ b/src/app/tasks/task-comments-viewer/extension-comment/extension-comment.component.ts @@ -26,8 +26,8 @@ export class ExtensionCommentComponent implements OnInit { return this.comment.extensionResponse; } const subject = this.isStudent ? 'You have ' : studentName + ' has '; - const message = `requested an extension for ${this.comment.weeksRequested} ${ - this.comment.weeksRequested === 1 ? 'week' : 'weeks' + const message = `requested an extension for ${this.comment.daysRequested} ${ + this.comment.daysRequested === 1 ? 'day' : 'days' }.`; return subject + message; } diff --git a/src/app/units/states/edit/directives/unit-details-editor/unit-details-editor.tpl.html b/src/app/units/states/edit/directives/unit-details-editor/unit-details-editor.tpl.html index 3cd81f09c..912e4941f 100644 --- a/src/app/units/states/edit/directives/unit-details-editor/unit-details-editor.tpl.html +++ b/src/app/units/states/edit/directives/unit-details-editor/unit-details-editor.tpl.html @@ -201,16 +201,16 @@

Update Unit

class="form-control" id="code" type="number" - placeholder="1" - ng-model="unit.extensionWeeksOnResubmitRequest" + placeholder="7" + ng-model="unit.extensionDaysOnResubmitRequest" /> - When tutors request resubmission of a task, this setting determines how many weeks the task will be + When tutors request resubmission of a task, this setting determines how many days the task will be extended to allow students to fix and resubmit their work. - +