Skip to content

Commit

Permalink
Merge branch 'dev-2.0' of github.com:SafeExamBrowser/seb-server into …
Browse files Browse the repository at this point in the history
…docu
  • Loading branch information
Nadim Ritter committed Aug 28, 2024
2 parents 54ec29d + 081b994 commit 7f7ac3e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public Boolean getLmsAvailable() {

@JsonIgnore
public boolean isLmsAvailable() {
return BooleanUtils.isTrue(this.lmsAvailable);
return BooleanUtils.isNotFalse(this.lmsAvailable);
}

public String getExternalId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static void decorateOnExamConsistency(
final Exam exam,
final PageService pageService) {

if (BooleanUtils.isFalse(exam.isLmsAvailable())) {
if (exam.lmsSetupId != null && BooleanUtils.isFalse(exam.isLmsAvailable())) {
item.setData(RWT.CUSTOM_VARIANT, CustomVariant.DISABLED.key);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Collection;
import java.util.Map;

import ch.ethz.seb.sebserver.gbl.model.user.UserRole;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -29,6 +30,7 @@
import org.springframework.core.io.Resource;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.core.type.TypeReference;
Expand Down Expand Up @@ -348,6 +350,12 @@ public PageAction openScreenProctoringTab(
httpEntity,
String.class);

if (tokenRequest.getStatusCode() == HttpStatus.UNAUTHORIZED &&
currentUser.get().hasAnyRole(UserRole.EXAM_SUPPORTER, UserRole.INSTITUTIONAL_ADMIN)) {
notifyUnauthorized(_action, currentUser);
return _action;
}

// Open SPS Gui redirect URL with login token (jwt token) in new browser tab
final String redirectLocation = redirect.getBody() + "/jwt?token=" + tokenRequest.getBody();
// final String script = "var win = window.open('', 'seb_screen_proctoring'); win.location.href = '"+ redirectLocation + "';";
Expand All @@ -357,13 +365,28 @@ public PageAction openScreenProctoringTab(
// .getService(JavaScriptExecutor.class)
// .execute(script);
} catch (final Exception e) {
if (e instanceof HttpClientErrorException) {
if (((HttpClientErrorException) e).getRawStatusCode() == HttpStatus.UNAUTHORIZED.value()) {
notifyUnauthorized(_action, this.pageService.getCurrentUser());
return _action;
}
}
log.error("Failed to open screen proctoring service group gallery view: ", e);
_action.pageContext()
.notifyError(new LocTextKey("Failed to open screen proctoring service group gallery view"), e);
.notifyError(new LocTextKey("sebserver.monitoring.sps.opengallery.fail"), e);
}
return _action;
}

private static void notifyUnauthorized(final PageAction _action, final CurrentUser currentUser) {
log.warn("No Access to Screen Proctoring for user: {}", currentUser.get().username);
_action
.pageContext()
.notifyError(
new LocTextKey("sebserver.monitoring.sps.noaccess"),
new RuntimeException("No access to Screen Proctoring. Please make sure you are assigned as Exam Supporter for this exam."));
}

private PageAction openExamProctoringRoom(
final ProctoringGUIService proctoringGUIService,
final ProctoringServiceSettings proctoringSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public LmsSetupTestResult testAdHoc(final LmsSetup lmsSetup) {
}

private LmsSetupTestResult fullIntegrationTest(final LmsAPITemplate template) {
if (template.lmsSetup().lmsType != LmsSetup.LmsType.MOODLE_PLUGIN) {
return null;
}
if (!template.fullIntegrationActive()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ default void processSessionUpdateTask() {
void updateClientConnections();

/** This goes through all running exams with screen proctoring enabled and updates the group attributes
* (mainly the number of active clients in the group) by call ing SPS API and store newest data. */
* (mainly the number of active clients in the group) by calling SPS API and store newest data. */
void updateActiveGroups();

@Async(AsyncServiceSpringConfig.EXECUTOR_BEAN_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Result<Set<String>> updateExamFromLMS(final Long lmsSetupId, final Map<String, E
.forEach(quizId -> {
try {
final Exam exam = exams.get(quizId);
if (exam.lmsAvailable == null || exam.isLmsAvailable()) {
if (exam.lmsSetupId != null && (exam.lmsAvailable == null || exam.isLmsAvailable())) {
this.examDAO.markLMSAvailability(quizId, false, updateId);
}
} catch (final Exception ee) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ private void registerJoinInstruction(
log.debug("Register JOIN instruction for client ");
}

final boolean checkActive = exam.lmsSetupId != null;
final SPSData spsData = this.screenProctoringAPIBinding.getSPSData(exam.id);
final String url = screenProctoringServiceBundle.bundled
? screenProctoringServiceBundle.serviceURL
Expand All @@ -597,7 +598,7 @@ private void registerJoinInstruction(
InstructionType.SEB_PROCTORING,
attributes,
ccRecord.getConnectionToken(),
true,
checkActive,
true)
.onError(error -> log.error(
"Failed to register screen proctoring join instruction for SEB connection: {}",
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ sebserver.clientconfig.form.sebServerFallbackPasswordHash=Fallback Password
sebserver.clientconfig.form.sebServerFallbackPasswordHash.tooltip=A password if set a SEB Client user must provide before SEB starts the fallback procedure
sebserver.clientconfig.form.sebServerFallbackPasswordHash.confirm=Confirm Password
sebserver.clientconfig.form.sebServerFallbackPasswordHash.tooltip.confirm=Please confirm the fallback password

sebserver.clientconfig.form.hashedQuitPassword=Quit Password
sebserver.clientconfig.form.hashedQuitPassword.tooltip=A password if set a SEB user must provide to be able to quit SEB
sebserver.clientconfig.form.hashedQuitPassword.confirm=Confirm Password
sebserver.clientconfig.form.hashedQuitPassword.tooltip.confirm=Please confirm the quit password
Expand Down Expand Up @@ -2423,6 +2423,9 @@ sebserver.monitoring.signaturegrant.signature=App Signature Key Hash
sebserver.monitoring.signaturegrant.tag=Tag
sebserver.monitoring.signaturegrant.message.granted=This App Signature Key is already granted for this exam

sebserver.monitoring.sps.opengallery.fail=Failed to open screen proctoring service group gallery view
sebserver.monitoring.sps.noaccess=No Access to Screen Proctoring

################################
# Finished Exams
################################
Expand Down

0 comments on commit 7f7ac3e

Please sign in to comment.