Search in sources :

Example 11 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method exportNode.

@Override
public void exportNode(File fExportDirectory, ICourse course) {
    // export the files
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    if (list != null && list.getList() != null) {
        for (Checkbox checkbox : list.getList()) {
            File dir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
            if (dir.exists()) {
                File fFileExportDir = new File(fExportDirectory, "checklistfiles/" + getIdent() + "/" + checkbox.getCheckboxId());
                fFileExportDir.mkdirs();
                FileUtils.copyDirContentsToDir(dir, fFileExportDir, false, "export files of checkbox");
            }
        }
    }
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Checkbox(org.olat.course.nodes.cl.model.Checkbox) File(java.io.File)

Example 12 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.

the class CheckedPDFExport method create.

public void create(CheckboxList checkboxList, List<CheckListAssessmentRow> rows) throws IOException, COSVisitorException, TransformerException {
    addMetadata(courseNodeTitle, courseTitle, author);
    int i = 0;
    for (Checkbox checkbox : checkboxList.getList()) {
        create(checkbox, i++, rows);
    }
    addPageNumbers();
}
Also used : Checkbox(org.olat.course.nodes.cl.model.Checkbox)

Example 13 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.

the class CheckListAssessmentController method loadDatas.

private List<CheckListAssessmentRow> loadDatas() {
    if (!(coachCourseEnv instanceof UserCourseEnvironmentImpl)) {
        return Collections.emptyList();
    }
    UserCourseEnvironmentImpl env = (UserCourseEnvironmentImpl) coachCourseEnv;
    List<Checkbox> checkboxColl = checkboxList.getList();
    int numOfCheckbox = checkboxList.getNumOfCheckbox();
    boolean courseAdmin = env.isAdmin();
    RepositoryEntry re = env.getCourseRepositoryEntry();
    boolean courseTutor = repositoryService.hasRole(getIdentity(), re, GroupRoles.coach.name());
    Set<Long> missingIdentityKeys = new HashSet<>();
    if (courseTutor || courseAdmin) {
        List<RepositoryEntryMembership> repoMemberships = repositoryManager.getRepositoryEntryMembership(re);
        for (RepositoryEntryMembership repoMembership : repoMemberships) {
            if (repoMembership.isParticipant()) {
                missingIdentityKeys.add(repoMembership.getIdentityKey());
            }
        }
    }
    List<BusinessGroup> coachedGroups = courseAdmin ? coachCourseEnv.getCourseEnvironment().getCourseGroupManager().getAllBusinessGroups() : env.getCoachedGroups();
    List<AssessmentData> dataList = checkboxManager.getAssessmentDatas(courseOres, courseNode.getIdent(), courseTutor || courseAdmin ? re : null, coachedGroups);
    List<CheckListAssessmentRow> boxList = getAssessmentDataViews(dataList, checkboxColl);
    Map<Long, CheckListAssessmentRow> identityToView = new HashMap<>();
    for (CheckListAssessmentRow box : boxList) {
        identityToView.put(box.getIdentityKey(), box);
        missingIdentityKeys.remove(box.getIdentityKey());
    }
    List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupsMembership(coachedGroups);
    for (BusinessGroupMembership membership : memberships) {
        if (!membership.isParticipant())
            continue;
        Long identityKey = membership.getIdentityKey();
        if (!identityToView.containsKey(identityKey)) {
            missingIdentityKeys.add(identityKey);
        }
    }
    List<Identity> missingIdentities = securityManager.loadIdentityByKeys(missingIdentityKeys);
    for (Identity missingIdentity : missingIdentities) {
        Boolean[] checked = new Boolean[numOfCheckbox];
        Float[] scores = new Float[numOfCheckbox];
        CheckListAssessmentRow view = new CheckListAssessmentRow(missingIdentity, checked, scores, null, userPropertyHandlers, getLocale());
        identityToView.put(missingIdentity.getKey(), view);
    }
    for (BusinessGroupMembership membership : memberships) {
        if (!membership.isParticipant())
            continue;
        CheckListAssessmentRow view = identityToView.get(membership.getIdentityKey());
        if (view != null) {
            view.addGroupKey(membership.getGroupKey());
        }
    }
    List<CheckListAssessmentRow> views = new ArrayList<>();
    views.addAll(identityToView.values());
    return views;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryEntryMembership(org.olat.repository.model.RepositoryEntryMembership) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Checkbox(org.olat.course.nodes.cl.model.Checkbox) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet) BusinessGroup(org.olat.group.BusinessGroup) AssessmentData(org.olat.course.nodes.cl.model.AssessmentData) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl)

Example 14 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.

the class CheckListBoxListEditController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (addLink == source) {
        Checkbox checkbox = new Checkbox();
        checkbox.setCheckboxId(UUID.randomUUID().toString());
        doOpenEdit(ureq, checkbox, true, translate("add.checkbox"));
    } else if (boxTable == source) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            String cmd = se.getCommand();
            if ("edit".equals(cmd)) {
                CheckboxConfigRow row = model.getObject(se.getIndex());
                doOpenEdit(ureq, row.getCheckbox(), false, translate("edit.checkbox"));
            } else if ("up".equals(cmd)) {
                doUp(ureq, se.getIndex());
            } else if ("down".equals(cmd)) {
                doDown(ureq, se.getIndex());
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : Checkbox(org.olat.course.nodes.cl.model.Checkbox) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Example 15 with Checkbox

use of org.olat.course.nodes.cl.model.Checkbox in project openolat by klemens.

the class CheckListBoxListEditController method updateModel.

private void updateModel() {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    List<CheckboxConfigRow> boxList = new ArrayList<CheckboxConfigRow>();
    if (list != null && list.getList() != null) {
        for (Checkbox checkbox : list.getList()) {
            DownloadLink download = null;
            VFSContainer container = checkboxManager.getFileContainer(courseEnv, courseNode);
            if (container != null) {
                VFSItem item = container.resolve(checkbox.getFilename());
                if (item instanceof VFSLeaf) {
                    download = uifactory.addDownloadLink("file_" + checkbox.getCheckboxId(), checkbox.getFilename(), null, (VFSLeaf) item, boxTable);
                }
            }
            boxList.add(new CheckboxConfigRow(checkbox, download));
        }
    }
    model.setObjects(boxList);
    boxTable.reset();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Checkbox(org.olat.course.nodes.cl.model.Checkbox) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem)

Aggregations

Checkbox (org.olat.course.nodes.cl.model.Checkbox)58 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)24 ArrayList (java.util.ArrayList)16 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)14 ModuleConfiguration (org.olat.modules.ModuleConfiguration)14 File (java.io.File)12 HashMap (java.util.HashMap)12 DBCheckbox (org.olat.course.nodes.cl.model.DBCheckbox)12 Identity (org.olat.core.id.Identity)10 HashSet (java.util.HashSet)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)8 ICourse (org.olat.course.ICourse)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)8 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6 DBCheck (org.olat.course.nodes.cl.model.DBCheck)6 Date (java.util.Date)4 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)4