use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class AdobeConnectCleanupJob method cleanupMeetings.
/**
* @param adobe
*/
protected void cleanupMeetings(AdobeConnectProvider adobe, int daysToKeep) {
boolean success = false;
Date lowerLimit = new Date((new Date()).getTime() - (daysToKeep * 24 * 60 * 60 * 1000));
// search all virtual classrooms with the used prefix
List<String> roomIds = adobe.findClassrooms(AdobeConnectProvider.PREFIX);
for (String roomId : roomIds) {
// format is olat-courseId-nodeId, e.g. olat-82823405537032-82823405537043
// load course and node
String courseId = roomId.split("-")[1];
String nodeId = roomId.split("-")[2];
ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
CourseNode vcNode = course.getRunStructure().getNode(nodeId);
if (!(vcNode instanceof VCCourseNode)) {
logger.warn("Tried to cleanup Adobe Connect meeting for a non Adobe Connect course node: " + roomId);
continue;
}
AdobeConnectConfiguration config = (AdobeConnectConfiguration) vcNode.getModuleConfiguration().get(VCCourseNode.CONF_VC_CONFIGURATION);
if (config == null) {
// invalid configuration, do nothing and continue
continue;
}
boolean keep = false;
for (MeetingDate date : config.getMeetingDates()) {
if (keep)
continue;
Date end = date.getEnd();
keep = lowerLimit.before(end);
}
// no planned date in the future, we can delete
// build the correct roomId
String toDelete = courseId + "-" + nodeId;
if (!keep)
success = adobe.removeClassroom(toDelete, config);
if (!success) {
logger.warn("Error when cleaning up Adobe Connect meeting \"" + roomId + "\"");
continue;
}
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class DeleteUserDataTask method deleteDropboxReturnbox.
private void deleteDropboxReturnbox(Identity identity, File courseDir) {
File returnboxDir = new File(courseDir, ReturnboxController.RETURNBOX_DIR_NAME);
File dropboxDir = new File(courseDir, DropboxController.DROPBOX_DIR_NAME);
if (returnboxDir.exists() || dropboxDir.exists()) {
ICourse currentCourse = null;
File[] dropboxReturnboxDirs = new File[] { returnboxDir, dropboxDir };
for (File dropboxReturnboxDir : dropboxReturnboxDirs) {
if (!dropboxReturnboxDir.exists())
continue;
File[] nodeDirs = dropboxReturnboxDir.listFiles();
// 3. loop over all node-id e.g. 78933379704296
for (File nodeDir : nodeDirs) {
String currentNodeId = nodeDir.getName();
if (currentCourse == null) {
currentCourse = loadCourse(courseDir);
}
if (currentCourse == null) {
// corrupted course
return;
} else if (isTaskNode(currentCourse, currentNodeId)) {
deleteUserDirectory(identity, nodeDir);
} else if (isProjectBrokerNode(currentCourse, currentNodeId)) {
// additional loop over project-id
File[] projectDirs = nodeDir.listFiles();
for (File projectDir : projectDirs) {
deleteUserDirectory(identity, projectDir);
}
} else {
log.warn("found dropbox or returnbox and node-type is NO Task- or ProjectBroker-Type courseId=" + courseDir.getName() + " nodeId=" + currentNodeId, null);
}
}
}
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CollaborationTools method createCalendarController.
/**
* Creates a calendar controller
* @param ureq
* @param wControl
* @param resourceableId
* @return Configured WeeklyCalendarController
*/
public CalendarController createCalendarController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup, boolean isAdmin, boolean isMember) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
KalendarRenderWrapper calRenderWrapper = collaborationManager.getCalendar(businessGroup, ureq, isAdmin);
calRenderWrapper.setPrivateEventsVisible(isAdmin || isMember);
// add linking
List<RepositoryEntry> repoEntries = CoreSpringFactory.getImpl(BusinessGroupService.class).findRepositoryEntries(Collections.singleton(businessGroup), 0, -1);
List<ICourse> courses = new ArrayList<>(repoEntries.size());
for (RepositoryEntry repoEntry : repoEntries) {
if (repoEntry.getOlatResource().getResourceableTypeName().equals(CourseModule.getCourseTypeName())) {
ICourse course = CourseFactory.loadCourse(repoEntry);
courses.add(course);
}
}
if (!courses.isEmpty()) {
CourseLinkProviderController clp = new CourseLinkProviderController(null, courses, ureq, wControl);
calRenderWrapper.setLinkProvider(clp);
}
List<KalendarRenderWrapper> calendars = new ArrayList<>();
calendars.add(calRenderWrapper);
return new WeeklyCalendarController(ureq, wControl, calendars, WeeklyCalendarController.CALLER_COLLAB, businessGroup, false);
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class InitialAttemptsRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/initial_attempts.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = formLayout.getTranslator();
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("attempts.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.getFormItemComponent().contextPut("id", id);
ICourse course = CourseFactory.loadCourse(entry);
String currentValue = null;
String currentUnit = null;
String currentCourseNode = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentUnit = r.getRightUnit();
currentValue = r.getRightOperand();
currentCourseNode = r.getLeftOperand();
}
List<CourseNode> attemptableNodes = new ArrayList<>();
searchAttemptableNodes(course.getRunStructure().getRootNode(), attemptableNodes);
String[] nodeKeys = new String[attemptableNodes.size()];
String[] nodeValues = new String[attemptableNodes.size()];
for (int i = 0; i < attemptableNodes.size(); i++) {
CourseNode attemptableNode = attemptableNodes.get(i);
nodeKeys[i] = attemptableNode.getIdent();
nodeValues[i] = attemptableNode.getShortTitle() + " ( " + attemptableNode.getIdent() + " )";
}
courseNodeEl = uifactory.addDropdownSingleselect("coursenodes.".concat(id), null, ruleCont, nodeKeys, nodeValues, null);
courseNodeEl.setDomReplacementWrapperRequired(false);
boolean nodeSelected = false;
if (currentCourseNode != null) {
for (String nodeKey : nodeKeys) {
if (currentCourseNode.equals(nodeKey)) {
courseNodeEl.select(nodeKey, true);
nodeSelected = true;
}
}
}
if (!nodeSelected && nodeKeys.length > 0) {
courseNodeEl.select(nodeKeys[0], true);
}
if (StringHelper.containsNonWhitespace(currentCourseNode) && !nodeSelected) {
courseNodeEl.setErrorKey("error.course.node.found", null);
}
valueEl = uifactory.addTextElement("attemptvalue.".concat(id), null, 128, currentValue, ruleCont);
valueEl.setDomReplacementWrapperRequired(false);
valueEl.setDisplaySize(3);
String[] unitValues = new String[] { trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()), trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name()) };
unitEl = uifactory.addDropdownSingleselect("attemptunit.".concat(id), null, ruleCont, unitKeys, unitValues, null);
unitEl.setDomReplacementWrapperRequired(false);
boolean selected = false;
if (currentUnit != null) {
for (String unitKey : unitKeys) {
if (currentUnit.equals(unitKey)) {
unitEl.select(unitKey, true);
selected = true;
}
}
}
if (!selected) {
unitEl.select(unitKeys[1], true);
}
return ruleCont;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class CourseSite method createController.
@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
if (entry == null) {
return getAlternativeController(ureq, wControl, config);
}
MainLayoutController c;
ICourse course = CourseFactory.loadCourse(entry);
UserSession usess = ureq.getUserSession();
// course-launch-state depending course-settings
RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
boolean isAllowedToLaunch = reSecurity.canLaunch();
boolean hasAccess = false;
if (isAllowedToLaunch) {
// either check with securityCallback or use access-settings from course-nodes
if (siteSecCallback != null) {
hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
} else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
hasAccess = false;
} else {
// check within course: accessibility of course root node
CourseNode rootNode = course.getRunStructure().getRootNode();
UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
}
}
// load course (admins always see content) or alternative controller if course is not launchable
if (hasAccess || usess.getRoles().isOLATAdmin()) {
rs.incrementLaunchCounter(entry);
// build up the context path for linked course
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
}
}, false, true);
// Configure run controller
// a: don't show close link, is opened as site not tab
runCtr.setCourseCloseEnabled(false);
// b: don't show toolbar
if (!showToolController) {
runCtr.setToolControllerEnabled(false);
}
c = runCtr;
} else {
// access restricted (not in group / author) -> show controller
// defined in olat_extensions (type autoCreator)
c = getAlternativeController(ureq, wControl, config);
}
return c;
}
Aggregations