SEBSERV-287 some fixes with privileges and unique indicator name
This commit is contained in:
parent
0dfde290ca
commit
8b9eebfe5b
4 changed files with 13 additions and 12 deletions
|
@ -45,7 +45,6 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.GetIndicator
|
|||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.NewExamTemplate;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.exam.SaveExamTemplate;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.EntityGrantCheck;
|
||||
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.CurrentUser.GrantCheck;
|
||||
import ch.ethz.seb.sebserver.gui.table.ColumnDefinition;
|
||||
import ch.ethz.seb.sebserver.gui.table.EntityTable;
|
||||
|
@ -192,7 +191,7 @@ public class ExamTemplateForm implements TemplateComposer {
|
|||
? this.restService.getRestCall(NewExamTemplate.class)
|
||||
: this.restService.getRestCall(SaveExamTemplate.class));
|
||||
|
||||
final boolean proctoringEnabled = this.restService
|
||||
final boolean proctoringEnabled = !isNew && this.restService
|
||||
.getBuilder(GetExamTemplateProctoringSettings.class)
|
||||
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
|
||||
.call()
|
||||
|
@ -200,8 +199,8 @@ public class ExamTemplateForm implements TemplateComposer {
|
|||
.getOr(false);
|
||||
|
||||
final GrantCheck userGrant = currentUser.grantCheck(EntityType.EXAM_TEMPLATE);
|
||||
final EntityGrantCheck userGrantCheck = currentUser.entityGrantCheck(examTemplate);
|
||||
final boolean modifyGrant = userGrantCheck.m();
|
||||
// final EntityGrantCheck userGrantCheck = currentUser.entityGrantCheck(examTemplate);
|
||||
// final boolean modifyGrant = userGrantCheck.m();
|
||||
// propagate content actions to action-pane
|
||||
this.pageService.pageActionBuilder(formContext.clearEntityKeys())
|
||||
|
||||
|
@ -228,13 +227,13 @@ public class ExamTemplateForm implements TemplateComposer {
|
|||
|
||||
.newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_ON)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant))
|
||||
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, userGrant.im()))
|
||||
.noEventPropagation()
|
||||
.publishIf(() -> proctoringEnabled && readonly)
|
||||
|
||||
.newAction(ActionDefinition.EXAM_TEMPLATE_PROCTORING_OFF)
|
||||
.withEntityKey(entityKey)
|
||||
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant))
|
||||
.withExec(this.proctoringSettingsPopup.settingsFunction(this.pageService, userGrant.im()))
|
||||
.noEventPropagation()
|
||||
.publishIf(() -> !proctoringEnabled && readonly);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||
.forRole(UserRole.SEB_SERVER_ADMIN)
|
||||
.withBasePrivilege(PrivilegeType.READ)
|
||||
.andForRole(UserRole.INSTITUTIONAL_ADMIN)
|
||||
.withInstitutionalPrivilege(PrivilegeType.READ)
|
||||
.withInstitutionalPrivilege(PrivilegeType.WRITE)
|
||||
.andForRole(UserRole.EXAM_ADMIN)
|
||||
.withInstitutionalPrivilege(PrivilegeType.WRITE)
|
||||
.create();
|
||||
|
|
|
@ -69,8 +69,6 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl.moodle.legacy.Mood
|
|||
@WebServiceProfile
|
||||
public class ExamDAOImpl implements ExamDAO {
|
||||
|
||||
//public static final String FAILED_TO_LOAD_QUIZ_DATA_MARK = "[FAILED TO LOAD DATA FROM LMS]";
|
||||
|
||||
private final ExamRecordMapper examRecordMapper;
|
||||
private final ExamRecordDAO examRecordDAO;
|
||||
private final ApplicationEventPublisher applicationEventPublisher;
|
||||
|
@ -979,7 +977,9 @@ public class ExamDAOImpl implements ExamDAO {
|
|||
.collect(Utils.toSingleton())
|
||||
.getValue();
|
||||
} catch (final Exception e) {
|
||||
log.error("Failed to get former name: examId: {} error: {}", id, e.getMessage());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.warn("Failed to get former name: examId: {} error: {}", id, e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -534,11 +534,13 @@ public class ExamTemplateDAOImpl implements ExamTemplateDAO {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkUniqueIndicatorName(final IndicatorTemplate indicatorTemplate,
|
||||
private void checkUniqueIndicatorName(
|
||||
final IndicatorTemplate indicatorTemplate,
|
||||
final Collection<IndicatorTemplate> indicators) {
|
||||
|
||||
// check unique name
|
||||
indicators.stream()
|
||||
.filter(it -> Objects.equals(it.name, indicatorTemplate.name))
|
||||
.filter(it -> !Objects.equals(it, indicatorTemplate) && Objects.equals(it.name, indicatorTemplate.name))
|
||||
.findAny()
|
||||
.ifPresent(it -> {
|
||||
throw new FieldValidationException(
|
||||
|
|
Loading…
Reference in a new issue