use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class ForumNodeForumCallback method createForum.
private Forum createForum(final CourseEnvironment courseEnv) {
final ForumManager fom = CoreSpringFactory.getImpl(ForumManager.class);
// creates resourceable from FOCourseNode.class and the current node id as key
OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(getIdent()));
// o_clusterOK by:ld
return CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>() {
@Override
public Forum execute() {
Forum forum;
CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
Property forumKeyProperty = cpm.findCourseNodeProperty(FOCourseNode.this, null, null, FORUM_KEY);
if (forumKeyProperty == null) {
// First call of forum, create new forum and save forum key as property
forum = fom.addAForum();
Long forumKey = forum.getKey();
forumKeyProperty = cpm.createCourseNodePropertyInstance(FOCourseNode.this, null, null, FORUM_KEY, null, forumKey, null, null);
cpm.saveProperty(forumKeyProperty);
} else {
// Forum does already exist, load forum with key from properties
Long forumKey = forumKeyProperty.getLongValue();
forum = fom.loadForum(forumKey);
if (forum == null) {
throw new OLATRuntimeException(FOCourseNode.class, "Tried to load forum with key " + forumKey.longValue() + " in course " + courseEnv.getCourseResourceableId() + " for node " + getIdent() + " as defined in course node property but forum manager could not load forum.", null);
}
}
return forum;
}
});
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class ForumNodeForumCallback method informOnDelete.
/**
* @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
* org.olat.course.ICourse)
*/
@Override
public String informOnDelete(Locale locale, ICourse course) {
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
Property forumKeyProperty = cpm.findCourseNodeProperty(this, null, null, FORUM_KEY);
// no forum created yet
if (forumKeyProperty == null)
return null;
return new PackageTranslator(PACKAGE_FO, locale).translate("warn.forumdelete");
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class TACourseNode method informOnDelete.
/**
* @see org.olat.course.nodes.CourseNode#informOnDelete(org.olat.core.gui.UserRequest,
* org.olat.course.ICourse)
*/
@Override
public String informOnDelete(Locale locale, ICourse course) {
Translator trans = new PackageTranslator(PACKAGE_TA, locale);
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
List<Property> list = cpm.listCourseNodeProperties(this, null, null, null);
// properties exist
if (list.size() != 0)
return trans.translate("warn.nodedelete");
File fTaskFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFolderPathRelToFolderRoot(course, this));
// task folder contains files
if (fTaskFolder.exists() && fTaskFolder.list().length > 0)
return trans.translate(NLS_WARN_NODEDELETE);
// no data yet.
return null;
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class TACourseNode method getDetailsListView.
/**
* @see org.olat.course.nodes.AssessableCourseNode#getDetailsListView(org.olat.course.run.userview.UserCourseEnvironment)
*/
@Override
public String getDetailsListView(UserCourseEnvironment userCourseEnvironment) {
Identity identity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
CoursePropertyManager propMgr = userCourseEnvironment.getCourseEnvironment().getCoursePropertyManager();
List<Property> samples = propMgr.findCourseNodeProperties(this, identity, null, TaskController.PROP_ASSIGNED);
// no sample assigned yet
if (samples.size() == 0)
return null;
return samples.get(0).getStringValue();
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class LTIRunController method storeDataExchangeAcceptance.
/**
* Helper to save the user accepted data exchange
*/
private void storeDataExchangeAcceptance() {
CoursePropertyManager propMgr = this.userCourseEnv.getCourseEnvironment().getCoursePropertyManager();
String hash = createHashFromExchangeDataProperties();
Property prop = propMgr.createCourseNodePropertyInstance(this.courseNode, getIdentity(), null, PROP_NAME_DATA_EXCHANGE_ACCEPTED, null, null, hash, null);
propMgr.saveProperty(prop);
}
Aggregations