use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class AbstractAssignmentEditController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (addTaskCtrl == source) {
if (event == Event.DONE_EVENT) {
TaskDefinition newTask = addTaskCtrl.getTask();
gtaManager.addTaskDefinition(newTask, courseEnv, gtaNode);
fireEvent(ureq, Event.DONE_EVENT);
updateModel();
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
// fireEvent(ureq, Event.DONE_EVENT);
} else if (editTaskCtrl == source) {
if (event == Event.DONE_EVENT) {
doFinishReplacementOfTask(editTaskCtrl.getFilenameToReplace(), editTaskCtrl.getTask());
updateModel();
// fireEvent(ureq, Event.DONE_EVENT);
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (newTaskCtrl == source) {
TaskDefinition newTask = newTaskCtrl.getTaskDefinition();
cmc.deactivate();
cleanUp();
if (event == Event.DONE_EVENT) {
gtaManager.addTaskDefinition(newTask, courseEnv, gtaNode);
doCreateTaskEditor(ureq, newTask);
updateModel();
}
} else if (newTaskEditorCtrl == source) {
if (event == Event.DONE_EVENT) {
updateModel();
// fireEvent(ureq, Event.DONE_EVENT);
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (editTaskEditorCtrl == source) {
if (event == Event.DONE_EVENT) {
gtaManager.updateTaskDefinition(null, editTaskEditorCtrl.getTask(), courseEnv, gtaNode);
updateModel();
// fireEvent(ureq, Event.DONE_EVENT);
notificationsManager.markPublisherNews(subscriptionContext, null, false);
}
cmc.deactivate();
cleanUp();
} else if (confirmDeleteCtrl == source) {
if (DialogBoxUIFactory.isOkEvent(event) || DialogBoxUIFactory.isYesEvent(event)) {
TaskDefinition row = (TaskDefinition) confirmDeleteCtrl.getUserObject();
doDelete(ureq, row);
}
cleanUp();
} else if (cmc == source) {
cleanUp();
}
super.event(ureq, source, event);
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class AbstractAssignmentEditController method doReplaceTask.
private void doReplaceTask(UserRequest ureq, TaskDefinition taskDef) {
List<TaskDefinition> currentDefinitions = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
editTaskCtrl = new EditTaskController(ureq, getWindowControl(), taskDef, tasksFolder, currentDefinitions);
listenTo(editTaskCtrl);
String title = translate("edit.task");
cmc = new CloseableModalController(getWindowControl(), null, editTaskCtrl.getInitialComponent(), true, title, false);
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class EditTaskController method formOK.
@Override
protected void formOK(UserRequest ureq) {
task.setTitle(titleEl.getValue());
task.setDescription(descriptionEl.getValue());
if (fileEl.getUploadFile() != null) {
if (replaceFile && StringHelper.containsNonWhitespace(task.getFilename())) {
int usage = 0;
if (currentDefinitions != null) {
for (TaskDefinition definition : currentDefinitions) {
if (task.getFilename().equals(definition.getFilename())) {
usage++;
}
}
}
if (usage == 1) {
File currentFile = new File(taskContainer, task.getFilename());
if (currentFile.exists()) {
currentFile.delete();
}
}
}
String filename = fileEl.getUploadFileName();
task.setFilename(filename);
try {
Path upload = fileEl.getUploadFile().toPath();
File target = new File(taskContainer, filename);
Files.move(upload, target.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (Exception ex) {
logError("", ex);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
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.nodes.gta.model.TaskDefinition in project openolat by klemens.
the class GTAParticipantController method showAssignedTask.
private void showAssignedTask(UserRequest ureq, Task assignedTask) {
String message = gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_USERS_TEXT);
TaskDefinition taskDef = getTaskDefinition(assignedTask);
assignedTaskCtrl = new GTAAssignedTaskController(ureq, getWindowControl(), assignedTask, taskDef, courseEnv, gtaNode, "task.assigned.description", "warning.no.task.choosed", message);
listenTo(assignedTaskCtrl);
mainVC.put("myAssignedTask", assignedTaskCtrl.getInitialComponent());
}
Aggregations