use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class AdditionalConditionManager method nextUserInputController.
/**
* used to get the gui element for the next condition that a user can influence or sees a more detailed error-message in
* call only if the evaluateCondtions() call answered with false or null
* @param ureq
* @param wControl
* @return null if either nothing is wrong or the user is unable to influence the condition in olat (and won't get a more detailed error-message)
*/
public Controller nextUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv) {
for (AdditionalCondition cond : node.getAdditionalConditions()) {
cond.setNode(node);
cond.setCourseId(courseId);
boolean retVal = cond.evaluate(answers);
if (!retVal) {
Controller ctrl = cond.getUserInputController(ureq, wControl, userCourseEnv);
CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfiguration(node.getType());
return TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, node, config.getIconCSSClass());
}
}
return null;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class GroupInfoMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
addToHistory(ureq);
return;
}
ContextEntry entry = entries.get(0);
String menuItem = entry.getOLATResourceable().getResourceableTypeName();
Object nodeUserObject = null;
Controller selectedController = null;
if ("Infos".equals(menuItem)) {
selectedController = getInfosController(ureq);
nodeUserObject = COMMAND_MENU_GROUPINFO;
} else if ("Contact".equals(menuItem)) {
selectedController = getContactController(ureq);
nodeUserObject = COMMAND_MENU_GROUPCONTACT;
} else if ("Members".equals(menuItem)) {
selectedController = getMembersController(ureq);
nodeUserObject = COMMAND_MENU_GROUPMEMBERS;
}
if (selectedController != null) {
TreeNode node = TreeHelper.findNodeByUserObject(nodeUserObject, menuTree.getTreeModel().getRootNode());
if (node != null) {
menuTree.setSelectedNode(node);
}
addToHistory(ureq, selectedController);
}
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class QTI21ResultsExportMediaResource method createResultDetail.
private List<ResultDetail> createResultDetail(Identity identity, ZipOutputStream zout, String idDir) throws IOException {
List<ResultDetail> assessments = new ArrayList<>();
List<AssessmentTestSession> sessions = qtiService.getAssessmentTestSessions(entry, courseNode.getIdent(), identity);
for (AssessmentTestSession session : sessions) {
Long assessmentID = session.getKey();
String idPath = idDir + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1) + SEP;
createZipDirectory(zout, idPath);
// content of result table
ResultDetail resultDetail = new ResultDetail(assessmentID.toString(), assessmentDateFormat.format(session.getCreationDate()), displayDateFormat.format(new Date(session.getDuration())), session.getScore(), session.getManualScore(), createPassedIcons(session.getPassed() == null ? true : session.getPassed()), idPath.replace(idDir, "") + assessmentID + ".html");
assessments.add(resultDetail);
// WindowControlMocker needed because this is not a controller
WindowControl mockwControl = new WindowControlMocker();
FileResourceManager frm = FileResourceManager.getInstance();
RepositoryEntry testEntry = session.getTestEntry();
testEntries.add(testEntry);
File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
// add test repo key
String mapperUri = "../../../test" + testEntry.getKey() + "/";
String submissionMapperUri = ".";
String exportUri = "../" + translator.translate("table.user.attempt") + (sessions.indexOf(session) + 1);
Controller assessmentResultController = new AssessmentResultController(ureq, mockwControl, identity, false, session, fUnzippedDirRoot, mapperUri, submissionMapperUri, QTI21AssessmentResultsOptions.allOptions(), false, true, false, exportUri);
Component component = assessmentResultController.getInitialComponent();
String componentHTML = createResultHTML(component);
convertToZipEntry(zout, idPath + assessmentID + ".html", componentHTML);
File resultXML = qtiService.getAssessmentResultFile(session);
convertToZipEntry(zout, idPath + assessmentID + ".xml", resultXML);
File signatureXML = qtiService.getAssessmentResultSignature(session);
if (signatureXML != null) {
convertToZipEntry(zout, idPath + "assessmentResultSignature.xml", signatureXML);
}
File submissionDir = qtiService.getSubmissionDirectory(session);
String baseDir = idPath + "submissions";
ZipUtil.addDirectoryToZip(submissionDir.toPath(), baseDir, zout);
}
return assessments;
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class EPArtefactViewController method initForm.
/**
* @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) {
if (detailsLinkEnabled && !artefactChooseMode) {
detailsLink = uifactory.addFormLink("details.link", formLayout, Link.BUTTON);
detailsLink.setElementCssClass("o_sel_artefact_details");
}
title = uifactory.addInlineTextElement("title", artefact.getTitle(), formLayout, this);
flc.contextPut("cssClosed", artefactInClosedMap ? "o_artefact_closed" : "");
flc.contextPut("viewOnly", viewOnlyMode);
if (viewOnlyMode || artefactInClosedMap)
title.setEnabled(false);
// get tags and prepare textboxlist-component
List<String> tagL = ePFMgr.getArtefactTags(artefact);
Map<String, String> tagLM = new HashMap<String, String>();
for (String tag : tagL) {
tagLM.put(tag, tag);
}
tblE = uifactory.addTextBoxListElement("tagTextbox", null, "tag.textboxlist.hint", tagLM, formLayout, getTranslator());
if (viewOnlyMode || artefactInClosedMap) {
tblE.setEnabled(false);
} else {
Map<String, String> allUsersTags = ePFMgr.getUsersMostUsedTags(getIdentity(), -1);
tblE.setAutoCompleteContent(allUsersTags);
}
// get maps wherein this artefact is linked and create links to them
List<PortfolioStructure> linkedMaps = ePFMgr.getReferencedMapsForArtefact(artefact);
if (linkedMaps != null && linkedMaps.size() != 0) {
List<FormLink> selectMapNames = new ArrayList<FormLink>(linkedMaps.size());
int count = 0;
for (PortfolioStructure ePMap : linkedMaps) {
String mapTitle = StringHelper.escapeHtml(ePMap.getTitle());
FormLink selectMap = uifactory.addFormLink("map-" + count++, "map", mapTitle, null, formLayout, Link.NONTRANSLATED);
selectMap.setUserObject(ePMap.getOlatResource());
selectMap.setEnabled(!viewOnlyMode && !artefactChooseMode);
selectMapNames.add(selectMap);
}
flc.contextPut("maps", selectMapNames);
}
// build link to original source
if (StringHelper.containsNonWhitespace(artefact.getBusinessPath())) {
String sourceLink = createLinkToArtefactSource(ureq, artefact.getBusinessPath());
flc.contextPut("artefactSourceLink", sourceLink);
}
// create a delete button
deleteBtn = uifactory.addFormLink("delete.artefact", formLayout, Link.BUTTON);
deleteBtn.setIconLeftCSS("o_icon o_icon_delete");
deleteBtn.addActionListener(FormEvent.ONCLICK);
if (viewOnlyMode || artefactChooseMode || artefactInClosedMap)
deleteBtn.setVisible(false);
// let the artefact-handler paint what is special for this kind of artefact
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Controller detCtrl = artHandler.createDetailsController(ureq, getWindowControl(), artefact, viewOnlyMode || artefactInClosedMap);
if (detCtrl != null) {
flc.put("detailsController", detCtrl.getInitialComponent());
}
// create edit buttons the adapt meta-data
if (!(viewOnlyMode || artefactChooseMode || artefactInClosedMap)) {
String reflexion = artefact.getReflexion();
reflexion = FilterFactory.getHtmlTagAndDescapingFilter().filter(reflexion);
reflexion = StringHelper.xssScan(reflexion);
reflexion = Formatter.truncate(reflexion, 50);
if (!StringHelper.containsNonWhitespace(reflexion)) {
// show a link even if empty
reflexion = " ";
}
reflexionBtn = uifactory.addFormLink("reflexionBtn", reflexion, null, formLayout, Link.NONTRANSLATED);
reflexionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
String description = artefact.getDescription();
description = FilterFactory.getHtmlTagAndDescapingFilter().filter(description);
description = Formatter.truncate(description, 50);
description = StringHelper.xssScan(description);
if (!StringHelper.containsNonWhitespace(description)) {
// show a link even if empty
description = " ";
}
descriptionBtn = uifactory.addFormLink("descriptionBtn", description, null, formLayout, Link.NONTRANSLATED);
descriptionBtn.setIconLeftCSS("o_icon o_icon_inline_editable");
}
// if in artefactChooseMode, add an "choose this" button
if (artefactChooseMode) {
chooseBtn = uifactory.addFormLink("choose.artefact", formLayout, Link.BUTTON);
chooseBtn.addActionListener(FormEvent.ONCLICK);
}
flc.contextPut("artefact", artefact);
setArtAttribConfig(artAttribConfig);
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class EPMultipleArtefactSmallReadOnlyPreviewController method init.
private void init(UserRequest ureq) {
if (artefactCtrls != null)
disposeArtefactControllers();
if (optionLinkCtrls != null)
disposeOptionLinkControllers();
optionLinkCtrls = new ArrayList<Controller>();
artefactCtrls = new ArrayList<Controller>();
List<List<Panel>> artefactCtrlCompLines = new ArrayList<List<Panel>>();
List<Panel> artefactCtrlCompLine = new ArrayList<Panel>();
int i = 1;
for (AbstractArtefact artefact : artefacts) {
EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(artefact.getResourceableTypeName());
Controller artCtrl;
// check for special art-display:
boolean special = artHandler.isProvidingSpecialMapViewController();
if (special) {
artCtrl = artHandler.getSpecialMapViewController(ureq, getWindowControl(), artefact);
if (artCtrl != null) {
// add the optionsLink to the artefact
EPArtefactViewOptionsLinkController optionsLinkCtrl = new EPArtefactViewOptionsLinkController(ureq, getWindowControl(), artefact, secCallback, struct);
vC.put("optionsLink" + i, optionsLinkCtrl.getInitialComponent());
listenTo(optionsLinkCtrl);
optionLinkCtrls.add(optionsLinkCtrl);
}
} else {
artCtrl = new EPArtefactViewReadOnlyController(ureq, getWindowControl(), artefact, struct, secCallback, true);
}
if (artCtrl != null) {
artefactCtrls.add(artCtrl);
Component artefactCtrlComponent = artCtrl.getInitialComponent();
listenTo(artCtrl);
Panel namedPanel = new Panel("artCtrl" + i);
namedPanel.setContent(artefactCtrlComponent);
if (special) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLines.add(Collections.singletonList(namedPanel));
artefactCtrlCompLine = new ArrayList<Panel>();
} else {
if (artefactCtrlCompLine.size() == 3) {
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
artefactCtrlCompLine = new ArrayList<Panel>();
}
artefactCtrlCompLine.add(namedPanel);
}
vC.put("artCtrl" + i, namedPanel);
if (special) {
// need a flag in a lopp for the velociy template
vC.put("specialartCtrl" + i, artefactCtrlComponent);
}
i++;
}
}
if (!artefactCtrlCompLine.isEmpty()) {
artefactCtrlCompLines.add(artefactCtrlCompLine);
}
vC.contextPut("artefactCtrlCompLines", artefactCtrlCompLines);
}
Aggregations