Skip to content
Snippets Groups Projects
Commit ecad70f0 authored by srosse's avatar srosse
Browse files

OO-1967: add option to show/hide the menu and the toolbat in course

parent de878346
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,7 @@ public class CourseConfig implements Serializable, Cloneable {
/**
* current config file version
*/
transient private final static int CURRENTVERSION = 10;
transient private final static int CURRENTVERSION = 11;
/**
* Log levels
*/
......@@ -100,6 +100,15 @@ public class CourseConfig implements Serializable, Cloneable {
transient public static final String RECERTIFICATION_TIMELAPSE = "RECERTIFICATION_TIMELAPSE";
transient public static final String RECERTIFICATION_TIMELAPSE_UNIT = "RECERTIFICATION_TIMELAPSE_UNIT";
/**
* The menu is enabled by default
*/
transient public static final String MENU_ENABLED = "MENU_ENABLED";
/**
* The toolbar is enabled by default
*/
transient public static final String TOOLBAR_ENABLED = "TOOLBAR_ENABLED";
/**
* course calendar
*/
......@@ -164,6 +173,10 @@ public class CourseConfig implements Serializable, Cloneable {
configuration.remove(KEY_LOGLEVEL_ADMIN);
configuration.remove(KEY_LOGLEVEL_USER);
configuration.remove(KEY_LOGLEVEL_STATISTIC);
configuration.put(MENU_ENABLED, Boolean.TRUE);
configuration.put(TOOLBAR_ENABLED, Boolean.TRUE);
this.version = CURRENTVERSION;
}
......@@ -241,7 +254,13 @@ public class CourseConfig implements Serializable, Cloneable {
if (!configuration.containsKey(RECERTIFICATION_TIMELAPSE)) configuration.put(RECERTIFICATION_TIMELAPSE, new Integer(0));
this.version = 10;
}
if (version == 10) {
if (!configuration.containsKey(MENU_ENABLED)) configuration.put(MENU_ENABLED, Boolean.TRUE);
if (!configuration.containsKey(TOOLBAR_ENABLED)) configuration.put(TOOLBAR_ENABLED, Boolean.TRUE);
this.version = 11;
}
/*
* after resolving the issues, the version number is merged to the
* CURRENTVERSION !! leave this!
......@@ -485,6 +504,24 @@ public class CourseConfig implements Serializable, Cloneable {
public void setCalendarEnabled(boolean b) {
configuration.put(KEY_CALENDAR_ENABLED, new Boolean(b));
}
public boolean isMenuEnabled() {
Boolean bool = (Boolean) configuration.get(MENU_ENABLED);
return bool.booleanValue();
}
public void setMenuEnabled(boolean b) {
configuration.put(MENU_ENABLED, new Boolean(b));
}
public boolean isToolbarEnabled() {
Boolean bool = (Boolean) configuration.get(TOOLBAR_ENABLED);
return bool.booleanValue();
}
public void setToolbarEnabled(boolean b) {
configuration.put(TOOLBAR_ENABLED, new Boolean(b));
}
/**
* Creates a deep clone for the current object.
......@@ -506,6 +543,8 @@ public class CourseConfig implements Serializable, Cloneable {
clone.setRecertificationEnabled(isRecertificationEnabled());
clone.setRecertificationTimelapse(getRecertificationTimelapse());
clone.setRecertificationTimelapseUnit(getRecertificationTimelapseUnit());
clone.setMenuEnabled(isMenuEnabled());
clone.setToolbarEnabled(isMenuEnabled());
return clone;
}
......
......@@ -84,12 +84,15 @@ public class CourseOptionsController extends FormBasicController {
private static final OLog log = Tracing.createLoggerFor(CourseOptionsController.class);
private static final String COMMAND_REMOVE = "command.glossary.remove";
private static final String COMMAND_ADD = "command.glossary.add";
private static final String[] onKeys = new String[] {"xx"};
private static final String[] onValues = new String[] {""};
private SelectionElement calendarEl, chatEl;
private SelectionElement menuEl, toolbarEl, calendarEl, chatEl;
private FormLink addGlossaryCommand, removeGlossaryCommand;
private StaticTextElement glossaryNameEl;
private FormLink saveButton;
private FormLayoutContainer saveCont;
private FormLayoutContainer saveCont, calendarCont, chatCont, glossaryCont;
private FormLink addFolderCommand, removeFolderCommand;
private StaticTextElement folderNameEl;
......@@ -122,7 +125,8 @@ public class CourseOptionsController extends FormBasicController {
this.entry = entry;
this.editable = editable;
initForm (ureq);
initForm(ureq);
updateToolbar();
//glossary setup
boolean managedGlossary = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.glossary);
......@@ -166,35 +170,55 @@ public class CourseOptionsController extends FormBasicController {
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer menuCont = FormLayoutContainer.createDefaultFormLayout("menutool", getTranslator());
menuCont.setRootForm(mainForm);
formLayout.add(menuCont);
menuEl = uifactory.addCheckboxesHorizontal("menuIsOn", "chkbx.menu.onoff", menuCont, onKeys, onValues);
menuEl.select(onKeys[0], courseConfig.isMenuEnabled());
toolbarEl = uifactory.addCheckboxesHorizontal("toolbarIsOn", "chkbx.toolbar.onoff", menuCont, onKeys, onValues);
toolbarEl.select(onKeys[0], courseConfig.isToolbarEnabled());
toolbarEl.addActionListener(FormEvent.ONCHANGE);
boolean canHideToolbar = true;
if(calendarModule.isEnabled() && calendarModule.isEnableCourseToolCalendar()) {
//calendar
FormLayoutContainer calCont = FormLayoutContainer.createDefaultFormLayout("cal", getTranslator());
calCont.setRootForm(mainForm);
formLayout.add(calCont);
calCont.setFormContextHelp("Course Settings#_optionen");
calendarCont = FormLayoutContainer.createDefaultFormLayout("cal", getTranslator());
calendarCont.setRootForm(mainForm);
formLayout.add(calendarCont);
calendarCont.setFormContextHelp("Course Settings#_optionen");
boolean calendarEnabled = courseConfig.isCalendarEnabled();
boolean managedCal = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.calendar);
calendarEl = uifactory.addCheckboxesHorizontal("calIsOn", "chkbx.calendar.onoff", calCont, new String[] {"xx"}, new String[] {""});
calendarEl = uifactory.addCheckboxesHorizontal("calIsOn", "chkbx.calendar.onoff", calendarCont, onKeys, onValues);
calendarEl.addActionListener(FormEvent.ONCHANGE);
calendarEl.select("xx", calendarEnabled);
calendarEl.setEnabled(editable && !managedCal);
if(managedCal && calendarEnabled) {
canHideToolbar &= false;
}
}
//chat
FormLayoutContainer chatCont = FormLayoutContainer.createDefaultFormLayout("chat", getTranslator());
chatCont = FormLayoutContainer.createDefaultFormLayout("chat", getTranslator());
chatCont.setRootForm(mainForm);
formLayout.add(chatCont);
boolean chatEnabled = courseConfig.isChatEnabled();
boolean managedChat = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.chat);
chatEl = uifactory.addCheckboxesHorizontal("chatIsOn", "chkbx.chat.onoff", chatCont, new String[] {"xx"}, new String[] {""});
chatEl = uifactory.addCheckboxesHorizontal("chatIsOn", "chkbx.chat.onoff", chatCont, onKeys, onValues);
chatEl.addActionListener(FormEvent.ONCHANGE);
chatEl.select("xx", chatEnabled);
chatEl.setEnabled(editable && !managedChat);
if(managedChat && chatEnabled) {
canHideToolbar &= false;
}
//glossary
FormLayoutContainer glossaryCont = FormLayoutContainer.createDefaultFormLayout("glossary", getTranslator());
glossaryCont = FormLayoutContainer.createDefaultFormLayout("glossary", getTranslator());
glossaryCont.setRootForm(mainForm);
formLayout.add(glossaryCont);
......@@ -209,6 +233,11 @@ public class CourseOptionsController extends FormBasicController {
addGlossaryCommand = uifactory.addFormLink(COMMAND_ADD, buttonsCont, Link.BUTTON);
addGlossaryCommand.setVisible(editable && !managedGlossary);
if(managedGlossary && StringHelper.containsNonWhitespace(courseConfig.getGlossarySoftKey())) {
canHideToolbar &= false;
}
toolbarEl.setEnabled(canHideToolbar);
//shared folder
boolean managedFolder = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.resourcefolder);
FormLayoutContainer sharedFolderCont = FormLayoutContainer.createDefaultFormLayout("sharedfolder", getTranslator());
......@@ -310,12 +339,25 @@ public class CourseOptionsController extends FormBasicController {
doRemoveSharedFolder();
setSaveButtonDirty();
}
} else if(toolbarEl == source) {
if(!toolbarEl.isSelected(0)) {
showWarning("chkbx.toolbar.off.warning");
}
updateToolbar();
setSaveButtonDirty();
} else if (source instanceof SelectionElement) {
setSaveButtonDirty();
} else if(saveButton == source) {
doSave(ureq);
}
}
private void updateToolbar() {
boolean enabled = toolbarEl.isSelected(0);
calendarCont.setVisible(enabled);
chatCont.setVisible(enabled);
glossaryCont.setVisible(enabled);
}
@Override
......@@ -383,19 +425,22 @@ public class CourseOptionsController extends FormBasicController {
ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
courseConfig = course.getCourseEnvironment().getCourseConfig();
boolean menuEnabled = menuEl.isSelected(0);
courseConfig.setMenuEnabled(menuEnabled);
boolean toolbarEnabled = toolbarEl.isSelected(0);
courseConfig.setToolbarEnabled(toolbarEnabled);
boolean enableChat = chatEl.isSelected(0);
boolean updateChat = courseConfig.isChatEnabled() != enableChat;
courseConfig.setChatIsEnabled(enableChat);
courseConfig.setChatIsEnabled(enableChat && toolbarEnabled);
boolean enableCalendar = calendarEl == null ? false : calendarEl.isSelected(0);
boolean updateCalendar = courseConfig.isCalendarEnabled() != enableCalendar && calendarModule.isEnableCourseToolCalendar();
courseConfig.setCalendarEnabled(enableCalendar);
courseConfig.setCalendarEnabled(enableCalendar && toolbarEnabled);
String currentGlossarySoftKey = courseConfig.getGlossarySoftKey();
RepositoryEntry glossary = (RepositoryEntry)glossaryNameEl.getUserObject();
String newGlossarySoftKey = glossary == null ? null : glossary.getSoftkey();
String newGlossarySoftKey = (glossary == null || !toolbarEnabled) ? null : glossary.getSoftkey();
boolean updateGlossary = (currentGlossarySoftKey == null && newGlossarySoftKey != null)
|| (currentGlossarySoftKey != null && newGlossarySoftKey == null)
|| (newGlossarySoftKey != null && !newGlossarySoftKey.equals(currentGlossarySoftKey));
......@@ -411,6 +456,8 @@ public class CourseOptionsController extends FormBasicController {
|| (currentFolderSoftKey != null && !currentFolderSoftKey.equals(newFolderSoftKey));
courseConfig.setSharedFolderSoftkey(newFolderSoftKey);
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
......
......@@ -2,6 +2,9 @@
chkbx.calendar.onoff=Kalender in der Werkzeugbox anzeigen
chkbx.chat.onoff=Kurs-Chat verwenden
chkbx.efficency.onoff=Leistungsnachweis verwenden
chkbx.menu.onoff=Menu sichtbar f\u00FCr Teilnehmer und Betreuer
chkbx.toolbar.onoff=Toolbar sichtbar f\u00FCr Teilnehmer
chkbx.toolbar.off.warning=Wenn sie den Toolbar abschalten, stehen die folgende Werkzeuge nicht mehr zur Verfgung: Glossar, Kurs-Chat und Kalendar.
command.choose=W\u00E4hlen
command.glossary.add=Glossar w\u00E4hlen
command.glossary.remove=Auswahl l\u00F6schen
......
......@@ -2,6 +2,9 @@
chkbx.calendar.onoff=Show calendar in the course's tool box
chkbx.chat.onoff=Use course chat
chkbx.efficency.onoff=Use evidence of achievement
chkbx.menu.onoff=Menu visible for participants and coaches
chkbx.toolbar.onoff=Toolbar visible for participants
chkbx.toolbar.off.warning=If you disable the toolbar the participants cannot use the calendar, chat and glossary.
command.choose=Choose
command.glossary.add=Select glossary
command.glossary.remove=Delete selection
......
......@@ -372,6 +372,17 @@ public class CourseRuntimeController extends RepositoryEntryRuntimeController im
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
UserCourseEnvironmentImpl uce = getUserCourseEnvironment();
if(!course.getCourseConfig().isToolbarEnabled() && !reSecurity.isEntryAdmin() && !reSecurity.isCourseCoach() && !reSecurity.isGroupCoach()
&& !hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) && !hasCourseRight(CourseRights.RIGHT_MEMBERMANAGEMENT)
&& !hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) && !hasCourseRight(CourseRights.RIGHT_ARCHIVING)
&& !hasCourseRight(CourseRights.RIGHT_STATISTICS) && !hasCourseRight(CourseRights.RIGHT_DB)
&& !hasCourseRight(CourseRights.RIGHT_ASSESSMENT)) {
toolbarPanel.setToolbarEnabled(false);
} else {
toolbarPanel.setToolbarEnabled(true);
}
if(!isAssessmentLock()) {
initTools(toolsDropdown, course, uce);
initSettingsTools(settingsDropdown);
......
......@@ -220,7 +220,13 @@ public class RunMainController extends MainLayoutBasicController implements Gene
// add text marker wrapper controller to implement course glossary
// textMarkerCtr must be created before the toolC!
CourseConfig cc = uce.getCourseEnvironment().getCourseConfig();
glossaryMarkerCtr = CourseGlossaryFactory.createGlossaryMarkupWrapper(ureq, wControl, contentP, cc);
glossaryMarkerCtr = CourseGlossaryFactory.createGlossaryMarkupWrapper(ureq, wControl, contentP, cc);
MenuTree layoutTree = luTree;
if(!cc.isMenuEnabled() && !uce.isAdmin()) {
layoutTree = null;
}
if (glossaryMarkerCtr != null) {
listenTo(glossaryMarkerCtr);
// enable / disable glossary highlighting according to user prefs
......@@ -237,9 +243,9 @@ public class RunMainController extends MainLayoutBasicController implements Gene
} else {
glossaryMarkerCtr.setTextMarkingEnabled(state.booleanValue());
}
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), luTree, glossaryMarkerCtr.getInitialComponent(), "course" + course.getResourceableId());
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), layoutTree, glossaryMarkerCtr.getInitialComponent(), "course" + course.getResourceableId());
} else {
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), luTree, contentP, "courseRun" + course.getResourceableId());
columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), layoutTree, contentP, "courseRun" + course.getResourceableId());
}
listenTo(columnLayoutCtr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment