Skip to content

Commit

Permalink
SEBSERV-435 gui and monitoring implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Oct 5, 2023
1 parent 1cbc97e commit a04c111
Show file tree
Hide file tree
Showing 21 changed files with 522 additions and 244 deletions.
1 change: 1 addition & 0 deletions src/main/java/ch/ethz/seb/sebserver/gbl/api/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ private BatchActionType(final EntityType entityType) {

public static final String EXAM_PROCTORING_ENDPOINT = EXAM_MONITORING_ENDPOINT + "/proctoring";
public static final String EXAM_PROCTORING_COLLECTING_ROOMS_SEGMENT = "/collecting-rooms";
public static final String EXAM_SCREEN_PROCTORING_GROUPS_SEGMENT = "/screenproctoring-groups";
public static final String EXAM_PROCTORING_OPEN_BREAK_OUT_ROOM_SEGMENT = "/open";
public static final String EXAM_PROCTORING_CLOSE_ROOM_SEGMENT = "/close";
public static final String EXAM_PROCTORING_NOTIFY_OPEN_ROOM_SEGMENT = "/notify-open-room";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,34 @@

import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.session.RemoteProctoringRoom;
import ch.ethz.seb.sebserver.gbl.model.session.ScreenProctoringGroup;

@JsonIgnoreProperties(ignoreUnknown = true)
public class MonitoringFullPageData {

public static final String ATTR_CONNECTIONS_DATA = "monitoringConnectionData";
public static final String ATTR_PROCTORING_DATA = "proctoringData";
public static final String ATTR_SCREEN_PROCTORING_DATA = "screenProctoringData";

@JsonProperty(Domain.CLIENT_CONNECTION.ATTR_EXAM_ID)
public final Long examId;
@JsonProperty(ATTR_CONNECTIONS_DATA)
public final MonitoringSEBConnectionData monitoringConnectionData;
@JsonProperty(ATTR_PROCTORING_DATA)
public final Collection<RemoteProctoringRoom> proctoringData;
@JsonProperty(ATTR_SCREEN_PROCTORING_DATA)
final Collection<ScreenProctoringGroup> screenProctoringData;

public MonitoringFullPageData(
@JsonProperty(Domain.CLIENT_CONNECTION.ATTR_EXAM_ID) final Long examId,
@JsonProperty(ATTR_CONNECTIONS_DATA) final MonitoringSEBConnectionData monitoringConnectionData,
@JsonProperty(ATTR_PROCTORING_DATA) final Collection<RemoteProctoringRoom> proctoringData) {
@JsonProperty(ATTR_PROCTORING_DATA) final Collection<RemoteProctoringRoom> proctoringData,
@JsonProperty(ATTR_SCREEN_PROCTORING_DATA) final Collection<ScreenProctoringGroup> screenProctoringData) {

this.examId = examId;
this.monitoringConnectionData = monitoringConnectionData;
this.proctoringData = proctoringData;
this.screenProctoringData = screenProctoringData;
}

public Long getExamId() {
Expand All @@ -51,6 +57,10 @@ public Collection<RemoteProctoringRoom> getProctoringData() {
return this.proctoringData;
}

public Collection<ScreenProctoringGroup> getScreenProctoringData() {
return this.screenProctoringData;
}

@Override
public int hashCode() {
final int prime = 31;
Expand Down Expand Up @@ -79,12 +89,14 @@ public boolean equals(final Object obj) {
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("OverallMonitroingData [examId=");
builder.append("MonitoringFullPageData [examId=");
builder.append(this.examId);
builder.append(", monitoringConnectionData=");
builder.append(this.monitoringConnectionData);
builder.append(", proctoringData=");
builder.append(this.proctoringData);
builder.append(", screenProctoringData=");
builder.append(this.screenProctoringData);
builder.append("]");
return builder.toString();
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class RAPSpringConfig {
@Value("${sebserver.gui.remote.proctoring.api-servler.endpoint:/remote-view-servlet}")
private String remoteProctoringViewServletEndpoint;

@Value("${sebserver.gui.screen.proctoring.api-servler.endpoint:/screen-proctoring}")
private String screenProctoringViewServletEndpoint;

@Bean
public StaticApplicationPropertyResolver staticApplicationPropertyResolver() {
return new StaticApplicationPropertyResolver();
Expand Down Expand Up @@ -83,6 +86,17 @@ public ServletRegistrationBean<ProctoringServlet> servletProctoringRegistrationB
this.remoteProctoringEndpoint + this.remoteProctoringViewServletEndpoint + "/*");
}

@Bean
public ServletRegistrationBean<ScreenProctoringServlet> servletScreenProctoringRegistrationBean(
final ApplicationContext applicationContext) {

final ScreenProctoringServlet proctoringServlet = applicationContext
.getBean(ScreenProctoringServlet.class);
return new ServletRegistrationBean<>(
proctoringServlet,
this.remoteProctoringEndpoint + this.screenProctoringViewServletEndpoint + "/*");
}

@Bean
public MessageSource messageSource() {
final ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2023 ETH Zürich, Educational Development and Technology (LET)
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

package ch.ethz.seb.sebserver.gui;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import ch.ethz.seb.sebserver.gbl.model.user.UserInfo;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.SEBServerAuthorizationContext;

@Component
@GuiProfile
public class ScreenProctoringServlet extends HttpServlet {

private static final long serialVersionUID = 4147410676185956971L;

@Override
protected void doGet(
final HttpServletRequest req,
final HttpServletResponse resp) throws ServletException, IOException {

final HttpSession httpSession = req.getSession();
final ServletContext servletContext = httpSession.getServletContext();
final WebApplicationContext webApplicationContext = WebApplicationContextUtils
.getRequiredWebApplicationContext(servletContext);

final UserInfo user = isAuthenticated(httpSession, webApplicationContext);

// TODO https://stackoverflow.com/questions/46582/response-redirect-with-post-instead-of-get

final String hello = "Hello";

// StringBuilder sb = new StringBuilder();
// sb.Append("<html>");
// sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
// sb.AppendFormat("<form name='form' action='{0}' method='post'>",postbackUrl);
// sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", id);
// // Other params go here
// sb.Append("</form>");
// sb.Append("</body>");
// sb.Append("</html>");

resp.getOutputStream().println(hello);

}

private UserInfo isAuthenticated(
final HttpSession httpSession,
final WebApplicationContext webApplicationContext) {

final AuthorizationContextHolder authorizationContextHolder = webApplicationContext
.getBean(AuthorizationContextHolder.class);
final SEBServerAuthorizationContext authorizationContext = authorizationContextHolder
.getAuthorizationContext(httpSession);
if (!authorizationContext.isValid() || !authorizationContext.isLoggedIn()) {
throw new RuntimeException("No authentication found");
}

return authorizationContext.getLoggedInUser().getOrThrow();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum ActionCategory {
STATE_FILTER(new LocTextKey("sebserver.exam.monitoring.action.category.statefilter"), 40),
GROUP_FILTER(new LocTextKey("sebserver.exam.monitoring.action.category.groupfilter"), 50),
PROCTORING(new LocTextKey("sebserver.exam.overall.action.category.proctoring"), 60),
SCREEN_PROCTORING(new LocTextKey("sebserver.exam.overall.action.category.screenproctoring"), 65),

FINISHED_EXAM_LIST(new LocTextKey("sebserver.finished.exam.list.actions"), 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1035,11 +1035,11 @@ public enum ActionDefinition {
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.CLIENT_EVENT_LIST),

MONITOR_EXAM_NEW_PROCTOR_ROOM(
new LocTextKey("sebserver.monitoring.exam.action.newroom"),
ImageIcon.VISIBILITY,
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.PROCTORING),
// MONITOR_EXAM_NEW_PROCTOR_ROOM(
// new LocTextKey("sebserver.monitoring.exam.action.newroom"),
// ImageIcon.VISIBILITY,
// PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
// ActionCategory.PROCTORING),
MONITOR_EXAM_VIEW_PROCTOR_ROOM(
new LocTextKey("sebserver.monitoring.exam.action.viewroom"),
ImageIcon.PROCTOR_ROOM,
Expand All @@ -1056,6 +1056,12 @@ public enum ActionDefinition {
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.PROCTORING),

MONITOR_EXAM_VIEW_SCREEN_PROCTOR_GROUP(
new LocTextKey("sebserver.monitoring.exam.action.viewgroup"),
ImageIcon.SCREEN_PROC_ON,
PageStateDefinitionImpl.MONITORING_RUNNING_EXAM,
ActionCategory.SCREEN_PROCTORING),

FINISHED_EXAM_VIEW_LIST(
new LocTextKey("sebserver.finished.action.list"),
PageStateDefinitionImpl.FINISHED_EXAM_LIST),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ public class ScreenProctoringSettingsPopup {
new LocTextKey("sebserver.exam.sps.form.accountId");
private final static LocTextKey FORM_ACCOUNT_SECRET_SPS =
new LocTextKey("sebserver.exam.sps.form.accountSecret");
private final static LocTextKey FORM_COLLECT_STRATEGY =
new LocTextKey("sebserver.exam.sps.form.collect.strategy");

private final static LocTextKey SAVE_TEXT_KEY =
new LocTextKey("sebserver.exam.sps.form.saveSettings");
Expand Down
Loading

0 comments on commit a04c111

Please sign in to comment.