Search in sources :

Example 56 with CourseAttributes

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

the class StudentCourseJoinAuthenticatedAction method addStatusMessageToUser.

private void addStatusMessageToUser() throws EntityDoesNotExistException {
    CourseAttributes course = logic.getCourse(getStudent().course);
    String courseDisplayText = "[" + course.getId() + "] " + SanitizationHelper.sanitizeForHtml(course.getName());
    statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.STUDENT_COURSE_JOIN_SUCCESSFUL, courseDisplayText), StatusMessageColor.SUCCESS));
    List<FeedbackSessionAttributes> fsa = logic.getFeedbackSessionsForUserInCourse(getStudent().course, getStudent().email);
    if (fsa.isEmpty()) {
        statusToUser.add(new StatusMessage(String.format(Const.StatusMessages.HINT_FOR_NO_SESSIONS_STUDENT, courseDisplayText), StatusMessageColor.INFO));
        StudentProfileAttributes spa = logic.getStudentProfile(account.googleId);
        String updateProfileMessage = spa.generateUpdateMessageForStudent();
        if (!updateProfileMessage.isEmpty()) {
            statusToUser.add(new StatusMessage(updateProfileMessage, StatusMessageColor.INFO));
        }
    }
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) StudentProfileAttributes(teammates.common.datatransfer.attributes.StudentProfileAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) StatusMessage(teammates.common.util.StatusMessage)

Example 57 with CourseAttributes

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

the class AdminAccountDetailsPageData method createStudentCourseListTable.

private List<AdminAccountDetailsStudentCourseListTableRow> createStudentCourseListTable(List<CourseAttributes> studentCourseList) {
    List<AdminAccountDetailsStudentCourseListTableRow> courseListTable = new ArrayList<>();
    if (studentCourseList != null) {
        for (CourseAttributes courseDetails : studentCourseList) {
            AdminAccountDetailsStudentCourseListTableRow row = new AdminAccountDetailsStudentCourseListTableRow(accountInformation.googleId, courseDetails, getSessionToken());
            courseListTable.add(row);
        }
    }
    return courseListTable;
}
Also used : AdminAccountDetailsStudentCourseListTableRow(teammates.ui.template.AdminAccountDetailsStudentCourseListTableRow) ArrayList(java.util.ArrayList) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 58 with CourseAttributes

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

the class StudentCourseJoinEmailWorkerAction method execute.

@Override
public void execute() {
    String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
    String studentEmail = getRequestParamValue(ParamsNames.STUDENT_EMAIL);
    Assumption.assertPostParamNotNull(ParamsNames.STUDENT_EMAIL, studentEmail);
    String isRejoinString = getRequestParamValue(ParamsNames.IS_STUDENT_REJOINING);
    Assumption.assertPostParamNotNull(ParamsNames.IS_STUDENT_REJOINING, isRejoinString);
    boolean isRejoin = Boolean.parseBoolean(isRejoinString);
    CourseAttributes course = logic.getCourse(courseId);
    Assumption.assertNotNull(course);
    StudentAttributes student = logic.getStudentForEmail(courseId, studentEmail);
    Assumption.assertNotNull(student);
    EmailWrapper email = isRejoin ? new EmailGenerator().generateStudentCourseRejoinEmailAfterGoogleIdReset(course, student) : new EmailGenerator().generateStudentCourseJoinEmail(course, student);
    try {
        emailSender.sendEmail(email);
    } catch (Exception e) {
        Assumption.fail("Unexpected error while sending email" + TeammatesException.toStringWithStackTrace(e));
    }
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) TeammatesException(teammates.common.exception.TeammatesException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 59 with CourseAttributes

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

the class AdminAccountDetailsPageAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    String googleId = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_ID);
    AccountAttributes accountInformation = logic.getAccount(googleId);
    List<CourseDetailsBundle> instructorCourseList;
    try {
        instructorCourseList = new ArrayList<>(logic.getCourseSummariesForInstructor(googleId).values());
    } catch (EntityDoesNotExistException e) {
        // Not an instructor of any course
        instructorCourseList = null;
    }
    List<CourseAttributes> studentCourseList;
    try {
        studentCourseList = logic.getCoursesForStudentAccount(googleId);
    } catch (EntityDoesNotExistException e) {
        // Not a student of any course
        studentCourseList = null;
    }
    AdminAccountDetailsPageData data = new AdminAccountDetailsPageData(account, sessionToken, accountInformation, instructorCourseList, studentCourseList);
    statusToAdmin = "adminAccountDetails Page Load<br>" + "Viewing details for " + data.getAccountInformation().name + "(" + googleId + ")";
    return createShowPageResult(Const.ViewURIs.ADMIN_ACCOUNT_DETAILS, data);
}
Also used : AdminAccountDetailsPageData(teammates.ui.pagedata.AdminAccountDetailsPageData) AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) CourseDetailsBundle(teammates.common.datatransfer.CourseDetailsBundle) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 60 with CourseAttributes

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

the class FeedbackSessionsLogicTest method testCopyFeedbackSession.

private void testCopyFeedbackSession() throws Exception {
    ______TS("Test copy");
    FeedbackSessionAttributes session1InCourse1 = dataBundle.feedbackSessions.get("session1InCourse1");
    InstructorAttributes instructor2OfCourse1 = dataBundle.instructors.get("instructor2OfCourse1");
    CourseAttributes typicalCourse2 = dataBundle.courses.get("typicalCourse2");
    FeedbackSessionAttributes copiedSession = fsLogic.copyFeedbackSession("Copied Session", typicalCourse2.getId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
    verifyPresentInDatastore(copiedSession);
    assertEquals("Copied Session", copiedSession.getFeedbackSessionName());
    assertEquals(typicalCourse2.getId(), copiedSession.getCourseId());
    List<FeedbackQuestionAttributes> questions1 = fqLogic.getFeedbackQuestionsForSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId());
    List<FeedbackQuestionAttributes> questions2 = fqLogic.getFeedbackQuestionsForSession(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
    assertEquals(questions1.size(), questions2.size());
    for (int i = 0; i < questions1.size(); i++) {
        FeedbackQuestionAttributes question1 = questions1.get(i);
        FeedbackQuestionDetails questionDetails1 = question1.getQuestionDetails();
        FeedbackQuestionAttributes question2 = questions2.get(i);
        FeedbackQuestionDetails questionDetails2 = question2.getQuestionDetails();
        assertEquals(questionDetails1.getQuestionText(), questionDetails2.getQuestionText());
        assertEquals(question1.giverType, question2.giverType);
        assertEquals(question1.recipientType, question2.recipientType);
        assertEquals(question1.questionType, question2.questionType);
        assertEquals(question1.numberOfEntitiesToGiveFeedbackTo, question2.numberOfEntitiesToGiveFeedbackTo);
    }
    assertEquals(0, copiedSession.getRespondingInstructorList().size());
    assertEquals(0, copiedSession.getRespondingStudentList().size());
    ______TS("Failure case: duplicate session");
    try {
        fsLogic.copyFeedbackSession(session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), session1InCourse1.getFeedbackSessionName(), session1InCourse1.getCourseId(), instructor2OfCourse1.email);
        signalFailureToDetectException();
    } catch (EntityAlreadyExistsException e) {
        ignoreExpectedException();
    }
    fsLogic.deleteFeedbackSessionCascade(copiedSession.getFeedbackSessionName(), copiedSession.getCourseId());
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackQuestionDetails(teammates.common.datatransfer.questions.FeedbackQuestionDetails) EntityAlreadyExistsException(teammates.common.exception.EntityAlreadyExistsException) FeedbackQuestionAttributes(teammates.common.datatransfer.attributes.FeedbackQuestionAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Aggregations

CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)106 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)48 Test (org.testng.annotations.Test)40 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)33 ArrayList (java.util.ArrayList)31 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)19 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)16 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)15 EmailWrapper (teammates.common.util.EmailWrapper)15 HashMap (java.util.HashMap)12 InvalidParametersException (teammates.common.exception.InvalidParametersException)10 EmailGenerator (teammates.logic.api.EmailGenerator)10 CourseDetailsBundle (teammates.common.datatransfer.CourseDetailsBundle)8 StatusMessage (teammates.common.util.StatusMessage)6 StudentProfileAttributes (teammates.common.datatransfer.attributes.StudentProfileAttributes)5 TeamDetailsBundle (teammates.common.datatransfer.TeamDetailsBundle)4 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)4 EntityAlreadyExistsException (teammates.common.exception.EntityAlreadyExistsException)4 InstructorCoursesPageData (teammates.ui.pagedata.InstructorCoursesPageData)4 InstructorFeedbackSessionsPageData (teammates.ui.pagedata.InstructorFeedbackSessionsPageData)4