Search in sources :

Example 91 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackResponseAdjustmentWorkerAction method execute.

@Override
public void execute() {
    String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
    String sessionName = getRequestParamValue(ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(ParamsNames.FEEDBACK_SESSION_NAME, sessionName);
    String enrollmentDetails = getRequestParamValue(ParamsNames.ENROLLMENT_DETAILS);
    Assumption.assertPostParamNotNull(ParamsNames.ENROLLMENT_DETAILS, enrollmentDetails);
    log.info("Adjusting submissions for feedback session :" + sessionName + "in course : " + courseId);
    FeedbackSessionAttributes feedbackSession = logic.getFeedbackSession(sessionName, courseId);
    String errorString = "Error encountered while adjusting feedback session responses of %s in course %s: %s%n%s";
    if (feedbackSession == null) {
        log.severe(String.format(errorString, sessionName, courseId, "feedback session is null", ""));
        setForRetry();
        return;
    }
    List<FeedbackResponseAttributes> allResponses = logic.getFeedbackResponsesForSession(feedbackSession.getFeedbackSessionName(), feedbackSession.getCourseId());
    List<StudentEnrollDetails> enrollmentList = JsonUtils.fromJson(enrollmentDetails, new TypeToken<List<StudentEnrollDetails>>() {
    }.getType());
    for (FeedbackResponseAttributes response : allResponses) {
        try {
            logic.adjustFeedbackResponseForEnrollments(enrollmentList, response);
        } catch (Exception e) {
            String url = HttpRequestHelper.getRequestedUrl(request);
            Map<String, String[]> params = HttpRequestHelper.getParameterMap(request);
            // no logged-in user for worker
            String logMessage = new LogMessageGenerator().generateActionFailureLogMessage(url, params, e, null);
            log.severe(String.format(errorString, sessionName, courseId, e.getMessage(), logMessage));
            setForRetry();
            return;
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackResponseAttributes(teammates.common.datatransfer.attributes.FeedbackResponseAttributes) TypeToken(com.google.gson.reflect.TypeToken) LogMessageGenerator(teammates.common.util.LogMessageGenerator) StudentEnrollDetails(teammates.common.datatransfer.StudentEnrollDetails) Map(java.util.Map)

Example 92 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionClosingRemindersAction method execute.

@Override
public void execute() {
    List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsClosingWithinTimeLimit();
    for (FeedbackSessionAttributes session : sessions) {
        List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionClosingEmails(session);
        try {
            taskQueuer.scheduleEmailsForSending(emailsToBeSent);
            session.setSentClosingEmail(true);
            logic.updateFeedbackSession(session);
        } catch (Exception e) {
            log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) TeammatesException(teammates.common.exception.TeammatesException) EmailWrapper(teammates.common.util.EmailWrapper)

Example 93 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionPublishedEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.EMAIL_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.EMAIL_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_COURSE, courseId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (session == null) {
        log.severe("Feedback session object for feedback session name: " + feedbackSessionName + " for course: " + courseId + " could not be fetched.");
        return;
    }
    List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionPublishedEmails(session);
    try {
        taskQueuer.scheduleEmailsForSending(emailsToBeSent);
        session.setSentPublishedEmail(true);
        logic.updateFeedbackSession(session);
    } catch (Exception e) {
        log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) TeammatesException(teammates.common.exception.TeammatesException) EmailWrapper(teammates.common.util.EmailWrapper)

Example 94 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionRemindEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.SUBMISSION_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.SUBMISSION_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.SUBMISSION_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.SUBMISSION_COURSE, courseId);
    String instructorId = getRequestParamValue(ParamsNames.USER_ID);
    Assumption.assertPostParamNotNull(ParamsNames.USER_ID, instructorId);
    try {
        FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
        List<StudentAttributes> studentList = logic.getStudentsForCourse(courseId);
        List<InstructorAttributes> instructorList = logic.getInstructorsForCourse(courseId);
        InstructorAttributes instructorToNotify = logic.getInstructorForGoogleId(courseId, instructorId);
        List<StudentAttributes> studentsToRemindList = new ArrayList<>();
        for (StudentAttributes student : studentList) {
            if (!logic.isFeedbackSessionCompletedByStudent(session, student.email)) {
                studentsToRemindList.add(student);
            }
        }
        // Filter out instructors who have submitted the feedback session
        List<InstructorAttributes> instructorsToRemindList = new ArrayList<>();
        for (InstructorAttributes instructor : instructorList) {
            if (!logic.isFeedbackSessionCompletedByInstructor(session, instructor.email)) {
                instructorsToRemindList.add(instructor);
            }
        }
        List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionReminderEmails(session, studentsToRemindList, instructorsToRemindList, instructorToNotify);
        taskQueuer.scheduleEmailsForSending(emails);
    } catch (Exception e) {
        log.severe("Unexpected error while sending emails: " + TeammatesException.toStringWithStackTrace(e));
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) ArrayList(java.util.ArrayList) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) TeammatesException(teammates.common.exception.TeammatesException) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 95 with FeedbackSessionAttributes

use of teammates.common.datatransfer.attributes.FeedbackSessionAttributes in project teammates by TEAMMATES.

the class FeedbackSessionUnpublishedEmailWorkerAction method execute.

@Override
public void execute() {
    String feedbackSessionName = getRequestParamValue(ParamsNames.EMAIL_FEEDBACK);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_FEEDBACK, feedbackSessionName);
    String courseId = getRequestParamValue(ParamsNames.EMAIL_COURSE);
    Assumption.assertPostParamNotNull(ParamsNames.EMAIL_COURSE, courseId);
    FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
    if (session == null) {
        log.severe("Feedback session object for feedback session name: " + feedbackSessionName + " for course: " + courseId + " could not be fetched.");
        return;
    }
    List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionUnpublishedEmails(session);
    try {
        taskQueuer.scheduleEmailsForSending(emailsToBeSent);
        session.setSentPublishedEmail(false);
        logic.updateFeedbackSession(session);
    } catch (Exception e) {
        log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) TeammatesException(teammates.common.exception.TeammatesException) EmailWrapper(teammates.common.util.EmailWrapper)

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