use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class StatisticCourseNodesController method buildTreeModel.
private TreeModel buildTreeModel(final UserRequest ureq, final UserCourseEnvironment userCourseEnv) {
final GenericTreeModel gtm = new GenericTreeModel();
final GenericTreeNode rootTreeNode = new GenericTreeNode();
rootTreeNode.setTitle("start");
gtm.setRootNode(rootTreeNode);
ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
CourseNode courseNode = (CourseNode) node;
StatisticResourceResult result = courseNode.createStatisticNodeResult(ureq, getWindowControl(), userCourseEnv, options, types);
if (result != null) {
StatisticResourceNode courseNodeTreeNode = new StatisticResourceNode(courseNode, result);
rootTreeNode.addChild(courseNodeTreeNode);
TreeModel subTreeModel = result.getSubTreeModel();
if (subTreeModel != null) {
TreeNode subRootNode = subTreeModel.getRootNode();
List<INode> subNodes = new ArrayList<>();
for (int i = 0; i < subRootNode.getChildCount(); i++) {
subNodes.add(subRootNode.getChildAt(i));
}
for (INode subNode : subNodes) {
courseNodeTreeNode.addChild(subNode);
}
}
}
}
}, course.getRunStructure().getRootNode(), true).visitAll();
return gtm;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class StatisticResult method getIndentednodeRendererMap.
private Map<String, Object> getIndentednodeRendererMap(int row) {
if (row >= orderedNodesList_.size()) {
throw new IllegalStateException("row count too big: " + row + ", only having " + orderedNodesList_.size() + " elements");
}
CourseNode node = orderedNodesList_.get(row);
int recursionLevel = 0;
INode parent = node.getParent();
while (parent != null) {
recursionLevel++;
parent = parent.getParent();
}
// Store node data in hash map. This hash map serves as data model for
// the user assessment overview table. Leave user data empty since not used in
// this table. (use only node data)
Map<String, Object> nodeData = new HashMap<String, Object>();
// indent
nodeData.put(AssessmentHelper.KEY_INDENT, new Integer(recursionLevel));
// course node data
nodeData.put(AssessmentHelper.KEY_TYPE, node.getType());
nodeData.put(AssessmentHelper.KEY_TITLE_SHORT, node.getShortTitle());
nodeData.put(AssessmentHelper.KEY_TITLE_LONG, node.getLongTitle());
nodeData.put(AssessmentHelper.KEY_IDENTIFYER, node.getIdent());
// plus the node
nodeData.put(StatisticResult.KEY_NODE, node);
return nodeData;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class StatisticResult method doAddQueryListResultsForNodeAndChildren.
private void doAddQueryListResultsForNodeAndChildren(CourseNode node, List<Object[]> result, Set<String> groupByKeys) {
orderedNodesList_.add(node);
for (Iterator<?> it = result.iterator(); it.hasNext(); ) {
Object[] columns = (Object[]) it.next();
if (columns.length != 3) {
throw new IllegalStateException("result should be three columns wide");
}
String businessPath = (String) columns[0];
if (!businessPath.matches("\\[RepositoryEntry:.*\\]\\[CourseNode:" + node.getIdent() + "\\]")) {
continue;
}
String groupByKey = String.valueOf(columns[1]);
groupByKeys.add(groupByKey);
int count = (Integer) columns[2];
Map<String, Integer> nodeMap = statistic_.get(node);
if (nodeMap == null) {
nodeMap = new HashMap<String, Integer>();
statistic_.put(node, nodeMap);
}
Integer existingCount = nodeMap.get(groupByKey);
if (existingCount == null) {
nodeMap.put(groupByKey, count);
} else {
nodeMap.put(groupByKey, existingCount + count);
}
it.remove();
}
int childCount = node.getChildCount();
for (int i = 0; i < childCount; i++) {
INode n = node.getChildAt(i);
if (n instanceof CourseNode) {
doAddQueryListResultsForNodeAndChildren((CourseNode) n, result, groupByKeys);
}
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class QTIEditorMainController method createReferenceesMsg.
/**
* helper method to create the message about qti resource stakeholders and
* from where the qti resource is referenced.
*
* @return
*/
private String createReferenceesMsg(UserRequest ureq) {
/*
* problems: A tries to reference this test, after test editor has been
* started
*/
changeEmail = new ContactMessage(ureq.getIdentity());
// the owners of this qtiPkg
RepositoryEntry myEntry = repositoryManager.lookupRepositoryEntry(qtiPackage.getRepresentingResourceable(), false);
// add qti resource owners as group
ContactList cl = new ContactList("qtiPkgOwners");
cl.addAllIdentites(repositoryService.getMembers(myEntry, GroupRoles.owner.name()));
changeEmail.addEmailTo(cl);
StringBuilder result = new StringBuilder();
result.append(translate("qti.restricted.leading"));
for (Iterator<Reference> iter = referencees.iterator(); iter.hasNext(); ) {
Reference element = iter.next();
if ("CourseModule".equals(element.getSource().getResourceableTypeName())) {
ICourse course = null;
try {
course = CourseFactory.loadCourse(element.getSource().getResourceableId());
if (course == null) {
continue;
}
} catch (CorruptedCourseException ex) {
logError("", ex);
continue;
}
CourseNode cn = course.getEditorTreeModel().getCourseNode(element.getUserdata());
if (cn == null) {
logError("Cannot find course element " + element.getUserdata() + " in course " + course, null);
continue;
}
String courseTitle = course.getCourseTitle();
StringBuilder stakeHolders = new StringBuilder();
// the course owners
RepositoryEntry entry = repositoryManager.lookupRepositoryEntry(course, false);
if (entry != null) {
// OO-1300
List<Identity> stakeHoldersIds = repositoryService.getMembers(entry, GroupRoles.owner.name());
if (stakeHoldersIds != null && stakeHoldersIds.size() > 0) {
// add stakeholders as group
cl = new ContactList(courseTitle);
cl.addAllIdentites(stakeHoldersIds);
changeEmail.addEmailTo(cl);
for (Identity stakeHoldersId : stakeHoldersIds) {
if (stakeHolders.length() > 0)
stakeHolders.append(", ");
User user = stakeHoldersId.getUser();
stakeHolders.append(user.getProperty(UserConstants.FIRSTNAME, getLocale())).append(" ").append(user.getProperty(UserConstants.LASTNAME, getLocale()));
}
}
}
String courseNodeTitle = cn.getShortTitle();
result.append(translate("qti.restricted.course", StringHelper.escapeHtml(courseTitle)));
result.append(translate("qti.restricted.node", StringHelper.escapeHtml(courseNodeTitle)));
result.append(translate("qti.restricted.owners", stakeHolders.toString()));
}
}
return result.toString();
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class EPFrontendManager method submitMap.
private void submitMap(PortfolioStructureMap map, boolean logActivity, Role by) {
// add an exception
if (!(map instanceof EPStructuredMap))
return;
EPStructuredMap submittedMap = (EPStructuredMap) map;
structureManager.submitMap(submittedMap);
EPTargetResource resource = submittedMap.getTargetResource();
OLATResourceable courseOres = resource.getOLATResourceable();
ICourse course = CourseFactory.loadCourse(courseOres);
AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
CourseNode courseNode = course.getRunStructure().getNode(resource.getSubPath());
List<Identity> owners = policyManager.getOwners(submittedMap);
for (Identity owner : owners) {
if (courseNode != null) {
// courseNode might have been deleted meanwhile
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(owner);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (logActivity) {
am.incrementNodeAttempts(courseNode, owner, uce, by);
} else {
am.incrementNodeAttemptsInBackground(courseNode, owner, uce);
}
RepositoryEntry referenceEntry = courseNode.getReferencedRepositoryEntry();
RepositoryEntry courseEntry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
assessmentService.updateAssessmentEntry(owner, courseEntry, courseNode.getIdent(), referenceEntry, AssessmentEntryStatus.inReview);
}
assessmentNotificationsHandler.markPublisherNews(owner, course.getResourceableId());
log.audit("Map " + map + " from " + owner.getName() + " has been submitted.");
}
}
Aggregations