Search in sources :

Example 51 with CoursePropertyManager

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

the class StatusManager method saveStatusFormData.

public void saveStatusFormData(StatusForm statusForm, CourseNode node, UserCourseEnvironment userCourseEnv) {
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    String selectedKey = statusForm.getSelectedStatus();
    CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    Property statusProperty;
    statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
    if (statusProperty == null) {
        statusProperty = cpm.createCourseNodePropertyInstance(node, identity, null, PROPERTY_KEY_STATUS, null, null, selectedKey, null);
        cpm.saveProperty(statusProperty);
    } else {
        statusProperty.setStringValue(selectedKey);
        cpm.updateProperty(statusProperty);
    }
}
Also used : Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 52 with CoursePropertyManager

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

the class StatusManager method loadStatusFormData.

/**
 * Initializes the user profile with the data from the database
 *
 * @param ident The current Subject
 */
public void loadStatusFormData(StatusForm statusForm, CourseNode node, UserCourseEnvironment userCourseEnv) {
    Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
    CoursePropertyManager cpm = userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
    Property statusProperty;
    statusProperty = cpm.findCourseNodeProperty(node, identity, null, PROPERTY_KEY_STATUS);
    if (statusProperty == null) {
        // found no status property => init DEFAULT value
        statusForm.setSelectedStatus(StatusForm.STATUS_VALUE_INITIAL);
    } else {
        String value = statusProperty.getStringValue();
        statusForm.setSelectedStatus(value);
    }
}
Also used : Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 53 with CoursePropertyManager

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

the class TaskController method setAssignedTask.

private void setAssignedTask(Identity identity, String task) {
    CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
    Property p = cpm.createCourseNodePropertyInstance(node, identity, null, PROP_ASSIGNED, null, null, task, null);
    cpm.saveProperty(p);
    AssessmentEvaluation eval = node.getUserScoreEvaluation(userCourseEnv);
    if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
        eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
        node.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.user);
    }
}
Also used : AssessmentEvaluation(org.olat.course.run.scoring.AssessmentEvaluation) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 54 with CoursePropertyManager

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

the class TaskController method removeAssignedTask.

/**
 * Cancel the task assignment.
 * @param identity
 * @param task
 */
private void removeAssignedTask(Identity identity) {
    CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
    // remove assigned
    List<Property> properties = cpm.findCourseNodeProperties(node, identity, null, PROP_ASSIGNED);
    if (properties != null && properties.size() > 0) {
        Property propety = properties.get(0);
        cpm.deleteProperty(propety);
        assignedTask = null;
    }
    // removed sampled
    properties = courseEnv.getCoursePropertyManager().findCourseNodeProperties(node, null, null, PROP_SAMPLED);
    if (properties != null && properties.size() > 0) {
        Property propety = properties.get(0);
        cpm.deleteProperty(propety);
    }
}
Also used : Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 55 with CoursePropertyManager

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

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