From d9327345e9f9016dc0268dff3b5b7625e7a9cefe Mon Sep 17 00:00:00 2001 From: ublefo <90136978+ublefo@users.noreply.github.com> Date: Thu, 2 May 2024 21:41:54 +1000 Subject: [PATCH] refactor: update extension granularity from weeks to days --- .../models/task-comment/extension-comment.ts | 2 +- src/app/api/models/task.ts | 19 +++---------------- 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.ts | 10 ++-------- .../task-description-card.component.html | 2 +- .../extension-comment.component.ts | 4 ++-- .../unit-details-editor.tpl.html | 4 ++-- 9 files changed, 17 insertions(+), 36 deletions(-) diff --git a/src/app/api/models/task-comment/extension-comment.ts b/src/app/api/models/task-comment/extension-comment.ts index 443bb34200..aab3954fce 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 58e282efb7..2e643b2301 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,21 +697,8 @@ 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); - } - - /** - * Returns the minimum number of weeks 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) { - return 0; - } else { - return minWeeks; - } + public maxDaysCanExtend(): number { + return this.daysBetween(this.localDueDate(), this.definition.localDeadlineDate()); } /** diff --git a/src/app/api/models/unit.ts b/src/app/api/models/unit.ts index c977efe538..0726111fe5 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 9e646be77d..8ed773232a 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 740e9b6cc1..9264ba1c9f 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.ts b/src/app/common/modals/extension-modal/extension-modal.component.ts index 92a6c12443..9481af88ee 100644 --- a/src/app/common/modals/extension-modal/extension-modal.component.ts +++ b/src/app/common/modals/extension-modal/extension-modal.component.ts @@ -40,14 +40,8 @@ export class ExtensionModalComponent { }); get extensionDuration(): number { - // calculating the number of weeks between now and the requested date, rounding up - const days = differenceInDays(this.extensionDate, this.data.task.localDueDate()); - let weeks = differenceInWeeks(this.extensionDate, this.data.task.localDueDate()); - if (days % 7 > 0 || weeks == 0) { - // round week count up if there are less than a week left or requested range is not in weeks - weeks++; - } - return weeks; + // calculating the number of days between now and the requested date + return differenceInDays(this.extensionDate, this.data.task.localDueDate()) + 1; } // minimum date is due date if before target date, current date if after target date diff --git a/src/app/projects/states/dashboard/directives/task-dashboard/directives/task-description-card/task-description-card.component.html b/src/app/projects/states/dashboard/directives/task-dashboard/directives/task-description-card/task-description-card.component.html index a71e1fbc32..5e9afd5d94 100644 --- a/src/app/projects/states/dashboard/directives/task-dashboard/directives/task-description-card/task-description-card.component.html +++ b/src/app/projects/states/dashboard/directives/task-dashboard/directives/task-description-card/task-description-card.component.html @@ -9,7 +9,7 @@
  • Start Date — Aim to start this task by {{ startDate() | date: 'EEE d MMM' }}.
  • Extension — You have an extension for - {{ task?.extensions }} week{{ task?.extensions > 1 ? 's' : '' }}. + {{ task?.extensions }} day{{ task?.extensions > 1 ? 's' : '' }}.
  • Due Date — Aim to complete by {{ dueDate() | date: 'EEE d MMM' }}.
  • 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 ae2a9513eb..05093f3489 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 3cd81f09c4..191cd3e71e 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 @@ -202,7 +202,7 @@

    Update Unit

    id="code" type="number" placeholder="1" - ng-model="unit.extensionWeeksOnResubmitRequest" + ng-model="unit.extensionDaysOnResubmitRequest" /> When tutors request resubmission of a task, this setting determines how many weeks the task will be @@ -210,7 +210,7 @@

    Update Unit

    - +