Search in sources :

Example 26 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class NewCachePersistingAssessmentManager method saveNodeComment.

/**
 * @see org.olat.course.assessment.AssessmentManager#saveNodeComment(org.olat.course.nodes.CourseNode,
 *      org.olat.core.id.Identity, org.olat.core.id.Identity,
 *      java.lang.String)
 */
public void saveNodeComment(final CourseNode courseNode, final Identity identity, 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, COMMENT);
            if (commentProperty == null) {
                commentProperty = cpm.createCourseNodePropertyInstance(courseNode, assessedIdentity, null, COMMENT, null, null, null, comment);
                cpm.saveProperty(commentProperty);
            } else {
                commentProperty.setTextValue(comment);
                cpm.updateProperty(commentProperty);
            }
            // add to cache
            putPropertyIntoCache(assessedIdentity, commentProperty);
        }
    });
    // node log
    UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
    am.appendToUserNodeLog(courseNode, identity, assessedIdentity, COMMENT + " set to: " + comment);
    // notify about changes
    AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_USER_COMMENT_CHANGED, assessedIdentity);
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course);
    // user activity logging
    ThreadLocalUserActivityLogger.log(AssessmentLoggingAction.ASSESSMENT_USERCOMMENT_UPDATED, getClass(), LoggingResourceable.wrap(assessedIdentity), LoggingResourceable.wrapNonOlatResource(StringResourceableType.qtiUserComment, "", StringHelper.stripLineBreaks(comment)));
}
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)

Example 27 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class CustomDBController method addCustomDb.

private void addCustomDb(final String category) {
    final ICourse course = CourseFactory.loadCourse(courseKey);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(course, new SyncerExecutor() {

        @Override
        public void execute() {
            CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
            CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
            Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
            if (p == null) {
                p = cpm.createCourseNodePropertyInstance(rootNode, null, null, CustomDBMainController.CUSTOM_DB, null, null, null, category);
                cpm.saveProperty(p);
            } else {
                String currentDbs = p.getTextValue();
                p.setTextValue(currentDbs + ":" + category);
                cpm.updateProperty(p);
            }
        }
    });
}
Also used : ICourse(org.olat.course.ICourse) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) CourseNode(org.olat.course.nodes.CourseNode) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 28 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project OpenOLAT by OpenOLAT.

the class GetRecentEnrollmentDateFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    /*
		 * argument check
		 */
    if (inStack.length > 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
    } else if (inStack.length < 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
    }
    /*
		 * argument type check
		 */
    if (!(inStack[0] instanceof String))
        return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
    String nodeId = (String) inStack[0];
    /*
		 * check reference integrity
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        if (!cev.existsNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
        }
        if (!cev.isEnrollmentNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notenrollment.coursenodeid", "solution.chooseenrollment"));
        }
        // Allow self-referencing but do not allow dependencies to parents as they create cycles.
        if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
            cev.addSoftReference("courseNodeId", nodeId, false);
        }
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    /*
		 * the real function evaluation which is used during run time
		 */
    CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
    // invalid node id's return still a valid double
    // TODO fg: check with editor tree model DONE: above checks ensure correct node references
    // if (node == null) return new Double(Double.NEGATIVE_INFINITY);
    CoursePropertyManager pm = getUserCourseEnv().getCourseEnvironment().getCoursePropertyManager();
    Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
    Property recentTime = pm.findCourseNodeProperty(node, identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE);
    if (recentTime != null) {
        String firstTimeMillis = recentTime.getStringValue();
        return Double.valueOf(firstTimeMillis);
    } else {
        // what to do in case of no date available??? -> return date in the future
        return new Double(Double.POSITIVE_INFINITY);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 29 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.

the class GetInitialEnrollmentDateFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    /*
		 * argument check
		 */
    if (inStack.length > 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
    } else if (inStack.length < 1) {
        return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
    }
    /*
		 * argument type check
		 */
    if (!(inStack[0] instanceof String))
        return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
    String nodeId = (String) inStack[0];
    /*
		 * check reference integrity
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        if (!cev.existsNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
        }
        if (!cev.isEnrollmentNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notenrollment.coursenodeid", "solution.chooseenrollment"));
        }
        // Allow self-referencing but do not allow dependencies to parents as they create cycles.
        if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
            cev.addSoftReference("courseNodeId", nodeId, false);
        }
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    /*
		 * the real function evaluation which is used during run time
		 */
    CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
    // invalid node id's return still a valid double
    // TODO fg: check with editor tree model DONE: the above checks ensure only
    // valid node references
    // if (node == null) return new Double(Double.NEGATIVE_INFINITY);
    CoursePropertyManager pm = getUserCourseEnv().getCourseEnvironment().getCoursePropertyManager();
    Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
    Property firstTime = pm.findCourseNodeProperty(node, identity, null, ENCourseNode.PROPERTY_INITIAL_ENROLLMENT_DATE);
    if (firstTime != null) {
        String firstTimeMillis = firstTime.getStringValue();
        return Double.valueOf(firstTimeMillis);
    } else {
        // what to do in case of no date available??? -> return date in the future
        return new Double(Double.POSITIVE_INFINITY);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 30 with CoursePropertyManager

use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.

the class FOCourseNodeIndexer method doIndexForum.

/**
 * Index a forum in a course.
 * @param parentResourceContext
 * @param course
 * @param courseNode
 * @param indexWriter
 * @throws IOException
 */
private void doIndexForum(SearchResourceContext parentResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    if (log.isDebug())
        log.debug("Index Course Forum...");
    ForumManager fom = ForumManager.getInstance();
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Property forumKeyProperty = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
        Long forumKey = forumKeyProperty.getLongValue();
        Forum forum = fom.loadForum(forumKey);
        parentResourceContext.setDocumentType(TYPE);
        doIndexAllMessages(parentResourceContext, forum, indexWriter);
    }
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) Forum(org.olat.modules.fo.Forum)

Aggregations

CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)108 Property (org.olat.properties.Property)62 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)44 Identity (org.olat.core.id.Identity)28 File (java.io.File)18 ICourse (org.olat.course.ICourse)18 ProjectBrokerManager (org.olat.course.nodes.projectbroker.service.ProjectBrokerManager)14 CourseNode (org.olat.course.nodes.CourseNode)12 Project (org.olat.course.nodes.projectbroker.datamodel.Project)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 AssessmentChangedEvent (org.olat.course.assessment.AssessmentChangedEvent)10 UserNodeAuditManager (org.olat.course.auditing.UserNodeAuditManager)10 ProjectGroupManager (org.olat.course.nodes.projectbroker.service.ProjectGroupManager)10 BusinessGroup (org.olat.group.BusinessGroup)10 XStream (com.thoughtworks.xstream.XStream)8 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)8 TaskExecutorManager (org.olat.core.commons.services.taskexecutor.TaskExecutorManager)8 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)8 Translator (org.olat.core.gui.translator.Translator)8 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)8