Skip to content

Commit

Permalink
refactor: update extension granularity from weeks to days
Browse files Browse the repository at this point in the history
  • Loading branch information
ublefo committed May 2, 2024
1 parent 4b6f81e commit 79a6137
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/app/api/models/task-comment/extension-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ExtensionComment extends TaskComment {
granted: boolean;
extensionResponse: string;
dateAssessed: Date;
weeksRequested: number;
daysRequested: number;

taskStatus: string;
taskDueDate: Date;
Expand Down
19 changes: 3 additions & 16 deletions src/app/api/models/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,29 +689,16 @@ export class Task extends Entity {
this.unit.allowStudentExtensionRequests &&
this.inStateThatAllowsExtension() &&
(!this.isPastDeadline() || this.wasSubmittedOnTime()) &&
this.maxWeeksCanExtend() > 0
this.maxDaysCanExtend() > 0
);
}

public wasSubmittedOnTime() {
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());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/models/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Unit extends Entity {
draftTaskDefinition: TaskDefinition;

allowStudentExtensionRequests: boolean;
extensionWeeksOnResubmitRequest: number;
extensionDaysOnResubmitRequest: number;
allowStudentChangeTutorial: boolean;

public readonly learningOutcomesCache: EntityCache<LearningOutcome> = new EntityCache<LearningOutcome>();
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/services/task-comment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class TaskCommentService extends CachedEntityService<TaskComment> {
'extensionResponse',
'granted',
'dateAssessed',
'weeksRequested',
'daysRequested',
'taskStatus',
['taskDueDate', 'due_date'],
['taskExtensions', 'extensions'],
Expand Down Expand Up @@ -184,12 +184,12 @@ export class TaskCommentService extends CachedEntityService<TaskComment> {
);
}

public requestExtension(reason: string, weeksRequested: number, task: any): Observable<TaskComment> {
public requestExtension(reason: string, daysRequested: number, task: any): Observable<TaskComment> {
const opts: RequestOptions<TaskComment> = {
endpointFormat: this.requestExtensionEndpointFormat,
body: {
comment: reason,
weeks_requested: weeksRequested,
days_requested: daysRequested,
},
cache: task.commentCache
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/services/unit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class UnitService extends CachedEntityService<Unit> {
'enableSyncEnrolments',
'enableSyncTimetable',
'allowStudentExtensionRequests',
'extensionWeeksOnResubmitRequest',
'extensionDaysOnResubmitRequest',
'allowStudentChangeTutorial',
{
keys: 'ilos',
Expand Down Expand Up @@ -234,7 +234,7 @@ export class UnitService extends CachedEntityService<Unit> {

'draftTaskDefinition',
'allowStudentExtensionRequests',
'extensionWeeksOnResubmitRequest',
'extensionDaysOnResubmitRequest',
'allowStudentChangeTutorial'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<li>Start Date &mdash; Aim to start this task by {{ startDate() | date: 'EEE d MMM' }}.</li>
<li [hidden]="!task?.extensions || task?.extensions <= 0">
Extension &mdash; You have an extension for
{{ task?.extensions }} week{{ task?.extensions > 1 ? 's' : '' }}.
{{ task?.extensions }} day{{ task?.extensions > 1 ? 's' : '' }}.
</li>
<li>Due Date &mdash; Aim to complete by {{ dueDate() | date: 'EEE d MMM' }}.</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ <h3 class="panel-title">Update Unit</h3>
id="code"
type="number"
placeholder="1"
ng-model="unit.extensionWeeksOnResubmitRequest"
ng-model="unit.extensionDaysOnResubmitRequest"
/>
<span class="help-block">
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.
</span>
</div>
</div>
<!--/extensionWeeksOnResubmitRequest-->
<!--/extensionDaysOnResubmitRequest-->

<div class="form-group">
<label class="col-sm-2 control-label" for="enddate">Auto apply extensions</label>
Expand Down

0 comments on commit 79a6137

Please sign in to comment.