Search in sources :

Example 71 with CoursePropertyManager

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

the class ForumNodeForumCallback method cleanupOnDelete.

/**
 * @see org.olat.course.nodes.GenericCourseNode#cleanupOnDelete(org.olat.course.ICourse)
 */
@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    // mark the subscription to this node as deleted
    SubscriptionContext forumSubContext = CourseModule.createTechnicalSubscriptionContext(course.getCourseEnvironment(), this);
    NotificationsManager.getInstance().delete(forumSubContext);
    // delete the forum, if there is one (is created on demand only)
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    if (forumKeyProperty != null) {
        Long forumKey = forumKeyProperty.getLongValue();
        // delete the forum
        ForumManager.getInstance().deleteForum(forumKey);
        // delete the property
        cpm.deleteProperty(forumKeyProperty);
    }
}
Also used : SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 72 with CoursePropertyManager

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

the class ForumNodeForumCallback method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
    if (forumKeyProperty == null) {
        return false;
    }
    Long forumKey = forumKeyProperty.getLongValue();
    if (ForumManager.getInstance().countThreadsByForumID(forumKey) <= 0) {
        return false;
    }
    String forumName = "forum_" + Formatter.makeStringFilesystemSave(getShortTitle()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    ForumStreamedRTFFormatter rtff = new ForumStreamedRTFFormatter(exportStream, forumName, false, locale);
    ForumArchiveManager.getInstance().applyFormatter(rtff, forumKey, null);
    return true;
}
Also used : ForumStreamedRTFFormatter(org.olat.modules.fo.archiver.formatters.ForumStreamedRTFFormatter) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager) Date(java.util.Date)

Example 73 with CoursePropertyManager

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

the class ForumNodeForumCallback method createForum.

private Forum createForum(final CourseEnvironment courseEnv) {
    final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
    // creates resourceable from FOCourseNode.class and the current node id as key
    OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(getIdent()));
    // o_clusterOK by:ld
    return CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>() {

        @Override
        public Forum execute() {
            Forum forum;
            CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
            Property forumKeyProperty = cpm.findCourseNodeProperty(FOCourseNode.this, null, null, FORUM_KEY);
            if (forumKeyProperty == null) {
                // First call of forum, create new forum and save forum key as property
                forum = fom.addAForum();
                Long forumKey = forum.getKey();
                forumKeyProperty = cpm.createCourseNodePropertyInstance(FOCourseNode.this, null, null, FORUM_KEY, null, forumKey, null, null);
                cpm.saveProperty(forumKeyProperty);
            } else {
                // Forum does already exist, load forum with key from properties
                Long forumKey = forumKeyProperty.getLongValue();
                forum = fom.loadForum(forumKey);
                if (forum == null) {
                    throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course " + courseEnv.getCourseResourceableId() + " for node " + getIdent() + " as defined in course node property but forum manager could not load forum.", null);
                }
            }
            return forum;
        }
    });
}
Also used : ForumManager(org.olat.modules.fo.manager.ForumManager) OLATResourceable(org.olat.core.id.OLATResourceable) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager) Forum(org.olat.modules.fo.Forum)

Example 74 with CoursePropertyManager

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

the class IQTESTCourseNode method cleanupOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#cleanupOnDelete(org.olat.course.ICourse)
 */
@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager();
    // 1) Delete all properties: score, passed, log, comment, coach_comment,
    // attempts
    pm.deleteNodeProperties(this, null);
    // 2) Delete all qtiresults for this node (QTI 1.2 + qtiworks)
    String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (re != null) {
        QTIResultManager.getInstance().deleteAllResults(course.getResourceableId(), getIdent(), re.getKey());
    }
    // 3) Delete all assessment test sessions (QTI 2.1)
    RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    CoreSpringFactory.getImpl(AssessmentTestSessionDAO.class).deleteAllUserTestSessionsByCourse(courseEntry, getIdent());
}
Also used : AssessmentTestSessionDAO(org.olat.ims.qti21.manager.AssessmentTestSessionDAO) RepositoryEntry(org.olat.repository.RepositoryEntry) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 75 with CoursePropertyManager

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

the class MSCourseNode method informOnDelete.

/**
 * @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
 *      org.olat.course.ICourse)
 */
@Override
public String informOnDelete(Locale locale, ICourse course) {
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    List<Property> list = cpm.listCourseNodeProperties(this, null, null, null);
    // no properties created yet
    if (list.size() == 0)
        return null;
    Translator trans = new PackageTranslator(PACKAGE_MS, locale);
    return trans.translate("warn.nodedelete");
}
Also used : PackageTranslator(org.olat.core.gui.translator.PackageTranslator) PackageTranslator(org.olat.core.gui.translator.PackageTranslator) Translator(org.olat.core.gui.translator.Translator) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

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