use of org.olat.core.gui.components.progressbar.ProgressBar in project OpenOLAT by OpenOLAT.
the class TranslationToolI18nItemEditCrumbController method initForm.
/*
* (non-Javadoc)
*
* @see
* org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm
* (org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
flc.contextPut("referenceLanguageKey", referenceLocale.toString());
flc.contextPut("referenceLanguage", i18nMgr.getLanguageTranslated(referenceLocale.toString(), false));
// Add bundles and keys selection
List<String> bundlesList = new ArrayList<String>();
List<String> keysList = new ArrayList<String>();
for (I18nItem item : i18nItems) {
if (!bundlesList.contains(item.getBundleName())) {
bundlesList.add(item.getBundleName());
}
if (currentItem.getBundleName().equals(item.getBundleName())) {
keysList.add(item.getKey());
}
}
String[] bundlesListArray = ArrayHelper.toArray(bundlesList);
String[] keysListArray = ArrayHelper.toArray(keysList);
bundlesSelection = uifactory.addDropdownSingleselect("bundlesSelection", this.flc, bundlesListArray, bundlesListArray, null);
bundlesSelection.setDomReplacementWrapperRequired(false);
bundlesSelection.addActionListener(FormEvent.ONCHANGE);
bundlesSelection.select(currentItem.getBundleName(), true);
keysSelection = uifactory.addDropdownSingleselect("keysSelection", this.flc, keysListArray, keysListArray, null);
keysSelection.setDomReplacementWrapperRequired(false);
keysSelection.addActionListener(FormEvent.ONCHANGE);
keysSelection.select(currentItem.getKey(), true);
// Add reference box
referenceArea = uifactory.addTextAreaElement("referenceArea", "edit.referenceArea", -1, 1, -1, true, null, this.flc);
// read only
referenceArea.setEnabled(false);
// Add compare box
Boolean compareEnabledPrefs = (Boolean) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_COMPARE_LANG_ENABLED, Boolean.FALSE);
compareArea = uifactory.addTextAreaElement("compareArea", "edit.compareArea", -1, 1, -1, true, null, this.flc);
// read only
compareArea.setEnabled(false);
compareArea.setVisible(compareEnabledPrefs.booleanValue());
String[] compareSwitchValues = new String[] { translate("generic.enable") };
compareSwitch = uifactory.addCheckboxesVertical("compareSwitch", null, flc, KEYS_ENABLED, compareSwitchValues, 1);
compareSwitch.setDomReplacementWrapperRequired(false);
compareSwitch.select(KEYS_ENABLED[0], compareEnabledPrefs.booleanValue());
compareSwitch.addActionListener(FormEvent.ONCLICK);
formLayout.add(compareSwitch);
flc.contextPut("compareSwitchEnabled", compareEnabledPrefs);
// Add compare language selection
Set<String> availableLangKeys = i18nModule.getAvailableLanguageKeys();
String[] comparelangKeys = ArrayHelper.toArray(availableLangKeys);
String[] compareLangValues = new String[comparelangKeys.length];
for (int i = 0; i < comparelangKeys.length; i++) {
String key = comparelangKeys[i];
String explLang = i18nMgr.getLanguageInEnglish(key, customizingMode);
String all = explLang;
if (explLang != null && !explLang.equals(key))
all += " (" + key + ")";
compareLangValues[i] = all;
}
ArrayHelper.sort(comparelangKeys, compareLangValues, false, true, false);
// Build css classes for comparison languages
String comparePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_COMPARE_LANG, I18nModule.getDefaultLocale().toString());
compareLocale = i18nMgr.getLocaleOrNull(comparePrefs);
if (compareLocale == null)
compareLocale = I18nModule.getDefaultLocale();
compareLangSelection = uifactory.addDropdownSingleselect("compareLangSelection", flc, comparelangKeys, compareLangValues, null);
compareLangSelection.setDomReplacementWrapperRequired(false);
compareLangSelection.select(i18nModule.getLocaleKey(compareLocale), true);
flc.contextPut("compareLanguageKey", i18nModule.getLocaleKey(compareLocale));
compareLangSelection.addActionListener(FormEvent.ONCHANGE);
compareLangSelection.setEnabled(compareEnabledPrefs.booleanValue());
// Add target box
flc.contextPut("targetLanguageKey", i18nModule.getLocaleKey(currentItem.getLocale()));
flc.contextPut("targetLanguage", i18nMgr.getLanguageTranslated(i18nModule.getLocaleKey(currentItem.getLocale()), false));
targetArea = uifactory.addTextAreaElement("targetArea", "edit.targetArea", -1, 5, -1, true, null, flc);
// Add annotation box
annotationArea = uifactory.addTextAreaElement("annotationArea", "edit.annotationArea", -1, 1, -1, true, null, flc);
// Add progress bar
// init with values
progressBarBundle = new ProgressBar("progressBarBundle", 300, 1, bundlesList.size(), translate("generic.bundles"));
progressBarBundle.setPercentagesEnabled(false);
flc.put("progressBarBundle", progressBarBundle);
progressBarKey = new ProgressBar("progressBarKey", 300, 1, keysList.size(), translate("generic.keys"));
progressBarKey.setPercentagesEnabled(false);
flc.put("progressBarKey", progressBarKey);
// Add navigation buttons
previousLink = uifactory.addFormLink("previousLink", "edit.button.previous", null, formLayout, Link.BUTTON);
previousLink.setIconLeftCSS("o_icon o_icon_previous_page");
saveLink = uifactory.addFormLink("saveLink", "edit.button.save", null, formLayout, Link.BUTTON);
saveNextLink = uifactory.addFormLink("saveNextLink", "edit.button.saveNext", null, formLayout, Link.BUTTON);
formLayout.add(saveNextLink);
nextLink = uifactory.addFormLink("nextLink", "edit.button.next", null, formLayout, Link.BUTTON);
nextLink.setIconRightCSS("o_icon o_icon_next_page");
formLayout.add(nextLink);
// init values from item
initOrUpdateCurrentItem(ureq);
// Override text labels for customizing mode
if (customizingMode) {
// don't edit annotations in customizing mode
annotationArea.setEnabled(false);
// target lang flags and lang name
Locale origLocale = i18nModule.getAllLocales().get(i18nMgr.createOrigianlLocaleKeyForOverlay(currentItem.getLocale()));
if (origLocale == null) {
origLocale = currentItem.getLocale();
}
String localeKey = i18nModule.getLocaleKey(origLocale);
flc.contextPut("targetLanguageKey", localeKey);
flc.contextPut("targetLanguage", i18nMgr.getLanguageTranslated(localeKey, true));
}
flc.contextPut("customizingMode", Boolean.valueOf(customizingMode));
flc.contextPut("customizingPrefix", (customizingMode ? "customize." : ""));
}
use of org.olat.core.gui.components.progressbar.ProgressBar in project OpenOLAT by OpenOLAT.
the class TranslationToolStartCrumbController method initLanguageSelectorElements.
private void initLanguageSelectorElements(UserSession usess, FormUIFactory formFactory, FormItemContainer formLayout) {
// Add language selection as a subform
List<String> referenceLangs;
if (customizingMode) {
// Add all enabled languages that can be customized
referenceLangs = new ArrayList<>(i18nModule.getEnabledLanguageKeys());
} else {
// Add configured reference languages in translation mode
referenceLangs = i18nModule.getTransToolReferenceLanguages();
}
String[] referencelangKeys = ArrayHelper.toArray(referenceLangs);
String[] referenceLangValues = new String[referencelangKeys.length];
for (int i = 0; i < referencelangKeys.length; i++) {
String key = referencelangKeys[i];
String explLang = i18nManager.getLanguageInEnglish(key, false);
String all = explLang;
if (explLang != null && !explLang.equals(key))
all += " (" + key + ")";
referenceLangValues[i] = all;
}
ArrayHelper.sort(referencelangKeys, referenceLangValues, false, true, false);
// Build css classes for reference languages
// Use first reference locale as default
referenceLocale = i18nManager.getLocaleOrNull(referenceLangs.get(0));
// Override with user preset
Preferences guiPrefs = usess.getGuiPreferences();
String referencePrefs = (String) guiPrefs.get(I18nModule.class, I18nModule.GUI_PREFS_PREFERRED_REFERENCE_LANG, referenceLangs.get(0));
for (String refLang : referencelangKeys) {
if (referencePrefs.equals(refLang)) {
referenceLocale = i18nManager.getLocaleOrNull(referencePrefs);
break;
}
}
referenceLangSelection = formFactory.addDropdownSingleselect("start.referenceLangSelection", formLayout, referencelangKeys, referenceLangValues, null);
referenceLangSelection.select(referenceLocale.toString(), true);
this.flc.contextPut("referenceLangKey", referenceLocale.toString());
referenceLangSelection.addActionListener(FormEvent.ONCHANGE);
// Add target languages without overlays
Set<String> translatableKeys;
if (customizingMode) {
// Use all enabled languages in customizing mode
translatableKeys = i18nModule.getOverlayLanguageKeys();
} else {
// Allow translators to also translate other languages if they really desire. Show all languages.
translatableKeys = i18nModule.getTranslatableLanguageKeys();
}
String[] targetlangKeys = ArrayHelper.toArray(translatableKeys);
String[] targetLangValues = new String[targetlangKeys.length];
for (int i = 0; i < targetlangKeys.length; i++) {
String key = targetlangKeys[i];
// Since in case of customizing mode the target lang key does already
// contain the customizing key, there is no need to get the language with
// overlay enabled, this would double the customizing extension to the key
String explLang;
if (customizingMode) {
String origKey = i18nManager.createOrigianlLocaleKeyForOverlay(i18nModule.getAllLocales().get(key));
explLang = i18nManager.getLanguageInEnglish(origKey, true);
} else {
explLang = i18nManager.getLanguageInEnglish(key, false);
}
String all = explLang;
if (explLang != null && !explLang.equals(key))
all += " (" + key + ")";
targetLangValues[i] = all;
}
ArrayHelper.sort(targetlangKeys, targetLangValues, false, true, false);
// Build css classes for reference languages
targetLangSelection = formFactory.addDropdownSingleselect("start.targetLangSelection", formLayout, targetlangKeys, targetLangValues, null);
// Select current language if in list or the first one in the menu
if (customizingMode) {
// Use same as reference language in customizing mode
targetLocale = i18nModule.getOverlayLocales().get(referenceLocale);
// Disable target lang selection - user should only choose reference language, target is updated automatically
targetLangSelection.setEnabled(false);
} else {
// Use users current language in translation mode
targetLocale = getTranslator().getLocale();
if (!Arrays.asList(targetlangKeys).contains(i18nModule.getLocaleKey(targetLocale))) {
targetLocale = i18nManager.getLocaleOrNull(targetlangKeys[0]);
}
}
targetLangSelection.select(i18nModule.getLocaleKey(targetLocale), true);
// Add lang key for image - don't use customizing lang key
if (customizingMode) {
this.flc.contextPut("targetLangKey", i18nManager.createOrigianlLocaleKeyForOverlay(targetLocale));
} else {
this.flc.contextPut("targetLangKey", targetLocale.toString());
}
targetLangSelection.addActionListener(FormEvent.ONCHANGE);
// Add progress bar as normal component (not a form element)
int bundlesCount = i18nManager.countBundles(null, true);
progressBar = new ProgressBar("progressBar", 300, 0, 0, translate("start.progressBar.unitLabel", bundlesCount + ""));
this.flc.put("progressBar", progressBar);
}
use of org.olat.core.gui.components.progressbar.ProgressBar in project OpenOLAT by OpenOLAT.
the class CmdUpload method execute.
public Controller execute(FolderComponent folderComponent, UserRequest ureq, Translator trans, boolean cancelResetsButton) {
this.cancelResetsForm = cancelResetsButton;
setTranslator(trans);
currentContainer = folderComponent.getCurrentContainer();
if (currentContainer.canWrite() != VFSConstants.YES)
throw new AssertException("Cannot write to selected folder.");
// mainVC is the main view
mainVC = createVelocityContainer("upload");
// Add progress bar
ubar = new ProgressBar("ubar");
ubar.setWidth(200);
ubar.setUnitLabel("MB");
ubar.setRenderLabelRights(true);
mainVC.put(ubar.getComponentName(), ubar);
// Calculate quota and limits
long actualUsage = 0;
quotaKB = Quota.UNLIMITED;
uploadLimitKB = Quota.UNLIMITED;
inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(currentContainer);
if (inheritingContainer != null) {
secCallback = inheritingContainer.getLocalSecurityCallback();
actualUsage = VFSManager.getUsageKB(inheritingContainer);
ubar.setActual(actualUsage / 1024);
if (inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
quotaKB = secCallback.getQuota().getQuotaKB().longValue();
uploadLimitKB = (int) secCallback.getQuota().getUlLimitKB().longValue();
}
}
// set wether we have a quota on this folder
if (quotaKB == Quota.UNLIMITED) {
ubar.setIsNoMax(true);
} else if (quotaKB == 0) {
ubar.setMax(quotaKB);
} else {
ubar.setMax(quotaKB / 1024f);
}
// set default ulLimit if none is defined...
if (uploadLimitKB == Quota.UNLIMITED) {
uploadLimitKB = QuotaManager.getInstance().getDefaultQuotaDependingOnRole(ureq.getIdentity()).getUlLimitKB().longValue();
}
// Add file upload form
long remainingQuotaKB;
if (quotaKB == Quota.UNLIMITED)
remainingQuotaKB = quotaKB;
else if (quotaKB - actualUsage < 0)
remainingQuotaKB = 0;
else
remainingQuotaKB = quotaKB - actualUsage;
removeAsListenerAndDispose(fileUploadCtr);
fileUploadCtr = new FileUploadController(getWindowControl(), currentContainer, ureq, uploadLimitKB, remainingQuotaKB, null, false, true, showMetadata, true, showCancel, false);
listenTo(fileUploadCtr);
mainVC.put("fileUploadCtr", fileUploadCtr.getInitialComponent());
mainVC.contextPut("showFieldset", Boolean.TRUE);
// if folder full show error msg
if (remainingQuotaKB == 0) {
String supportAddr = WebappHelper.getMailConfig("mailQuota");
String msg = translate("QuotaExceededSupport", new String[] { supportAddr });
getWindowControl().setError(msg);
return null;
}
putInitialPanel(mainVC);
return this;
}
use of org.olat.core.gui.components.progressbar.ProgressBar in project OpenOLAT by OpenOLAT.
the class IQDisplayController method init.
private void init(IQSecurityCallback secCallback, UserRequest ureq) {
this.iqsec = secCallback;
this.translator = Util.createPackageTranslator(IQDisplayController.class, ureq.getLocale());
this.ready = false;
retrieveListenerOres = new IQRetrievedEvent(ureq.getIdentity(), courseResId, courseNodeIdent);
CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(), retrieveListenerOres);
iqm = CoreSpringFactory.getImpl(IQManager.class);
myContent = new VelocityContainer("olatmodiqrun", VELOCITY_ROOT + "/qti.html", translator, this);
// Check if fibautocompl.js and fibautocompl.css exists for enhance FIB autocomplete feature
Resolver autcompResolver = null;
if (resolver == null) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, true);
autcompResolver = new ImsRepositoryResolver(re);
} else {
autcompResolver = this.resolver;
}
if (autcompResolver != null && autcompResolver.hasAutocompleteFiles()) {
// Add Autocomplte JS and CSS file to header
StringBuilder sb = new StringBuilder();
// must be like <script type="text/javascript" src="/olat/secstatic/qti/74579818809617/_unzipped_/fibautocompl.js"></script>
sb.append("<script type=\"text/javascript\" src=\"").append(autcompResolver.getStaticsBaseURI()).append("/").append(ImsRepositoryResolver.QTI_FIB_AUTOCOMPLETE_JS_FILE).append("\"></script>\n");
// must be like <link rel="StyleSheet" href="/olat/secstatic/qti/74579818809617/_unzipped_/fibautocompl.css" type="text/css" media="screen, print">
sb.append("<link rel=\"StyleSheet\" href=\"").append(autcompResolver.getStaticsBaseURI()).append("/").append(ImsRepositoryResolver.QTI_FIB_AUTOCOMPLETE_CSS_FILE).append("\" type=\"text/css\" media=\"screen\" >\n");
JSAndCSSComponent autoCompleteJsCss = new JSAndCSSComponent("auto_complete_js_css", this.getClass(), true, sb.toString());
myContent.put("autoCompleteJsCss", autoCompleteJsCss);
}
closeButton = LinkFactory.createButton("close", myContent, this);
closeButton.setPrimary(true);
qtiscoreprogress = new ProgressBar("qtiscoreprogress", 150, 0, 0, "");
myContent.put("qtiscoreprogress", qtiscoreprogress);
Boolean displayScoreProgress = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_SCOREPROGRESS);
// migration,
if (displayScoreProgress == null)
displayScoreProgress = Boolean.TRUE;
// menu
if (!displayScoreProgress.booleanValue())
qtiscoreprogress.setVisible(false);
myContent.contextPut("displayScoreProgress", displayScoreProgress);
qtiquestionprogress = new ProgressBar("qtiquestionprogress", 150, 0, 0, "");
myContent.put("qtiquestionprogress", qtiquestionprogress);
Boolean displayQuestionProgress = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_QUESTIONPROGRESS);
// migration,
if (displayQuestionProgress == null)
displayQuestionProgress = Boolean.FALSE;
if (!displayQuestionProgress.booleanValue())
qtiquestionprogress.setVisible(false);
myContent.contextPut("displayQuestionProgress", displayQuestionProgress);
Boolean displayMenu = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_DISPLAYMENU);
// migration
if (displayMenu == null)
displayMenu = Boolean.TRUE;
myContent.contextPut("displayMenu", displayMenu);
Boolean enableCancel = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLECANCEL);
if (enableCancel == null) {
if (// migration:
modConfig.get(IQEditController.CONFIG_KEY_TYPE).equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS))
// migration:
enableCancel = Boolean.FALSE;
else
// disable
// cancel
// for
// assessments
// migration: enable otherwise
enableCancel = Boolean.TRUE;
}
myContent.contextPut("enableCancel", enableCancel);
Boolean enableSuspend = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLESUSPEND);
// migration
if (enableSuspend == null)
enableSuspend = Boolean.FALSE;
myContent.contextPut("enableSuspend", enableSuspend);
qtistatus = new IQStatus(translator);
qtistatus.setPreview(iqsec.isPreview());
myContent.contextPut("qtistatus", qtistatus);
setInitialComponent(myContent);
// get the assessment
AssessmentInstance ai = null;
if (repositorySoftkey != null) {
// instantiate from repository
// build path information which will be used to store tempory qti file
String resourcePathInfo = courseResId + File.separator + courseNodeIdent;
ai = AssessmentFactory.createAssessmentInstance(ureq.getIdentity(), ureq.getHttpReq().getRemoteAddr(), modConfig, iqsec.isPreview(), courseResId, courseNodeIdent, resourcePathInfo, this);
} else if (resolver != null) {
// instantiate from given resolver
ai = AssessmentFactory.createAssessmentInstance(ureq.getIdentity(), ureq.getHttpReq().getRemoteAddr(), courseResId, courseNodeIdent, resolver, persister, modConfig, this);
}
// check for null instance or instance with no items
if (ai == null || ai.getAssessmentContext().getSectionContext(0).getItemContextCount() == 0)
throw new AssertException("Assessment Instance was null or no sections/items found.");
if (!iqsec.isAllowed(ai)) {
// security check
getWindowControl().setError(translator.translate("status.notallowed"));
return;
}
if (iqsec.attemptsLeft(ai) < 1) {
// security check
// note: important: do not check on == 0 since the nr of attempts can be
// republished for the same test with a smaller number as the latest time.
getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.nomoreattempts" : "status.assess.nomoreattempts"));
return;
}
if (ai.isResuming()) {
getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.resumed" : "status.assess.resumed"));
}
ai.setPreview(iqsec.isPreview());
/*
* menu render option: render only section titles or titles and questions.
*/
Object tmp = modConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION);
Boolean renderSectionsOnly;
if (tmp == null) {
// migration
modConfig.set(IQEditController.CONFIG_KEY_RENDERMENUOPTION, Boolean.FALSE);
renderSectionsOnly = Boolean.FALSE;
} else {
renderSectionsOnly = (Boolean) tmp;
}
boolean enabledMenu = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLEMENU).booleanValue();
boolean itemPageSequence = ((String) modConfig.get(IQEditController.CONFIG_KEY_SEQUENCE)).equals(AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM);
IQMenuDisplayConf mdc = new IQMenuDisplayConf(renderSectionsOnly.booleanValue(), enabledMenu, itemPageSequence);
Boolean tmpMemo = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_MEMO);
boolean memo = tmpMemo == null ? false : tmpMemo.booleanValue();
qticomp = new IQComponent("qticomponent", translator, ai, mdc, memo);
qticomp.addListener(this);
myContent.put("qticomp", qticomp);
if (!ai.isResuming()) {
Navigator navigator = ai.getNavigator();
navigator.startAssessment();
} else {
// fxdiff BAKS-7 Resume function
AssessmentContext act = ai.getAssessmentContext();
if (act.getCurrentSectionContextPos() >= 0) {
int sectionPos = act.getCurrentSectionContextPos();
OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
WindowControl bwControl = addToHistory(ureq, sres, null, getWindowControl(), false);
if (!ai.isSectionPage()) {
SectionContext sct = act.getCurrentSectionContext();
int itemPos = sct.getCurrentItemContextPos();
if (itemPos >= 0) {
OLATResourceable ires = OresHelper.createOLATResourceableInstance("git", new Long(itemPos));
addToHistory(ureq, ires, null, bwControl, true);
}
}
}
}
qtistatus.update(ai);
if (!qtistatus.isSurvey()) {
qtiscoreprogress.setMax(ai.getAssessmentContext().getMaxScore());
qtiscoreprogress.setActual(ai.getAssessmentContext().getScore());
}
qtiquestionprogress.setMax(Integer.parseInt(qtistatus.getMaxQuestions()));
updateQuestionProgressDisplay(ai);
ready = true;
}
use of org.olat.core.gui.components.progressbar.ProgressBar in project openolat by klemens.
the class IQDisplayController method init.
private void init(IQSecurityCallback secCallback, UserRequest ureq) {
this.iqsec = secCallback;
this.translator = Util.createPackageTranslator(IQDisplayController.class, ureq.getLocale());
this.ready = false;
retrieveListenerOres = new IQRetrievedEvent(ureq.getIdentity(), courseResId, courseNodeIdent);
CoordinatorManager.getInstance().getCoordinator().getEventBus().registerFor(this, ureq.getIdentity(), retrieveListenerOres);
iqm = CoreSpringFactory.getImpl(IQManager.class);
myContent = new VelocityContainer("olatmodiqrun", VELOCITY_ROOT + "/qti.html", translator, this);
// Check if fibautocompl.js and fibautocompl.css exists for enhance FIB autocomplete feature
Resolver autcompResolver = null;
if (resolver == null) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, true);
autcompResolver = new ImsRepositoryResolver(re);
} else {
autcompResolver = this.resolver;
}
if (autcompResolver != null && autcompResolver.hasAutocompleteFiles()) {
// Add Autocomplte JS and CSS file to header
StringBuilder sb = new StringBuilder();
// must be like <script type="text/javascript" src="/olat/secstatic/qti/74579818809617/_unzipped_/fibautocompl.js"></script>
sb.append("<script type=\"text/javascript\" src=\"").append(autcompResolver.getStaticsBaseURI()).append("/").append(ImsRepositoryResolver.QTI_FIB_AUTOCOMPLETE_JS_FILE).append("\"></script>\n");
// must be like <link rel="StyleSheet" href="/olat/secstatic/qti/74579818809617/_unzipped_/fibautocompl.css" type="text/css" media="screen, print">
sb.append("<link rel=\"StyleSheet\" href=\"").append(autcompResolver.getStaticsBaseURI()).append("/").append(ImsRepositoryResolver.QTI_FIB_AUTOCOMPLETE_CSS_FILE).append("\" type=\"text/css\" media=\"screen\" >\n");
JSAndCSSComponent autoCompleteJsCss = new JSAndCSSComponent("auto_complete_js_css", this.getClass(), true, sb.toString());
myContent.put("autoCompleteJsCss", autoCompleteJsCss);
}
closeButton = LinkFactory.createButton("close", myContent, this);
closeButton.setPrimary(true);
qtiscoreprogress = new ProgressBar("qtiscoreprogress", 150, 0, 0, "");
myContent.put("qtiscoreprogress", qtiscoreprogress);
Boolean displayScoreProgress = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_SCOREPROGRESS);
// migration,
if (displayScoreProgress == null)
displayScoreProgress = Boolean.TRUE;
// menu
if (!displayScoreProgress.booleanValue())
qtiscoreprogress.setVisible(false);
myContent.contextPut("displayScoreProgress", displayScoreProgress);
qtiquestionprogress = new ProgressBar("qtiquestionprogress", 150, 0, 0, "");
myContent.put("qtiquestionprogress", qtiquestionprogress);
Boolean displayQuestionProgress = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_QUESTIONPROGRESS);
// migration,
if (displayQuestionProgress == null)
displayQuestionProgress = Boolean.FALSE;
if (!displayQuestionProgress.booleanValue())
qtiquestionprogress.setVisible(false);
myContent.contextPut("displayQuestionProgress", displayQuestionProgress);
Boolean displayMenu = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_DISPLAYMENU);
// migration
if (displayMenu == null)
displayMenu = Boolean.TRUE;
myContent.contextPut("displayMenu", displayMenu);
Boolean enableCancel = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLECANCEL);
if (enableCancel == null) {
if (// migration:
modConfig.get(IQEditController.CONFIG_KEY_TYPE).equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS))
// migration:
enableCancel = Boolean.FALSE;
else
// disable
// cancel
// for
// assessments
// migration: enable otherwise
enableCancel = Boolean.TRUE;
}
myContent.contextPut("enableCancel", enableCancel);
Boolean enableSuspend = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLESUSPEND);
// migration
if (enableSuspend == null)
enableSuspend = Boolean.FALSE;
myContent.contextPut("enableSuspend", enableSuspend);
qtistatus = new IQStatus(translator);
qtistatus.setPreview(iqsec.isPreview());
myContent.contextPut("qtistatus", qtistatus);
setInitialComponent(myContent);
// get the assessment
AssessmentInstance ai = null;
if (repositorySoftkey != null) {
// instantiate from repository
// build path information which will be used to store tempory qti file
String resourcePathInfo = courseResId + File.separator + courseNodeIdent;
ai = AssessmentFactory.createAssessmentInstance(ureq.getIdentity(), ureq.getHttpReq().getRemoteAddr(), modConfig, iqsec.isPreview(), courseResId, courseNodeIdent, resourcePathInfo, this);
} else if (resolver != null) {
// instantiate from given resolver
ai = AssessmentFactory.createAssessmentInstance(ureq.getIdentity(), ureq.getHttpReq().getRemoteAddr(), courseResId, courseNodeIdent, resolver, persister, modConfig, this);
}
// check for null instance or instance with no items
if (ai == null || ai.getAssessmentContext().getSectionContext(0).getItemContextCount() == 0)
throw new AssertException("Assessment Instance was null or no sections/items found.");
if (!iqsec.isAllowed(ai)) {
// security check
getWindowControl().setError(translator.translate("status.notallowed"));
return;
}
if (iqsec.attemptsLeft(ai) < 1) {
// security check
// note: important: do not check on == 0 since the nr of attempts can be
// republished for the same test with a smaller number as the latest time.
getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.nomoreattempts" : "status.assess.nomoreattempts"));
return;
}
if (ai.isResuming()) {
getWindowControl().setInfo(translator.translate(ai.isSurvey() ? "status.survey.resumed" : "status.assess.resumed"));
}
ai.setPreview(iqsec.isPreview());
/*
* menu render option: render only section titles or titles and questions.
*/
Object tmp = modConfig.get(IQEditController.CONFIG_KEY_RENDERMENUOPTION);
Boolean renderSectionsOnly;
if (tmp == null) {
// migration
modConfig.set(IQEditController.CONFIG_KEY_RENDERMENUOPTION, Boolean.FALSE);
renderSectionsOnly = Boolean.FALSE;
} else {
renderSectionsOnly = (Boolean) tmp;
}
boolean enabledMenu = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_ENABLEMENU).booleanValue();
boolean itemPageSequence = ((String) modConfig.get(IQEditController.CONFIG_KEY_SEQUENCE)).equals(AssessmentInstance.QMD_ENTRY_SEQUENCE_ITEM);
IQMenuDisplayConf mdc = new IQMenuDisplayConf(renderSectionsOnly.booleanValue(), enabledMenu, itemPageSequence);
Boolean tmpMemo = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_MEMO);
boolean memo = tmpMemo == null ? false : tmpMemo.booleanValue();
qticomp = new IQComponent("qticomponent", translator, ai, mdc, memo);
qticomp.addListener(this);
myContent.put("qticomp", qticomp);
if (!ai.isResuming()) {
Navigator navigator = ai.getNavigator();
navigator.startAssessment();
} else {
// fxdiff BAKS-7 Resume function
AssessmentContext act = ai.getAssessmentContext();
if (act.getCurrentSectionContextPos() >= 0) {
int sectionPos = act.getCurrentSectionContextPos();
OLATResourceable sres = OresHelper.createOLATResourceableInstance("gse", new Long(sectionPos));
WindowControl bwControl = addToHistory(ureq, sres, null, getWindowControl(), false);
if (!ai.isSectionPage()) {
SectionContext sct = act.getCurrentSectionContext();
int itemPos = sct.getCurrentItemContextPos();
if (itemPos >= 0) {
OLATResourceable ires = OresHelper.createOLATResourceableInstance("git", new Long(itemPos));
addToHistory(ureq, ires, null, bwControl, true);
}
}
}
}
qtistatus.update(ai);
if (!qtistatus.isSurvey()) {
qtiscoreprogress.setMax(ai.getAssessmentContext().getMaxScore());
qtiscoreprogress.setActual(ai.getAssessmentContext().getScore());
}
qtiquestionprogress.setMax(Integer.parseInt(qtistatus.getMaxQuestions()));
updateQuestionProgressDisplay(ai);
ready = true;
}
Aggregations