Search in sources :

Example 56 with CoursePropertyManager

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

the class DENCourseNode method cleanupOnDelete.

@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
    cpm.deleteNodeProperties(this, CONF_CANCEL_ENROLL_ENABLED);
    DENManager denManager = DENManager.getInstance();
    // empty List as first argument, so all dates for this course node are going to delete
    denManager.persistDENSettings(new ArrayList<KalendarEvent>(), course, this);
}
Also used : DENManager(de.bps.course.nodes.den.DENManager) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 57 with CoursePropertyManager

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

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 58 with CoursePropertyManager

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

the class PreviewConfigController method generateEnvironment.

private void generateEnvironment() {
    List<BGArea> tmpAreas = areaManager.loadAreas(psf.getAreaKeys());
    List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(psf.getGroupKeys());
    // get learning areas for groups
    Set<BGArea> areas = new HashSet<BGArea>();
    areas.addAll(tmpAreas);
    List<BGArea> areaByGroups = areaManager.findBGAreasOfBusinessGroups(groups);
    areas.addAll(areaByGroups);
    role = psf.getRole();
    ICourse course = CourseFactory.loadCourse(ores);
    // default is student
    isGlobalAuthor = false;
    isGuestOnly = false;
    isCoach = false;
    isCourseAdmin = false;
    /*
		 * if (role.equals(PreviewSettingsForm.ROLE_STUDENT)) { } else
		 */
    if (role.equals(PreviewSettingsForm.ROLE_GUEST)) {
        isGuestOnly = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSECOACH)) {
        isCoach = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_COURSEADMIN)) {
        isCourseAdmin = true;
    } else if (role.equals(PreviewSettingsForm.ROLE_GLOBALAUTHOR)) {
        isGlobalAuthor = true;
    }
    final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(groups), new ArrayList<BGArea>(areas), isCoach, isCourseAdmin);
    final UserNodeAuditManager auditman = new PreviewAuditManager();
    final AssessmentManager am = new PreviewAssessmentManager();
    final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
    final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
    final String title = course.getCourseTitle();
    final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
    simCourseEnv = new PreviewCourseEnvironment(title, runStructure, psf.getDate(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
    simIdentEnv = new IdentityEnvironment();
    simIdentEnv.setRoles(new Roles(false, false, false, isGlobalAuthor, isGuestOnly, false, false));
    final Identity ident = new PreviewIdentity();
    simIdentEnv.setIdentity(ident);
    // identity must be set before attributes OLAT-4811
    simIdentEnv.setAttributes(psf.getAttributesMap());
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseConfig(org.olat.course.config.CourseConfig) BGArea(org.olat.group.area.BGArea) Structure(org.olat.course.Structure) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) HashSet(java.util.HashSet) BusinessGroup(org.olat.group.BusinessGroup) Roles(org.olat.core.id.Roles) UserNodeAuditManager(org.olat.course.auditing.UserNodeAuditManager) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 59 with CoursePropertyManager

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

the class ForumCourseNodeWebService method addMessage.

/**
 * Internal helper method to add a message to a forum.
 * @param courseId
 * @param nodeId
 * @param parentMessageId can be null (will lead to new thread)
 * @param title
 * @param body
 * @param identityName
 * @param isSticky only necessary when adding new thread
 * @param request
 * @return
 */
private Response addMessage(Long courseId, String nodeId, Long parentMessageId, String title, String body, String identityName, Boolean isSticky, HttpServletRequest request) {
    if (!isAuthor(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BaseSecurity securityManager = BaseSecurityManager.getInstance();
    Identity identity;
    if (identityName != null) {
        identity = securityManager.findIdentityByName(identityName);
    } else {
        identity = RestSecurityHelper.getIdentity(request);
    }
    if (identity == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    // load forum
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    } else if (!isAuthorEditor(course, request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    CourseNode courseNode = getParentNode(course, nodeId);
    if (courseNode == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    Property forumKeyProp = cpm.findCourseNodeProperty(courseNode, null, null, FOCourseNode.FORUM_KEY);
    Forum forum = null;
    ForumManager fom = ForumManager.getInstance();
    if (forumKeyProp != null) {
        // Forum does already exist, load forum with key from properties
        Long forumKey = forumKeyProp.getLongValue();
        forum = fom.loadForum(forumKey);
    }
    if (forum == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    MessageVO vo;
    if (parentMessageId == null || parentMessageId == 0L) {
        // creating the thread (a message without a parent message)
        Message newThread = fom.createMessage(forum, identity, false);
        if (isSticky != null && isSticky.booleanValue()) {
            // set sticky
            org.olat.modules.fo.Status status = new org.olat.modules.fo.Status();
            status.setSticky(true);
            newThread.setStatusCode(org.olat.modules.fo.Status.getStatusCode(status));
        }
        newThread.setTitle(title);
        newThread.setBody(body);
        // open a new thread
        fom.addTopMessage(newThread);
        vo = new MessageVO(newThread);
    } else {
        // adding response message (a message with a parent message)
        Message threadMessage = fom.loadMessage(parentMessageId);
        if (threadMessage == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        // create new message
        Message message = fom.createMessage(forum, identity, false);
        message.setTitle(title);
        message.setBody(body);
        fom.replyToMessage(message, threadMessage);
        vo = new MessageVO(message);
    }
    return Response.ok(vo).build();
}
Also used : Status(javax.ws.rs.core.Response.Status) Message(org.olat.modules.fo.Message) ICourse(org.olat.course.ICourse) BaseSecurity(org.olat.basesecurity.BaseSecurity) Forum(org.olat.modules.fo.Forum) ForumManager(org.olat.modules.fo.manager.ForumManager) FOCourseNode(org.olat.course.nodes.FOCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 60 with CoursePropertyManager

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

the class ChecklistCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    if (getChecklistKey(cpm) != null)
        deleteChecklistKeyConf(cpm);
    File importFile = new File(importDirectory, getExportFilename());
    String importContent = FileUtils.load(importFile, WebappHelper.getDefaultCharset());
    if (importContent == null || importContent.isEmpty()) {
        return;
    }
    XStream xstream = XStreamHelper.createXStreamInstance();
    Checklist checklist = (Checklist) xstream.fromXML(importContent);
    if (checklist != null) {
        checklist = ChecklistManager.getInstance().copyChecklist(checklist);
        setChecklistKey(cpm, checklist.getKey());
    }
}
Also used : XStream(com.thoughtworks.xstream.XStream) Checklist(de.bps.olat.modules.cl.Checklist) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

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