diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java index df0e389c..87a6dbb0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/exam/Exam.java @@ -61,6 +61,7 @@ public final class Exam implements GrantEntity { public static final String FILTER_ATTR_TYPE = "type"; public static final String FILTER_ATTR_STATUS = "status"; public static final String FILTER_CACHED_QUIZZES = "cached-quizzes"; + public static final String FILTER_ATTR_HIDE_MISSING = "show-missing"; public static final String ATTR_ADDITIONAL_ATTRIBUTES = "additionalAttributes"; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java index e2f8737d..1ab0e433 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/action/ActionDefinition.java @@ -297,6 +297,17 @@ public enum ActionDefinition { PageStateDefinitionImpl.EXAM_VIEW, ActionCategory.FORM), + EXAM_LIST_HIDE_MISSING( + new LocTextKey("sebserver.exam.action.list.hide.missing"), + ImageIcon.TOGGLE_OFF, + PageStateDefinitionImpl.EXAM_LIST, + ActionCategory.EXAM_LIST), + EXAM_LIST_SHOW_MISSING( + new LocTextKey("sebserver.exam.action.list.show.missing"), + ImageIcon.TOGGLE_ON, + PageStateDefinitionImpl.EXAM_LIST, + ActionCategory.EXAM_LIST), + EXAM_MODIFY_SEB_RESTRICTION_DETAILS( new LocTextKey("sebserver.exam.action.sebrestriction.details"), ImageIcon.RESTRICTION, @@ -956,6 +967,7 @@ public enum ActionDefinition { ImageIcon.TOGGLE_ON, PageStateDefinitionImpl.MONITORING_RUNNING_EXAM, ActionCategory.STATE_FILTER), + MONITOR_EXAM_HIDE_CLOSED_CONNECTION( new LocTextKey("sebserver.monitoring.exam.connection.action.hide.closed"), ImageIcon.TOGGLE_OFF, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java index cb6f6512..6d0dc0ac 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamList.java @@ -243,6 +243,29 @@ public class ExamList implements TemplateComposer { EMPTY_SELECTION_TEXT_KEY) .publishIf(() -> userGrant.im(), false); + actionBuilder + .newAction(ActionDefinition.EXAM_LIST_HIDE_MISSING) + .withExec(action -> hideMissingExams(action, table)) + .noEventPropagation() + .withSwitchAction( + actionBuilder.newAction(ActionDefinition.EXAM_LIST_SHOW_MISSING) + .withExec(action -> showMissingExams(action, table)) + .noEventPropagation() + .create()) + .publish(); + + } + + private PageAction showMissingExams(final PageAction action, final EntityTable table) { + table.setStaticFilter(Exam.FILTER_ATTR_HIDE_MISSING, Constants.FALSE_STRING); + table.applyFilter(); + return action; + } + + private PageAction hideMissingExams(final PageAction action, final EntityTable table) { + table.setStaticFilter(Exam.FILTER_ATTR_HIDE_MISSING, Constants.TRUE_STRING); + table.applyFilter(); + return action; } static PageAction modifyExam(final PageAction action, final EntityTable table) { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index b2fef43a..241604e1 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -254,6 +254,10 @@ public class EntityTable { return this.sortOrder; } + public void setStaticFilter(final String name, final String value) { + this.staticQueryParams.set(name, value); + } + public EntityType getEntityType() { if (this.pageSupplier != null) { return this.pageSupplier.getEntityType(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java index 3b791e0a..d6a81aa6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java @@ -183,6 +183,13 @@ public class ExamRecordDAO { ExamRecordDynamicSqlSupport.type, isEqualToWhenPresent(filterMap.getExamType())); + // SEBSERV-298 + if (filterMap.getBoolean(Exam.FILTER_ATTR_HIDE_MISSING)) { + whereClause = whereClause.and( + ExamRecordDynamicSqlSupport.lmsAvailable, + SqlBuilder.isGreaterThan(0)); + } + final String examStatus = filterMap.getExamStatus(); if (StringUtils.isNotBlank(examStatus)) { whereClause = whereClause diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index e0b92817..2db525b3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -265,7 +265,8 @@ public class ExamSessionServiceImpl implements ExamSessionService { filterMap .putIfAbsent(Exam.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING) - .putIfAbsent(Exam.FILTER_ATTR_STATUS, ExamStatus.RUNNING.name()); + .putIfAbsent(Exam.FILTER_ATTR_STATUS, ExamStatus.RUNNING.name()) + .putIfAbsent(Exam.FILTER_ATTR_HIDE_MISSING, Constants.TRUE_STRING); return this.examDAO.allMatching(filterMap, predicate) .map(col -> col.stream() diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 5a821bc5..a8789a59 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -528,6 +528,8 @@ sebserver.exam.autogen.error.config.text=There was an unexpected error while set sebserver.exam.action.list=Exam sebserver.exam.action.list.view=View Exam sebserver.exam.action.list.modify=Edit Exam +sebserver.exam.action.list.hide.missing=Hide Missing Exams +sebserver.exam.action.list.show.missing=Show Missing Exams sebserver.exam.action.modify=Edit Exam sebserver.exam.action.import=Import From Quizzes sebserver.exam.action.save=Save Exam