use of org.olat.course.nodes.STCourseNode in project OpenOLAT by OpenOLAT.
the class GetPassedFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String childId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
if (!cev.isAssessable(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notassessable.coursenodid", "solution.takeassessablenode"));
}
// dependencies to parents as they create cycles.
if (!childId.equals(cev.getCurrentCourseNodeId()) || cev.getNode(cev.getCurrentCourseNodeId()) instanceof STCourseNode) {
cev.addSoftReference("courseNodeId", childId, true);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
ScoreAccounting sa = getUserCourseEnv().getScoreAccounting();
Boolean passed = sa.evalPassedOfCourseNode(childId);
return (passed.booleanValue() ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE);
}
use of org.olat.course.nodes.STCourseNode in project OpenOLAT by OpenOLAT.
the class GetScoreFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String childId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
if (!cev.isAssessable(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notassessable.coursenodid", "solution.takeassessablenode"));
}
// dependencies to parents as they create cycles.
if (!childId.equals(cev.getCurrentCourseNodeId()) || cev.getNode(cev.getCurrentCourseNodeId()) instanceof STCourseNode) {
cev.addSoftReference("courseNodeId", childId, true);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
ScoreAccounting sa = getUserCourseEnv().getScoreAccounting();
Float score = sa.evalScoreOfCourseNode(childId);
return new Double(score);
}
use of org.olat.course.nodes.STCourseNode in project OpenOLAT by OpenOLAT.
the class CheckListStepRunnerCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
GeneratorData data = (GeneratorData) runContext.get("data");
List<Checkbox> templateCheckbox = data.getCheckboxList();
ModuleConfiguration templateConfig = data.getModuleConfiguration();
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
CourseEnvironment courseEnv = course.getCourseEnvironment();
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CourseNode structureNode = createCourseNode(data.getStructureShortTitle(), data.getStructureTitle(), data.getStructureObjectives(), "st");
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
course.getEditorTreeModel().addCourseNode(structureNode, parentNode.getCourseNode());
List<CheckListNode> nodes = data.getNodes();
List<String> nodesIdent = new ArrayList<>();
for (CheckListNode node : nodes) {
String title = node.getTitle();
CheckListCourseNode checkNode = (CheckListCourseNode) createCourseNode(title, title, null, "checklist");
nodesIdent.add(checkNode.getIdent());
ModuleConfiguration config = checkNode.getModuleConfiguration();
config.putAll(templateConfig);
CheckboxList checkboxList = new CheckboxList();
List<Checkbox> boxes = new ArrayList<>();
for (Checkbox templateBox : templateCheckbox) {
Checkbox checkbox = templateBox.clone();
boxes.add(checkbox);
if (StringHelper.containsNonWhitespace(templateBox.getFilename())) {
File path = new File(FolderConfig.getCanonicalTmpDir(), templateBox.getCheckboxId());
VFSContainer tmpContainer = new LocalFolderImpl(path);
VFSItem item = tmpContainer.resolve(templateBox.getFilename());
if (item instanceof VFSLeaf) {
VFSContainer container = checkboxManager.getFileContainer(courseEnv, checkNode);
VFSManager.copyContent(tmpContainer, container);
tmpContainer.deleteSilently();
}
}
}
checkboxList.setList(boxes);
config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, checkboxList);
boolean dueDate = node.getDueDate() != null;
if (dueDate) {
config.set(CheckListCourseNode.CONFIG_KEY_DUE_DATE, node.getDueDate());
}
config.set(CheckListCourseNode.CONFIG_KEY_CLOSE_AFTER_DUE_DATE, new Boolean(dueDate));
course.getEditorTreeModel().addCourseNode(checkNode, structureNode);
}
setScoreCalculation(data, (STCourseNode) structureNode, nodesIdent);
return StepsMainRunController.DONE_MODIFIED;
}
use of org.olat.course.nodes.STCourseNode in project OpenOLAT by OpenOLAT.
the class PassedRuleSPI method filter.
@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String nodeIdent = r.getLeftOperand();
String status = r.getRightOperand();
ICourse course = CourseFactory.loadCourse(entry);
CourseNode courseNode = course.getRunStructure().getNode(nodeIdent);
if (courseNode == null) {
identities.clear();
log.error("Passed rule in course " + entry.getKey() + " (" + entry.getDisplayname() + ") is missing a course element");
return;
}
Map<Long, Boolean> passeds;
if (courseNode instanceof STCourseNode) {
passeds = new HashMap<>();
STCourseNode structureNode = (STCourseNode) courseNode;
if (structureNode.hasPassedConfigured()) {
for (Identity identity : identities) {
UserCourseEnvironment uce = AssessmentHelper.createAndInitUserCourseEnvironment(identity, course);
ScoreEvaluation scoreEval = structureNode.getUserScoreEvaluation(uce);
Boolean passed = scoreEval.getPassed();
if (passed != null) {
passeds.put(identity.getKey(), passed);
}
}
}
} else {
passeds = helperDao.getPassed(entry, courseNode, identities);
}
if ("passed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed == null || !passed.booleanValue()) {
identityIt.remove();
}
}
} else if ("failed".equals(status)) {
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Boolean passed = passeds.get(identityIt.next().getKey());
if (passed != null && passed.booleanValue()) {
identityIt.remove();
}
}
}
}
}
use of org.olat.course.nodes.STCourseNode in project OpenOLAT by OpenOLAT.
the class AssessmentIdentityCourseController method hasPrevious.
private boolean hasPrevious(CourseNode courseNode) {
int index = treeOverviewCtrl.getIndexOf(courseNode);
int numOfNodes = treeOverviewCtrl.getNumberOfNodes();
if (index > 0 && index <= numOfNodes) {
for (int i = index; i-- > 0; ) {
CourseNode previousNode = treeOverviewCtrl.getNode(i);
if (previousNode instanceof AssessableCourseNode && !(previousNode instanceof STCourseNode)) {
return true;
}
}
}
return false;
}
Aggregations