Search in sources :

Example 36 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_10_4_0 method migrateCalendarConfigurations.

private boolean migrateCalendarConfigurations(UpgradeManager upgradeManager, UpgradeHistoryData uhd) {
    if (!uhd.getBooleanDataValue(CALENDAR_USER_CONFIGS)) {
        int counter = 0;
        List<Property> properties;
        do {
            properties = getUserGUIProperties(counter, BATCH_SIZE);
            for (Property property : properties) {
                processCalendarGUIProperty(property);
                if (counter % 20 == 0) {
                    dbInstance.commit();
                }
            }
            counter += properties.size();
            log.audit("Calendar GUI properties processed: " + properties.size() + ", total processed (" + counter + ")");
            dbInstance.commitAndCloseSession();
        } while (properties.size() == BATCH_SIZE);
        uhd.setBooleanDataValue(CALENDAR_USER_CONFIGS, true);
        upgradeManager.setUpgradesHistory(uhd, VERSION);
    }
    return true;
}
Also used : Property(org.olat.properties.Property)

Example 37 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_11_2_1 method processTaskCourseNode.

private boolean processTaskCourseNode(ICourse course, RepositoryEntry entry, TACourseNode courseNode) {
    List<AssessmentEntry> assessmentEntries = getAssessmentEntries(entry, courseNode);
    if (assessmentEntries.size() > 0) {
        CourseEnvironment courseEnv = course.getCourseEnvironment();
        CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
        File dropbox = new File(FolderConfig.getCanonicalRoot(), DropboxController.getDropboxPathRelToFolderRoot(courseEnv, courseNode));
        File returnBox = new File(FolderConfig.getCanonicalRoot(), ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, courseNode));
        for (AssessmentEntry assessmentEntry : assessmentEntries) {
            Identity assessedIdentity = assessmentEntry.getIdentity();
            boolean changed = false;
            List<Property> properties = cpm.findCourseNodeProperties(courseNode, assessedIdentity, null, TaskController.PROP_ASSIGNED);
            if (properties != null && properties.size() > 0) {
                assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
            } else {
                File identityDropbox = new File(dropbox, assessedIdentity.getName());
                File identityReturnBox = new File(returnBox, assessedIdentity.getName());
                if (hasBoxedFiles(identityDropbox, identityReturnBox)) {
                    assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
                }
            }
            if (changed) {
                courseEnv.getAssessmentManager().updateAssessmentEntry(assessmentEntry);
            }
        }
        dbInstance.commitAndCloseSession();
    }
    return true;
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) Identity(org.olat.core.id.Identity) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 38 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method getOrLoadScorePassedAttemptsMap.

/**
 * retrieves the Map which contains all data for this course and the given user.
 * if the cache evicted the map in the meantime, then it is recreated
 * by querying the database and fetching all that data in one query, and then reput into the cache.
 * <br>
 * this method is threadsafe.
 *
 * @param identity the identity
 * @param notify if true, then the
 * @return a Map containing nodeident+"_"+ e.g. PASSED as key, Boolean (for PASSED), Float (for SCORE), or Integer (for ATTEMPTS) as values
 */
private Map<String, Serializable> getOrLoadScorePassedAttemptsMap(Identity identity, List<Property> properties, boolean prepareForNewData) {
    // a user is only active on one node at the same time.
    NewCacheKey cacheKey = new NewCacheKey(ores.getResourceableId(), identity.getKey());
    HashMap<String, Serializable> m = courseCache.get(cacheKey);
    if (m == null) {
        // cache entry (=all data of the given identity in this course) has expired or has never been stored yet into the cache.
        // or has been invalidated (in cluster mode when puts occurred from an other node for the same cache)
        m = new HashMap<String, Serializable>();
        // load data
        List<Property> loadedProperties = properties == null ? loadPropertiesFor(Collections.singletonList(identity)) : properties;
        for (Property property : loadedProperties) {
            addPropertyToCache(m, property);
        }
        // If property not found, prefill with default value.
        if (!m.containsKey(ATTEMPTS)) {
            m.put(ATTEMPTS, INTEGER_ZERO);
        }
        if (!m.containsKey(SCORE)) {
            m.put(SCORE, FLOAT_ZERO);
        }
        if (!m.containsKey(LAST_MODIFIED)) {
            m.put(LAST_MODIFIED, null);
        }
        // we did not generate new data, but simply asked to reload it.
        if (prepareForNewData) {
            courseCache.update(cacheKey, m);
        } else {
            courseCache.put(cacheKey, m);
        }
    } else {
        // still in cache.
        if (prepareForNewData) {
            // but we need to notify that data has changed: we reput the data into the cache - a little hacky yes
            courseCache.update(cacheKey, m);
        }
    }
    return m;
}
Also used : Serializable(java.io.Serializable) Property(org.olat.properties.Property)

Example 39 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveNodeCoachComment.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeCoachComment(org.olat.course.nodes.CourseNode,
 *      org.olat.core.id.Identity, java.lang.String)
 */
public void saveNodeCoachComment(final CourseNode courseNode, final Identity assessedIdentity, final String comment) {
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {

        public void execute() {
            Property commentProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, COACH_COMMENT);
            if (commentProperty == null) {
                commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COACH_COMMENT, null, null, null, comment);
                cpm.saveProperty(commentProperty);
            } else {
                commentProperty.setTextValue(comment);
                cpm.updateProperty(commentProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, commentProperty);
        }
    });
    // olat::: no node log here? (because what we did above is a node log with custom text AND by a coach)?
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_COACH_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_COACHCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiCoachComment, "", StringHelper.stripLineBreaks(comment)));
}
Also used : AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 40 with Property

use of org.olat.properties.Property in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveNodeAttempts.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeAttempts(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.core.id.Identity,
 *      java.lang.Integer)
 */
public void saveNodeAttempts(final CourseNode courseNode, final Identity identity, final Identity assessedIdentity, final Integer attempts) {
    // A note on updating the EfficiencyStatement:
    // In the equivalent method incrementNodeAttempts() in this class, the following code is executed:
    // // Update users efficiency statement
    // EfficiencyStatementManager esm =	EfficiencyStatementManager.getInstance();
    // esm.updateUserEfficiencyStatement(userCourseEnv);
    // One would expect that saveNodeAttempts would also have to update the EfficiencyStatement - or
    // the caller of this method would have to make sure that this happens in the same transaction.
    // While this is not explicitly so, implicitly it is: currently the only user this method is
    // the AssessmentEditController - which as the 2nd last method calls into saveScoreEvaluation
    // - which in turn does update the EfficiencyStatement - at which point we're happy and everything works fine.
    // But it seems like this mechanism is a bit unobvious and might well be worth some refactoring...
    ICourse course = CourseFactory.loadCourse(ores);
    final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerExecutor() {

        public void execute() {
            Property attemptsProperty = cpm.findCourseNodeProperty(courseNode, assessedIdentity, null, ATTEMPTS);
            if (attemptsProperty == null) {
                attemptsProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, ATTEMPTS, null, new Long(attempts.intValue()), null, null);
                cpm.saveProperty(attemptsProperty);
            } else {
                attemptsProperty.setLongValue(new Long(attempts.intValue()));
                cpm.updateProperty(attemptsProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, attemptsProperty);
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, ATTEMPTS + " set to: " + String.valueOf(attempts));
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_ATTEMPTS_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_ATTEMPTS_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiAttempts, "", String.valueOf(attempts)));
}
Also used : UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) AssessmentChangedEvent(org.olat.course.assessment.AssessmentChangedEvent) ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

Property (org.olat.properties.Property)270 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)62 PropertyManager (org.olat.properties.PropertyManager)48 Identity (org.olat.core.id.Identity)36 NarrowedPropertyManager (org.olat.properties.NarrowedPropertyManager)36 ArrayList (java.util.ArrayList)24 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)22 BusinessGroup (org.olat.group.BusinessGroup)18 File (java.io.File)16 ICourse (org.olat.course.ICourse)16 Translator (org.olat.core.gui.translator.Translator)14 AssertException (org.olat.core.logging.AssertException)14 CourseNode (org.olat.course.nodes.CourseNode)14 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)14 Test (org.junit.Test)12 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)12 XStream (com.thoughtworks.xstream.XStream)10 HashMap (java.util.HashMap)10 List (java.util.List)10