Search in sources :

Example 1 with Property

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

the class TaskFolderCallback method removeAssignedTask.

/**
 * Cancel the task assignment for this task and all Identities.
 * @param course
 * @param task
 * @return Returns the Identities list that have had this task assigned.
 */
private List<Identity> removeAssignedTask(ICourse course, String task) {
    // identities to be notified
    List<Identity> identityList = new ArrayList<Identity>();
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    List<Property> properties = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
    if (properties != null && properties.size() > 0) {
        for (Object propetyObj : properties) {
            Property propety = (Property) propetyObj;
            identityList.add(propety.getIdentity());
            cpm.deleteProperty(propety);
        }
    }
    return identityList;
}
Also used : ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 2 with Property

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

the class ConvertToGTACourseNode method convertAssessmentDatas.

private void convertAssessmentDatas(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    CoursePropertyManager propertyMgr = courseEnv.getCoursePropertyManager();
    Map<Long, AssessmentEntry> datas = new HashMap<>();
    List<AssessmentEntry> properties = courseEnv.getAssessmentManager().getAssessmentEntries(sourceNode);
    for (AssessmentEntry property : properties) {
        Identity identity = property.getIdentity();
        datas.put(identity.getKey(), property);
    }
    properties = null;
    DBFactory.getInstance().getCurrentEntityManager().clear();
    AssessmentManager assessmentMgr = courseEnv.getAssessmentManager();
    for (AssessmentEntry assessmentData : datas.values()) {
        Identity assessedIdentity = securityManager.loadIdentityByKey(assessmentData.getIdentity().getKey());
        if (assessmentData.getPassed() != null || assessmentData.getScore() != null) {
            UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
            Float score = assessmentData.getScore() == null ? null : assessmentData.getScore().floatValue();
            ScoreEvaluation scoreEval = new ScoreEvaluation(score, assessmentData.getPassed());
            assessmentMgr.saveScoreEvaluation(gtaNode, null, assessedIdentity, scoreEval, userCourseEnv, false, Role.auto);
            // set graded
            Task task = gtaManager.getTask(assessedIdentity, taskList);
            if (task == null) {
                gtaManager.createTask(null, taskList, TaskProcess.graded, null, assessedIdentity, gtaNode);
            } else {
                gtaManager.updateTask(task, TaskProcess.graded, gtaNode, Role.auto);
            }
        }
        if (assessmentData.getAttempts() != null) {
            assessmentMgr.saveNodeAttempts(gtaNode, null, assessedIdentity, assessmentData.getAttempts().intValue(), Role.auto);
        }
        if (StringHelper.containsNonWhitespace(assessmentData.getCoachComment())) {
            assessmentMgr.saveNodeCoachComment(gtaNode, assessedIdentity, assessmentData.getCoachComment());
        }
        if (StringHelper.containsNonWhitespace(assessmentData.getComment())) {
            assessmentMgr.saveNodeComment(gtaNode, null, assessedIdentity, assessmentData.getComment());
        }
    }
    DBFactory.getInstance().getCurrentEntityManager().clear();
    // copy log entries
    List<Property> logEntries = propertyMgr.listCourseNodeProperties(sourceNode, null, null, UserNodeAuditManager.LOG_IDENTIFYER);
    for (Property logEntry : logEntries) {
        String logText = logEntry.getTextValue();
        Identity identity = securityManager.loadIdentityByKey(logEntry.getIdentity().getKey());
        Property targetProp = propertyMgr.findCourseNodeProperty(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER);
        if (targetProp == null) {
            targetProp = propertyMgr.createCourseNodePropertyInstance(gtaNode, identity, null, UserNodeAuditManager.LOG_IDENTIFYER, null, null, null, logText);
        } else {
            targetProp.setTextValue(logText);
        }
        propertyMgr.saveProperty(targetProp);
    }
}
Also used : ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) Task(org.olat.course.nodes.gta.Task) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) HashMap(java.util.HashMap) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) AssessmentManager(org.olat.course.assessment.AssessmentManager) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Example 3 with Property

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

the class ReturnboxFullAccessCallback method removeAssignedTask.

/**
 * Cancel the task assignment.
 * @param identity
 * @param task
 */
private void removeAssignedTask(UserCourseEnvironment courseEnv, Identity identity) {
    CoursePropertyManager cpm = courseEnv.getCourseEnvironment().getCoursePropertyManager();
    List<Property> properties = cpm.findCourseNodeProperties(node, identity, null, TaskController.PROP_ASSIGNED);
    if (properties != null && properties.size() > 0) {
        Property propety = properties.get(0);
        cpm.deleteProperty(propety);
        assignedTask = null;
    }
    // removed sampled
    properties = cpm.findCourseNodeProperties(node, null, null, TaskController.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 4 with Property

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

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 5 with Property

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

the class PersistingCoursePropertyManager method getAnonymizedUserName.

/**
 * @see org.olat.ims.qti.export.helper.IdentityAnonymizerCallback#getAnonymizedUserName(org.olat.core.id.Identity)
 */
public String getAnonymizedUserName(Identity identity) {
    synchronized (anonymizerMap) {
        String anonymizedName = anonymizerMap.get(identity.getName());
        if (anonymizedName == null) {
            // try to fetch from course properties
            Property anonymizedProperty = pm.findProperty(identity, null, "Anonymizing", "AnonymizedUserName");
            if (anonymizedProperty == null) {
                // not found - create a new anonymized name
                anonymizedName = "RANDOM-" + random.nextInt(100000000);
                // add as course properties
                anonymizedProperty = pm.createPropertyInstance(identity, null, "Anonymizing", "AnonymizedUserName", null, null, anonymizedName, null);
                pm.saveProperty(anonymizedProperty);
            } else {
                // property found - use property value from there
                anonymizedName = anonymizedProperty.getStringValue();
            }
            anonymizerMap.put(identity.getName(), anonymizedName);
        }
        return anonymizedName;
    }
}
Also used : Property(org.olat.properties.Property)

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