001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/settings/ApplicationSettings.java $
003: * $Id: ApplicationSettings.java 22608 2007-03-14 19:27:17Z lydial@stanford.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the"License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.assessment.settings;
021:
022: import java.io.IOException;
023: import java.util.Properties;
024: import org.sakaiproject.util.ResourceLoader;
025:
026: import org.apache.commons.logging.Log;
027: import org.apache.commons.logging.LogFactory;
028:
029: /**
030: * @author <a href="mailto:lance@indiana.edu">Lance Speelmon </a>
031: * @version $Id: ApplicationSettings.java,v 1.1 2004/06/17 19:20:21
032: * lancespeelmon Exp $
033: */
034: public class ApplicationSettings {
035: private static Log log = LogFactory
036: .getLog(ApplicationSettings.class);
037: private static boolean disableMultipleChoiceSingle = false;
038: private static boolean disableMultipleChoiceMultiple = false;
039: private static boolean disableMultipleChoiceSurvey = false;
040: private static boolean disableShortAnswerEssay = false;
041: private static boolean disableFillInTheBlank = false;
042: private static boolean disableFillInNumeric = false;
043: private static boolean disableMatching = false;
044: private static boolean disableTrueFalse = false;
045: private static boolean disableAudioRecording = false;
046: private static boolean disableFileUpload = false;
047: private static boolean poolingUserAdminDisabled = false;
048: private static boolean enableAutoSaveForGrading = false;
049: private static String buildVersion;
050: private static String buildTime;
051: private static String buildTag;
052:
053: static {
054: try {
055: Properties p = PathInfo.getInstance()
056: .getSettingsProperties(Constants.SETTINGS_FILE);
057: if (p == null) {
058: throw new RuntimeException(
059: "Could not find settings file: "
060: + Constants.SETTINGS_FILE);
061: }
062:
063: Boolean b = null;
064: // disableMultipleChoiceSingle
065: b = Boolean.valueOf(p.getProperty(
066: "disableMultipleChoiceSingle", "false"));
067: if (b.booleanValue()) {
068: log.info("disableMultipleChoiceSingle = true");
069: disableMultipleChoiceSingle = true;
070: }
071: // disableMultipleChoiceMultiple
072: b = Boolean.valueOf(p.getProperty(
073: "disableMultipleChoiceMultiple", "false"));
074: if (b.booleanValue()) {
075: log.info("disableMultipleChoiceMultiple = true");
076: disableMultipleChoiceMultiple = true;
077: }
078: // disableMultipleChoiceSurvey
079: b = Boolean.valueOf(p.getProperty(
080: "disableMultipleChoiceSurvey", "false"));
081: if (b.booleanValue()) {
082: log.info("disableMultipleChoiceSurvey = true");
083: disableMultipleChoiceSurvey = true;
084: }
085: // disableShortAnswerEssay
086: b = Boolean.valueOf(p.getProperty(
087: "disableShortAnswerEssay", "false"));
088: if (b.booleanValue()) {
089: log.info("disableShortAnswerEssay = true");
090: disableShortAnswerEssay = true;
091: }
092: // disableFillInTheBlank
093: b = Boolean.valueOf(p.getProperty("disableFillInTheBlank",
094: "false"));
095: if (b.booleanValue()) {
096: log.info("disableFillInTheBlank = true");
097: disableFillInTheBlank = true;
098: }
099: // disableFillInNumeric
100: b = Boolean.valueOf(p.getProperty("disableFillInNumeric",
101: "false"));
102: if (b.booleanValue()) {
103: log.info("disableFillInNumeric = true");
104: disableFillInNumeric = true;
105: }
106: // disableMatching
107: b = Boolean.valueOf(p.getProperty("disableMatching",
108: "false"));
109: if (b.booleanValue()) {
110: log.info("disableMatching = true");
111: disableMatching = true;
112: }
113: // disableTrueFalse
114: b = Boolean.valueOf(p.getProperty("disableTrueFalse",
115: "false"));
116: if (b.booleanValue()) {
117: log.info("disableTrueFalse = true");
118: disableTrueFalse = true;
119: }
120: // disableAudioRecording
121: b = Boolean.valueOf(p.getProperty("disableAudioRecording",
122: "false"));
123: if (b.booleanValue()) {
124: log.info("disableAudioRecording = true");
125: disableAudioRecording = true;
126: }
127: // disableFileUpload
128: b = Boolean.valueOf(p.getProperty("disableFileUpload",
129: "false"));
130: if (b.booleanValue()) {
131: log.info("disableFileUpload = true");
132: disableFileUpload = true;
133: }
134: // poolingUserAdminDisabled
135: b = Boolean.valueOf(p.getProperty(
136: "poolingUserAdminDisabled", "false"));
137: if (b.booleanValue()) {
138: log.info("poolingUserAdminDisabled = true");
139: poolingUserAdminDisabled = true;
140: }
141:
142: // enableAutoSaveForGrading
143: b = Boolean.valueOf(p.getProperty(
144: "enableAutoSaveForGrading", "false"));
145: if (b.booleanValue()) {
146: log.info("enableAutoSaveForGrading= true");
147: enableAutoSaveForGrading = true;
148: }
149:
150: // build information
151: final ResourceLoader rb = new ResourceLoader(
152: "org.navigoproject.build");
153: buildVersion = rb.getString("build.version");
154: buildTime = rb.getString("build.time");
155: buildTag = rb.getString("build.tag");
156: if (log.isInfoEnabled()) {
157: log.info("buildVersion=" + buildVersion);
158: log.info("buildTime=" + buildTime);
159: log.info("buildTag=" + buildTag);
160: }
161: } catch (IOException e) {
162: log.fatal(e);
163: throw new RuntimeException(e);
164: }
165: }
166:
167: /**
168: * @return Returns the disableAudioRecording.
169: */
170: public static boolean isDisableAudioRecording() {
171: return disableAudioRecording;
172: }
173:
174: /**
175: * @return Returns the disableFileUpload.
176: */
177: public static boolean isDisableFileUpload() {
178: return disableFileUpload;
179: }
180:
181: /**
182: * @return Returns the disableFillInTheBlank.
183: */
184: public static boolean isDisableFillInTheBlank() {
185: return disableFillInTheBlank;
186: }
187:
188: /**
189: * @return Returns the disableFillNumeric
190: */
191: public static boolean isDisableFillInNumeric() {
192: return disableFillInNumeric;
193: }
194:
195: /**
196: * @return Returns the disableMatching.
197: */
198: public static boolean isDisableMatching() {
199: return disableMatching;
200: }
201:
202: /**
203: * @return Returns the disableMultipleChoiceMultiple.
204: */
205: public static boolean isDisableMultipleChoiceMultiple() {
206: return disableMultipleChoiceMultiple;
207: }
208:
209: /**
210: * @return Returns the disableMultipleChoiceSingle.
211: */
212: public static boolean isDisableMultipleChoiceSingle() {
213: return disableMultipleChoiceSingle;
214: }
215:
216: /**
217: * @return Returns the disableMultipleChoiceSurvey.
218: */
219: public static boolean isDisableMultipleChoiceSurvey() {
220: return disableMultipleChoiceSurvey;
221: }
222:
223: /**
224: * @return Returns the disableShortAnswerEssay.
225: */
226: public static boolean isDisableShortAnswerEssay() {
227: return disableShortAnswerEssay;
228: }
229:
230: /**
231: * @return Returns the disableTrueFalse.
232: */
233: public static boolean isDisableTrueFalse() {
234: return disableTrueFalse;
235: }
236:
237: /**
238: * @return Returns the poolingUserAdminDisabled.
239: */
240: public static boolean isPoolingUserAdminDisabled() {
241: return poolingUserAdminDisabled;
242: }
243:
244: /**
245: * @return Returns the enableAutoSaveForGrading.
246: */
247: public static boolean isEnableAutoSaveForGrading() {
248: return enableAutoSaveForGrading;
249: }
250:
251: /**
252: * @return Returns the buildTag.
253: */
254: public static String getBuildTag() {
255: return buildTag;
256: }
257:
258: /**
259: * @return Returns the buildTime.
260: */
261: public static String getBuildTime() {
262: return buildTime;
263: }
264:
265: /**
266: * @return Returns the buildVersion.
267: */
268: public static String getBuildVersion() {
269: return buildVersion;
270: }
271: }
|