use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class ConditionConfigEasyController method addAssessmentSwitch.
private void addAssessmentSwitch(FormItemContainer formLayout) {
assessSubContainer = FormLayoutContainer.createDefaultFormLayout("assessSubContainer", getTranslator());
formLayout.add(assessSubContainer);
Translator translator = getTranslator();
final String[] assessmentSwitchKeys = new String[] { NODEPASSED_VAL_PASSED, NODEPASSED_VAL_SCORE };
final String[] assessmentSwitchValues = new String[] { translator.translate("form.easy.assessmentSwitch.passed"), translator.translate("form.easy.assessmentSwitch.score") };
String nodePassedInitVal = validatedCondition.getEasyModeNodePassedId();
String cutInitStrValue = validatedCondition.getEasyModeCutValue();
int cutInitValue = 0;
assessmentSwitch = uifactory.addCheckboxesHorizontal("assessmentSwitch", null, formLayout, new String[] { "ison" }, new String[] { translate("form.easy.assessmentSwitch") });
assessmentSwitch.addActionListener(FormEvent.ONCLICK);
boolean selectedNodeIsInList = false;
List<String> keysList = new ArrayList<String>();
List<String> valuesList = new ArrayList<String>();
if (nodeIdentList.size() > 0) {
// there are nodes to be selected
keysList.add(NO_NODE_SELECTED_IDENTIFYER);
valuesList.add("- " + translator.translate("form.easy.nodePassed.select") + " -");
for (int i = 0; i < nodeIdentList.size(); i++) {
CourseNode courseNode = nodeIdentList.get(i);
keysList.add(courseNode.getIdent());
valuesList.add(courseNode.getShortName() + " (Id:" + courseNode.getIdent() + ")");
if (courseNode.getIdent().equals(nodePassedInitVal))
selectedNodeIsInList = true;
}
} else {
// no nodes to be selected
keysList.add(NO_NODE_SELECTED_IDENTIFYER);
valuesList.add("- " + translator.translate("form.easy.nodePassed.noNodes"));
// disable switch
assessmentSwitch.setEnabled(false);
}
// add dummy value if needed
if (nodePassedInitVal != null && !selectedNodeIsInList) {
keysList.add(DELETED_NODE_IDENTIFYER);
valuesList.add("- " + translator.translate("form.easy.nodePassed.deletedNode") + " -");
}
final String[] nodePassedKeys = new String[keysList.size()];
keysList.toArray(nodePassedKeys);
final String[] nodePassedValues = new String[valuesList.size()];
valuesList.toArray(nodePassedValues);
nodePassed = uifactory.addDropdownSingleselect("nodePassed", "form.easy.nodePassed", assessSubContainer, nodePassedKeys, nodePassedValues, null);
if (nodePassedInitVal != null) {
if (selectedNodeIsInList) {
nodePassed.select(nodePassedInitVal, true);
} else {
nodePassed.select(DELETED_NODE_IDENTIFYER, true);
}
} else {
nodePassed.select(NO_NODE_SELECTED_IDENTIFYER, true);
}
assessmentTypeSwitch = uifactory.addRadiosVertical("assessmentTypeSwitch", null, assessSubContainer, assessmentSwitchKeys, assessmentSwitchValues);
assessmentTypeSwitch.setLabel("form.easy.assessmentSwitch.type", null);
assessmentTypeSwitch.addActionListener(FormEvent.ONCLICK);
if (nodePassedInitVal != null) {
// has a node configured
if (cutInitStrValue == null) {
// with cut value
assessmentTypeSwitch.select(NODEPASSED_VAL_PASSED, true);
} else {
cutInitValue = Integer.valueOf(cutInitStrValue);
assessmentTypeSwitch.select(NODEPASSED_VAL_SCORE, true);
}
assessmentSwitch.select("ison", true);
assessmentTypeSwitch.setVisible(true);
} else {
assessmentSwitch.select("ison", false);
assessmentTypeSwitch.setVisible(false);
assessmentTypeSwitch.select(NODEPASSED_VAL_PASSED, true);
}
cutValue = uifactory.addIntegerElement("cutval", "form.easy.cutValue", cutInitValue, assessSubContainer);
cutValue.setDisplaySize(3);
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class PassedRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/passed.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
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 currentStatus = null;
String currentCourseNode = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentStatus = r.getRightOperand();
currentCourseNode = r.getLeftOperand();
}
List<CourseNode> attemptableNodes = new ArrayList<>();
searchPassedNodes(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);
}
Translator trans = formLayout.getTranslator();
String[] statusValues = new String[] { trans.translate("passed"), trans.translate("failed") };
statusEl = uifactory.addDropdownSingleselect("status.".concat(id), null, ruleCont, statusKeys, statusValues, null);
statusEl.setDomReplacementWrapperRequired(false);
boolean statusSelected = false;
if (currentStatus != null) {
for (String statusKey : statusKeys) {
if (currentStatus.equals(statusKey)) {
statusEl.select(statusKey, true);
statusSelected = true;
}
}
}
if (!statusSelected) {
statusEl.select(statusKeys[1], true);
}
return ruleCont;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class PassedRuleEditor method searchPassedNodes.
private void searchPassedNodes(CourseNode courseNode, List<CourseNode> nodes) {
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasPassedConfigured()) {
nodes.add(courseNode);
}
}
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
searchPassedNodes(child, nodes);
}
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method hasAssessableSTCourseNode.
private List<STCourseNode> hasAssessableSTCourseNode(ICourse course) {
List<STCourseNode> assessableSTNodes = new ArrayList<>();
CourseNode rootNode = course.getRunStructure().getRootNode();
new TreeVisitor(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof STCourseNode) {
STCourseNode stNode = (STCourseNode) node;
ScoreCalculator calculator = stNode.getScoreCalculator();
if (StringHelper.containsNonWhitespace(calculator.getPassedExpression())) {
assessableSTNodes.add(stNode);
} else if (StringHelper.containsNonWhitespace(calculator.getScoreExpression())) {
assessableSTNodes.add(stNode);
}
}
}
}, rootNode, true).visitAll();
return assessableSTNodes;
}
use of org.olat.course.nodes.CourseNode in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_0_0 method compareCourseNodeAssessment.
private boolean compareCourseNodeAssessment(AssessmentEntryImpl entry, NewCachePersistingAssessmentManager assessmentManager, ICourse course, RepositoryEntry courseEntry) {
CourseNode node = course.getRunStructure().getNode(entry.getSubIdent());
if (node == null) {
CourseEditorTreeNode editorNode = course.getEditorTreeModel().getCourseEditorNodeById(entry.getSubIdent());
if (editorNode != null) {
node = editorNode.getCourseNode();
}
}
boolean allOk = true;
if (node instanceof AssessableCourseNode && !(node instanceof STCourseNode)) {
Identity assessedIdentity = entry.getIdentity();
Integer attempts = assessmentManager.getNodeAttempts(node, assessedIdentity);
if ((attempts == null && entry.getAttempts() == null) || (attempts != null && entry.getAttempts() != null && attempts.equals(entry.getAttempts()))) {
// ok
} else {
log.audit("ERROR number of attempts: " + attempts + " / " + entry.getAttempts() + getErrorAt(courseEntry, node));
allOk &= false;
}
Boolean passed = assessmentManager.getNodePassed(node, assessedIdentity);
if ((passed == null && entry.getPassed() == null) || (passed != null && entry.getPassed() != null && passed.equals(entry.getPassed()))) {
// ok
} else {
log.audit("ERROR passed: " + passed + " / " + entry.getPassed() + getErrorAt(courseEntry, node));
allOk &= false;
}
Boolean fullyAssessed = assessmentManager.getNodeFullyAssessed(node, assessedIdentity);
if ((fullyAssessed == null && entry.getFullyAssessed() == null) || (fullyAssessed != null && entry.getFullyAssessed() != null && fullyAssessed.equals(entry.getFullyAssessed()))) {
// ok
} else {
log.audit("ERROR fullyAssessed: " + fullyAssessed + " / " + entry.getFullyAssessed() + getErrorAt(courseEntry, node));
allOk &= false;
}
Float score = assessmentManager.getNodeScore(node, assessedIdentity);
if ((score == null && entry.getScore() == null) || (score != null && entry.getScore() != null && Math.abs(score.floatValue() - entry.getScore().floatValue()) < 0.00001f)) {
// ok
} else {
log.audit("ERROR score: " + score + " / " + entry.getScore() + getErrorAt(courseEntry, node));
allOk &= false;
}
}
return allOk;
}
Aggregations