Search in sources :

Example 86 with FeedbackSessionAttributes

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 87 with FeedbackSessionAttributes

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;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList)

Example 88 with FeedbackSessionAttributes

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);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 89 with FeedbackSessionAttributes

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;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) FeedbackSessionDetailsBundle(teammates.common.datatransfer.FeedbackSessionDetailsBundle)

Example 90 with FeedbackSessionAttributes

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;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSession(teammates.storage.entity.FeedbackSession) Calendar(java.util.Calendar) Instant(java.time.Instant) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Date(java.util.Date)

Aggregations

FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)205 Test (org.testng.annotations.Test)85 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)78 ArrayList (java.util.ArrayList)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)35 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)32 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)30 RedirectResult (teammates.ui.controller.RedirectResult)27 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)21 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)19 StatusMessage (teammates.common.util.StatusMessage)19 HashMap (java.util.HashMap)17 InvalidParametersException (teammates.common.exception.InvalidParametersException)14 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)13 EmailWrapper (teammates.common.util.EmailWrapper)12 Text (com.google.appengine.api.datastore.Text)11 DataBundle (teammates.common.datatransfer.DataBundle)11 EmailGenerator (teammates.logic.api.EmailGenerator)10 List (java.util.List)9 TaskWrapper (teammates.common.util.TaskWrapper)9