fixed start time filter for exams. Running exams are always shown
This commit is contained in:
		
							parent
							
								
									03937afc62
								
							
						
					
					
						commit
						14334f0d7e
					
				
					 2 changed files with 7 additions and 3 deletions
				
			
		|  | @ -153,6 +153,10 @@ public class ExamDAOImpl implements ExamDAO { | ||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|                 if (from != null) { |                 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)) { |                     if (exam.startTime.isBefore(from)) { | ||||||
|                         return false; |                         return false; | ||||||
|                     } |                     } | ||||||
|  | @ -755,7 +759,7 @@ public class ExamDAOImpl implements ExamDAO { | ||||||
|             try { |             try { | ||||||
|                 status = ExamStatus.valueOf(record.getStatus()); |                 status = ExamStatus.valueOf(record.getStatus()); | ||||||
|             } catch (final Exception e) { |             } 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; |                 status = ExamStatus.UP_COMING; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  | @ -766,7 +770,7 @@ public class ExamDAOImpl implements ExamDAO { | ||||||
|                     record.getExternalId(), |                     record.getExternalId(), | ||||||
|                     (quizData != null) ? quizData.name : Constants.EMPTY_NOTE, |                     (quizData != null) ? quizData.name : Constants.EMPTY_NOTE, | ||||||
|                     (quizData != null) ? quizData.description : 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.endTime : null, | ||||||
|                     (quizData != null) ? quizData.startURL : Constants.EMPTY_NOTE, |                     (quizData != null) ? quizData.startURL : Constants.EMPTY_NOTE, | ||||||
|                     ExamType.valueOf(record.getType()), |                     ExamType.valueOf(record.getType()), | ||||||
|  |  | ||||||
|  | @ -106,7 +106,7 @@ public interface LmsAPIService { | ||||||
|             final boolean nameFilter = StringUtils.isBlank(name) || (q.name != null && q.name.contains(name)); |             final boolean nameFilter = StringUtils.isBlank(name) || (q.name != null && q.name.contains(name)); | ||||||
|             final boolean startTimeFilter = |             final boolean startTimeFilter = | ||||||
|                     (from == null) || (q.startTime != null && (q.startTime.isEqual(from) || q.startTime.isAfter(from))); |                     (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); |             return nameFilter && (startTimeFilter || currentlyRunning); | ||||||
|         }; |         }; | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 anhefti
						anhefti