use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class QuickPublishController method doAutoPublish.
private boolean doAutoPublish() {
ICourse course = CourseFactory.loadCourse(courseOres);
CourseEditorTreeModel cetm = course.getEditorTreeModel();
PublishProcess publishProcess = PublishProcess.getInstance(course, cetm, getLocale());
PublishTreeModel publishTreeModel = publishProcess.getPublishTreeModel();
if (publishTreeModel.hasPublishableChanges()) {
List<String> nodeToPublish = new ArrayList<String>();
visitPublishModel(publishTreeModel.getRootNode(), publishTreeModel, nodeToPublish);
// only add selection if changes were possible
for (Iterator<String> selectionIt = nodeToPublish.iterator(); selectionIt.hasNext(); ) {
String ident = selectionIt.next();
TreeNode node = publishProcess.getPublishTreeModel().getNodeById(ident);
if (!publishTreeModel.isSelectable(node)) {
selectionIt.remove();
}
}
publishProcess.createPublishSetFor(nodeToPublish);
PublishSetInformations set = publishProcess.testPublishSet(getLocale());
StatusDescription[] status = set.getWarnings();
// publish not possible when there are errors
StringBuilder errMsg = new StringBuilder();
for (int i = 0; i < status.length; i++) {
if (status[i].isError()) {
errMsg.append(status[i].getLongDescription(getLocale()));
logError("Status error by publish: " + status[i].getLongDescription(getLocale()), null);
}
}
if (errMsg.length() > 0) {
getWindowControl().setWarning(errMsg.toString());
return false;
}
PublishEvents publishEvents = publishProcess.getPublishEvents();
try {
publishProcess.applyPublishSet(getIdentity(), getLocale(), false);
} catch (Exception e) {
logError("", e);
}
if (publishEvents.getPostPublishingEvents().size() > 0) {
for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, courseOres);
}
}
}
return true;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class BCWebService method getFolder.
/**
* Retrieves metadata of the course node
* @response.representation.200.qname {http://www.example.com}folderVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The course node metadatas
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_FOLDERVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or parentNode not found
* @param courseId The course resourceable's id
* @param nodeId The node's id
* @param httpRequest The HTTP request
* @return The persisted structure element (fully populated)
*/
@GET
@Path("{nodeId}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getFolder(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!CourseWebService.isCourseAccessible(course, false, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CourseNode courseNode = course.getRunStructure().getNode(nodeId);
if (courseNode == null || !(courseNode instanceof BCCourseNode)) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
UserRequest ureq = getUserRequest(httpRequest);
boolean accessible = (new CourseTreeVisitor(course, ureq.getUserSession().getIdentityEnvironment())).isAccessible(courseNode, new VisibleTreeFilter());
if (accessible) {
Set<String> subscribed = new HashSet<String>();
NotificationsManager man = NotificationsManager.getInstance();
List<String> notiTypes = Collections.singletonList("FolderModule");
List<Subscriber> subs = man.getSubscribers(ureq.getIdentity(), notiTypes);
for (Subscriber sub : subs) {
Long courseKey = sub.getPublisher().getResId();
if (courseId.equals(courseKey)) {
subscribed.add(sub.getPublisher().getSubidentifier());
}
}
FolderVO folderVo = createFolderVO(ureq.getUserSession().getIdentityEnvironment(), course, (BCCourseNode) courseNode, subscribed);
return Response.ok(folderVo).build();
} else {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class QTIArchiver method exportQTI21.
public MediaResource exportQTI21() {
ICourse course = CourseFactory.loadCourse(courseOres);
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
return new QTI21ArchiveFormat(locale, searchParams).exportCourseElement();
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class QTIArchiver method hasResults.
public boolean hasResults() {
if (results != null)
return results.booleanValue();
ICourse course = CourseFactory.loadCourse(courseOres);
RepositoryEntry testRe = courseNode.getReferencedRepositoryEntry();
boolean success = false;
if (ImsQTI21Resource.TYPE_NAME.equals(testRe.getOlatResource().getResourceableTypeName())) {
type = Type.qti21;
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
QTI21StatisticSearchParams searchParams = new QTI21StatisticSearchParams(testRe, courseEntry, courseNode.getIdent(), allUsers, anonymUsers);
success = new QTI21ArchiveFormat(locale, searchParams).hasResults();
} else {
type = Type.qti12;
success = qrm.hasResultSets(courseOres.getResourceableId(), courseNode.getIdent(), testRe.getKey());
}
results = Boolean.valueOf(success);
return success;
}
use of org.olat.course.ICourse 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;
}
Aggregations