use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.
the class CourseCalendarPeekViewController method init.
private void init(UserRequest ureq, CalCourseNode courseNode, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
CourseCalendars myCal = CourseCalendars.createCourseCalendarsWrapper(ureq, getWindowControl(), courseEnv, ne);
Date refDate;
ModuleConfiguration config = courseNode.getModuleConfiguration();
if (CalEditController.getAutoDate(config)) {
refDate = new Date();
} else {
refDate = CalEditController.getStartDate(config);
if (refDate == null)
refDate = new Date();
}
List<KalendarEvent> nextEvents = new ArrayList<KalendarEvent>();
for (KalendarRenderWrapper calendar : myCal.getCalendars()) {
Kalendar cal = calendar.getKalendar();
Collection<KalendarEvent> events = cal.getEvents();
for (KalendarEvent event : events) {
if (refDate.compareTo(event.getBegin()) <= 0) {
nextEvents.add(event);
}
}
}
Collections.sort(nextEvents, new KalendarEventComparator());
List<KalendarEvent> nextThreeEvents = nextEvents.subList(0, Math.min(3, nextEvents.size()));
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("calendar.noEvents"));
tableConfig.setDisplayTableHeader(false);
tableConfig.setCustomCssClass("o_portlet_table");
tableConfig.setDisplayRowCount(false);
tableConfig.setPageingEnabled(false);
tableConfig.setDownloadOffered(false);
tableConfig.setSortingEnabled(false);
removeAsListenerAndDispose(tableController);
tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
listenTo(tableController);
// dummy header key, won't be used since setDisplayTableHeader is set to
// false
tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.date", 0, null, ureq.getLocale()));
tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.subject", 1, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));
tableController.setTableDataModel(new CourseCalendarPeekViewModel(nextThreeEvents, getTranslator()));
}
use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.
the class MultiSPController method create.
private void create(MultipleSelectionElement selection, ICourse course, CourseNode parentNode) {
SelectNodeObject node = (SelectNodeObject) selection.getUserObject();
if (selection.isMultiselect() && selection.isSelected(0)) {
VFSItem item = node.getItem();
CourseNode newNode = null;
if (item instanceof VFSLeaf) {
// create node
newNode = createCourseNode(item, "sp");
ModuleConfiguration moduleConfig = newNode.getModuleConfiguration();
String path = getRelativePath(item);
moduleConfig.set(SPEditController.CONFIG_KEY_FILE, path);
moduleConfig.setBooleanEntry(SPEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS, true);
} else if (item instanceof VFSContainer) {
// add structure
newNode = createCourseNode(item, "st");
}
int pos = -1;
if (position >= 0 && selectedNode.getCourseNode().getIdent().equals(parentNode.getIdent())) {
pos = position++;
}
if (pos < 0 || pos >= parentNode.getChildCount()) {
course.getEditorTreeModel().addCourseNode(newNode, parentNode);
} else {
course.getEditorTreeModel().insertCourseNodeAt(newNode, parentNode, pos);
}
if (item instanceof VFSContainer) {
parentNode = newNode;
}
}
// recurse
for (MultipleSelectionElement childElement : node.getChildren()) {
create(childElement, course, parentNode);
}
}
use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method updateOnPublish.
@Override
public void updateOnPublish(Locale locale, ICourse course, Identity publisher, PublishEvents publishEvents) {
ModuleConfiguration config = getModuleConfiguration();
// sync the checkbox with the database
CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
checkboxManager.syncCheckbox(list, course, getIdent());
CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager();
List<Identity> assessedUsers = pm.getAllIdentitiesWithCourseAssessmentData(null);
int count = 0;
for (Identity assessedIdentity : assessedUsers) {
updateScorePassedOnPublish(assessedIdentity, publisher, checkboxManager, course);
if (++count % 10 == 0) {
DBFactory.getInstance().commitAndCloseSession();
}
}
DBFactory.getInstance().commitAndCloseSession();
super.updateOnPublish(locale, course, publisher, publishEvents);
}
use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method updateScorePassedOnPublish.
private void updateScorePassedOnPublish(Identity assessedIdentity, Identity coachIdentity, CheckboxManager checkboxManager, ICourse course) {
AssessmentManager am = course.getCourseEnvironment().getAssessmentManager();
Float currentScore = am.getNodeScore(this, assessedIdentity);
Boolean currentPassed = am.getNodePassed(this, assessedIdentity);
Float updatedScore = null;
Boolean updatedPassed = null;
ModuleConfiguration config = getModuleConfiguration();
Boolean scoreGrantedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
if (scoreGrantedBool != null && scoreGrantedBool.booleanValue()) {
updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
} else {
updatedScore = null;
}
Boolean passedBool = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD);
if (passedBool != null && passedBool.booleanValue()) {
Float cutValue = (Float) config.get(MSCourseNode.CONFIG_KEY_PASSED_CUT_VALUE);
Boolean sumCheckbox = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CHECKBOX);
if (sumCheckbox != null && sumCheckbox.booleanValue()) {
Integer minValue = (Integer) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_SUM_CUTVALUE);
int checkedBox = checkboxManager.countChecked(assessedIdentity, course, getIdent());
if (minValue != null && minValue.intValue() <= checkedBox) {
updatedPassed = Boolean.TRUE;
} else {
updatedPassed = Boolean.FALSE;
}
} else if (cutValue != null) {
if (updatedScore == null) {
updatedScore = checkboxManager.calculateScore(assessedIdentity, course, getIdent());
}
if (updatedScore != null && cutValue.floatValue() <= updatedScore.floatValue()) {
updatedPassed = Boolean.TRUE;
} else {
updatedPassed = Boolean.FALSE;
}
}
} else {
updatedPassed = null;
}
boolean needUpdate = false;
Boolean manualCorrection = (Boolean) config.get(CheckListCourseNode.CONFIG_KEY_PASSED_MANUAL_CORRECTION);
if (manualCorrection == null || !manualCorrection.booleanValue()) {
// update passed
if ((currentPassed == null && updatedPassed != null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentPassed != null && updatedPassed == null) || (currentPassed != null && !currentPassed.equals(updatedPassed))) {
needUpdate = true;
}
}
if ((currentScore == null && updatedScore != null && updatedScore.floatValue() > 0f) || (currentScore != null && updatedScore == null) || (currentScore != null && !currentScore.equals(updatedScore))) {
needUpdate = true;
}
if (needUpdate) {
ScoreEvaluation scoreEval = new ScoreEvaluation(updatedScore, updatedPassed);
IdentityEnvironment identityEnv = new IdentityEnvironment(assessedIdentity, null);
UserCourseEnvironment uce = new UserCourseEnvironmentImpl(identityEnv, course.getCourseEnvironment());
am.saveScoreEvaluation(this, coachIdentity, assessedIdentity, scoreEval, uce, false, Role.coach);
}
}
use of org.olat.modules.ModuleConfiguration in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method hasScoreConfigured.
/**
* @see org.olat.course.nodes.AssessableCourseNode#hasScoreConfigured()
*/
@Override
public boolean hasScoreConfigured() {
ModuleConfiguration config = getModuleConfiguration();
Boolean score = (Boolean) config.get(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD);
if (score == null)
return false;
return score.booleanValue();
}
Aggregations