use of org.olat.course.editor.StatusDescription in project openolat by klemens.
the class IQSURVCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid()
*/
@Override
public StatusDescription isConfigValid() {
/*
* first check the one click cache
*/
if (oneClickStatusCache != null) {
return oneClickStatusCache[0];
}
boolean isValid = getModuleConfiguration().get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY) != null;
if (isValid) {
/*
* COnfiugre an IQxxx BB with a repo entry, do not publish this BB, mark
* IQxxx as deleted, remove repo entry, undelete BB IQxxx and bang you
* enter this if.
*/
Object repoEntry = IQEditController.getIQReference(getModuleConfiguration(), false);
if (repoEntry == null) {
isValid = false;
IQEditController.removeIQReference(getModuleConfiguration());
}
}
StatusDescription sd = StatusDescription.NOERROR;
if (!isValid) {
String shortKey = "error.surv.undefined.short";
String longKey = "error.surv.undefined.long";
String[] params = new String[] { getShortTitle() };
sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, PACKAGE_IQ);
sd.setDescriptionForUnit(getIdent());
// set which pane is affected by error
sd.setActivateableViewIdentifier(IQEditController.PANE_TAB_IQCONFIG_SURV);
}
return sd;
}
use of org.olat.course.editor.StatusDescription in project openolat by klemens.
the class MSCourseNode method isConfigValid.
/**
* @see org.olat.course.nodes.CourseNode#isConfigValid()
*/
@Override
public StatusDescription isConfigValid() {
/*
* first check the one click cache
*/
if (oneClickStatusCache != null) {
return oneClickStatusCache[0];
}
boolean isValid = MSEditFormController.isConfigValid(getModuleConfiguration());
StatusDescription sd = StatusDescription.NOERROR;
if (!isValid) {
// FIXME: refine statusdescriptions by moving the statusdescription
// generation to the MSEditForm
String shortKey = "error.missingconfig.short";
String longKey = "error.missingconfig.long";
String[] params = new String[] { this.getShortTitle() };
sd = new StatusDescription(StatusDescription.ERROR, shortKey, longKey, params, PACKAGE_MS);
sd.setDescriptionForUnit(getIdent());
// set which pane is affected by error
sd.setActivateableViewIdentifier(MSCourseNodeEditController.PANE_TAB_CONFIGURATION);
}
return sd;
}
use of org.olat.course.editor.StatusDescription in project openolat by klemens.
the class GTACourseNode method addStatusWarningDescription.
private void addStatusWarningDescription(String key, String pane, List<StatusDescription> status) {
String[] params = new String[] { getShortTitle() };
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, key, key, params, PACKAGE_GTA);
sd.setDescriptionForUnit(getIdent());
sd.setActivateableViewIdentifier(pane);
status.add(sd);
}
use of org.olat.course.editor.StatusDescription in project openolat by klemens.
the class GTACourseNode method validateInternalConfiguration.
private List<StatusDescription> validateInternalConfiguration(CourseEditorEnv cev) {
List<StatusDescription> sdList = new ArrayList<>(5);
ModuleConfiguration config = getModuleConfiguration();
boolean hasScoring = config.getBooleanSafe(GTASK_GRADING);
if (hasScoring) {
if (!config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD) && !config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD) && !config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_COMMENT_FIELD)) {
addStatusErrorDescription("error.missing.score.config", GTAEditController.PANE_TAB_GRADING, sdList);
}
}
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
if (groupKeys.isEmpty() && areaKeys.isEmpty()) {
addStatusErrorDescription("error.missing.group", GTAEditController.PANE_TAB_GRADING, sdList);
}
}
// at least one step
if (!config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT) && !config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) && !config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION) && !config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD) && !config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION) && !config.getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
addStatusErrorDescription("error.select.atleastonestep", GTAEditController.PANE_TAB_WORKLOW, sdList);
}
if (cev != null) {
// check assignment
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
RepositoryEntry courseRe = cev.getCourseGroupManager().getCourseEntry();
ICourse course = CourseFactory.loadCourse(courseRe);
if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT)) {
File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
if (!TaskHelper.hasDocuments(taskDirectory)) {
if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
addStatusWarningDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
} else {
addStatusErrorDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
}
} else {
List<TaskDefinition> taskList = gtaManager.getTaskDefinitions(course.getCourseEnvironment(), this);
if (taskList == null || taskList.isEmpty()) {
if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
addStatusWarningDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
} else {
addStatusErrorDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
}
} else {
String[] filenames = taskDirectory.list();
for (TaskDefinition taskDef : taskList) {
boolean found = false;
for (String filename : filenames) {
if (filename.equals(taskDef.getFilename())) {
found = true;
break;
}
}
if (!found) {
addStatusWarningDescription("error.missing.file", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
}
}
}
}
}
// check solutions
if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
File solutionDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
if (!TaskHelper.hasDocuments(solutionDirectory)) {
if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
addStatusWarningDescription("error.missing.solutions", GTAEditController.PANE_TAB_SOLUTIONS, sdList);
} else {
addStatusErrorDescription("error.missing.solutions", GTAEditController.PANE_TAB_SOLUTIONS, sdList);
}
}
}
List<IdentityRef> participants = gtaManager.getDuplicatedMemberships(this);
if (participants.size() > 0) {
UserManager um = CoreSpringFactory.getImpl(UserManager.class);
StringBuilder sb = new StringBuilder();
for (IdentityRef participant : participants) {
String fullname = um.getUserDisplayName(participant.getKey());
if (sb.length() > 0)
sb.append(", ");
sb.append(fullname);
}
String[] params = new String[] { getShortTitle(), sb.toString() };
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.duplicate.memberships", "error.duplicate.memberships", params, PACKAGE_GTA);
sd.setDescriptionForUnit(getIdent());
sd.setActivateableViewIdentifier(GTAEditController.PANE_TAB_WORKLOW);
sdList.add(sd);
}
}
return sdList;
}
use of org.olat.course.editor.StatusDescription in project openolat by klemens.
the class GenericCourseNode method isConfigValidWithTranslator.
/**
* @param userCourseEnv
* @param translatorStr
* @return
*/
// for StatusDescription.WARNING
protected List<StatusDescription> isConfigValidWithTranslator(CourseEditorEnv cev, String translatorStr, List<ConditionExpression> condExprs) {
List<StatusDescription> condExprsStatusDescs = new ArrayList<>();
// check valid configuration without course environment
StatusDescription first = isConfigValid();
// check valid configuration within the course environment
if (cev == null) {
// course environment not configured!??
condExprsStatusDescs.add(first);
return condExprsStatusDescs;
}
/*
* there is course editor environment, we can check further. Iterate over
* all conditions of this course node, validate the condition expression and
* transform the condition error message into a status description
*/
for (int i = 0; i < condExprs.size(); i++) {
ConditionExpression ce = condExprs.get(i);
ConditionErrorMessage[] cems = cev.validateConditionExpression(ce);
if (cems != null && cems.length > 0) {
for (int j = 0; j < cems.length; j++) {
StatusDescription sd = new StatusDescription(StatusDescription.WARNING, cems[j].errorKey, cems[j].solutionMsgKey, cems[j].errorKeyParams, translatorStr);
sd.setDescriptionForUnit(getIdent());
condExprsStatusDescs.add(sd);
}
}
}
condExprsStatusDescs.add(first);
return condExprsStatusDescs;
}
Aggregations