fixed moodle course filter

This commit is contained in:
anhefti 2020-12-14 12:40:13 +01:00
parent 34c8e2e33c
commit 39a90d201b
3 changed files with 16 additions and 3 deletions

View file

@ -41,11 +41,15 @@ public class MonitoringExamSearchPopup {
new LocTextKey("sebserver.monitoring.search.list.empty");
private static final LocTextKey TABLE_COLUMN_NAME =
new LocTextKey("sebserver.monitoring.search.list.name");
private static final LocTextKey TABLE_COLUMN_IP_ADDRESS =
new LocTextKey("sebserver.monitoring.search.list.ip");
private final PageService pageService;
private final TableFilterAttribute nameFilter =
new TableFilterAttribute(CriteriaType.TEXT, ClientConnection.FILTER_ATTR_SESSION_ID);
private final TableFilterAttribute ipFilter =
new TableFilterAttribute(CriteriaType.TEXT, ClientConnection.FILTER_ATTR_IP_STRING);
protected MonitoringExamSearchPopup(final PageService pageService) {
this.pageService = pageService;
@ -79,6 +83,13 @@ public class MonitoringExamSearchPopup {
TABLE_COLUMN_NAME,
ClientConnection::getUserSessionId)
.withFilter(this.nameFilter))
.withColumn(new ColumnDefinition<>(
Domain.CLIENT_CONNECTION.ATTR_CLIENT_ADDRESS,
TABLE_COLUMN_IP_ADDRESS,
ClientConnection::getClientAddress)
.withFilter(this.ipFilter))
.withDefaultAction(t -> actionBuilder
.newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION)
.withParentEntityKey(examKey)

View file

@ -277,7 +277,7 @@ public class MoodleCourseAccess extends CourseAccess {
private Predicate<CourseData> getCourseFilter(final long from) {
final long now = DateTime.now(DateTimeZone.UTC).getMillis() / 1000;
return course -> {
if (course.end_date != null && course.end_date > 0 && course.end_date < now) {
if (course.end_date != null && course.end_date > now) {
return false;
}
if (course.time_created != null && course.time_created.longValue() < from) {
@ -294,7 +294,8 @@ public class MoodleCourseAccess extends CourseAccess {
final int size) throws JsonParseException, JsonMappingException, IOException {
try {
final long aYearAgo = DateTime.now(DateTimeZone.UTC).minusYears(1).getMillis() / 1000;
// TODO use start date from filter
final long twoYearsAgo = DateTime.now(DateTimeZone.UTC).minusYears(3).getMillis() / 1000;
// get course ids per page
final LinkedMultiValueMap<String, String> attributes = new LinkedMultiValueMap<>();
attributes.add(MOODLE_COURSE_API_SEARCH_CRITERIA_NAME, "search");
@ -325,7 +326,7 @@ public class MoodleCourseAccess extends CourseAccess {
final Collection<CourseData> result = getCoursesForIds(restTemplate, ids)
.stream()
.filter(getCourseFilter(aYearAgo))
.filter(getCourseFilter(twoYearsAgo))
.collect(Collectors.toList());
log.info("After filtering {} left", result.size());

View file

@ -1502,6 +1502,7 @@ sebserver.monitoring.search.title=Search Connections
sebserver.monitoring.search.action=Search
sebserver.monitoring.search.list.empty=No Client Connections available
sebserver.monitoring.search.list.name=Session or User Name
sebserver.monitoring.search.list.ip=IP Address
sebserver.monitoring.exam.connection.emptySelection=At first please select a Connection from the list