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