/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.repository;
import org.olat.core.gui.components.form.Form;
import org.olat.core.gui.formelements.CheckBoxElement;
import org.olat.core.gui.formelements.SingleSelectionElement;
import org.olat.core.gui.formelements.StaticSingleSelectionElement;
import org.olat.core.gui.translator.Translator;
import org.olat.core.id.Roles;
import org.olat.core.util.Util;
import org.olat.course.CourseModule;
import org.olat.course.ICourse;
import org.olat.course.config.CourseConfig;
import org.olat.instantMessaging.InstantMessagingModule;
/**
*
*/
public class DisplayCourseInfoForm extends Form {
private SingleSelectionElement layout;
private SingleSelectionElement sfolder;
private CheckBoxElement chatIsOn;
private CheckBoxElement efficencyStatement;
private CheckBoxElement calendar;
private StaticSingleSelectionElement glossary;
private static final String KEY_NO = "0";
private static final String KEY_YES = "1";
public DisplayCourseInfoForm(String name, Translator translator, ICourse course) {
super(name, translator);
init(course);
setDisplayOnly(true);
}
/**
* Initialize form data based on repository entry.
*/
public void init(ICourse course) {
CourseConfig cc = course.getCourseEnvironment().getCourseConfig();
// java.util.logging.Level admin = cc.getLoglevelFor(UserActivityLogger.LOG_ADMIN);
// java.util.logging.Level user = cc.getLoglevelFor(UserActivityLogger.LOG_USER);
// java.util.logging.Level stat = cc.getLoglevelFor(UserActivityLogger.LOG_STAT);
/*
Translator logTrans = Util.createPackageTranslator(CourseLogController.class, getLocale());
String[] valuesLogLevel = new String[] {
logTrans.translate("log.disabled"),
logTrans.translate("log.level.normal") + " (INFO)",
logTrans.translate("log.level.detailed")+" (INFO + FINE)"};
String[] keysLogLevel = new String[] { "" + CourseConfig.LOGLEVEL_OFF, "" + CourseConfig.LOGLEVEL_INFO, "" + CourseConfig.LOGLEVEL_FINE };
*/
/* if (roles.isOLATAdmin() || CourseModule.isAdminLogVisible()) {
logLevelSelectadmin = new StaticSingleSelectionElement("form.log.level.admin", keysLogLevel, valuesLogLevel);
logLevelSelectadmin.select("" + admin.intValue(), true);
addFormElement("logLeveladmin", logLevelSelectadmin);
}
if (roles.isOLATAdmin() || CourseModule.isUserLogVisible()) {
logLevelSelectuser = new StaticSingleSelectionElement("form.log.level.user", keysLogLevel, valuesLogLevel);
logLevelSelectuser.select("" + user.intValue(), true);
addFormElement("logLeveluser", logLevelSelectuser);
}
if (roles.isOLATAdmin() || CourseModule.isStatisticLogVisible()) {
logLevelSelectstat = new StaticSingleSelectionElement("form.log.level.stat", keysLogLevel, valuesLogLevel);
logLevelSelectstat.select("" + stat.intValue(), true);
addFormElement("logLevelstat", logLevelSelectstat);
}*/
if (InstantMessagingModule.isEnabled()&& CourseModule.isCourseChatEnabled()) {
chatIsOn = new CheckBoxElement("chkbx.chat.onoff", cc.isChatEnabled());
addFormElement("chatIsOn", chatIsOn);
}
// FIXME: remove "" and fix package...
String[] values = new String[] { cc.getCssLayoutRef(), "" + translate("form.layout.setsystemcss") };
String[] keys = new String[] { KEY_NO, KEY_YES };
layout = new StaticSingleSelectionElement("form.layout.cssfile", keys, values);
if (cc.hasCustomCourseCSS()) layout.select(KEY_NO, true);
else layout.select(KEY_YES, true);
addFormElement("layout", layout);
String name;
String softkey = cc.getSharedFolderSoftkey();
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(softkey, false);
if (re == null) {
cc.setSharedFolderSoftkey(CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY);
name = translate("sf.notconfigured");
} else {
name = re.getDisplayname();
}
String[] sfvalues = new String[] { name, translate("sf.notconfigured") };
String[] sfkeys = new String[] { KEY_NO, KEY_YES };
sfolder = new StaticSingleSelectionElement("sf.resourcetitle", sfkeys, sfvalues);
if (cc.hasCustomSharedFolder()) sfolder.select(KEY_NO, true);
else sfolder.select(KEY_YES, true);
addFormElement("sfolder", sfolder);
efficencyStatement = new CheckBoxElement("chkbx.efficency.onoff", cc.isEfficencyStatementEnabled());
addFormElement("efficencyStatement", efficencyStatement);
calendar = new CheckBoxElement("chkbx.calendar.onoff", cc.isCalendarEnabled());
addFormElement("calendar", calendar);
/*
* glossary show name instead of check box OLAT-2126
*/
String glossName;
String glossSoftKey = cc.getGlossarySoftKey();
re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(glossSoftKey, false);
if (re == null) {
glossName = translate("glossary.no.glossary");
} else {
glossName = re.getDisplayname();
}
String[] glovalues = new String[] { glossName, translate("glossary.no.glossary") };
glossary = new StaticSingleSelectionElement("glossary.isconfigured", sfkeys, glovalues);
if (cc.hasGlossary()) glossary.select(KEY_NO, true);
else glossary.select(KEY_YES, true);
addFormElement("glossary", glossary);
//glossary = new CheckBoxElement("chkbx.glossary.onoff", cc.hasGlossary());
//addFormElement("glossary", glossary);
addSubmitKey("submit", "submit");
}
/**
* @see org.olat.core.gui.components.Form#validate(org.olat.core.gui.UserRequest)
*/
public boolean validate() {
return true;
}
}