use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class FinishCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
FOCourseNode node = (FOCourseNode) runContext.get(SendMailStepForm.FORUM);
ICourse course = (ICourse) runContext.get(SendMailStepForm.ICOURSE);
CourseEnvironment courseEnv = course.getCourseEnvironment();
Forum chosenforum = node.loadOrCreateForum(courseEnv);
Message msg = (Message) runContext.get(SendMailStepForm.MESSAGE_TO_MOVE);
msg = forumManager.getMessageById(msg.getKey());
Message parentMessage = (Message) runContext.get(SendMailStepForm.PARENT_MESSAGE);
if (parentMessage != null) {
parentMessage = forumManager.getMessageById(parentMessage.getKey());
}
if (msg.getParentKey() == null && msg.getThreadtop() == null) {
msg = forumManager.createOrAppendThreadInAnotherForum(msg, chosenforum, parentMessage);
} else {
msg = forumManager.moveMessageToAnotherForum(msg, chosenforum, parentMessage);
}
// commit before sending event
DBFactory.getInstance().commit();
if ((Boolean) runContext.get(SendMailStepForm.SENDMAIL)) {
sendMail(ureq, wControl, runContext);
}
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class IQTESTCourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String repositorySoftKey = (String) getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
Long courseResourceableId = course.getResourceableId();
// 1) prepare result export
CourseEnvironment courseEnv = course.getCourseEnvironment();
try {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftKey, true);
boolean onyx = OnyxModule.isOnyxTest(re.getOlatResource());
if (onyx) {
return true;
} else if (ImsQTI21Resource.TYPE_NAME.equals(re.getOlatResource().getResourceableTypeName())) {
// 2a) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI21ResultsExportMediaResource(courseEnv, identities, this, locale).exportTestResults(exportStream);
// excel results
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(options, re, courseEntry, getIdent());
QTI21ArchiveFormat qaf = new QTI21ArchiveFormat(locale, searchParams);
qaf.exportCourseElement(exportStream);
return true;
} else {
// 2b) create export resource
List<Identity> identities = ScoreAccountingHelper.loadUsers(courseEnv, options);
new QTI12ResultsExportMediaResource(courseEnv, locale, identities, this).exportTestResults(exportStream);
// excel results
String shortTitle = getShortTitle();
QTIExportManager qem = QTIExportManager.getInstance();
QTIExportFormatter qef = new QTIExportFormatterCSVType1(locale, "\t", "\"", "\r\n", false);
if (options != null && options.getExportFormat() != null) {
Map<Class<?>, QTIExportItemFormatConfig> itemConfigs = new HashMap<>();
Class<?>[] itemTypes = new Class<?>[] { QTIExportSCQItemFormatConfig.class, QTIExportMCQItemFormatConfig.class, QTIExportKPRIMItemFormatConfig.class, QTIExportFIBItemFormatConfig.class, QTIExportEssayItemFormatConfig.class };
for (Class<?> itemClass : itemTypes) {
itemConfigs.put(itemClass, new QTIExportItemFormatDelegate(options.getExportFormat()));
}
qef.setMapWithExportItemConfigs(itemConfigs);
}
return qem.selectAndExportResults(qef, courseResourceableId, shortTitle, getIdent(), re, exportStream, locale, ".xls");
}
} catch (IOException e) {
log.error("", e);
return false;
}
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class WikiEditController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == previewLink) {
// Preview as modal dialogue only if the config is valid
RepositoryEntry re = getWikiRepoReference(moduleConfiguration, false);
if (re == null) {
// we cannot preview it, because the repository entry
// had been deleted between the time when it was
// chosen here, and now
this.showError("error.repoentrymissing");
} else {
// File cpRoot =
// FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
Identity ident = ureq.getIdentity();
boolean isOlatAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isResourceOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ident, re);
CourseEnvironment cenv = course.getCourseEnvironment();
SubscriptionContext subsContext = WikiManager.createTechnicalSubscriptionContextForCourse(cenv, wikiCourseNode);
WikiSecurityCallback callback = new WikiSecurityCallbackImpl(null, isOlatAdmin, false, false, isResourceOwner, subsContext);
wikiCtr = WikiManager.getInstance().createWikiMainController(ureq, getWindowControl(), re.getOlatResource(), callback, null);
cmcWikiCtr = new CloseableModalController(getWindowControl(), translate("command.close"), wikiCtr.getInitialComponent());
this.listenTo(cmcWikiCtr);
cmcWikiCtr.activate();
}
} else if (source == chooseButton || source == changeButton) {
searchController = new ReferencableEntriesSearchController(getWindowControl(), ureq, WikiResource.TYPE_NAME, translate("command.choose"));
this.listenTo(searchController);
cmcSearchController = new CloseableModalController(getWindowControl(), translate("close"), searchController.getInitialComponent(), true, translate("command.create"));
cmcSearchController.activate();
} else if (source == editLink) {
RepositoryEntry repositoryEntry = wikiCourseNode.getReferencedRepositoryEntry();
if (repositoryEntry == null) {
// do nothing
return;
}
String bPath = "[RepositoryEntry:" + repositoryEntry.getKey() + "][Editor:0]";
NewControllerFactory.getInstance().launch(bPath, ureq, getWindowControl());
}
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
the class DropboxController method init.
protected void init(UserRequest ureq, WindowControl wControl, boolean previewMode, boolean hasNotification) {
myContent = createVelocityContainer("dropbox");
ulButton = LinkFactory.createButton("dropbox.upload", myContent, this);
ulButton.setVisible(!userCourseEnv.isCourseReadOnly());
if (!previewMode) {
VFSContainer fDropbox = getDropBox(ureq.getIdentity());
int numFiles = fDropbox.getItems().size();
if (numFiles > 0)
myContent.contextPut("numfiles", new String[] { Integer.toString(numFiles) });
} else {
myContent.contextPut("numfiles", "0");
}
myContent.contextPut("previewMode", previewMode ? Boolean.TRUE : Boolean.FALSE);
// notification
CourseEnvironment courseEnv = userCourseEnv.getCourseEnvironment();
subsContext = DropboxFileUploadNotificationHandler.getSubscriptionContext(courseEnv, node);
if (hasNotification && !previewMode) {
// offer subscription, but not to guests
if (subsContext != null) {
String path = getDropboxPathRelToFolderRoot(courseEnv, node);
contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, path, subsContext, DropboxController.class);
myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
myContent.contextPut("hasNotification", Boolean.TRUE);
}
} else {
myContent.contextPut("hasNotification", Boolean.FALSE);
}
putInitialPanel(myContent);
}
use of org.olat.course.run.environment.CourseEnvironment in project OpenOLAT by OpenOLAT.
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;
}
Aggregations