Skip to content

Commit

Permalink
SEBSERV-460 implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Dec 6, 2023
1 parent 3fa6044 commit a9d2724
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ public class LoginPage implements TemplateComposer {
public LoginPage(
final PageService pageService,
final DefaultRegisterPage defaultRegisterPage,
@Value("${sebserver.gui.self-registering:false}") final Boolean registeringEnabled) {
@Value("${sebserver.gui.registering:false}") final Boolean registeringEnabled) {

this.pageService = pageService;
this.authorizationContextHolder = pageService.getAuthorizationContextHolder();
this.widgetFactory = pageService.getWidgetFactory();
this.i18nSupport = pageService.getI18nSupport();
this.defaultRegisterPage = defaultRegisterPage;
this.registeringEnabled = BooleanUtils.toBoolean(registeringEnabled);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class RegisterPage implements TemplateComposer {
private final RestTemplate restTemplate;
private final boolean multilingual;



protected RegisterPage(
final PageService pageService,
final WebserviceURIService webserviceURIService,
Expand Down Expand Up @@ -200,7 +202,7 @@ public void compose(final PageContext pageContext) {
.addField(FormBuilder.singleSelection(
Domain.USER.ATTR_TIMEZONE,
FORM_TIMEZONE_TEXT_KEY,
Constants.DEFAULT_TIME_ZONE_CODE,
this.pageService.getI18nSupport().getDefaultTimeZone().getID(),
this.resourceService::timeZoneResources)
.mandatory())
.addField(FormBuilder.text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.joda.time.DateTime;

import ch.ethz.seb.sebserver.gbl.util.Utils;
import org.joda.time.DateTimeZone;

public interface I18nSupport {

Expand All @@ -22,6 +23,8 @@ public interface I18nSupport {
String FORMAL_LOCALE_KEY = "sebserver.gui.date.displayformat";
String ATTR_CURRENT_SESSION_LOCALE = "CURRENT_SESSION_LOCALE";

DateTimeZone getDefaultTimeZone();

/** Get all supported languages as a collection of Locale
*
* @return all supported languages as a collection of Locale */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
Expand All @@ -48,14 +49,16 @@ public class I18nSupportImpl implements I18nSupport {
private final Locale defaultLocale = Locale.ENGLISH;
private final Collection<Locale> supportedLanguages;

private DateTimeZone defaultTimeZone;

public I18nSupportImpl(
final CurrentUser currentUser,
final MessageSource messageSource,
final Environment environment) {
final Environment environment,
@Value("${sebserver.gui.registering.default.timeZone:UTC}") final String defaultTimeZone) {

this.currentUser = currentUser;
this.messageSource = messageSource;

final String defaultFormatLocaleString = environment.getProperty(
FORMAL_LOCALE_KEY,
Constants.DEFAULT_LANG_CODE);
Expand All @@ -79,6 +82,17 @@ public I18nSupportImpl(
this.supportedLanguages = Utils.immutableCollectionOf(Locale.ENGLISH);
}

try {
this.defaultTimeZone = DateTimeZone.forID(defaultTimeZone);
} catch (final Exception e) {
log.warn("Failed to set default time zone from configuration: ", e);
this.defaultTimeZone = DateTimeZone.forID(Constants.DEFAULT_TIME_ZONE_CODE);
}
}

@Override
public DateTimeZone getDefaultTimeZone() {
return defaultTimeZone;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public RemoteProctoringRoomServiceImpl(
final ProctoringAdminService proctoringAdminService,
final ExamSessionService examSessionService,
final SEBClientInstructionService sebInstructionService,
@Value("${sebserver.webservice.proctoring.resetBroadcastOnLeav:true}") final boolean sendBroadcastReset) {
@Value("${sebserver.webservice.proctoring.resetBroadcastOnLeave:true}") final boolean sendBroadcastReset) {

this.remoteProctoringRoomDAO = remoteProctoringRoomDAO;
this.clientConnectionDAO = clientConnectionDAO;
Expand Down
15 changes: 11 additions & 4 deletions src/main/resources/config/application-dev-ws.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,23 @@ sebserver.webservice.lms.moodle.api.token.request.paths=
sebserver.webservice.lms.address.alias=lms.mockup.com=lms.address.alias
sebserver.webservice.cache.moodle.course.pageSize=250

springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true

# actuator configuration
management.server.port=${server.port}
management.endpoints.web.base-path=/management
management.endpoints.web.exposure.include=logfile,loggers,jolokia
management.endpoints.web.path-mapping.jolokia=jmx
### Open API Documentation
springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true
springdoc.swagger-ui.oauth.clientId=guiClient
springdoc.swagger-ui.oauth.clientSecret=${sebserver.password}
#springdoc.consumes-to-match=application/json,application/x-www-form-urlencoded
#springdoc.default-consumes-media-type=application/x-www-form-urlencoded
springdoc.paths-to-exclude=/exam-api,/exam-api/discovery,/sebserver/error,/sebserver/check,/oauth,/exam-api/v1/*


sebserver.feature.seb.screenProctoring.bundled=true
sebserver.feature.seb.screenProctoring.bundled.url=http://localhost:8090
sebserver.feature.seb.screenProctoring.bundled.clientId=sebserverClient
sebserver.feature.seb.screenProctoring.bundled.sebserveraccount.username=SEBServerAPIAccount
sebserver.feature.seb.screenProctoring.bundled.sebserveraccount.username=SEBServerAPIAccount

3 changes: 2 additions & 1 deletion src/main/resources/config/application-gui.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ sebserver.gui.list.page.size=20
sebserver.gui.defaultLogo=classpath:/static/images/sebserver-logo.png

# User Account
sebserver.gui.self-registering=true
sebserver.gui.registering=true
sebserver.gui.registering.default.timeZone=Europe/Zurich
sebserver.gui.multilingual=false
sebserver.gui.supported.languages=en
sebserver.gui.date.displayformat=de
Expand Down
14 changes: 2 additions & 12 deletions src/main/resources/config/application-ws.properties
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ sebserver.webservice.http.external.port=
sebserver.webservice.http.redirect.gui=/gui
sebserver.webservice.ping.service.strategy=BLOCKING

### Open API Documentation
springdoc.api-docs.enabled=false
springdoc.swagger-ui.enabled=false
springdoc.swagger-ui.oauth.clientId=guiClient
springdoc.swagger-ui.oauth.clientSecret=${sebserver.password}
#springdoc.consumes-to-match=application/json,application/x-www-form-urlencoded
#springdoc.default-consumes-media-type=application/x-www-form-urlencoded
springdoc.paths-to-exclude=/exam-api,/exam-api/discovery,/sebserver/error,/sebserver/check,/oauth,/exam-api/v1/*



### webservice API
sebserver.webservice.api.admin.clientId=guiClient
Expand All @@ -74,7 +64,7 @@ sebserver.webservice.api.exam.config.init.permittedProcesses=config/initialPermi
sebserver.webservice.api.exam.config.init.prohibitedProcesses=config/initialProhibitedProcesses.xml
sebserver.webservice.api.exam.endpoint=/exam-api
sebserver.webservice.api.exam.endpoint.discovery=${sebserver.webservice.api.exam.endpoint}/discovery
sebserver.webservice.api.exam.endpoint.v1=${sebserver.webservice.api.exam.endpoint}/v1
sebserver.webservice.api.exam.endpoint.v1=${sebserver.webservice.api.exam.endpoint}/v1
sebserver.webservice.api.exam.accessTokenValiditySeconds=43200
sebserver.webservice.api.exam.enable-indicator-cache=true
sebserver.webservice.api.pagination.maxPageSize=500
Expand All @@ -88,7 +78,7 @@ sebserver.webservice.lms.olat.sendAdditionalAttributesWithRestriction=false
sebserver.webservice.lms.address.alias=
sebserver.webservice.lms.datafetch.validity.seconds=600

sebserver.webservice.proctoring.resetBroadcastOnLeav=true
sebserver.webservice.proctoring.resetBroadcastOnLeave=true
sebserver.webservice.proctoring.zoom.enableWaitingRoom=false
sebserver.webservice.proctoring.zoom.sendRejoinForCollectingRoom=false

Expand Down

0 comments on commit a9d2724

Please sign in to comment.