Search in sources :

Example 51 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class CourseCalendarPeekViewController method init.

private void init(UserRequest ureq, CalCourseNode courseNode, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    CourseCalendars myCal = CourseCalendars.createCourseCalendarsWrapper(ureq, getWindowControl(), courseEnv, ne);
    Date refDate;
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    if (CalEditController.getAutoDate(config)) {
        refDate = new Date();
    } else {
        refDate = CalEditController.getStartDate(config);
        if (refDate == null)
            refDate = new Date();
    }
    List<KalendarEvent> nextEvents = new ArrayList<KalendarEvent>();
    for (KalendarRenderWrapper calendar : myCal.getCalendars()) {
        Kalendar cal = calendar.getKalendar();
        Collection<KalendarEvent> events = cal.getEvents();
        for (KalendarEvent event : events) {
            if (refDate.compareTo(event.getBegin()) <= 0) {
                nextEvents.add(event);
            }
        }
    }
    Collections.sort(nextEvents, new KalendarEventComparator());
    List<KalendarEvent> nextThreeEvents = nextEvents.subList(0, Math.min(3, nextEvents.size()));
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("calendar.noEvents"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    // dummy header key, won't be used since setDisplayTableHeader is set to
    // false
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.date", 0, null, ureq.getLocale()));
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.subject", 1, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));
    tableController.setTableDataModel(new CourseCalendarPeekViewModel(nextThreeEvents, getTranslator()));
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) TableController(org.olat.core.gui.components.table.TableController) ArrayList(java.util.ArrayList) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Date(java.util.Date) Kalendar(org.olat.commons.calendar.model.Kalendar) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 52 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class MultiSPController method create.

private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
    SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
    if (selection.isMultiselect() && selection.isSelected(0)) {
        VFSItem item = node.getItem();
        CourseNode newNode = null;
        if (item instanceof VFSLeaf) {
            // create node
            newNode = createCourseNode(item, "sp");
            ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
            String path = getRelativePath(item);
            moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
            moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
        } else if (item instanceof VFSContainer) {
            // add structure
            newNode = createCourseNode(item, "st");
        }
        int pos = -1;
        if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
            pos = position++;
        }
        if (pos < 0 || pos >= parentNode.getChildCount()) {
            course.getEditorTreeModel().addCourseNode(newNode, parentNode);
        } else {
            course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
        }
        if (item instanceof VFSContainer) {
            parentNode = newNode;
        }
    }
    // recurse
    for (MultipleSelectionElement childElement : node.getChildren()) {
        create(childElement, course, parentNode);
    }
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) ModuleConfiguration(org.olat.modules.ModuleConfiguration) MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) CourseNode(org.olat.course.nodes.CourseNode)

Example 53 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method updateOnPublish.

@Override
public void updateOnPublish(Locale locale, ICourse course, Identity publisher, PublishEvents publishEvents) {
    ModuleConfiguration config = getModuleConfiguration();
    // sync the checkbox with the database
    CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
    CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
    checkboxManager.syncCheckbox(list, course, getIdent());
    CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager();
    List<Identity> assessedUsers = pm.getAllIdentitiesWithCourseAssessmentData(null);
    int count = 0;
    for (Identity assessedIdentity : assessedUsers) {
        updateScorePassedOnPublish(assessedIdentity, publisher, checkboxManager, course);
        if (++count % 10 == 0) {
            DBFactory.getInstance().commitAndCloseSession();
        }
    }
    DBFactory.getInstance().commitAndCloseSession();
    super.updateOnPublish(locale, course, publisher, publishEvents);
}
Also used : CheckboxManager(org.olat.course.nodes.cl.CheckboxManager) CheckboxList(org.olat.course.nodes.cl.model.CheckboxList) ModuleConfiguration(org.olat.modules.ModuleConfiguration) Identity(org.olat.core.id.Identity) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 54 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method updateScorePassedOnPublish.

private void updateScorePassedOnPublish(Identity assessedIdentity, Identity coachIdentity, CheckboxManager checkboxManager, ICourse course) {
    AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
    Float currentScore = am.getNodeScore(this, assessedIdentity);
    Boolean currentPassed = am.getNodePassed(this, assessedIdentity);
    Float updatedScore = null;
    Boolean updatedPassed = null;
    ModuleConfiguration config = getModuleConfiguration();
    Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
        updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
    } else {
        updatedScore = null;
    }
    Boolean passedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
    if (passedBool != null && passedBool.booleanValue()) {
        Float cutValue = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
        Boolean sumCheckbox = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CHECKBOX);
        if (sumCheckbox != null && sumCheckbox.booleanValue()) {
            Integer minValue = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
            int checkedBox = checkboxManager.countChecked(assessedIdentity, course, getIdent());
            if (minValue != null && minValue.intValue() <= checkedBox) {
                updatedPassed = Boolean.TRUE;
            } else {
                updatedPassed = Boolean.FALSE;
            }
        } else if (cutValue != null) {
            if (updatedScore == null) {
                updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
            }
            if (updatedScore != null && cutValue.floatValue() <= updatedScore.floatValue()) {
                updatedPassed = Boolean.TRUE;
            } else {
                updatedPassed = Boolean.FALSE;
            }
        }
    } else {
        updatedPassed = null;
    }
    boolean needUpdate = false;
    Boolean manualCorrection = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_MANUAL_CORRECTION);
    if (manualCorrection == null || !manualCorrection.booleanValue()) {
        // update passed
        if ((currentPassed == null && updatedPassed != null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentPassed != null && updatedPassed == null) || (currentPassed != null && !currentPassed.equals(updatedPassed))) {
            needUpdate = true;
        }
    }
    if ((currentScore == null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentScore != null && updatedScore == null) || (currentScore != null && !currentScore.equals(updatedScore))) {
        needUpdate = true;
    }
    if (needUpdate) {
        ScoreEvaluation scoreEval = new ScoreEvaluation(updatedScore, updatedPassed);
        IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, null);
        UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
        am.saveScoreEvaluation(this, coachIdentity, assessedIdentity, scoreEval, uce, false, Role.coach);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) ModuleConfiguration(org.olat.modules.ModuleConfiguration) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 55 with ModuleConfiguration

use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.

the class CheckListCourseNode method hasScoreConfigured.

/**
 * @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured()
 */
@Override
public boolean hasScoreConfigured() {
    ModuleConfiguration config = getModuleConfiguration();
    Boolean score = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
    if (score == null)
        return false;
    return score.booleanValue();
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration)

Aggregations

ModuleConfiguration (org.olat.modules.ModuleConfiguration)296 ArrayList (java.util.ArrayList)34 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)28 ICourse (org.olat.course.ICourse)26 CourseNode (org.olat.course.nodes.CourseNode)26 Date (java.util.Date)22 RepositoryEntry (org.olat.repository.RepositoryEntry)22 File (java.io.File)20 CheckboxList (org.olat.course.nodes.cl.model.CheckboxList)18 List (java.util.List)16 Identity (org.olat.core.id.Identity)16 CheckboxManager (org.olat.course.nodes.cl.CheckboxManager)16 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)16 Translator (org.olat.core.gui.translator.Translator)14 AssessmentManager (org.olat.course.assessment.AssessmentManager)14 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)14 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)14 VFSItem (org.olat.core.util.vfs.VFSItem)12 BusinessGroup (org.olat.group.BusinessGroup)12 Checkbox (org.olat.course.nodes.cl.model.Checkbox)11