use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class ProjectBrokerCourseNodeIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext repositoryResourceContext, ICourse course, CourseNode courseNode, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
SearchResourceContext courseNodeResourceContext = createSearchResourceContext(repositoryResourceContext, courseNode, TYPE);
Document nodeDocument = CourseNodeDocument.createDocument(courseNodeResourceContext, courseNode);
indexWriter.addDocument(nodeDocument);
// go further, index my projects
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
Long projectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, courseNode);
if (projectBrokerId != null) {
List<Project> projects = projectBrokerManager.getProjectListBy(projectBrokerId);
for (Project project : projects) {
Document document = ProjectBrokerProjectDocument.createDocument(courseNodeResourceContext, project);
indexWriter.addDocument(document);
}
} else {
log.debug("projectBrokerId is null, courseNode=" + courseNode + " , course=" + course);
}
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class OLATUpgrade_11_2_1 method processTaskCourseNode.
private boolean processTaskCourseNode(ICourse course, RepositoryEntry entry, TACourseNode courseNode) {
List<AssessmentEntry> assessmentEntries = getAssessmentEntries(entry, courseNode);
if (assessmentEntries.size() > 0) {
CourseEnvironment courseEnv = course.getCourseEnvironment();
CoursePropertyManager cpm = courseEnv.getCoursePropertyManager();
File dropbox = new File(FolderConfig.getCanonicalRoot(), DropboxController.getDropboxPathRelToFolderRoot(courseEnv, courseNode));
File returnBox = new File(FolderConfig.getCanonicalRoot(), ReturnboxController.getReturnboxPathRelToFolderRoot(courseEnv, courseNode));
for (AssessmentEntry assessmentEntry : assessmentEntries) {
Identity assessedIdentity = assessmentEntry.getIdentity();
boolean changed = false;
List<Property> properties = cpm.findCourseNodeProperties(courseNode, assessedIdentity, null, TaskController.PROP_ASSIGNED);
if (properties != null && properties.size() > 0) {
assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
} else {
File identityDropbox = new File(dropbox, assessedIdentity.getName());
File identityReturnBox = new File(returnBox, assessedIdentity.getName());
if (hasBoxedFiles(identityDropbox, identityReturnBox)) {
assessmentEntry.setAssessmentStatus(AssessmentEntryStatus.inProgress);
}
}
if (changed) {
courseEnv.getAssessmentManager().updateAssessmentEntry(assessmentEntry);
}
}
dbInstance.commitAndCloseSession();
}
return true;
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class CustomDBController method addCustomDb.
private void addCustomDb(final String category) {
final ICourse course = CourseFactory.loadCourse(courseKey);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(course, new SyncerExecutor() {
@Override
public void execute() {
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
if (p == null) {
p = cpm.createCourseNodePropertyInstance(rootNode, null, null, CustomDBMainController.CUSTOM_DB, null, null, null, category);
cpm.saveProperty(p);
} else {
String currentDbs = p.getTextValue();
p.setTextValue(currentDbs + ":" + category);
cpm.updateProperty(p);
}
}
});
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class CustomDBController method updateDBList.
private void updateDBList(FormItemContainer formLayout) {
ICourse course = CourseFactory.loadCourse(courseKey);
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
CourseNode rootNode = ((CourseEditorTreeNode) course.getEditorTreeModel().getRootNode()).getCourseNode();
Property p = cpm.findCourseNodeProperty(rootNode, null, null, CustomDBMainController.CUSTOM_DB);
List<String> databases = new ArrayList<>();
if (p != null && p.getTextValue() != null) {
String[] dbs = p.getTextValue().split(":");
for (String db : dbs) {
databases.add(db);
}
}
List<String> currentlyUsed = courseDbManager.getUsedCategories(course);
for (String db : currentlyUsed) {
if (!databases.contains(db)) {
databases.add(db);
}
}
int count = 0;
for (String db : databases) {
if (!StringHelper.containsNonWhitespace(db))
continue;
uifactory.addStaticExampleText("category_" + count, "customDb.category", db, formLayout);
String url = Settings.getServerContextPathURI() + RestSecurityHelper.SUB_CONTEXT + "/repo/courses/" + courseKey + "/db/" + db;
uifactory.addStaticExampleText("url_" + count, "customDb.url", url, formLayout);
final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout_" + count, getTranslator());
formLayout.add(buttonLayout);
FormLink resetDb = uifactory.addFormLink("db-reset_" + count, "customDb.reset", "customDb.reset", buttonLayout, Link.BUTTON_SMALL);
resetDb.setUserObject(db);
resetDb.setVisible(!readOnly);
resetDbs.add(resetDb);
FormLink deleteDb = uifactory.addFormLink("db-delete_" + count, "delete", "delete", buttonLayout, Link.BUTTON_SMALL);
deleteDb.setUserObject(db);
deleteDb.setVisible(!readOnly);
deleteDbs.add(deleteDb);
FormLink exportDb = uifactory.addFormLink("db-export_" + count, "customDb.export", "customDb.export", buttonLayout, Link.BUTTON_SMALL);
exportDb.setUserObject(db);
exportDbs.add(exportDb);
count++;
}
}
use of org.olat.course.properties.CoursePropertyManager in project openolat by klemens.
the class GetRecentEnrollmentDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String nodeId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(nodeId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
if (!cev.isEnrollmentNode(nodeId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notenrollment.coursenodeid", "solution.chooseenrollment"));
}
// Allow self-referencing but do not allow dependencies to parents as they create cycles.
if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
cev.addSoftReference("courseNodeId", nodeId, false);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
// invalid node id's return still a valid double
// TODO fg: check with editor tree model DONE: above checks ensure correct node references
// if (node == null) return new Double(Double.NEGATIVE_INFINITY);
CoursePropertyManager pm = getUserCourseEnv().getCourseEnvironment().getCoursePropertyManager();
Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
Property recentTime = pm.findCourseNodeProperty(node, identity, null, ENCourseNode.PROPERTY_RECENT_ENROLLMENT_DATE);
if (recentTime != null) {
String firstTimeMillis = recentTime.getStringValue();
return Double.valueOf(firstTimeMillis);
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
Aggregations