use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class AbstractDueDateTaskRuleSPI method getPeopleToRemind.
protected List<Identity> getPeopleToRemind(RepositoryEntry entry, GTACourseNode gtaNode) {
ModuleConfiguration config = gtaNode.getModuleConfiguration();
TaskList taskList = gtaManager.getTaskList(entry, gtaNode);
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
return getGroupsToRemind(taskList, gtaNode);
} else {
return getIndividualsToRemind(taskList, entry, gtaNode);
}
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GroupBulkDownloadResource method prepare.
@Override
public void prepare(HttpServletResponse hres) {
try {
hres.setCharacterEncoding(encoding);
} catch (Exception e) {
log.error("", e);
}
String label = StringHelper.transformDisplayNameToFileSystemName(courseNode.getShortName()) + "_" + Formatter.formatDatetimeWithMinutes(new Date()) + ".zip";
String urlEncodedLabel = StringHelper.urlEncodeUTF8(label);
hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + urlEncodedLabel);
hres.setHeader("Content-Description", urlEncodedLabel);
try (ZipOutputStream zout = new ZipOutputStream(hres.getOutputStream())) {
zout.setLevel(9);
ICourse course = CourseFactory.loadCourse(courseOres);
GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
if (courseNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
List<Identity> assessableIdentities = CoreSpringFactory.getImpl(BusinessGroupService.class).getMembers(groups, GroupRoles.participant.name());
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(courseNode);
try (OutputStream out = new ShieldOutputStream(zout)) {
zout.putNextEntry(new ZipEntry(fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(assessableIdentities, nodes, course, locale, out);
zout.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), courseNode);
for (BusinessGroup businessGroup : groups) {
courseNode.archiveNodeData(course, businessGroup, taskList, "", zout);
}
} catch (Exception e) {
log.error("", e);
}
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method assignTaskAutomatically.
private AssignmentResponse assignTaskAutomatically(TaskList tasks, BusinessGroup businessGroup, Identity identity, CourseEnvironment courseEnv, GTACourseNode cNode) {
Task currentTask;
if (businessGroup != null) {
currentTask = getTask(businessGroup, tasks);
} else {
currentTask = getTask(identity, tasks);
}
AssignmentResponse response;
if (currentTask == null) {
TaskList reloadedTasks = loadForUpdate(tasks);
File tasksFolder = getTasksDirectory(courseEnv, cNode);
String[] taskFiles = tasksFolder.list(SystemFilenameFilter.FILES_ONLY);
List<String> assignedFilenames = getAssignedTasks(reloadedTasks);
String taskName;
if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(cNode.getModuleConfiguration().get(GTACourseNode.GTASK_SAMPLING))) {
taskName = nextUnique(taskFiles, assignedFilenames);
} else {
taskName = nextSlotRoundRobin(taskFiles, assignedFilenames);
}
if (taskName == null) {
response = AssignmentResponse.NO_MORE_TASKS;
} else {
TaskProcess nextStep = nextStep(TaskProcess.assignment, cNode);
TaskImpl task = createTask(taskName, reloadedTasks, nextStep, businessGroup, identity, cNode);
task.setAssignmentDate(new Date());
dbInstance.getCurrentEntityManager().persist(task);
dbInstance.commit();
syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
response = new AssignmentResponse(task, Status.ok);
}
} else {
if (currentTask.getTaskStatus() == TaskProcess.assignment) {
((TaskImpl) currentTask).setTaskStatus(TaskProcess.submit);
}
currentTask = dbInstance.getCurrentEntityManager().merge(currentTask);
syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
response = new AssignmentResponse(currentTask, Status.ok);
}
return response;
}
use of org.olat.course.nodes.gta.TaskList in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
final ModuleConfiguration config = getModuleConfiguration();
String prefix;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
prefix = "grouptask_";
} else {
prefix = "ita_";
}
String dirName = prefix + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), this);
// save assessment datas
List<Identity> users = null;
if (config.getBooleanSafe(GTASK_GRADING)) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(this);
try (OutputStream out = new ShieldOutputStream(exportStream)) {
exportStream.putNextEntry(new ZipEntry(dirName + "/" + fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(users, nodes, course, locale, out);
exportStream.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
// copy tasks
if (taskList != null) {
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<BusinessGroup> selectedGroups;
if (options != null && options.getGroup() != null) {
selectedGroups = Collections.singletonList(options.getGroup());
} else {
selectedGroups = gtaManager.getBusinessGroups(this);
}
for (BusinessGroup businessGroup : selectedGroups) {
archiveNodeData(course, businessGroup, taskList, dirName, exportStream);
}
} else {
if (users == null) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
}
Set<Identity> uniqueUsers = new HashSet<>(users);
for (Identity user : uniqueUsers) {
archiveNodeData(course, user, taskList, dirName, exportStream);
}
}
}
// copy solutions
if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
VFSContainer solutions = gtaManager.getSolutionsContainer(course.getCourseEnvironment(), this);
if (solutions.exists()) {
String solutionDirName = dirName + "/solutions";
for (VFSItem solution : solutions.getItems(new SystemItemFilter())) {
ZipUtil.addToZip(solution, solutionDirName, exportStream);
}
}
}
return true;
}
use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
the class GTAManagerImpl method syncWithTaskList.
private void syncWithTaskList(CourseEnvironment courseEnv, GTACourseNode cNode, TaskListSynched synched) {
TaskList tasks = getTaskList(courseEnv.getCourseGroupManager().getCourseEntry(), cNode);
if (tasks != null) {
loadForUpdate(tasks);
synched.sync();
dbInstance.commit();
} else {
synched.sync();
}
}
Aggregations