Search in sources :

Example 11 with VelocityContainer

use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.

the class HTMLEditorController method initEditorForm.

private void initEditorForm(VFSContainer bContainer, String relFilePath, CustomLinkTreeModel linkTreeModel, String mPath, boolean editorCheck, boolean versions, boolean withButtons) {
    this.baseContainer = bContainer;
    this.fileRelPath = relFilePath;
    this.mediaPath = mPath;
    this.versionsEnabled = versions;
    this.buttonsEnabled = withButtons;
    this.customLinkTreeModel = linkTreeModel;
    this.editorCheckEnabled = editorCheck;
    // make sure the filename doesn't start with a slash
    this.fileName = ((relFilePath.charAt(0) == '/') ? relFilePath.substring(1) : relFilePath);
    this.fileLeaf = (VFSLeaf) bContainer.resolve(fileName);
    if (fileLeaf == null)
        throw new AssertException("file::" + getFileDebuggingPath(bContainer, relFilePath) + " does not exist!");
    long size = fileLeaf.getSize();
    if (size > FolderConfig.getMaxEditSizeLimit()) {
        // limit to reasonable size, see OO-57
        fileToLargeError = translate("plaintext.error.tolarge", new String[] { (size / 1000) + "", (FolderConfig.getMaxEditSizeLimit() / 1000) + "" });
        this.body = "";
        this.editable = false;
        return;
    }
    // check if someone else is already editing the file
    if (fileLeaf instanceof LocalFileImpl) {
        // Cast to LocalFile necessary because the VFSItem is missing some
        // ID mechanism that identifies an item within the system
        OLATResourceable lockResourceable = createLockResourceable(fileLeaf);
        // OLAT-5066: the use of "fileName" gives users the (false) impression that the file they wish to access
        // is already locked by someone else. Since the lock token must be smaller than 50 characters we us an
        // MD5 hash of the absolute file path which will always be 32 characters long and virtually unique.
        String lockToken = createLockToken(bContainer, relFilePath);
        lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockResourceable, getIdentity(), lockToken);
        VelocityContainer vc = (VelocityContainer) flc.getComponent();
        if (!lock.isSuccess()) {
            vc.contextPut("locked", Boolean.TRUE);
            String fullname = UserManager.getInstance().getUserDisplayName(lock.getOwner());
            vc.contextPut("lockOwner", fullname);
            editable = false;
            return;
        } else {
            vc.contextPut("locked", Boolean.FALSE);
        }
    }
    // Parse the content of the page
    this.body = parsePage(fileLeaf);
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 12 with VelocityContainer

use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.

the class MembersPrintController method initFormMemberList.

private void initFormMemberList(String name, String label, List<Identity> members) {
    List<Member> memberWrappers = members.stream().map(m -> createMember(m)).collect(Collectors.toList());
    VelocityContainer listVC = createVelocityContainer("printList");
    listVC.contextPut("label", label);
    listVC.contextPut("avatarBaseURL", avatarBaseURL);
    listVC.contextPut("members", memberWrappers);
    listVC.contextPut("typecss", "o_" + name);
    listVC.contextPut("userPropertyPrintHandlers", userPropertyPrintHandlers);
    // add lookup table so the avatar properties can be read out from the member object that contains the full list of attributes
    Map<String, Integer> handlerLookupMap = new HashMap<String, Integer>();
    for (int i = userPropertyPrintHandlers.size(); i-- > 0; ) {
        UserPropertyHandler handler = userPropertyPrintHandlers.get(i);
        handlerLookupMap.put(handler.getName(), i);
    }
    listVC.contextPut("handlerLookupMap", handlerLookupMap);
    mainVC.put(name, listVC);
}
Also used : Util(org.olat.core.util.Util) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) MediaResource(org.olat.core.gui.media.MediaResource) Event(org.olat.core.gui.control.Event) Member(org.olat.course.nodes.members.Member) HttpServletRequest(javax.servlet.http.HttpServletRequest) MainPanel(org.olat.core.gui.components.panel.MainPanel) UserConstants(org.olat.core.id.UserConstants) Locale(java.util.Locale) Map(java.util.Map) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) BaseSecurityModule(org.olat.basesecurity.BaseSecurityModule) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Translator(org.olat.core.gui.translator.Translator) WindowControl(org.olat.core.gui.control.WindowControl) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DisplayPortraitManager(org.olat.user.DisplayPortraitManager) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) Mapper(org.olat.core.dispatcher.mapper.Mapper) NotFoundMediaResource(org.olat.core.gui.media.NotFoundMediaResource) UserManager(org.olat.user.UserManager) BasicController(org.olat.core.gui.control.controller.BasicController) List(java.util.List) Identity(org.olat.core.id.Identity) VFSMediaResource(org.olat.core.util.vfs.VFSMediaResource) UserRequest(org.olat.core.gui.UserRequest) Roles(org.olat.core.id.Roles) HashMap(java.util.HashMap) Member(org.olat.course.nodes.members.Member) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 13 with VelocityContainer

use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.

the class GTAParticipantController method setSolutions.

private void setSolutions(UserRequest ureq, Task assignedTask) {
    DueDate availableDate = getSolutionDueDate(assignedTask);
    boolean visible = availableDate == null || (availableDate.getDueDate() != null && availableDate.getDueDate().compareTo(new Date()) <= 0);
    if (visible) {
        File documentsDir = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
        VFSContainer documentsContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
        if ((availableDate != null && !availableDate.isRelative() && gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION_VISIBLE_ALL, false)) || TaskHelper.hasDocuments(documentsDir)) {
            solutionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "run.solutions.description", "bulk.solutions", "solutions");
            listenTo(solutionsCtrl);
            mainVC.put("solutions", solutionsCtrl.getInitialComponent());
        }
    } else {
        VelocityContainer waitVC = createVelocityContainer("wait_for_solutions");
        mainVC.put("solutions", waitVC);
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) DueDate(org.olat.course.nodes.gta.model.DueDate) File(java.io.File) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 14 with VelocityContainer

use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.

the class QTI12ItemStatisticsController method initItem.

protected void initItem(StatisticsItem itemStats) {
    Series series = seriesfactory.getSeries(item, itemStats);
    VelocityContainer vc = createVelocityContainer("hbar_item");
    vc.contextPut("series", series);
    mainVC.put("questionChart", vc);
    mainVC.contextPut("series", series);
}
Also used : VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 15 with VelocityContainer

use of org.olat.core.gui.components.velocity.VelocityContainer in project OpenOLAT by OpenOLAT.

the class QTI21OnyxAssessmentStatisticsController method initScoreHistogram.

private void initScoreHistogram(StatisticAssessment stats) {
    VelocityContainer scoreHistogramVC = createVelocityContainer("histogram_score");
    scoreHistogramVC.contextPut("datas", BarSeries.datasToString(stats.getScores()));
    mainVC.put("scoreHistogram", scoreHistogramVC);
}
Also used : VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)162 Component (org.olat.core.gui.components.Component)22 ArrayList (java.util.ArrayList)16 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)14 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)14 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)14 Link (org.olat.core.gui.components.link.Link)12 Panel (org.olat.core.gui.components.panel.Panel)12 UserRequest (org.olat.core.gui.UserRequest)10 JSAndCSSComponent (org.olat.core.gui.components.htmlheader.jscss.JSAndCSSComponent)10 List (java.util.List)8 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)8 WindowControl (org.olat.core.gui.control.WindowControl)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 Translator (org.olat.core.gui.translator.Translator)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 HashMap (java.util.HashMap)6 Collectors (java.util.stream.Collectors)6 Mapper (org.olat.core.dispatcher.mapper.Mapper)6 BarSeries (org.olat.core.gui.components.chart.BarSeries)6