Search in sources :

Example 91 with TaskList

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) Identity(org.olat.core.id.Identity) IdentityMark(org.olat.course.nodes.gta.IdentityMark) Test(org.junit.Test)

Example 92 with TaskList

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) Identity(org.olat.core.id.Identity) IdentityMark(org.olat.course.nodes.gta.IdentityMark) Test(org.junit.Test)

Example 93 with TaskList

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) Identity(org.olat.core.id.Identity) IdentityMark(org.olat.course.nodes.gta.IdentityMark) Test(org.junit.Test)

Example 94 with TaskList

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) GTAManager(org.olat.course.nodes.gta.GTAManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 95 with TaskList

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;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) ZipOutputStream(java.util.zip.ZipOutputStream) OutputStream(java.io.OutputStream) ZipEntry(java.util.zip.ZipEntry) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem) SystemItemFilter(org.olat.core.util.vfs.filters.SystemItemFilter) Date(java.util.Date) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) GTAManager(org.olat.course.nodes.gta.GTAManager) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Aggregations

TaskList (org.olat.course.nodes.gta.TaskList)102 Identity (org.olat.core.id.Identity)68 Test (org.junit.Test)64 RepositoryEntry (org.olat.repository.RepositoryEntry)60 GTACourseNode (org.olat.course.nodes.GTACourseNode)48 File (java.io.File)36 Task (org.olat.course.nodes.gta.Task)36 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)32 BusinessGroup (org.olat.group.BusinessGroup)20 ArrayList (java.util.ArrayList)16 Date (java.util.Date)12 List (java.util.List)12 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)12 TaskProcess (org.olat.course.nodes.gta.TaskProcess)10 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)10 IdentityMark (org.olat.course.nodes.gta.IdentityMark)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 Calendar (java.util.Calendar)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 GTAManager (org.olat.course.nodes.gta.GTAManager)6