use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method clearInstructorRespondents.
public void clearInstructorRespondents(String feedbackSessionName, String courseId) throws EntityDoesNotExistException, InvalidParametersException {
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, feedbackSessionName);
Assumption.assertNotNull(Const.StatusCodes.NULL_PARAMETER, courseId);
FeedbackSessionAttributes sessionToUpdate = getFeedbackSession(feedbackSessionName, courseId);
if (sessionToUpdate == null) {
throw new EntityDoesNotExistException(ERROR_NON_EXISTENT_FS_UPDATE + courseId + "/" + feedbackSessionName);
}
fsDb.clearInstructorRespondents(sessionToUpdate);
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionsClosingWithinTimeLimit.
public List<FeedbackSessionAttributes> getFeedbackSessionsClosingWithinTimeLimit() {
ArrayList<FeedbackSessionAttributes> requiredSessions = new ArrayList<>();
List<FeedbackSessionAttributes> nonPrivateSessions = fsDb.getFeedbackSessionsPossiblyNeedingClosingEmail();
for (FeedbackSessionAttributes session : nonPrivateSessions) {
if (session.getFeedbackSessionType() != FeedbackSessionType.PRIVATE && session.isClosingWithinTimeLimit(SystemParams.NUMBER_OF_HOURS_BEFORE_CLOSING_ALERT)) {
requiredSessions.add(session);
}
}
return requiredSessions;
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method deleteFeedbackSessionCascade.
/**
* Deletes a specific feedback session, and all its question and responses.
*/
public void deleteFeedbackSessionCascade(String feedbackSessionName, String courseId) {
try {
fqLogic.deleteFeedbackQuestionsForSession(feedbackSessionName, courseId);
} catch (EntityDoesNotExistException e) {
// Silently fail if session does not exist
log.warning(TeammatesException.toStringWithStackTrace(e));
}
FeedbackSessionAttributes sessionToDelete = FeedbackSessionAttributes.builder(feedbackSessionName, courseId, "").build();
fsDb.deleteEntity(sessionToDelete);
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsLogic method getFeedbackSessionDetailsForCourse.
private List<FeedbackSessionDetailsBundle> getFeedbackSessionDetailsForCourse(String courseId, String instructorEmail) throws EntityDoesNotExistException {
List<FeedbackSessionDetailsBundle> fsDetailsWithoutPrivate = new ArrayList<>();
List<FeedbackSessionAttributes> fsInCourse = fsDb.getFeedbackSessionsForCourse(courseId);
for (FeedbackSessionAttributes fsa : fsInCourse) {
if (!fsa.isPrivateSession() || fsa.isCreator(instructorEmail)) {
fsDetailsWithoutPrivate.add(getFeedbackSessionDetails(fsa));
}
}
return fsDetailsWithoutPrivate;
}
use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.
the class FeedbackSessionsDb method getAllOpenFeedbackSessions.
public List<FeedbackSessionAttributes> getAllOpenFeedbackSessions(Date startUtc, Date endUtc) {
List<FeedbackSessionAttributes> list = new LinkedList<>();
Calendar startCal = Calendar.getInstance();
startCal.setTime(startUtc);
Calendar endCal = Calendar.getInstance();
endCal.setTime(endUtc);
// To retrieve legacy data where local dates are stored instead of UTC
// TODO: remove after all legacy data has been converted
Date curStart = TimeHelper.convertToUserTimeZone(startCal, -25).getTime();
Date curEnd = TimeHelper.convertToUserTimeZone(endCal, 25).getTime();
List<FeedbackSession> endEntities = load().filter("endTime >", curStart).filter("endTime <=", curEnd).list();
List<FeedbackSession> startEntities = load().filter("startTime >=", curStart).filter("startTime <", curEnd).list();
List<FeedbackSession> endTimeEntities = new ArrayList<>(endEntities);
List<FeedbackSession> startTimeEntities = new ArrayList<>(startEntities);
endTimeEntities.removeAll(startTimeEntities);
startTimeEntities.removeAll(endTimeEntities);
endTimeEntities.addAll(startTimeEntities);
Instant start = startUtc.toInstant();
Instant end = endUtc.toInstant();
// TODO: remove after all legacy data has been converted
for (FeedbackSession feedbackSession : endTimeEntities) {
FeedbackSessionAttributes fs = makeAttributes(feedbackSession);
Instant fsStart = fs.getStartTime();
Instant fsEnd = fs.getEndTime();
boolean isStartTimeWithinRange = (fsStart.isAfter(start) || fsStart.equals(start)) && fsStart.isBefore(end);
boolean isEndTimeWithinRange = fsEnd.isAfter(start) && (fsEnd.isBefore(end) || fsEnd.equals(end));
if (isStartTimeWithinRange || isEndTimeWithinRange) {
list.add(fs);
}
}
return list;
}
Aggregations