Search in sources :

Example 6 with CheckboxList

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

the class CheckListBoxListEditController method doDelete.

private void doDelete(UserRequest ureq, Checkbox checkbox) {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list == null || checkbox == null)
        return;
    list.remove(checkbox);
    config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, list);
    fireEvent(ureq, Event.DONE_EVENT);
    updateModel();
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList)

Example 7 with CheckboxList

use of org.olat.course.nodes.cl.model.CheckboxList 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)

Example 8 with CheckboxList

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

the class CheckListBoxListEditController method doEdit.

private void doEdit(UserRequest ureq, Checkbox checkbox) {
    CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
    if (list == null) {
        list = new CheckboxList();
    }
    list.add(checkbox);
    config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, list);
    fireEvent(ureq, Event.DONE_EVENT);
    updateModel();
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList)

Example 9 with CheckboxList

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

the class CheckListConfigurationController method getAvailableSumCutValues.

private String[] getAvailableSumCutValues() {
    int currentNumOfCheckbox;
    if (data == null) {
        CheckboxList list = (CheckboxList) config.get(CheckListCourseNode.CONFIG_KEY_CHECKBOX);
        currentNumOfCheckbox = list == null ? 0 : list.getNumOfCheckbox();
    } else {
        currentNumOfCheckbox = data.getNumOfCheckbox();
    }
    String[] numKeys = new String[currentNumOfCheckbox + 1];
    for (int i = 0; i <= currentNumOfCheckbox; i++) {
        numKeys[i] = Integer.toString(i);
    }
    return numKeys;
}
Also used : CheckboxList(org.olat.course.nodes.cl.model.CheckboxList)

Example 10 with CheckboxList

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

the class CheckListCourseNode method doUpdateAssessmentBySum.

private void doUpdateAssessmentBySum(Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
    ModuleConfiguration config = getModuleConfiguration();
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    int checkedBox = checkboxManager.countChecked(assessedIdentity, courseOres, getIdent());
    CheckboxList checkboxList = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    Integer cut = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
    int minNumOfCheckbox = cut == null ? checkboxList.getNumOfCheckbox() : cut.intValue();
    boolean passed = checkedBox >= minNumOfCheckbox;
    Float score = null;
    if (passed) {
        Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
        if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
            score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
            Float maxScore = (Float) config.get(MSCourseNode.CONFIG_KEY_SCORE_MAX);
            if (maxScore != null && maxScore.floatValue() < score) {
                score = maxScore.floatValue();
            }
        }
    }
    ScoreEvaluation sceval = new ScoreEvaluation(score, new Boolean(passed));
    AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
    am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OLATResourceable(org.olat.core.id.OLATResourceable) AssessmentManager(org.olat.course.assessment.AssessmentManager)

Aggregations

CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)34 Checkbox (org.olat.course.nodes.cl.model.Checkbox)24 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)18 ModuleConfiguration (org.olat.modules.ModuleConfiguration)18 File (java.io.File)12 Identity (org.olat.core.id.Identity)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 ArrayList (java.util.ArrayList)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)4 CellStyle (org.olat.core.util.openxml.workbookstyle.CellStyle)4 ICourse (org.olat.course.ICourse)4 CheckListCourseNode (org.olat.course.nodes.CheckListCourseNode)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)4 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)4 IOException (java.io.IOException)2 OutputStream (java.io.OutputStream)2 Collections (java.util.Collections)2