use of org.olat.modules.lecture.LectureBlockRollCallSearchParameters in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method getRollCalls_searchParams_True.
@Test
public void getRollCalls_searchParams_True() {
// 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();
{
// only absences
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasAbsence(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only with supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasSupervisorNotificationDate(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only closed
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
{
// only with supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.TRUE);
searchParams.setHasAbsence(Boolean.TRUE);
searchParams.setHasSupervisorNotificationDate(Boolean.TRUE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertTrue(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertFalse(rollCalls.contains(rollCall4));
}
}
use of org.olat.modules.lecture.LectureBlockRollCallSearchParameters in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallDAOTest method getRollCalls_searchParams_False.
@Test
public void getRollCalls_searchParams_False() {
// 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();
{
// only not closed
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without absence
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasAbsence(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// open, without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
searchParams.setHasAbsence(Boolean.FALSE);
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
}
use of org.olat.modules.lecture.LectureBlockRollCallSearchParameters in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallWebService method updateLectureBlockRollCall.
private Response updateLectureBlockRollCall(LectureBlockRollCallVO rollCallVo, HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
if (rollCallVo.getKey() == null) {
return Response.serverError().status(Status.BAD_REQUEST).build();
}
LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setRollCallKey(rollCallVo.getKey());
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
if (rollCalls.size() == 1) {
LectureBlockRollCall rollCall = rollCalls.get(0);
rollCall.setAbsenceSupervisorNotificationDate(rollCallVo.getAbsenceSupervisorNotificationDate());
if (rollCallVo.getAbsenceReason() != null) {
rollCall.setAbsenceReason(rollCallVo.getAbsenceReason());
}
if (rollCallVo.getComment() != null) {
rollCall.setComment(rollCallVo.getComment());
}
rollCall = lectureService.updateRollCall(rollCall);
LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
return Response.ok(vo).build();
}
return Response.serverError().status(Status.NOT_FOUND).build();
}
use of org.olat.modules.lecture.LectureBlockRollCallSearchParameters in project OpenOLAT by OpenOLAT.
the class LectureBlockRollCallWebService method getRollCall.
/**
* Return the lecture block roll call specified by the primary key.
*
* @response.representation.200.qname {http://www.example.com}lectureBlockRollCallVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc A lecture block roll call
* @response.representation.200.example {@link org.olat.modules.lecture.restapi.Examples#SAMPLE_LECTUREBLOCKROLLCALLVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The role call was not found
* @param rollCallKey The primary key of the roll call
* @param httpRequest The HTTP request
* @return The roll call
*/
@GET
@Path("{rollCallKey}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getRollCall(@PathParam("rollCallKey") Long rollCallKey, @Context HttpServletRequest httpRequest) {
Roles roles = getRoles(httpRequest);
if (!roles.isOLATAdmin()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
LectureService lectureService = CoreSpringFactory.getImpl(LectureService.class);
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setRollCallKey(rollCallKey);
List<LectureBlockRollCall> rollCalls = lectureService.getRollCalls(searchParams);
if (rollCalls.size() == 1) {
LectureBlockRollCall rollCall = rollCalls.get(0);
LectureBlockRollCallVO vo = new LectureBlockRollCallVO(rollCall);
return Response.ok(vo).build();
}
return Response.serverError().status(Status.NOT_FOUND).build();
}
use of org.olat.modules.lecture.LectureBlockRollCallSearchParameters in project openolat by klemens.
the class LectureBlockRollCallDAOTest method getRollCalls_searchParams_False.
@Test
public void getRollCalls_searchParams_False() {
// 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();
{
// only not closed
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without absence
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasAbsence(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertTrue(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertTrue(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
{
// open, without supervisor date
LectureBlockRollCallSearchParameters searchParams = new LectureBlockRollCallSearchParameters();
searchParams.setClosed(Boolean.FALSE);
searchParams.setHasAbsence(Boolean.FALSE);
searchParams.setHasSupervisorNotificationDate(Boolean.FALSE);
List<LectureBlockRollCall> rollCalls = lectureBlockRollCallDao.getRollCalls(searchParams);
Assert.assertFalse(rollCalls.contains(rollCall1));
Assert.assertFalse(rollCalls.contains(rollCall2));
Assert.assertFalse(rollCalls.contains(rollCall3));
Assert.assertTrue(rollCalls.contains(rollCall4));
}
}
Aggregations