use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class PreviewConfigHelper method getPreviewCourseEnvironment.
public static CourseEnvironment getPreviewCourseEnvironment(boolean isCoach, boolean isCourseAdmin, ICourse course) {
// generateEnvironment();
final RepositoryEntry courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
final CourseGroupManager cgm = new PreviewCourseGroupManager(courseResource, new ArrayList<BusinessGroup>(), new ArrayList<BGArea>(), isCoach, isCourseAdmin);
final UserNodeAuditManager auditman = new PreviewAuditManager();
final AssessmentManager am = new PreviewAssessmentManager();
final CoursePropertyManager cpm = new PreviewCoursePropertyManager();
final Structure runStructure = course.getEditorTreeModel().createStructureForPreview();
final String title = course.getCourseTitle();
final CourseConfig courseConfig = course.getCourseEnvironment().getCourseConfig();
CourseEnvironment previewCourseEnvironment = new PreviewCourseEnvironment(title, runStructure, new Date(), course.getCourseFolderContainer(), course.getCourseBaseContainer(), course.getResourceableId(), cpm, cgm, auditman, am, courseConfig);
return previewCourseEnvironment;
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method importCourseFromZip.
/**
* Import a course from a ZIP file.
*
* @param ores
* @param zipFile
* @return New Course.
*/
public static ICourse importCourseFromZip(OLATResource ores, File zipFile) {
// Generate course with filesystem
PersistingCourseImpl newCourse = new PersistingCourseImpl(ores);
CourseConfigManagerImpl.getInstance().deleteConfigOf(newCourse);
// Unzip course strucure in new course
File fCanonicalCourseBasePath = newCourse.getCourseBaseContainer().getBasefile();
if (ZipUtil.unzip(zipFile, fCanonicalCourseBasePath)) {
// Load course strucure now
try {
newCourse.load();
CourseConfig cc = CourseConfigManagerImpl.getInstance().loadConfigFor(newCourse);
// newCourse is not in cache yet, so we cannot call setCourseConfig()
newCourse.setCourseConfig(cc);
loadedCourses.put(newCourse.getResourceableId(), newCourse);
return newCourse;
} catch (AssertException ae) {
// ok failed, cleanup below
// better logging to search error
log.error("rollback importCourseFromZip", ae);
}
}
// cleanup if not successfull
FileUtils.deleteDirsAndFiles(fCanonicalCourseBasePath, true, true);
return null;
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method copyCourse.
/**
* Copies a course. More specifically, the run and editor structures and the
* course folder will be copied to create a new course.
*
* @param sourceRes
* @param ureq
* @return copy of the course.
*/
public static OLATResourceable copyCourse(OLATResourceable sourceRes, OLATResource targetRes) {
PersistingCourseImpl sourceCourse = (PersistingCourseImpl) loadCourse(sourceRes);
PersistingCourseImpl targetCourse = new PersistingCourseImpl(targetRes);
File fTargetCourseBasePath = targetCourse.getCourseBaseContainer().getBasefile();
// close connection before file copy
DBFactory.getInstance().commitAndCloseSession();
synchronized (sourceCourse) {
// o_clusterNOK - cannot be solved with doInSync since could take too long (leads to error: "Lock wait timeout exceeded")
// copy configuration
CourseConfig courseConf = CourseConfigManagerImpl.getInstance().copyConfigOf(sourceCourse);
targetCourse.setCourseConfig(courseConf);
// save structures
targetCourse.setRunStructure((Structure) XStreamHelper.xstreamClone(sourceCourse.getRunStructure()));
targetCourse.saveRunStructure();
targetCourse.setEditorTreeModel((CourseEditorTreeModel) XStreamHelper.xstreamClone(sourceCourse.getEditorTreeModel()));
targetCourse.saveEditorTreeModel();
// copy course folder
File fSourceCourseFolder = sourceCourse.getIsolatedCourseBaseFolder();
if (fSourceCourseFolder.exists())
FileUtils.copyDirToDir(fSourceCourseFolder, fTargetCourseBasePath, false, "copy course folder");
// copy folder nodes directories
File fSourceFoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + BCCourseNode.getFoldernodesPathRelToFolderBase(sourceCourse.getCourseEnvironment()));
if (fSourceFoldernodesFolder.exists())
FileUtils.copyDirToDir(fSourceFoldernodesFolder, fTargetCourseBasePath, false, "copy folder nodes directories");
// copy task folder directories
File fSourceTaskfoldernodesFolder = new File(FolderConfig.getCanonicalRoot() + TACourseNode.getTaskFoldersPathRelToFolderRoot(sourceCourse.getCourseEnvironment()));
if (fSourceTaskfoldernodesFolder.exists())
FileUtils.copyDirToDir(fSourceTaskfoldernodesFolder, fTargetCourseBasePath, false, "copy task folder directories");
// update references
List<Reference> refs = referenceManager.getReferences(sourceCourse);
int count = 0;
for (Reference ref : refs) {
referenceManager.addReference(targetCourse, ref.getTarget(), ref.getUserdata());
if (count % 20 == 0) {
DBFactory.getInstance().intermediateCommit();
}
}
// set quotas
Quota sourceQuota = VFSManager.isTopLevelQuotaContainer(sourceCourse.getCourseFolderContainer());
Quota targetQuota = VFSManager.isTopLevelQuotaContainer(targetCourse.getCourseFolderContainer());
if (sourceQuota != null && targetQuota != null) {
QuotaManager qm = QuotaManager.getInstance();
if (sourceQuota.getQuotaKB() != qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_COURSE).getQuotaKB()) {
targetQuota = qm.createQuota(targetQuota.getPath(), sourceQuota.getQuotaKB(), sourceQuota.getUlLimitKB());
qm.setCustomQuotaKB(targetQuota);
}
}
}
return targetRes;
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method getCustomCourseCss.
/**
* Create a custom css object for the course layout. This can then be set on a
* MainLayoutController to activate the course layout
*
* @param usess The user session
* @param courseEnvironment the course environment
* @return The custom course css or NULL if no course css is available
*/
public static CustomCSS getCustomCourseCss(UserSession usess, CourseEnvironment courseEnvironment) {
CustomCSS customCSS = null;
CourseConfig courseConfig = courseEnvironment.getCourseConfig();
if (courseConfig.hasCustomCourseCSS()) {
// Notify the current tab that it should load a custom CSS
return CourseLayoutHelper.getCustomCSS(usess, courseEnvironment);
}
return customCSS;
}
use of org.olat.course.config.CourseConfig in project OpenOLAT by OpenOLAT.
the class EfficiencyStatementManager method updateUserEfficiencyStatement.
/**
* Updates the users efficiency statement for this course
* @param userCourseEnv
* @param repoEntryKey
* @param courseOres
*/
private void updateUserEfficiencyStatement(final UserCourseEnvironment userCourseEnv, final RepositoryEntry repoEntry) {
// o_clusterOK: by ld
CourseConfig cc = userCourseEnv.getCourseEnvironment().getCourseConfig();
// write only when enabled for this course
if (cc.isEfficencyStatementEnabled()) {
Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
AssessmentNodesLastModified lastModifications = new AssessmentNodesLastModified();
List<AssessmentNodeData> assessmentNodeList = AssessmentHelper.getAssessmentNodeDataList(userCourseEnv, lastModifications, true, true, true);
updateUserEfficiencyStatement(identity, userCourseEnv.getCourseEnvironment(), assessmentNodeList, lastModifications, repoEntry);
}
}
Aggregations