Skip to content

Commit

Permalink
calculate endDate of exam with workingTime (ls1intum#1775)
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-gregurevic authored Jul 1, 2020
1 parent 6a8a30a commit 7648294
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<jhi-exam-navigation-bar
id="exam-navigation-bar"
[exercises]="studentExam.exercises"
[endDate]="exam.endDate"
[endDate]="individualStudentEndDate"
(onExerciseChanged)="onExerciseChange($event)"
></jhi-exam-navigation-bar>
<ng-container *ngFor="let exercise of studentExam.exercises; let i = index">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { Submission } from 'app/entities/submission.model';
import { Exam } from 'app/entities/exam.model';
import { ArtemisServerDateService } from 'app/shared/server-date.service';
import { ProgrammingExercise } from 'app/entities/programming-exercise.model';
import * as moment from 'moment';
import { Moment } from 'moment';

@Component({
selector: 'jhi-exam-participation',
Expand All @@ -44,6 +46,8 @@ export class ExamParticipationComponent implements OnInit, OnDestroy {
exam: Exam;
studentExam: StudentExam;

individualStudentEndDate: Moment;

activeExercise: Exercise;
unsavedChanges = false;
disconnected = false;
Expand Down Expand Up @@ -93,6 +97,7 @@ export class ExamParticipationComponent implements OnInit, OnDestroy {
this.examId = parseInt(params['examId'], 10);
this.examParticipationService.loadExam(this.courseId, this.examId).subscribe((exam) => {
this.exam = exam;
this.individualStudentEndDate = exam.endDate ? exam.endDate : this.serverDateService.now();
if (this.isOver()) {
this.examParticipationService.loadStudentExam(this.exam.course.id, this.exam.id).subscribe((studentExam: StudentExam) => {
this.studentExam = studentExam;
Expand Down Expand Up @@ -122,6 +127,8 @@ export class ExamParticipationComponent implements OnInit, OnDestroy {
// init studentExam and activeExercise
this.studentExam = studentExam;
this.activeExercise = studentExam.exercises[0];
// set endDate with workingTime
this.individualStudentEndDate = this.exam.startDate ? moment(this.exam.startDate).add(studentExam.workingTime, 'seconds') : this.individualStudentEndDate;
// initializes array which manages submission component initialization
this.submissionComponentVisited = new Array(studentExam.exercises.length).fill(false);
this.submissionComponentVisited[0] = true;
Expand Down Expand Up @@ -184,10 +191,7 @@ export class ExamParticipationComponent implements OnInit, OnDestroy {
* check if exam is over
*/
isOver(): boolean {
if (!this.exam) {
return false;
}
return this.exam.endDate ? this.exam.endDate.isBefore(this.serverDateService.now()) : false;
return this.individualStudentEndDate.isBefore(this.serverDateService.now());
}

/**
Expand Down

0 comments on commit 7648294

Please sign in to comment.