fixed some issues with proctoring rooms and error handling
This commit is contained in:
parent
3b1641994a
commit
696a85a1fe
4 changed files with 99 additions and 50 deletions
|
@ -47,6 +47,7 @@ import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
import ch.ethz.seb.sebserver.gui.service.page.PageService;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
import ch.ethz.seb.sebserver.gui.service.page.TemplateComposer;
|
||||||
|
import ch.ethz.seb.sebserver.gui.service.page.event.ActionActivationEvent;
|
||||||
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
import ch.ethz.seb.sebserver.gui.service.page.impl.PageAction;
|
||||||
import ch.ethz.seb.sebserver.gui.service.push.ServerPushContext;
|
import ch.ethz.seb.sebserver.gui.service.push.ServerPushContext;
|
||||||
import ch.ethz.seb.sebserver.gui.service.push.ServerPushService;
|
import ch.ethz.seb.sebserver.gui.service.push.ServerPushService;
|
||||||
|
@ -75,16 +76,16 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(MonitoringClientConnection.class);
|
private static final Logger log = LoggerFactory.getLogger(MonitoringClientConnection.class);
|
||||||
|
|
||||||
// @formatter:off
|
// // @formatter:off
|
||||||
private static final String OPEN_SINGEL_ROOM_SCRIPT =
|
// private static final String OPEN_SINGEL_ROOM_SCRIPT =
|
||||||
"var existingWin = window.open('', '%s', 'height=420,width=640,location=no,scrollbars=yes,status=no,menubar=yes,toolbar=yes,titlebar=yes,dialog=yes');\n" +
|
// "var existingWin = window.open('', '%s', 'height=420,width=640,location=no,scrollbars=yes,status=no,menubar=yes,toolbar=yes,titlebar=yes,dialog=yes');\n" +
|
||||||
"if(existingWin.location.href === 'about:blank'){\n" +
|
// "if(existingWin.location.href === 'about:blank'){\n" +
|
||||||
" existingWin.location.href = '%s%s';\n" +
|
// " existingWin.location.href = '%s%s';\n" +
|
||||||
" existingWin.focus();\n" +
|
// " existingWin.focus();\n" +
|
||||||
"} else {\n" +
|
// "} else {\n" +
|
||||||
" existingWin.focus();\n" +
|
// " existingWin.focus();\n" +
|
||||||
"}";
|
// "}";
|
||||||
// @formatter:on
|
// // @formatter:on
|
||||||
|
|
||||||
private static final LocTextKey PAGE_TITLE_KEY =
|
private static final LocTextKey PAGE_TITLE_KEY =
|
||||||
new LocTextKey("sebserver.monitoring.exam.connection.title");
|
new LocTextKey("sebserver.monitoring.exam.connection.title");
|
||||||
|
@ -289,8 +290,7 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
.publishIf(() -> currentUser.get().hasRole(UserRole.EXAM_SUPPORTER) &&
|
.publishIf(() -> currentUser.get().hasRole(UserRole.EXAM_SUPPORTER) &&
|
||||||
connectionData.clientConnection.status == ConnectionStatus.ACTIVE);
|
connectionData.clientConnection.status == ConnectionStatus.ACTIVE);
|
||||||
|
|
||||||
// TODO if (connectionData.clientConnection.status == ConnectionStatus.ACTIVE) {
|
if (connectionData.clientConnection.status == ConnectionStatus.ACTIVE) {
|
||||||
if (connectionData.clientConnection.status != ConnectionStatus.DISABLED) {
|
|
||||||
final ProctoringSettings procotringSettings = restService
|
final ProctoringSettings procotringSettings = restService
|
||||||
.getBuilder(GetProctoringSettings.class)
|
.getBuilder(GetProctoringSettings.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, parentEntityKey.modelId)
|
.withURIVariable(API.PARAM_MODEL_ID, parentEntityKey.modelId)
|
||||||
|
@ -311,6 +311,16 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
.withExec(action -> this.openExamCollectionProctorScreen(action, connectionData))
|
.withExec(action -> this.openExamCollectionProctorScreen(action, connectionData))
|
||||||
.noEventPropagation()
|
.noEventPropagation()
|
||||||
.publish();
|
.publish();
|
||||||
|
|
||||||
|
clientConnectionDetails.setStatusChangeListener(ccd -> {
|
||||||
|
this.pageService.firePageEvent(
|
||||||
|
new ActionActivationEvent(
|
||||||
|
ccd.clientConnection.status == ConnectionStatus.ACTIVE,
|
||||||
|
ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_QUIT,
|
||||||
|
ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_PROCTORING,
|
||||||
|
ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_EXAM_ROOM_PROCTORING),
|
||||||
|
pageContext);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,8 +359,10 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
|
|
||||||
ProctoringGUIService.setCurrentProctoringWindowData(examId, proctoringConnectionData);
|
ProctoringGUIService.setCurrentProctoringWindowData(examId, proctoringConnectionData);
|
||||||
final String script = String.format(
|
final String script = String.format(
|
||||||
MonitoringRunningExam.OPEN_EXAM_COLLECTION_ROOM_SCRIPT,
|
MonitoringRunningExam.OPEN_ROOM_SCRIPT,
|
||||||
room.name,
|
room.name,
|
||||||
|
800,
|
||||||
|
1200,
|
||||||
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
||||||
this.remoteProctoringEndpoint);
|
this.remoteProctoringEndpoint);
|
||||||
|
|
||||||
|
@ -396,8 +408,10 @@ public class MonitoringClientConnection implements TemplateComposer {
|
||||||
|
|
||||||
final JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
|
final JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
|
||||||
final String script = String.format(
|
final String script = String.format(
|
||||||
OPEN_SINGEL_ROOM_SCRIPT,
|
MonitoringRunningExam.OPEN_ROOM_SCRIPT,
|
||||||
roomName,
|
roomName,
|
||||||
|
420,
|
||||||
|
640,
|
||||||
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
||||||
this.remoteProctoringEndpoint);
|
this.remoteProctoringEndpoint);
|
||||||
javaScriptExecutor.execute(script);
|
javaScriptExecutor.execute(script);
|
||||||
|
|
|
@ -91,13 +91,18 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
private static final Logger log = LoggerFactory.getLogger(MonitoringRunningExam.class);
|
private static final Logger log = LoggerFactory.getLogger(MonitoringRunningExam.class);
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
static final String OPEN_EXAM_COLLECTION_ROOM_SCRIPT =
|
static final String OPEN_ROOM_SCRIPT =
|
||||||
"var existingWin = window.open('', '%s', 'height=800,width=1200,location=no,scrollbars=yes,status=no,menubar=yes,toolbar=yes,titlebar=yes,dialog=yes');\n" +
|
"try {\n" +
|
||||||
|
"var existingWin = window.open('', '%s', 'height=%s,width=%s,location=no,scrollbars=yes,status=no,menubar=0,toolbar=no,titlebar=no,dialog=no');\n" +
|
||||||
"if(existingWin.location.href === 'about:blank'){\n" +
|
"if(existingWin.location.href === 'about:blank'){\n" +
|
||||||
" existingWin.location.href = '%s%s';\n" +
|
" existingWin.location.href = '%s%s';\n" +
|
||||||
" existingWin.focus();\n" +
|
" existingWin.focus();\n" +
|
||||||
"} else {\n" +
|
"} else {\n" +
|
||||||
" existingWin.focus();\n" +
|
" existingWin.focus();\n" +
|
||||||
|
"}" +
|
||||||
|
"}\n" +
|
||||||
|
"catch(err) {\n" +
|
||||||
|
" alert(\"Unexpected Javascript Error happened: \" + err);\n"+
|
||||||
"}";
|
"}";
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
|
@ -411,6 +416,7 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction openTownhallRoom(final PageAction action) {
|
private PageAction openTownhallRoom(final PageAction action) {
|
||||||
|
try {
|
||||||
final EntityKey examId = action.getEntityKey();
|
final EntityKey examId = action.getEntityKey();
|
||||||
|
|
||||||
final ProctoringGUIService proctoringGUIService = this.pageService
|
final ProctoringGUIService proctoringGUIService = this.pageService
|
||||||
|
@ -425,7 +431,8 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
examId.modelId,
|
examId.modelId,
|
||||||
this.pageService.getI18nSupport().getText(EXAM_ROOM_NAME))
|
this.pageService.getI18nSupport().getText(EXAM_ROOM_NAME))
|
||||||
.onError(error -> log.error(
|
.onError(error -> log.error(
|
||||||
"Failed to open all collecting room for exam {} {}", examId.modelId, error.getMessage()))
|
"Failed to open all collecting room for exam {} {}", examId.modelId,
|
||||||
|
error.getMessage()))
|
||||||
.getOrThrow();
|
.getOrThrow();
|
||||||
ProctoringGUIService.setCurrentProctoringWindowData(
|
ProctoringGUIService.setCurrentProctoringWindowData(
|
||||||
examId.modelId,
|
examId.modelId,
|
||||||
|
@ -435,31 +442,45 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
|
|
||||||
final JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
|
final JavaScriptExecutor javaScriptExecutor = RWT.getClient().getService(JavaScriptExecutor.class);
|
||||||
final String script = String.format(
|
final String script = String.format(
|
||||||
OPEN_EXAM_COLLECTION_ROOM_SCRIPT,
|
OPEN_ROOM_SCRIPT,
|
||||||
activeAllRoomName,
|
activeAllRoomName,
|
||||||
|
800,
|
||||||
|
1200,
|
||||||
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
||||||
this.remoteProctoringEndpoint);
|
this.remoteProctoringEndpoint);
|
||||||
javaScriptExecutor.execute(script);
|
javaScriptExecutor.execute(script);
|
||||||
proctoringGUIService.registerProctoringWindow(activeAllRoomName);
|
proctoringGUIService.registerProctoringWindow(activeAllRoomName);
|
||||||
|
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log.error("Failed to open popup for townhall room: ", e);
|
||||||
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PageAction closeTownhallRoom(final PageAction action) {
|
private PageAction closeTownhallRoom(final PageAction action) {
|
||||||
|
final String examId = action.getEntityKey().modelId;
|
||||||
final RemoteProctoringRoom townhall = this.pageService.getRestService()
|
final RemoteProctoringRoom townhall = this.pageService.getRestService()
|
||||||
.getBuilder(GetTownhallRoom.class)
|
.getBuilder(GetTownhallRoom.class)
|
||||||
.withURIVariable(API.PARAM_MODEL_ID, action.getEntityKey().modelId)
|
.withURIVariable(API.PARAM_MODEL_ID, examId)
|
||||||
.call()
|
.call()
|
||||||
.getOr(null);
|
.getOr(null);
|
||||||
|
|
||||||
if (townhall == null || townhall.id == null) {
|
if (townhall == null || townhall.id == null) {
|
||||||
|
log.warn(
|
||||||
|
"Close townhall action cannot get active townhall form webservice for exam: {}",
|
||||||
|
examId);
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
final ProctoringGUIService proctoringGUIService = this.pageService
|
final ProctoringGUIService proctoringGUIService = this.pageService
|
||||||
.getCurrentUser()
|
.getCurrentUser()
|
||||||
.getProctoringGUIService();
|
.getProctoringGUIService();
|
||||||
|
|
||||||
proctoringGUIService.closeRoom(townhall.name);
|
proctoringGUIService.closeRoom(townhall.name);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log.error("Failed to close procotring townhall room for exam: {}", examId);
|
||||||
|
}
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,8 +637,10 @@ public class MonitoringRunningExam implements TemplateComposer {
|
||||||
proctoringConnectionData);
|
proctoringConnectionData);
|
||||||
|
|
||||||
final String script = String.format(
|
final String script = String.format(
|
||||||
OPEN_EXAM_COLLECTION_ROOM_SCRIPT,
|
OPEN_ROOM_SCRIPT,
|
||||||
room.name,
|
room.name,
|
||||||
|
800,
|
||||||
|
1200,
|
||||||
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
this.guiServiceInfo.getExternalServerURIBuilder().toUriString(),
|
||||||
this.remoteProctoringEndpoint);
|
this.remoteProctoringEndpoint);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ package ch.ethz.seb.sebserver.gui.service.session;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
@ -58,6 +59,7 @@ public class ClientConnectionDetails {
|
||||||
|
|
||||||
private ClientConnectionData connectionData = null;
|
private ClientConnectionData connectionData = null;
|
||||||
private boolean statusChanged = true;
|
private boolean statusChanged = true;
|
||||||
|
private Consumer<ClientConnectionData> statusChangeListener = null;
|
||||||
|
|
||||||
public ClientConnectionDetails(
|
public ClientConnectionDetails(
|
||||||
final PageService pageService,
|
final PageService pageService,
|
||||||
|
@ -112,6 +114,10 @@ public class ClientConnectionDetails {
|
||||||
this.formHandle = formBuilder.build();
|
this.formHandle = formBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStatusChangeListener(final Consumer<ClientConnectionData> statusChangeListener) {
|
||||||
|
this.statusChangeListener = statusChangeListener;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateData() {
|
public void updateData() {
|
||||||
final ClientConnectionData connectionData = this.restCallBuilder
|
final ClientConnectionData connectionData = this.restCallBuilder
|
||||||
.call()
|
.call()
|
||||||
|
@ -123,8 +129,8 @@ public class ClientConnectionDetails {
|
||||||
if (this.connectionData != null && connectionData != null) {
|
if (this.connectionData != null && connectionData != null) {
|
||||||
this.statusChanged =
|
this.statusChanged =
|
||||||
this.connectionData.clientConnection.status != connectionData.clientConnection.status ||
|
this.connectionData.clientConnection.status != connectionData.clientConnection.status ||
|
||||||
BooleanUtils.toBoolean(this.connectionData.missingPing) !=
|
BooleanUtils.toBoolean(this.connectionData.missingPing) != BooleanUtils
|
||||||
BooleanUtils.toBoolean(connectionData.missingPing);
|
.toBoolean(connectionData.missingPing);
|
||||||
}
|
}
|
||||||
this.connectionData = connectionData;
|
this.connectionData = connectionData;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +158,10 @@ public class ClientConnectionDetails {
|
||||||
final Color statusTextColor = this.colorData.getStatusTextColor(statusColor);
|
final Color statusTextColor = this.colorData.getStatusTextColor(statusColor);
|
||||||
form.setFieldColor(Domain.CLIENT_CONNECTION.ATTR_STATUS, statusColor);
|
form.setFieldColor(Domain.CLIENT_CONNECTION.ATTR_STATUS, statusColor);
|
||||||
form.setFieldTextColor(Domain.CLIENT_CONNECTION.ATTR_STATUS, statusTextColor);
|
form.setFieldTextColor(Domain.CLIENT_CONNECTION.ATTR_STATUS, statusTextColor);
|
||||||
|
|
||||||
|
if (this.statusChangeListener != null) {
|
||||||
|
this.statusChangeListener.accept(this.connectionData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update indicators
|
// update indicators
|
||||||
|
|
|
@ -228,6 +228,8 @@ public class ProctoringGUIService {
|
||||||
name,
|
name,
|
||||||
error.getMessage()));
|
error.getMessage()));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("No proctoring room with name: {} found for closing.", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue