Search in sources :

Example 66 with InstructorAttributes

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

the class InstructorCourseStudentDeleteAllActionTest method testExecuteAndPostProcess.

@Override
@Test
public void testExecuteAndPostProcess() {
    InstructorAttributes instructor1OfCourse1 = typicalBundle.instructors.get("instructor1OfCourse1");
    ______TS("success: delete all students");
    gaeSimulation.loginAsInstructor(instructor1OfCourse1.googleId);
    String[] submissionParams = new String[] { Const.ParamsNames.COURSE_ID, instructor1OfCourse1.courseId };
    InstructorCourseStudentDeleteAllAction action = getAction(submissionParams);
    RedirectResult redirectResult = getRedirectResult(action);
    assertEquals(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE, redirectResult.destination);
    assertFalse(redirectResult.isError);
    assertEquals(Const.StatusMessages.STUDENTS_DELETED, redirectResult.getStatusMessage());
    AssertHelper.assertLogMessageEquals("TEAMMATESLOG|||instructorCourseStudentDeleteAll|||" + "instructorCourseStudentDeleteAll|||true|||Instructor|||Instructor 1 of Course 1|||" + "idOfInstructor1OfCourse1|||instr1@course1.tmt|||All the Students in Course " + "<span class=\"bold\">[idOfTypicalCourse1]</span> are deleted.|||" + "/page/instructorCourseStudentDeleteAll", action.getLogMessage());
}
Also used : InstructorCourseStudentDeleteAllAction(teammates.ui.controller.InstructorCourseStudentDeleteAllAction) RedirectResult(teammates.ui.controller.RedirectResult) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) Test(org.testng.annotations.Test)

Example 67 with InstructorAttributes

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

the class BaseTestCaseWithDatastoreAccess method verifyPresentInDatastore.

protected void verifyPresentInDatastore(DataBundle data) {
    Map<String, AccountAttributes> accounts = data.accounts;
    for (AccountAttributes account : accounts.values()) {
        verifyPresentInDatastore(account);
    }
    Map<String, InstructorAttributes> instructors = data.instructors;
    for (InstructorAttributes instructor : instructors.values()) {
        verifyPresentInDatastore(instructor);
    }
    Map<String, CourseAttributes> courses = data.courses;
    for (CourseAttributes course : courses.values()) {
        verifyPresentInDatastore(course);
    }
    Map<String, StudentAttributes> students = data.students;
    for (StudentAttributes student : students.values()) {
        verifyPresentInDatastore(student);
    }
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) StudentAttributes(teammates.common.datatransfer.attributes.StudentAttributes) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) CourseAttributes(teammates.common.datatransfer.attributes.CourseAttributes)

Example 68 with InstructorAttributes

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

the class AdminInstructorAccountAddAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyAdminPrivileges(account);
    AdminHomePageData data = new AdminHomePageData(account, sessionToken);
    data.instructorName = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_NAME).trim();
    data.instructorEmail = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_EMAIL).trim();
    data.instructorInstitution = getNonNullRequestParamValue(Const.ParamsNames.INSTRUCTOR_INSTITUTION).trim();
    data.isInstructorAddingResultForAjax = true;
    data.statusForAjax = "";
    data.instructorName = data.instructorName.trim();
    data.instructorEmail = data.instructorEmail.trim();
    data.instructorInstitution = data.instructorInstitution.trim();
    try {
        logic.verifyInputForAdminHomePage(data.instructorName, data.instructorInstitution, data.instructorEmail);
    } catch (InvalidParametersException e) {
        data.statusForAjax = e.getMessage().replace(System.lineSeparator(), Const.HTML_BR_TAG);
        data.isInstructorAddingResultForAjax = false;
        statusToUser.add(new StatusMessage(data.statusForAjax, StatusMessageColor.DANGER));
        return createAjaxResult(data);
    }
    String courseId = null;
    try {
        courseId = importDemoData(data);
    } catch (Exception e) {
        String retryUrl = Const.ActionURIs.ADMIN_INSTRUCTORACCOUNT_ADD;
        retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_NAME, data.instructorName);
        retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_EMAIL, data.instructorEmail);
        retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.INSTRUCTOR_INSTITUTION, data.instructorInstitution);
        retryUrl = Url.addParamToUrl(retryUrl, Const.ParamsNames.SESSION_TOKEN, data.getSessionToken());
        StringBuilder errorMessage = new StringBuilder(100);
        String retryLink = "<a href=" + retryUrl + ">Exception in Importing Data, Retry</a>";
        errorMessage.append(retryLink);
        statusToUser.add(new StatusMessage(errorMessage.toString(), StatusMessageColor.DANGER));
        String message = "<span class=\"text-danger\">Servlet Action failure in AdminInstructorAccountAddAction" + "<br>" + e.getClass() + ": " + TeammatesException.toStringWithStackTrace(e) + "<br></span>";
        errorMessage.append("<br>").append(message);
        statusToUser.add(new StatusMessage("<br>" + message, StatusMessageColor.DANGER));
        statusToAdmin = message;
        data.isInstructorAddingResultForAjax = false;
        data.statusForAjax = errorMessage.toString();
        return createAjaxResult(data);
    }
    List<InstructorAttributes> instructorList = logic.getInstructorsForCourse(courseId);
    String joinLink = Config.getAppUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN).withRegistrationKey(StringHelper.encrypt(instructorList.get(0).key)).withInstructorInstitution(data.instructorInstitution).toAbsoluteString();
    EmailWrapper email = new EmailGenerator().generateNewInstructorAccountJoinEmail(instructorList.get(0).email, data.instructorName, joinLink);
    try {
        emailSender.sendEmail(email);
    } catch (EmailSendingException e) {
        log.severe("Instructor welcome email failed to send: " + TeammatesException.toStringWithStackTrace(e));
    }
    data.statusForAjax = "Instructor " + SanitizationHelper.sanitizeForHtml(data.instructorName) + " has been successfully created " + "<a href=" + joinLink + ">" + Const.JOIN_LINK + "</a>";
    statusToUser.add(new StatusMessage(data.statusForAjax, StatusMessageColor.SUCCESS));
    statusToAdmin = "A New Instructor <span class=\"bold\">" + SanitizationHelper.sanitizeForHtmlTag(data.instructorName) + "</span> has been created.<br>" + "<span class=\"bold\">Id: </span>" + "ID will be assigned when the verification link was clicked and confirmed" + "<br>" + "<span class=\"bold\">Email: </span>" + SanitizationHelper.sanitizeForHtmlTag(data.instructorEmail) + "<span class=\"bold\">Institution: </span>" + SanitizationHelper.sanitizeForHtmlTag(data.instructorInstitution);
    return createAjaxResult(data);
}
Also used : EmailGenerator(teammates.logic.api.EmailGenerator) AdminHomePageData(teammates.ui.pagedata.AdminHomePageData) EmailSendingException(teammates.common.exception.EmailSendingException) InvalidParametersException(teammates.common.exception.InvalidParametersException) EntityDoesNotExistException(teammates.common.exception.EntityDoesNotExistException) EmailSendingException(teammates.common.exception.EmailSendingException) TeammatesException(teammates.common.exception.TeammatesException) InvalidParametersException(teammates.common.exception.InvalidParametersException) StatusMessage(teammates.common.util.StatusMessage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) EmailWrapper(teammates.common.util.EmailWrapper)

Example 69 with InstructorAttributes

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

the class AdminSearchPageAction method putInstructorHomePageLinkIntoMap.

private AdminSearchPageData putInstructorHomePageLinkIntoMap(List<InstructorAttributes> instructors, AdminSearchPageData data) {
    for (InstructorAttributes instructor : instructors) {
        if (instructor.googleId == null) {
            continue;
        }
        String curLink = Url.addParamToUrl(Const.ActionURIs.INSTRUCTOR_HOME_PAGE, Const.ParamsNames.USER_ID, instructor.googleId);
        data.instructorHomePageLinkMap.put(instructor.googleId, curLink);
    }
    return data;
}
Also used : InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Example 70 with InstructorAttributes

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

the class FeedbackSessionStatsPageAction method execute.

@Override
protected ActionResult execute() throws EntityDoesNotExistException {
    String courseId = getRequestParamValue(Const.ParamsNames.COURSE_ID);
    Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID, courseId);
    String feedbackSessionName = getRequestParamValue(Const.ParamsNames.FEEDBACK_SESSION_NAME);
    Assumption.assertPostParamNotNull(Const.ParamsNames.FEEDBACK_SESSION_NAME, feedbackSessionName);
    FeedbackSessionStatsPageData data = new FeedbackSessionStatsPageData(account, sessionToken);
    FeedbackSessionAttributes fsa = logic.getFeedbackSession(feedbackSessionName, courseId);
    InstructorAttributes instructor = logic.getInstructorForGoogleId(courseId, account.googleId);
    gateKeeper.verifyAccessible(instructor, fsa, false);
    data.sessionDetails = logic.getFeedbackSessionDetails(feedbackSessionName, courseId);
    return createAjaxResult(data);
}
Also used : FeedbackSessionAttributes(teammates.common.datatransfer.attributes.FeedbackSessionAttributes) FeedbackSessionStatsPageData(teammates.ui.pagedata.FeedbackSessionStatsPageData) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes)

Aggregations

InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)325 Test (org.testng.annotations.Test)127 StudentAttributes (teammates.common.datatransfer.attributes.StudentAttributes)84 FeedbackSessionAttributes (teammates.common.datatransfer.attributes.FeedbackSessionAttributes)77 ArrayList (java.util.ArrayList)58 CourseAttributes (teammates.common.datatransfer.attributes.CourseAttributes)47 FeedbackQuestionAttributes (teammates.common.datatransfer.attributes.FeedbackQuestionAttributes)46 RedirectResult (teammates.ui.controller.RedirectResult)46 StatusMessage (teammates.common.util.StatusMessage)34 ShowPageResult (teammates.ui.controller.ShowPageResult)31 FeedbackResponseAttributes (teammates.common.datatransfer.attributes.FeedbackResponseAttributes)30 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)29 HashMap (java.util.HashMap)25 EntityDoesNotExistException (teammates.common.exception.EntityDoesNotExistException)24 InvalidParametersException (teammates.common.exception.InvalidParametersException)24 FeedbackResponsesDb (teammates.storage.api.FeedbackResponsesDb)20 UnauthorizedAccessException (teammates.common.exception.UnauthorizedAccessException)18 EmailWrapper (teammates.common.util.EmailWrapper)15 InstructorPrivileges (teammates.common.datatransfer.InstructorPrivileges)14 DataBundle (teammates.common.datatransfer.DataBundle)13