Skip to content

Commit

Permalink
Fixed Issue TEAMMATES#12655: Instructor Edit Session Page: If make se…
Browse files Browse the repository at this point in the history
…ssion visible is later than submission opening time, automatically default to opening time
  • Loading branch information
willzoo committed Feb 11, 2024
1 parent f469c45 commit feb3ae3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ <h5>Or</h5>
[date]="model.submissionStartDate"></tm-datepicker>
</div>
<div class="col-md-5">
<tm-timepicker id="submission-start-time" [isDisabled]="!model.isEditable" (timeChange)="triggerModelChange('submissionStartTime', $event)"
<tm-timepicker id="submission-start-time" [isDisabled]="!model.isEditable" (timeChange)="triggerSubmissionOpeningTimeModelChange('submissionStartTime', $event)"
[minDate]="minDateForSubmissionStart" [maxDate]="maxDateForSubmissionStart"
[date]="model.submissionStartDate"
[minTime]="minTimeForSubmissionStart" [maxTime]="maxTimeForSubmissionStart"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,29 @@ export class SessionEditFormComponent {
this.configureSubmissionOpeningTime(minTime);
this.model.submissionStartTime = minTime;
}

// Checks for case where Session Visible Date later than Submission Opening Date
this.configureSessionVisibleDateTime(date, this.model.submissionStartTime)

this.triggerModelChange(field, date);
}

/**
* Triggers the change of the model when the submission opening date changes.
*/
triggerSubmissionOpeningTimeModelChange(field: string, time: TimeFormat): void {
const date : DateFormat = this.model.submissionStartDate;
const sessionDate : DateFormat = this.model.customSessionVisibleDate
const sessionTime: TimeFormat = this.model.customSessionVisibleTime;

// Case where session visible and submission opening dates equal but submission opening time is earlier
if (DateTimeService.compareDateFormat(date, sessionDate) === 0
&& DateTimeService.compareTimeFormat(time, sessionTime) === -1) {
this.configureSessionVisibleDateTime(date, time);
}

this.triggerModelChange(field, time);
}

/**
* Configures the time for the submission opening time.
Expand All @@ -164,6 +184,23 @@ export class SessionEditFormComponent {
}
}

/**
* Checks validity of Session Visible Date and Time, changes if invalid
*/
configureSessionVisibleDateTime(date : DateFormat, time : TimeFormat) : void {
const sessionDate: DateFormat = this.model.customSessionVisibleDate;
const sessionTime: TimeFormat = this.model.customSessionVisibleTime;

//Case where changed submission opening date is earlier than session visible date
if(DateTimeService.compareDateFormat(date, sessionDate) === -1){
this.model.customSessionVisibleDate = date;
} else if (DateTimeService.compareDateFormat(date, sessionDate) === 0
&& DateTimeService.compareTimeFormat(time, sessionTime)){
//Case where submission opening is same date but earlier time than session visible
this.model.customSessionVisibleTime = time;
}
}

/**
* Handles course Id change event.
*
Expand Down

0 comments on commit feb3ae3

Please sign in to comment.