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;
}
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);
}
}
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);
}
}
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);
}
}
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;
}
}
Aggregations