use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
the class GTAIdentityMarkDAOTest method shouldDeleteMarkOfAMarker.
@Test
public void shouldDeleteMarkOfAMarker() {
TaskList taskList = createTaskList();
TaskList otherTaskList = createTaskList();
Identity marker = JunitTestHelper.createAndPersistIdentityAsAuthor("coach");
Identity otherMarker = JunitTestHelper.createAndPersistIdentityAsAuthor("otherCoach");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsUser("participant1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsUser("participant2");
Identity participant3 = JunitTestHelper.createAndPersistIdentityAsUser("participant3");
IdentityMark mark1 = sut.createAndPersisitMark(taskList, marker, participant1);
sut.createAndPersisitMark(taskList, marker, participant2);
sut.createAndPersisitMark(otherTaskList, marker, participant3);
sut.createAndPersisitMark(taskList, otherMarker, participant3);
IdentityMark mark3 = sut.createAndPersisitMark(taskList, marker, participant3);
dbInstance.commitAndCloseSession();
sut.deleteMark(taskList, marker, participant2);
dbInstance.commitAndCloseSession();
List<IdentityMark> marks = sut.loadMarks(taskList, marker);
assertThat(marks).hasSize(2);
assertThat(marks).containsExactly(mark1, mark3);
}
use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
the class GTAIdentityMarkDAOTest method shouldLoadAllMarksOfAMarker.
@Test
public void shouldLoadAllMarksOfAMarker() {
TaskList taskList = createTaskList();
TaskList otherTaskList = createTaskList();
Identity marker = JunitTestHelper.createAndPersistIdentityAsAuthor("coach");
Identity otherMarker = JunitTestHelper.createAndPersistIdentityAsAuthor("otherCoach");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsUser("participant1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsUser("participant2");
Identity participant3 = JunitTestHelper.createAndPersistIdentityAsUser("participant3");
IdentityMark mark1 = sut.createAndPersisitMark(taskList, marker, participant1);
IdentityMark mark2 = sut.createAndPersisitMark(taskList, marker, participant2);
sut.createAndPersisitMark(otherTaskList, marker, participant3);
sut.createAndPersisitMark(taskList, otherMarker, participant3);
IdentityMark mark3 = sut.createAndPersisitMark(taskList, marker, participant3);
dbInstance.commitAndCloseSession();
List<IdentityMark> marks = sut.loadMarks(taskList, marker);
assertThat(marks).hasSize(3);
assertThat(marks).containsExactly(mark1, mark2, mark3);
}
use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
the class GTAIdentityMarkDAOTest method shouldDeleteMarkOfATaskList.
@Test
public void shouldDeleteMarkOfATaskList() {
TaskList taskList = createTaskList();
TaskList otherTaskList = createTaskList();
Identity marker = JunitTestHelper.createAndPersistIdentityAsAuthor("coach");
Identity otherMarker = JunitTestHelper.createAndPersistIdentityAsAuthor("otherCoach");
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsUser("participant1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsUser("participant2");
Identity participant3 = JunitTestHelper.createAndPersistIdentityAsUser("participant3");
sut.createAndPersisitMark(taskList, marker, participant1);
sut.createAndPersisitMark(taskList, marker, participant2);
sut.createAndPersisitMark(otherTaskList, marker, participant3);
sut.createAndPersisitMark(taskList, otherMarker, participant3);
sut.createAndPersisitMark(taskList, marker, participant3);
dbInstance.commitAndCloseSession();
int numberDeleted = sut.deleteMark(taskList);
dbInstance.commitAndCloseSession();
assertThat(numberDeleted).isSameAs(4);
List<IdentityMark> marksOfDeletedTaskList = sut.loadMarks(taskList, marker);
assertThat(marksOfDeletedTaskList).hasSize(0);
List<IdentityMark> marksOfExistinTaskList = sut.loadMarks(otherTaskList, marker);
assertThat(marksOfExistinTaskList).hasSize(1);
}
use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
the class BulkAssessmentTask method updateTasksState.
private void updateTasksState(GTACourseNode courseNode, UserCourseEnvironment uce, TaskProcess status) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
Identity identity = uce.getIdentityEnvironment().getIdentity();
RepositoryEntry entry = uce.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
org.olat.course.nodes.gta.Task gtaTask;
TaskList taskList = gtaManager.getTaskList(entry, courseNode);
if (taskList == null) {
taskList = gtaManager.createIfNotExists(entry, courseNode);
gtaTask = gtaManager.createTask(null, taskList, status, null, identity, courseNode);
} else {
gtaTask = gtaManager.getTask(identity, taskList);
if (gtaTask == null) {
gtaManager.createTask(null, taskList, status, null, identity, courseNode);
}
}
gtaManager.nextStep(status, courseNode);
}
use of org.olat.course.nodes.gta.TaskList in project openolat by klemens.
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;
}
Aggregations