Search in sources :

Example 61 with FeedbackSessionAttributes

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

the class BackDoorLogic method editFeedbackSessionAsJson.

public void editFeedbackSessionAsJson(String feedbackSessionJson) throws InvalidParametersException, EntityDoesNotExistException {
    FeedbackSessionAttributes feedbackSession = JsonUtils.fromJson(feedbackSessionJson, FeedbackSessionAttributes.class);
    updateFeedbackSession(feedbackSession);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes)

Example 62 with FeedbackSessionAttributes

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

the class EmailGenerator method generateFeedbackSessionSummaryOfCourse.

/**
 * Generates the email containing the summary of the feedback sessions
 * email for the given {@code courseId} for {@code student}.
 * @param courseId - ID of the course
 * @param student - attributes of student to send feedback session summary to
 */
public EmailWrapper generateFeedbackSessionSummaryOfCourse(String courseId, StudentAttributes student) {
    CourseAttributes course = coursesLogic.getCourse(courseId);
    List<FeedbackSessionAttributes> sessions = new ArrayList<>();
    List<FeedbackSessionAttributes> fsInCourse = fsLogic.getFeedbackSessionsForCourse(courseId);
    for (FeedbackSessionAttributes fsa : fsInCourse) {
        if (!fsa.isPrivateSession() && (fsa.isSentOpenEmail() || fsa.isSentPublishedEmail())) {
            sessions.add(fsa);
        }
    }
    StringBuffer linksFragmentValue = new StringBuffer(1000);
    String joinUrl = Config.getAppUrl(student.getRegistrationUrl()).toAbsoluteString();
    String joinFragmentValue = isYetToJoinCourse(student) ? Templates.populateTemplate(EmailTemplates.FRAGMENT_STUDENT_COURSE_JOIN, "${joinUrl}", joinUrl, "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName())) : "";
    for (FeedbackSessionAttributes fsa : sessions) {
        String submitUrlHtml = "(Feedback session is not yet opened)";
        String reportUrlHtml = "(Feedback session is not yet published)";
        if (fsa.isOpened() || fsa.isClosed()) {
            String submitUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_FEEDBACK_SUBMISSION_EDIT_PAGE).withCourseId(course.getId()).withSessionName(fsa.getFeedbackSessionName()).withRegistrationKey(StringHelper.encrypt(student.key)).withStudentEmail(student.email).toAbsoluteString();
            submitUrlHtml = "<a href=\"" + submitUrl + "\">" + submitUrl + "</a>";
        }
        if (fsa.isPublished()) {
            String reportUrl = Config.getAppUrl(Const.ActionURIs.STUDENT_FEEDBACK_RESULTS_PAGE).withCourseId(course.getId()).withSessionName(fsa.getFeedbackSessionName()).withRegistrationKey(StringHelper.encrypt(student.key)).withStudentEmail(student.email).toAbsoluteString();
            reportUrlHtml = "<a href=\"" + reportUrl + "\">" + reportUrl + "</a>";
        }
        linksFragmentValue.append(Templates.populateTemplate(EmailTemplates.FRAGMENT_SINGLE_FEEDBACK_SESSION_LINKS, "${feedbackSessionName}", fsa.getFeedbackSessionName(), "${deadline}", fsa.getEndTimeString() + (fsa.isClosed() ? " (Passed)" : ""), "${submitUrl}", submitUrlHtml, "${reportUrl}", reportUrlHtml));
    }
    String additionalContactInformation = getAdditionalContactInformationFragment(course);
    String emailBody = Templates.populateTemplate(EmailTemplates.USER_FEEDBACK_SESSION_RESEND_ALL_LINKS, "${userName}", SanitizationHelper.sanitizeForHtml(student.name), "${userEmail}", student.email, "${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()), "${courseId}", course.getId(), "${joinFragment}", joinFragmentValue, "${linksFragment}", linksFragmentValue.toString(), "${additionalContactInformation}", additionalContactInformation);
    EmailWrapper email = getEmptyEmailAddressedToEmail(student.email);
    email.setSubject(String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), course.getName(), course.getId()));
    email.setContent(emailBody);
    return email;
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 63 with FeedbackSessionAttributes

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

the class EmailGeneratorTest method testGenerateFeedbackSessionEmails_testSanitization.

@Test
public void testGenerateFeedbackSessionEmails_testSanitization() throws IOException {
    FeedbackSessionAttributes session = fsLogic.getFeedbackSession("Normal feedback session name", "idOfTestingSanitizationCourse");
    CourseAttributes course = coursesLogic.getCourse(session.getCourseId());
    StudentAttributes student1 = studentsLogic.getStudentForEmail(course.getId(), "normal@sanitization.tmt");
    InstructorAttributes instructor1 = instructorsLogic.getInstructorForEmail(course.getId(), "instructor1@sanitization.tmt");
    ______TS("feedback session opening emails: sanitization required");
    List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionOpeningEmails(session);
    assertEquals(2, emails.size());
    String subject = String.format(EmailType.FEEDBACK_OPENING.getSubject(), course.getName(), session.getFeedbackSessionName());
    verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionOpeningEmailTestingSanitzationForStudent.html");
    verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionOpeningEmailTestingSanitizationForInstructor.html");
    ______TS("feedback session closed alerts: sanitization required");
    emails = new EmailGenerator().generateFeedbackSessionClosedEmails(session);
    assertEquals(2, emails.size());
    subject = String.format(EmailType.FEEDBACK_CLOSED.getSubject(), course.getName(), session.getFeedbackSessionName());
    verifyEmailReceivedCorrectly(emails, student1.email, subject, "/sessionClosedEmailTestingSanitizationForStudent.html");
    verifyEmailReceivedCorrectly(emails, instructor1.email, subject, "/sessionClosedEmailTestingSanitizationForInstructor.html");
    ______TS("feedback sessions summary of course email: sanitization required");
    EmailWrapper email = new EmailGenerator().generateFeedbackSessionSummaryOfCourse(session.getCourseId(), student1);
    subject = String.format(EmailType.STUDENT_EMAIL_CHANGED.getSubject(), course.getName(), course.getId());
    verifyEmail(email, student1.email, subject, "/summaryOfFeedbackSessionsOfCourseEmailTestingSanitizationForStudent.html");
    ______TS("feedback session submission email: sanitization required");
    Instant time = TimeHelper.parseInstant("2016-09-04 05:30 AM +0000");
    email = new EmailGenerator().generateFeedbackSubmissionConfirmationEmailForInstructor(session, instructor1, time);
    subject = String.format(EmailType.FEEDBACK_SUBMISSION_CONFIRMATION.getSubject(), course.getName(), session.getFeedbackSessionName());
    verifyEmail(email, instructor1.email, subject, "/sessionSubmissionConfirmationEmailTestingSanitization.html");
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) EmailGenerator(teammates.logic.api.EmailGenerator) Instant(java.time.Instant) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper) Test(org.testng.annotations.Test)

Example 64 with FeedbackSessionAttributes

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

the class FeedbackSessionsLogicTest method testIsFeedbackSessionFullyCompletedByStudent.

private void testIsFeedbackSessionFullyCompletedByStudent() throws Exception {
    FeedbackSessionAttributes fs = dataBundle.feedbackSessions.get("session1InCourse1");
    StudentAttributes student1OfCourse1 = dataBundle.students.get("student1InCourse1");
    StudentAttributes student3OfCourse1 = dataBundle.students.get("student3InCourse1");
    ______TS("failure: non-existent feedback session for student");
    try {
        fsLogic.isFeedbackSessionFullyCompletedByStudent("nonExistentFSName", fs.getCourseId(), "random.student@email");
        signalFailureToDetectException();
    } catch (EntityDoesNotExistException edne) {
        assertEquals("Trying to check a non-existent feedback session: " + fs.getCourseId() + "/" + "nonExistentFSName", edne.getMessage());
    }
    ______TS("success case: fully done by student 1");
    assertTrue(fsLogic.isFeedbackSessionFullyCompletedByStudent(fs.getFeedbackSessionName(), fs.getCourseId(), student1OfCourse1.email));
    ______TS("success case: partially done by student 3");
    assertFalse(fsLogic.isFeedbackSessionFullyCompletedByStudent(fs.getFeedbackSessionName(), fs.getCourseId(), student3OfCourse1.email));
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException)

Example 65 with FeedbackSessionAttributes

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

the class FeedbackSessionsLogicTest method testGetFeedbackSessionsListForInstructor.

private void testGetFeedbackSessionsListForInstructor() {
    List<FeedbackSessionAttributes> finalFsa = new ArrayList<>();
    Collection<FeedbackSessionAttributes> allFsa = dataBundle.feedbackSessions.values();
    String courseId = dataBundle.courses.get("typicalCourse1").getId();
    String instructorGoogleId = dataBundle.instructors.get("instructor1OfCourse1").googleId;
    for (FeedbackSessionAttributes fsa : allFsa) {
        if (fsa.getCourseId().equals(courseId)) {
            finalFsa.add(fsa);
        }
    }
    AssertHelper.assertSameContentIgnoreOrder(finalFsa, fsLogic.getFeedbackSessionsListForInstructor(instructorGoogleId, false));
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) ArrayList(java.util.ArrayList)

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