Search in sources :

Example 21 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class AbstractLectureBlockAuditLogExport method getLectureBlockTitle.

private String getLectureBlockTitle(Long lectureBlockKey) {
    if (lectureBlockKey == null)
        return null;
    String title = lectureBlockTitles.get(lectureBlockKey);
    if (title == null) {
        LectureBlock block = lectureService.getLectureBlock(new LectureBlockRefForLog(lectureBlockKey));
        if (block == null) {
            title = lectureBlockKey.toString();
        } else {
            title = block.getTitle();
        }
        lectureBlockTitles.put(lectureBlockKey, title);
    }
    return title;
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock)

Example 22 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class TeacherOverviewController method getRows.

@Override
protected List<LectureBlockRow> getRows(LecturesBlockSearchParameters searchParams) {
    Identity filterByTeacher = ((Boolean) allTeachersSwitch.getUserObject()).booleanValue() ? null : getIdentity();
    List<LectureBlockWithTeachers> blocksWithTeachers = lectureService.getLectureBlocksWithTeachers(entry, filterByTeacher, searchParams);
    // only show the start button if
    List<LectureBlockRow> rows = new ArrayList<>(blocksWithTeachers.size());
    if (ConfigurationHelper.isRollCallEnabled(entryConfig, lectureModule)) {
        for (LectureBlockWithTeachers blockWithTeachers : blocksWithTeachers) {
            LectureBlock block = blockWithTeachers.getLectureBlock();
            StringBuilder teachers = new StringBuilder(32);
            List<Identity> teacherList = blockWithTeachers.getTeachers();
            String separator = translate("user.fullname.separator");
            for (Identity teacher : blockWithTeachers.getTeachers()) {
                if (teachers.length() > 0)
                    teachers.append(" ").append(separator).append(" ");
                teachers.append(userManager.getUserDisplayName(teacher));
            }
            rows.add(new LectureBlockRow(block, entry.getDisplayname(), entry.getExternalRef(), teachers.toString(), teacherList.contains(getIdentity())));
        }
    }
    return rows;
}
Also used : LectureBlockWithTeachers(org.olat.modules.lecture.model.LectureBlockWithTeachers) LectureBlock(org.olat.modules.lecture.LectureBlock) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) LectureBlockRow(org.olat.modules.lecture.model.LectureBlockRow)

Example 23 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LectureBlockRollCallDAO method getParticipantLectureBlockAndRollCalls.

public List<LectureBlockAndRollCall> getParticipantLectureBlockAndRollCalls(RepositoryEntryRef entry, IdentityRef identity, String teacherSeaparator) {
    StringBuilder sb = new StringBuilder();
    sb.append("select block, call, re.displayname").append(" from lectureblock block").append(" inner join block.entry re").append(" inner join block.groups blockToGroup").append(" inner join blockToGroup.group bGroup").append(" inner join bGroup.members membership").append(" inner join lectureparticipantsummary as summary on (summary.identity.key=membership.identity.key and summary.entry.key=block.entry.key)").append(" left join lectureblockrollcall as call on (call.identity.key=membership.identity.key and call.lectureBlock.key=block.key)").append(" where membership.identity.key=:identityKey and membership.role='").append(GroupRoles.participant.name()).append("'").append(" and block.entry.key=:repoEntryKey and block.endDate>=summary.firstAdmissionDate");
    List<Object[]> rawObjects = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("identityKey", identity.getKey()).setParameter("repoEntryKey", entry.getKey()).getResultList();
    Map<Long, LectureBlockAndRollCall> blockToRollCallMap = new HashMap<>();
    for (Object[] objects : rawObjects) {
        int pos = 0;
        LectureBlock block = (LectureBlock) objects[pos++];
        LectureBlockRollCall rollCall = (LectureBlockRollCall) objects[pos++];
        String displayname = (String) objects[pos++];
        blockToRollCallMap.put(block.getKey(), new LectureBlockAndRollCall(displayname, block, rollCall));
    }
    appendCoaches(entry, blockToRollCallMap, teacherSeaparator);
    return new ArrayList<>(blockToRollCallMap.values());
}
Also used : LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall)

Example 24 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LecturesBlocksRootTest method createLectureBlock.

private LectureBlock createLectureBlock(RepositoryEntry entry) {
    LectureBlock lectureBlock = lectureService.createLectureBlock(entry);
    lectureBlock.setStartDate(new Date());
    lectureBlock.setEndDate(new Date());
    lectureBlock.setTitle("Hello lecturers");
    lectureBlock.setPlannedLecturesNumber(4);
    return lectureService.save(lectureBlock, null);
}
Also used : LectureBlock(org.olat.modules.lecture.LectureBlock) Date(java.util.Date)

Example 25 with LectureBlock

use of org.olat.modules.lecture.LectureBlock in project OpenOLAT by OpenOLAT.

the class LecturesBlockRollCallTest method getRollCalls_searchParams_True.

@Test
public void getRollCalls_searchParams_True() throws IOException, URISyntaxException {
    // an open lecture block
    LectureBlock openLectureBlock = createMinimalLectureBlock(3);
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("lecturer-2");
    dbInstance.commitAndCloseSession();
    // a closed lecture block
    LectureBlock closedLectureBlock = createMinimalLectureBlock(3);
    dbInstance.commitAndCloseSession();
    closedLectureBlock.setStatus(LectureBlockStatus.done);
    closedLectureBlock.setRollCallStatus(LectureRollCallStatus.closed);
    lectureBlockDao.update(closedLectureBlock);
    List<Integer> absences = Arrays.asList(1, 2);
    LectureBlockRollCall rollCall1 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id1, null, null, null, Collections.emptyList());
    LectureBlockRollCall rollCall2 = lectureBlockRollCallDao.createAndPersistRollCall(closedLectureBlock, id2, null, null, null, absences);
    LectureBlockRollCall rollCall3 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id1, null, null, null, absences);
    LectureBlockRollCall rollCall4 = lectureBlockRollCallDao.createAndPersistRollCall(openLectureBlock, id2, null, null, null, Collections.emptyList());
    dbInstance.commit();
    rollCall2.setAbsenceSupervisorNotificationDate(new Date());
    rollCall2 = lectureBlockRollCallDao.update(rollCall2);
    dbInstance.commitAndCloseSession();
    // REST call
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("lectures").path("rollcalls").queryParam("hasAbsences", "true").queryParam("closed", "true").queryParam("hasSupervisorNotificationDate", "true").build();
    HttpGet method = conn.createGet(uri, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    List<LectureBlockRollCallVO> voList = parseLectureBlockRollCallArray(response.getEntity().getContent());
    Assert.assertNotNull(voList);
    // check the return values
    List<Long> rollCallVoKeys = voList.stream().map(vo -> vo.getKey()).collect(Collectors.toList());
    Assert.assertFalse(rollCallVoKeys.contains(rollCall1.getKey()));
    Assert.assertTrue(rollCallVoKeys.contains(rollCall2.getKey()));
    Assert.assertFalse(rollCallVoKeys.contains(rollCall3.getKey()));
    Assert.assertFalse(rollCallVoKeys.contains(rollCall4.getKey()));
    // check that roll call 2 has a date
    boolean found = false;
    for (LectureBlockRollCallVO vo : voList) {
        if (vo.getKey().equals(rollCall2.getKey()) && vo.getAbsenceSupervisorNotificationDate() != null) {
            found = true;
        }
    }
    Assert.assertTrue(found);
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) Arrays(java.util.Arrays) LectureBlockRollCallSearchParameters(org.olat.modules.lecture.LectureBlockRollCallSearchParameters) Date(java.util.Date) LectureBlockDAO(org.olat.modules.lecture.manager.LectureBlockDAO) URISyntaxException(java.net.URISyntaxException) Autowired(org.springframework.beans.factory.annotation.Autowired) RepositoryEntry(org.olat.repository.RepositoryEntry) MediaType(javax.ws.rs.core.MediaType) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) LectureBlockStatus(org.olat.modules.lecture.LectureBlockStatus) LectureBlock(org.olat.modules.lecture.LectureBlock) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) JunitTestHelper(org.olat.test.JunitTestHelper) List(java.util.List) LectureBlockRollCallVO(org.olat.modules.lecture.restapi.LectureBlockRollCallVO) HttpGet(org.apache.http.client.methods.HttpGet) DB(org.olat.core.commons.persistence.DB) TypeReference(org.codehaus.jackson.type.TypeReference) Identity(org.olat.core.id.Identity) LectureBlockRollCallDAO(org.olat.modules.lecture.manager.LectureBlockRollCallDAO) HttpResponse(org.apache.http.HttpResponse) Assert(org.junit.Assert) LectureRollCallStatus(org.olat.modules.lecture.LectureRollCallStatus) Collections(java.util.Collections) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) InputStream(java.io.InputStream) OlatJerseyTestCase(org.olat.test.OlatJerseyTestCase) LectureBlockRollCallVO(org.olat.modules.lecture.restapi.LectureBlockRollCallVO) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) URI(java.net.URI) Date(java.util.Date) LectureBlock(org.olat.modules.lecture.LectureBlock) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

LectureBlock (org.olat.modules.lecture.LectureBlock)232 Identity (org.olat.core.id.Identity)132 Test (org.junit.Test)116 RepositoryEntry (org.olat.repository.RepositoryEntry)98 Date (java.util.Date)64 LectureBlockRollCall (org.olat.modules.lecture.LectureBlockRollCall)42 URI (java.net.URI)30 ArrayList (java.util.ArrayList)30 HttpResponse (org.apache.http.HttpResponse)30 Group (org.olat.basesecurity.Group)30 Calendar (java.util.Calendar)26 ICourse (org.olat.course.ICourse)24 BusinessGroup (org.olat.group.BusinessGroup)24 CourseConfigVO (org.olat.restapi.support.vo.CourseConfigVO)24 LectureBlockToGroup (org.olat.modules.lecture.LectureBlockToGroup)22 RepositoryEntryLectureConfiguration (org.olat.modules.lecture.RepositoryEntryLectureConfiguration)20 LecturesBlockSearchParameters (org.olat.modules.lecture.model.LecturesBlockSearchParameters)16 List (java.util.List)14 HttpGet (org.apache.http.client.methods.HttpGet)14 LectureBlockToTeacher (org.olat.modules.lecture.model.LectureBlockToTeacher)14