fixed start time filter for exams. Running exams are always shown

This commit is contained in:
anhefti 2020-10-21 14:17:34 +02:00
parent 03937afc62
commit 14334f0d7e
2 changed files with 7 additions and 3 deletions

View file

@ -153,6 +153,10 @@ public class ExamDAOImpl implements ExamDAO {
}
if (from != null) {
// always show exams that has not ended yet
if (exam.endTime == null || exam.endTime.isAfter(from)) {
return true;
}
if (exam.startTime.isBefore(from)) {
return false;
}
@ -755,7 +759,7 @@ public class ExamDAOImpl implements ExamDAO {
try {
status = ExamStatus.valueOf(record.getStatus());
} catch (final Exception e) {
log.error("Missing exam status form data base. Set ExamStatus.UP_COMING as fallback ", e);
log.error("Missing exam status from data base. Set ExamStatus.UP_COMING as fallback ", e);
status = ExamStatus.UP_COMING;
}
@ -766,7 +770,7 @@ public class ExamDAOImpl implements ExamDAO {
record.getExternalId(),
(quizData != null) ? quizData.name : Constants.EMPTY_NOTE,
(quizData != null) ? quizData.description : Constants.EMPTY_NOTE,
(quizData != null) ? quizData.startTime : null,
(quizData != null) ? quizData.startTime : new DateTime(0),
(quizData != null) ? quizData.endTime : null,
(quizData != null) ? quizData.startURL : Constants.EMPTY_NOTE,
ExamType.valueOf(record.getType()),

View file

@ -106,7 +106,7 @@ public interface LmsAPIService {
final boolean nameFilter = StringUtils.isBlank(name) || (q.name != null && q.name.contains(name));
final boolean startTimeFilter =
(from == null) || (q.startTime != null && (q.startTime.isEqual(from) || q.startTime.isAfter(from)));
final boolean currentlyRunning = DateTime.now(DateTimeZone.UTC).isBefore(q.endTime);
final boolean currentlyRunning = q.endTime == null || DateTime.now(DateTimeZone.UTC).isBefore(q.endTime);
return nameFilter && (startTimeFilter || currentlyRunning);
};
}