Skip to content

Commit

Permalink
Merge pull request #1 from WISVCH/master
Browse files Browse the repository at this point in the history
Update fork
  • Loading branch information
JoepdeJong authored Apr 20, 2021
2 parents 34e52cc + 0cb2019 commit 76c2807
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class CourseController(val courseService: CourseService, val examService: ExamSe
if (request.getParameter("study") != null && request.getParameter("study") != "") {
val studyEnum = Study.valueOf(request.getParameter("study"))

courses = courses.filter { item -> item.study!! == studyEnum }
courses = courses.filter { item -> item.study == studyEnum }
}

if (request.getParameter("program") != null && request.getParameter("program") != "") {
val studyProgramEnum = StudyProgram.valueOf(request.getParameter("program"))

courses = courses.filter { item -> item.studyProgram!! == studyProgramEnum }
courses = courses.filter { item -> item.studyProgram == studyProgramEnum }
}
} catch (e: IllegalArgumentException) {
return createResponseEntity(HttpStatus.BAD_REQUEST, "Invalid study or program input.")
Expand All @@ -105,6 +105,8 @@ class CourseController(val courseService: CourseService, val examService: ExamSe
val coursesDTO = courses.stream().map { course -> CourseDTO(course, getPredecessorsExams(course)) }
.collect(Collectors.toList())

coursesDTO.forEachIndexed { index, courseDTO -> coursesDTO[index].exam = courseDTO.exam?.sortedByDescending{it.date} }

return createResponseEntity(HttpStatus.OK, "List of all courses that match the search query", coursesDTO)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/ch/wisv/choice/course/model/CourseDTO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data class CourseDTO(
/**
* List of exam of this course
*/
var exam: Set<Exam>? = null
var exam: List<Exam>? = null
) {
constructor(course: Course, exams: Set<Exam>): this(course.code, course.name, course.predecessor, course.study, course.studyProgram, exams)
constructor(course: Course, exams: Set<Exam>): this(course.code, course.name, course.predecessor, course.study, course.studyProgram, exams.toList())
}
4 changes: 2 additions & 2 deletions src/main/resources/templates/dashboard/exam/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h3 class="panel-title">Add exam</h3>

<div class="form-group">
<label class="control-label">Date</label>
<input th:field="*{date}" type="date" class="form-control" required
<input id="date" name="date" type="date" class="form-control" required
placeholder="Click to select a date..." title="date">
</div>

Expand Down Expand Up @@ -145,7 +145,7 @@ <h3 class="panel-title">Add exam</h3>
enableTime: false,
altInput: true,
altFormat: 'F j, Y',
dateFormat: "d-m-yy"
dateFormat: "d-m-Y"
});
</script>
</body>
Expand Down

0 comments on commit 76c2807

Please sign in to comment.