Search in sources :

Example 1 with InstructorCourseJoinConfirmationPageData

use of teammates.ui.pagedata.InstructorCourseJoinConfirmationPageData in project teammates by TEAMMATES.

the class InstructorCourseJoinConfirmationPageDataTest method testAll.

@Test
public void testAll() {
    ______TS("test typical case");
    AccountAttributes account = dataBundle.accounts.get("instructor1OfCourse1");
    String regkey = "someRandomKey";
    String institute = "Institute Name";
    InstructorCourseJoinConfirmationPageData pageData = new InstructorCourseJoinConfirmationPageData(account, dummySessionToken, regkey, institute);
    assertNotNull(pageData.getRegkey());
    assertEquals(regkey, pageData.getRegkey());
    assertNotNull(pageData.getInstitute());
    assertEquals(institute, pageData.getInstitute());
    assertNotNull(pageData.getConfirmationLink());
    String confirmationLink = Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey + "&" + Const.ParamsNames.INSTRUCTOR_INSTITUTION + "=" + SanitizationHelper.sanitizeForUri(institute);
    assertEquals(confirmationLink, pageData.getConfirmationLink());
    ______TS("test case when institute is null");
    account = dataBundle.accounts.get("instructor1OfCourse1");
    regkey = "someRandomKey";
    pageData = new InstructorCourseJoinConfirmationPageData(account, dummySessionToken, regkey, null);
    assertNotNull(pageData.getRegkey());
    assertEquals(regkey, pageData.getRegkey());
    assertNull(pageData.getInstitute());
    assertNotNull(pageData.getConfirmationLink());
    confirmationLink = Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED + "?key=" + regkey;
    assertEquals(confirmationLink, pageData.getConfirmationLink());
}
Also used : AccountAttributes(teammates.common.datatransfer.attributes.AccountAttributes) InstructorCourseJoinConfirmationPageData(teammates.ui.pagedata.InstructorCourseJoinConfirmationPageData) Test(org.testng.annotations.Test)

Example 2 with InstructorCourseJoinConfirmationPageData

use of teammates.ui.pagedata.InstructorCourseJoinConfirmationPageData in project teammates by TEAMMATES.

the class InstructorCourseJoinAction method execute.

@Override
public ActionResult execute() {
    String institute = getRequestParamValue(Const.ParamsNames.INSTRUCTOR_INSTITUTION);
    Assumption.assertNotNull(regkey);
    gateKeeper.verifyLoggedInUserPrivileges();
    /* Process confirmation for instructor if needed and setup status to be shown to admin */
    statusToAdmin = "Action Instructor Clicked Join Link" + "<br>Google ID: " + account.googleId + "<br>Key: " + regkey;
    InstructorAttributes instructor = logic.getInstructorForRegistrationKey(regkey);
    if (instructor != null && instructor.isRegistered()) {
        // Bypass confirmation if instructor is already registered
        String redirectUrl = Url.addParamToUrl(Const.ActionURIs.INSTRUCTOR_COURSE_JOIN_AUTHENTICATED, Const.ParamsNames.REGKEY, regkey);
        // so it must be passed to instructorCourseJoinAuthenticated action
        if (institute != null) {
            redirectUrl = Url.addParamToUrl(redirectUrl, Const.ParamsNames.INSTRUCTOR_INSTITUTION, institute);
        }
        return createRedirectResult(redirectUrl);
    }
    // 1.For instructors added by admin, institute is passed from the join link and should be passed
    // to the confirmation page and later to authenticated action for account creation
    // 2.For instructors added by other instructors, institute is not passed from the link so the value
    // will be null
    InstructorCourseJoinConfirmationPageData pageData = new InstructorCourseJoinConfirmationPageData(account, sessionToken, regkey, institute);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_JOIN_CONFIRMATION, pageData);
}
Also used : InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) InstructorCourseJoinConfirmationPageData(teammates.ui.pagedata.InstructorCourseJoinConfirmationPageData)

Aggregations

InstructorCourseJoinConfirmationPageData (teammates.ui.pagedata.InstructorCourseJoinConfirmationPageData)2 Test (org.testng.annotations.Test)1 AccountAttributes (teammates.common.datatransfer.attributes.AccountAttributes)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1